Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--assembly/features/org.eclipse.jpt.patch/.project17
-rw-r--r--assembly/features/org.eclipse.jpt.patch/build.properties10
-rw-r--r--assembly/features/org.eclipse.jpt.patch/buildnotes_org.eclipse.jpt.patch.html20
-rw-r--r--assembly/features/org.eclipse.jpt.patch/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--assembly/features/org.eclipse.jpt.patch/epl-v10.html328
-rw-r--r--assembly/features/org.eclipse.jpt.patch/feature.properties143
-rw-r--r--assembly/features/org.eclipse.jpt.patch/feature.xml35
-rw-r--r--assembly/features/org.eclipse.jpt.patch/license.html93
-rw-r--r--assembly/features/org.eclipse.jpt.sdk/.cvsignore4
-rw-r--r--assembly/features/org.eclipse.jpt.sdk/.project17
-rw-r--r--assembly/features/org.eclipse.jpt.sdk/build.properties15
-rw-r--r--assembly/features/org.eclipse.jpt.sdk/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--assembly/features/org.eclipse.jpt.sdk/epl-v10.html328
-rw-r--r--assembly/features/org.eclipse.jpt.sdk/feature.properties145
-rw-r--r--assembly/features/org.eclipse.jpt.sdk/feature.xml42
-rw-r--r--assembly/features/org.eclipse.jpt.sdk/license.html98
-rw-r--r--assembly/features/org.eclipse.jpt.tests/.cvsignore3
-rw-r--r--assembly/features/org.eclipse.jpt.tests/.project17
-rw-r--r--assembly/features/org.eclipse.jpt.tests/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--assembly/features/org.eclipse.jpt.tests/build.properties5
-rw-r--r--assembly/features/org.eclipse.jpt.tests/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--assembly/features/org.eclipse.jpt.tests/epl-v10.html328
-rw-r--r--assembly/features/org.eclipse.jpt.tests/feature.properties145
-rw-r--r--assembly/features/org.eclipse.jpt.tests/feature.xml28
-rw-r--r--assembly/features/org.eclipse.jpt.tests/license.html98
-rw-r--r--assembly/features/org.eclipse.jpt/.cvsignore2
-rw-r--r--assembly/features/org.eclipse.jpt/.project17
-rw-r--r--assembly/features/org.eclipse.jpt/build.properties16
-rw-r--r--assembly/features/org.eclipse.jpt/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--assembly/features/org.eclipse.jpt/epl-v10.html328
-rw-r--r--assembly/features/org.eclipse.jpt/feature.properties144
-rw-r--r--assembly/features/org.eclipse.jpt/feature.xml42
-rw-r--r--assembly/features/org.eclipse.jpt/license.html93
-rw-r--r--assembly/plugins/org.eclipse.jpt/.cvsignore2
-rw-r--r--assembly/plugins/org.eclipse.jpt/.project22
-rw-r--r--assembly/plugins/org.eclipse.jpt/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--assembly/plugins/org.eclipse.jpt/META-INF/MANIFEST.MF7
-rw-r--r--assembly/plugins/org.eclipse.jpt/about.html34
-rw-r--r--assembly/plugins/org.eclipse.jpt/about.ini44
-rw-r--r--assembly/plugins/org.eclipse.jpt/about.mappings6
-rw-r--r--assembly/plugins/org.eclipse.jpt/about.properties24
-rw-r--r--assembly/plugins/org.eclipse.jpt/build.properties19
-rw-r--r--assembly/plugins/org.eclipse.jpt/component.xml12
-rw-r--r--assembly/plugins/org.eclipse.jpt/eclipse32.gifbin1706 -> 0 bytes
-rw-r--r--assembly/plugins/org.eclipse.jpt/eclipse32.pngbin4594 -> 0 bytes
-rw-r--r--assembly/plugins/org.eclipse.jpt/plugin.properties13
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/.cvsignore1
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/.project17
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/build.properties15
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/epl-v10.html328
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/feature.properties140
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/feature.xml60
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/license.html98
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/build.properties16
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/epl-v10.html328
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/feature.properties145
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/license.html82
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.html27
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.ini31
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.mappings6
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.properties26
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/build.properties11
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/eclipse32.gifbin1706 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/eclipse32.pngbin4634 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/epl-v10.html328
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/license.html83
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/plugin.properties13
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/.cvsignore3
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/.project17
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/build.properties9
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/epl-v10.html328
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/feature.properties140
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/feature.xml28
-rw-r--r--jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/license.html98
-rw-r--r--jpa/features/org.eclipse.jpt.feature/.cvsignore1
-rw-r--r--jpa/features/org.eclipse.jpt.feature/.project17
-rw-r--r--jpa/features/org.eclipse.jpt.feature/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/features/org.eclipse.jpt.feature/build.properties15
-rw-r--r--jpa/features/org.eclipse.jpt.feature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt.feature/epl-v10.html328
-rw-r--r--jpa/features/org.eclipse.jpt.feature/feature.properties140
-rw-r--r--jpa/features/org.eclipse.jpt.feature/feature.xml121
-rw-r--r--jpa/features/org.eclipse.jpt.feature/license.html98
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/build.properties16
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/epl-v10.html328
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/feature.properties145
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/license.html82
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.html27
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.ini31
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.mappings6
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.properties26
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/build.properties11
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.gifbin1706 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.pngbin4634 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/epl-v10.html328
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/license.html83
-rw-r--r--jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/plugin.properties13
-rw-r--r--jpa/features/org.eclipse.jpt.tests.feature/.cvsignore1
-rw-r--r--jpa/features/org.eclipse.jpt.tests.feature/.project17
-rw-r--r--jpa/features/org.eclipse.jpt.tests.feature/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/features/org.eclipse.jpt.tests.feature/build.properties10
-rw-r--r--jpa/features/org.eclipse.jpt.tests.feature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt.tests.feature/epl-v10.html328
-rw-r--r--jpa/features/org.eclipse.jpt.tests.feature/feature.properties145
-rw-r--r--jpa/features/org.eclipse.jpt.tests.feature/feature.xml44
-rw-r--r--jpa/features/org.eclipse.jpt.tests.feature/license.html98
-rw-r--r--jpa/features/org.eclipse.jpt_sdk.feature/.cvsignore3
-rw-r--r--jpa/features/org.eclipse.jpt_sdk.feature/.project17
-rw-r--r--jpa/features/org.eclipse.jpt_sdk.feature/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/features/org.eclipse.jpt_sdk.feature/build.properties9
-rw-r--r--jpa/features/org.eclipse.jpt_sdk.feature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--jpa/features/org.eclipse.jpt_sdk.feature/epl-v10.html328
-rw-r--r--jpa/features/org.eclipse.jpt_sdk.feature/feature.properties140
-rw-r--r--jpa/features/org.eclipse.jpt_sdk.feature/feature.xml28
-rw-r--r--jpa/features/org.eclipse.jpt_sdk.feature/license.html98
-rw-r--r--jpa/plugins/org.eclipse.jpt.db.ui/.classpath7
-rw-r--r--jpa/plugins/org.eclipse.jpt.db.ui/.cvsignore6
-rw-r--r--jpa/plugins/org.eclipse.jpt.db.ui/.project28
-rw-r--r--jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--jpa/plugins/org.eclipse.jpt.db.ui/META-INF/MANIFEST.MF14
-rw-r--r--jpa/plugins/org.eclipse.jpt.db.ui/about.html34
-rw-r--r--jpa/plugins/org.eclipse.jpt.db.ui/build.properties17
-rw-r--r--jpa/plugins/org.eclipse.jpt.db.ui/component.xml1
-rw-r--r--jpa/plugins/org.eclipse.jpt.db.ui/plugin.properties25
-rw-r--r--jpa/plugins/org.eclipse.jpt.db.ui/src/org/eclipse/jpt/db/ui/internal/DTPUiTools.java101
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/.classpath7
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/.cvsignore6
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/.project28
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/META-INF/MANIFEST.MF17
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/about.html34
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/build.properties19
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/component.xml1
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/plugin.properties25
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Catalog.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Column.java80
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionAdapter.java72
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionListener.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfile.java193
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfileAdapter.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfileListener.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfileRepository.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Database.java90
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ForeignKey.java123
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/JptDbPlugin.java71
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Schema.java87
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/SchemaContainer.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Sequence.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Table.java115
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileHolder.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPCatalogWrapper.java89
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPColumnWrapper.java211
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileRepository.java225
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java479
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java301
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPForeignKeyWrapper.java362
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSchemaContainerWrapper.java159
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSchemaWrapper.java289
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSequenceWrapper.java76
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTableWrapper.java351
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java81
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/InternalDatabase.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java175
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java148
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/.project22
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/META-INF/MANIFEST.MF8
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/about.htm42
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/build.properties102
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/add_persistence.xml63
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/create_entity.xml44
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/map_entity.xml88
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm45
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/concept_persistence.htm40
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm59
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm42
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm44
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm45
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/contexts.xml422
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/dcommon/css/blafdoc.css21
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/dcommon/html/cpyr.htm12
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm49
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started001.htm59
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started002.htm53
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started003.htm84
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started004.htm105
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started005.htm132
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started006.htm42
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started007.htm209
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started008.htm46
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started009.htm62
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started010.htm57
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started011.htm76
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started012.htm54
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started013.htm58
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started014.htm126
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started015.htm127
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started016.htm83
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started017.htm65
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started018.htm83
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/getting_started019.htm61
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/address_java_open.pngbin5702 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_details.pngbin8558 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_structure.pngbin4099 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/button_jpa_perspective.pngbin318 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/database_explorer.pngbin4645 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/details_entitymappings.pngbin5647 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/edit_join_column_dialog.pngbin10049 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/error_sample.pngbin13762 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/generate_entities.pngbin6223 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_11mapping.pngbin244 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_1mmapping.pngbin303 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_basicmapping.pngbin476 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddable.pngbin354 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedidmapping.pngbin213 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedmapping.pngbin400 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_idmapping.pngbin521 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_m1mapping.pngbin301 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_mmmapping.pngbin255 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_nonpersistent.pngbin210 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_persistent.pngbin649 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_superclass.pngbin632 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_transientmapping.pngbin224 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/icon_versionmapping.pngbin443 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_join.pngbin11615 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_single.pngbin3359 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_tab.pngbin4236 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/java_editor_address.pngbin7823 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_details_employee.pngbin8587 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_facet_dialog.pngbin25146 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/new_jpa_project_dialog.pngbin23157 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/new_project_2.pngbin7208 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelc.pngbin667 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelr.pngbin615 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelt.pngbin568 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/open_persistence_editor.pngbin12962 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_address.pngbin7215 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_empid.pngbin6734 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_entity.pngbin2090 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fields.pngbin4307 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fname.pngbin6658 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_owner.pngbin6409 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_phone.pngbin7292 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_version.pngbin6923 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_view.pngbin8746 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_perspective.pngbin43141 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_address.pngbin8600 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_addressid.pngbin9705 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_embedded.pngbin8080 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid.pngbin6545 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid_pk.pngbin12188 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_employee.pngbin8850 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_entity.pngbin8013 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_firstname.pngbin8892 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_manytoone.pngbin11009 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_mappedsprc.pngbin8293 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetomany.pngbin17395 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetoone.pngbin9280 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_version.pngbin7852 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_xml_editor.pngbin2899 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/properties_persistence.pngbin19758 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/quickstart_project.pngbin9094 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/secondary_tables.pngbin1750 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/synchornize_classes.pngbin16378 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/table_entity.pngbin9169 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/img/tutorial_object_model.pngbin7632 -> 0 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/index.xml555
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/legal.htm39
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/plugin.properties32
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml37
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/ref_details_orm.htm46
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/ref_jpa_facet.htm85
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/ref_mapping_general.htm225
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project.htm85
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project_wizard.htm48
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_map_view.htm51
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_outline.htm49
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_perspective.htm59
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_prop_view.htm51
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/ref_primary_key.htm138
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/ref_project_properties.htm80
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference.htm59
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm42
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm51
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm97
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm75
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm47
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm101
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm78
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm67
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm94
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm103
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference011.htm42
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm45
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm65
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm45
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm110
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm59
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm38
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/reference018.htm52
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/task_add_persistence.htm59
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/task_additonal_tables.htm70
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/task_create_new_project.htm97
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/task_generate_entities.htm72
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm134
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/task_manage_orm.htm62
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/task_manage_persistence.htm62
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/task_mapping.htm72
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm68
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm61
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks002.htm61
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm62
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks004.htm75
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm66
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm80
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm184
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm107
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm87
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm169
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm172
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm127
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm162
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm134
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm65
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm128
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm66
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm40
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm53
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm91
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm49
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tasks022.htm83
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/tips_and_tricks.htm65
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/toc.xml119
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm40
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm44
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm57
-rw-r--r--jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm56
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/.classpath11
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/.cvsignore1
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/.project17
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/src/org/eclipse/jpt/eclipselink/core/ddlgen/Main.java217
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/Main.java217
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/.classpath14
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/.cvsignore3
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/.project28
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/META-INF/MANIFEST.MF30
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/about.html34
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/build.properties20
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.properties23
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.xml13
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties233
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java260
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EntityDialog.java106
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/JptEclipseLinkUiPlugin.java108
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheSizeComposite.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java89
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/DefaultCacheSizeComposite.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/DefaultCacheTypeComposite.java91
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/DefaultSharedCacheComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EclipseLinkCachingComposite.java57
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCacheProperties.java114
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCachingPropertyComposite.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java163
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/PersistenceXmlCachingTab.java87
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/SharedCacheComposite.java155
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/BatchWritingComposite.java86
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsPropertiesComposite.java213
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/ConnectionPropertiesComposite.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/DataSourcePropertiesComposite.java136
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/EclipseLinkConnectionComposite.java55
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcBindParametersComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcConnectionPropertiesComposite.java320
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcDriverComposite.java107
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcPropertiesComposite.java72
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionPropertiesComposite.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMaxComposite.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMinComposite.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsSharedComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionPropertiesComposite.java58
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMaxComposite.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMinComposite.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/NativeSqlComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/PersistenceXmlConnectionTab.java83
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/TransactionTypeComposite.java111
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/CustomizerComposite.java112
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EclipseLinkCustomizationComposite.java71
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityCustomizationPropertyComposite.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityCustomizerProperties.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityListComposite.java172
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/PersistenceXmlCustomizationTab.java87
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/SessionCustomizerComposite.java111
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/ThrowExceptionsComposite.java97
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingChangeTrackingComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingComposite.java87
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingFetchGroupsComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingLazyComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java175
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/wizards/GenerateDDLWizard.java83
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/EclipseLinkLoggingComposite.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/ExceptionsComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/LoggerComposite.java197
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/LoggingLevelComposite.java89
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/PersistenceXmlLoggingTab.java83
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/SessionComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/ThreadComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/TimestampComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/EclipseLinkOptionsComposite.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/EventListenerComposite.java107
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/IncludeDescriptorQueriesComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/PersistenceXmlOptionsTab.java83
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/SessionNameComposite.java110
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/SessionsXmlComposite.java110
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/TargetDatabaseComposite.java85
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/EclipseLinkNavigatorItemContentProviderFactory.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/EclipseLinkNavigatorItemLabelProviderFactory.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/PersistenceDetailsProvider.java45
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/PersistenceXmlDetailsPage.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkNavigatorProvider.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkPlatformUI.java81
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkUiFactory.java158
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/CreateDdlFileNameComposite.java110
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/DdlGenerationLocationComposite.java98
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/DdlGenerationTypeComposite.java87
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/DropDdlFileNameComposite.java110
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/EclipseLinkSchemaGenerationComposite.java49
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/OutputModeComposite.java85
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/PersistenceXmlSchemaGenerationTab.java55
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/.classpath7
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/.cvsignore6
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/.project28
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/META-INF/MANIFEST.MF15
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/about.html34
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/build.properties16
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/component.xml1
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/plugin.properties24
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/EntityGenerator.java1520
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenScope.java175
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenTable.java345
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToManyRelation.java104
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToOneRelation.java61
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/OneToManyRelation.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java91
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/.classpath7
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/.cvsignore4
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/.project28
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF67
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/about.html34
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/build.properties17
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/component.xml1
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/plugin.properties24
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/Command.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/CommandExecutor.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/CommandExecutorProvider.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/Filter.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/JavaType.java105
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/AbstractAssociation.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Association.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Bag.java128
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BidiFilter.java80
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BidiStringConverter.java127
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BidiTransformer.java81
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BitTools.java214
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassTools.java1678
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Classpath.java912
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/CollectionTools.java3901
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Counter.java109
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/EmptyIterable.java51
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/FileTools.java1006
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java842
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IdentityHashBag.java814
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IndentingPrintWriter.java148
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCTools.java350
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCType.java167
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java323
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NullList.java151
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Range.java87
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ReverseComparator.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleAssociation.java69
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleFilter.java108
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleJavaType.java229
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStack.java95
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStringMatcher.java260
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Stack.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringConverter.java68
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringMatcher.java58
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringTools.java3243
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBoolean.java365
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedObject.java373
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedStack.java280
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Transformer.java69
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/XMLStringEncoder.java182
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayIterator.java72
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayListIterator.java78
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ChainIterator.java145
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneIterator.java154
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneListIterator.java254
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeIterator.java126
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeListIterator.java194
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyEnumeration.java55
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyIterator.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyListIterator.java83
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EnumerationIterator.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/FilteringIterator.java135
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GenericIteratorWrapper.java48
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GraphIterator.java242
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/IteratorEnumeration.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/PeekableIterator.java100
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyCompositeListIterator.java179
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyIterator.java61
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyListIterator.java93
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ResultSetIterator.java154
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementIterator.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementListIterator.java94
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationIterator.java80
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationListIterator.java108
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TreeIterator.java195
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/AbstractModel.java1002
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/CallbackChangeSupport.java83
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java2363
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/SingleAspectChangeSupport.java332
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTCollectionChangeListenerWrapper.java151
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTListChangeListenerWrapper.java199
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTPropertyChangeListenerWrapper.java76
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTStateChangeListenerWrapper.java75
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTTreeChangeListenerWrapper.java151
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AbstractTreeNodeValueModel.java195
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AspectAdapter.java279
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AspectPropertyValueModelAdapter.java179
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/BufferedWritablePropertyValueModel.java345
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java239
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java297
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionPropertyValueModelAdapter.java140
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java180
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java407
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeListValueModel.java575
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java205
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java172
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringPropertyValueModel.java138
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringWritablePropertyValueModel.java125
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemAspectListValueModelAdapter.java296
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemCollectionListValueModelAdapter.java98
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemListListValueModelAdapter.java104
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemPropertyListValueModelAdapter.java85
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemStateListValueModelAdapter.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemTreeListValueModelAdapter.java98
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListAspectAdapter.java288
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java301
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCurator.java221
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListPropertyValueModelAdapter.java166
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListValueModelWrapper.java207
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullListValueModel.java72
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullPropertyValueModel.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullTreeValueModel.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyAspectAdapter.java256
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java195
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyListValueModelAdapter.java220
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyValueModelWrapper.java145
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java184
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleListValueModel.java317
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimplePropertyValueModel.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java133
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StatePropertyValueModelAdapter.java100
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticCollectionValueModel.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticListValueModel.java79
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticPropertyValueModel.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticTreeValueModel.java60
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java242
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationPropertyValueModel.java114
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationWritablePropertyValueModel.java127
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreeAspectAdapter.java216
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreePropertyValueModelAdapter.java137
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueAspectAdapter.java163
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueCollectionAdapter.java87
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueListAdapter.java93
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValuePropertyAdapter.java76
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueStateAdapter.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueTreeAdapter.java85
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencePropertyValueModel.java346
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java201
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/AbstractTreeModel.java217
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/CheckBoxModelAdapter.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ColumnAdapter.java49
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ComboBoxModelAdapter.java141
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DateSpinnerModelAdapter.java200
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DocumentAdapter.java364
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListModelAdapter.java287
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListSpinnerModelAdapter.java220
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java224
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ObjectListSelectionModel.java427
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/PrimitiveListTreeModel.java235
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/RadioButtonModelAdapter.java151
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/SpinnerModelAdapter.java208
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TableModelAdapter.java412
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ToggleButtonModelAdapter.java226
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TreeModelAdapter.java724
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AbstractNode.java941
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AsynchronousValidator.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/DefaultProblem.java80
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Node.java419
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/PluggableValidator.java121
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Problem.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/RunnableValidation.java129
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/SynchronousValidator.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/CachingComboBoxModel.java42
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/CheckBoxTableCellRenderer.java208
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ComboBoxTableCellRenderer.java330
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/Displayable.java95
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/EmptyIcon.java55
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListBrowser.java140
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListPanel.java457
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ListChooser.java427
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/NodeSelector.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/NonCachingComboBoxModel.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SimpleDisplayable.java178
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SimpleListBrowser.java86
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SimpleListCellRenderer.java129
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SpinnerTableCellRenderer.java187
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/TableCellEditorAdapter.java97
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/Model.java195
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/ChangeEvent.java65
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/CollectionChangeEvent.java138
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/ListChangeEvent.java263
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/PropertyChangeEvent.java104
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/StateChangeEvent.java57
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/TreeChangeEvent.java111
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ChangeListener.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/CollectionChangeAdapter.java48
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/CollectionChangeListener.java60
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ListChangeAdapter.java56
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ListChangeListener.java80
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/MultiMethodReflectiveChangeListener.java146
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/PropertyChangeListener.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ReflectiveChangeListener.java313
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/SingleMethodReflectiveChangeListener.java61
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/StateChangeListener.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/TreeChangeAdapter.java48
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/TreeChangeListener.java62
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/CollectionValueModel.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/ListValueModel.java56
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/PropertyValueModel.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/TreeNodeValueModel.java71
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/TreeValueModel.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/WritablePropertyValueModel.java31
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.classpath7
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.cvsignore6
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.project28
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/META-INF/MANIFEST.MF25
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/build.properties19
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/plugin.properties24
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/plugin.xml27
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/ExtensionTestPlugin.java44
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestAttributeMapping.java38
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestAttributeMappingProvider.java48
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestTypeMapping.java43
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestTypeMappingProvider.java51
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJavaBasicMapping.java20
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJavaEntity.java20
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaFactory.java37
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaPlatform.java50
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaPlatformUi.java55
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaUiFactory.java26
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/.classpath14
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/.cvsignore5
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/.project28
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF40
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/about.html34
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/build.properties19
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/plugin.properties22
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptAllCoreTests.java35
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptCoreTests.java48
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/ProjectUtility.java217
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/ContextModelTestCase.java193
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java352
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JptCoreContextModelTests.java39
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAssociationOverrideTests.java421
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAttributeOverrideTests.java296
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaBasicMappingTests.java1000
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaColumnTests.java848
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaDiscriminatorColumnTests.java327
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddableTests.java184
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java605
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java607
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java2902
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaGeneratedValueTests.java160
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaIdMappingTests.java730
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java541
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java1000
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java923
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java905
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaMappedSuperclassTests.java252
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedNativeQueryTests.java446
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedQueryTests.java345
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java899
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java1311
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentAttributeTests.java226
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java701
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPrimaryKeyJoinColumnTests.java318
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaQueryHintTests.java164
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSecondaryTableTests.java759
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSequenceGeneratorTests.java270
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableGeneratorTests.java699
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableTests.java573
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTransientMappingTests.java259
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaVersionMappingTests.java413
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JptCoreContextJavaModelTests.java62
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/EntityMappingsTests.java1067
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/JptCoreOrmContextModelTests.java66
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmAssociationOverrideTests.java255
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmAttributeOverrideTests.java96
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmBasicMappingTests.java764
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmCascadeTests.java280
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmColumnTests.java850
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmDiscriminatorColumnTests.java350
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddableTests.java297
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedIdMappingTests.java493
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedMappingTests.java700
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java1909
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmGeneratedValueTests.java129
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmIdMappingTests.java796
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinColumnTests.java506
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java1181
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToManyMappingTests.java654
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToOneMappingTests.java570
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmMappedSuperclassTests.java347
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmNamedNativeQueryTests.java358
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmNamedQueryTests.java273
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToManyMappingTests.java655
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToOneMappingTests.java984
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPersistentAttributeTests.java275
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPersistentTypeTests.java510
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPrimaryKeyJoinColumnTests.java304
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmQueryHintTests.java122
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSecondaryTableTests.java775
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSequenceGeneratorTests.java223
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableGeneratorTests.java622
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableTests.java760
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTransientMappingTests.java313
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmVersionMappingTests.java505
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmXmlTests.java111
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/PersistenceUnitDefaultsTests.java369
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/PersistenceUnitMetadataTests.java105
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/ClassRefTests.java114
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/JptCorePersistenceContextModelTests.java37
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/MappingFileRefTests.java97
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceTests.java137
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java1123
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceXmlTests.java92
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/RootContextTests.java93
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaModelTests.java227
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JptCoreModelTests.java32
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/BaseJpaPlatformTests.java68
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformExtensionTests.java71
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformTests.java127
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java80
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java124
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJpaProject.java77
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestPlatformProject.java163
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/JptCoreResourceModelTests.java38
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/OrmModelTests.java46
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/PersistenceModelTests.java46
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverrideTests.java272
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverridesTests.java345
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverrideTests.java173
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverridesTests.java300
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/BasicTests.java154
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ColumnTests.java423
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorColumnTests.java225
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorValueTests.java84
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddableTests.java76
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedIdTests.java50
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedTests.java50
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EntityTests.java128
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EnumeratedTests.java91
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/GeneratedValueTests.java144
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdClassTests.java111
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdTests.java50
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/InheritanceTests.java86
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JPTToolsTests.java527
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java137
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentAttributeTests.java900
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentTypeTests.java998
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnTests.java369
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnsTests.java444
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinTableTests.java686
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JpaCompilationUnitTests.java77
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JptJavaResourceTests.java82
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/LobTests.java49
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToManyTests.java406
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToOneTests.java398
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MapKeyTests.java89
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MappedSuperclassTests.java76
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueriesTests.java441
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueryTests.java355
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java351
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueryTests.java273
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToManyTests.java408
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToOneTests.java459
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OrderByTests.java88
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnTests.java197
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnsTests.java268
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/QueryHintTests.java77
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTableTests.java459
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTablesTests.java532
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SequenceGeneratorTests.java242
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableGeneratorTests.java521
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableTests.java359
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TemporalTests.java91
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TransientTests.java50
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/VersionTests.java49
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/AnnotationTestCase.java506
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapterTests.java728
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/DefaultAnnotationEditFormatterTests.java74
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/JDTToolsTests.java86
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/JptCoreUtilityJdtTests.java39
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/MemberAnnotationElementAdapterTests.java948
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedDeclarationAnnotationAdapterTests.java763
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapterTests.java2218
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/SimpleDeclarationAnnotationAdapterTests.java204
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/TypeTests.java43
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/test.xml40
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/.classpath11
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/.cvsignore1
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/.project28
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/META-INF/MANIFEST.MF19
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/build.properties15
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/config/derby101.properties21
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/config/mysql41.properties22
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/config/oracle10g.properties20
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/config/oracle10gXE.properties20
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/config/oracle9i.properties20
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/config/postgresql824.properties21
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/config/sqlserver2005.properties30
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/config/sybase12.properties21
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/plugin.properties25
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTests.java39
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTestsPlugin.java56
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/AllPlatformTests.java41
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DTPPlatformTests.java414
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Derby101Tests.java62
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/MySQL41Tests.java57
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gTests.java57
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gXETests.java57
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle9iTests.java57
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/PostgreSQL824Tests.java57
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SQLServer2005Tests.java62
-rw-r--r--jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Sybase12Tests.java57
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.classpath13
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.cvsignore5
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.project28
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/META-INF/MANIFEST.MF21
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/about.html34
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/build.properties17
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/plugin.properties22
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/JptEclipseLinkCoreTests.java44
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/PersistenceUnitTestCase.java422
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/caching/CachingAdapterTests.java442
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/caching/CachingValueModelTests.java398
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/caching/JptEclipseLinkCoreCachingTests.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/connection/ConnectionAdapterTests.java586
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/connection/JptEclipseLinkCoreConnectionTests.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/customization/CustomizationAdapterTests.java458
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/customization/CustomizationValueModelTests.java160
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/customization/JptEclipseLinkCoreCustomizationTests.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/logging/JptEclipseLinkCoreLoggingTests.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/logging/LoggingAdapterTests.java355
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/logging/LoggingValueModelTests.java159
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/options/JptEclipseLinkCoreOptionsTests.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/options/OptionsAdapterTests.java254
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/options/OptionsValueModelTests.java159
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/JptEclipseLinkCoreSchemaGenerationTests.java35
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/SchemaGenerationAdapterTests.java265
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/SchemaGenerationBasicAdapterTests.java192
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/SchemaGenerationValueModelTests.java232
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/test.xml40
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/.classpath13
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/.project28
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/META-INF/MANIFEST.MF23
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/build.properties4
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/plugin.properties22
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/JptUiTests.java36
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/jface/DelegatingLabelProviderUiTest.java589
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/jface/DelegatingTreeContentProviderUiTest.java569
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/platform/JpaPlatformUiExtensionTests.java59
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/platform/JptUiPlatformTests.java27
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/AbstractComboModelAdapterTest.java780
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/CComboModelAdapterTest.java75
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/CheckBoxModelAdapterUITest.java318
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/ComboModelAdapterTest.java78
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/JptUiSWTTests.java39
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/ListBoxModelAdapterUITest.java641
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/SpinnerModelAdapterTest.java341
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/TableModelAdapterTest.java1203
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/TextFieldModelAdapterUITest.java252
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/TriStateCheckBoxModelAdapterUITest.java320
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlAlignerTest.java801
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlEnablerTest.java85
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlSwitcherTest.java188
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlVisibilityEnablerTest.java85
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/JptUiUtilTests.java44
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/LabeledButtonTest.java123
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/LabeledControlUpdaterTest.java125
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/LabeledLabelTest.java123
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/PaneEnablerTest.java94
-rw-r--r--jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/PaneVisibilityEnablerTest.java94
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/.classpath11
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/.cvsignore5
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/.project28
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/META-INF/MANIFEST.MF18
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/about.html34
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/build.properties16
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/plugin.properties24
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java243
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java633
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java289
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java3881
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CounterTests.java93
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/EmptyIterableTests.java31
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java594
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java493
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IdentityHashBagTests.java511
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IndentingPrintWriterTests.java107
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java66
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JavaTypeTests.java252
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java61
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/NameToolsTests.java227
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/RangeTests.java74
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java101
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleAssociationTests.java99
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleStackTests.java142
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java1176
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedBooleanTests.java226
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedObjectTests.java293
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedStackTests.java271
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java142
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java135
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayIteratorTests.java126
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayListIteratorTests.java150
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ChainIteratorTests.java132
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneIteratorTests.java252
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneListIteratorTests.java408
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeIteratorTests.java350
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeListIteratorTests.java331
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyEnumerationTests.java53
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyIteratorTests.java63
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyListIteratorTests.java127
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EnumerationIteratorTests.java119
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java299
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/GraphIteratorTests.java196
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/IteratorEnumerationTests.java98
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java55
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/PeekableIteratorTests.java140
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyCompositeListIteratorTests.java205
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyIteratorTests.java118
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java203
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementIteratorTests.java71
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementListIteratorTests.java111
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationIteratorTests.java229
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationListIteratorTests.java321
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TreeIteratorTests.java210
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/AbstractModelTests.java1686
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/JptUtilityModelTests.java37
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java188
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/JptUtilityModelListenerTests.java34
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java455
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java744
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java195
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java146
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveTreeChangeListenerTests.java515
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/BufferedWritablePropertyValueModelTests.java410
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionAspectAdapterTests.java369
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java237
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java236
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java416
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeListValueModelTests.java849
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CoordinatedBag.java149
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CoordinatedList.java256
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ExtendedListValueModelWrapperTests.java294
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java288
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringPropertyValueModelTests.java187
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java242
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java243
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java333
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java304
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/JptUtilityModelValueTests.java72
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListAspectAdapterTests.java475
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java274
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCuratorTests.java316
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullCollectionValueModelTests.java45
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullListValueModelTests.java55
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullPropertyValueModelTests.java41
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyAspectAdapterTests.java327
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java154
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyListValueModelAdapterTests.java201
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java411
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleListValueModelTests.java329
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimplePropertyValueModelTests.java94
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java198
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticCollectionValueModelTests.java63
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticListValueModelTests.java66
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticValueModelTests.java47
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/TransformationListValueModelAdapterTests.java319
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java185
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/TreeAspectAdapterTests.java355
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValueCollectionAdapterTests.java158
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValueListAdapterTests.java169
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValuePropertyAdapterTests.java144
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValueStateAdapterTests.java144
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/JptUtilityModelValuePrefsTests.java31
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java383
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java277
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java87
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java136
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java315
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java113
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java393
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java75
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java162
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java160
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java257
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/JptUtilityModelValueSwingTests.java42
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java318
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java372
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java135
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java149
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java204
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java200
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java231
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java259
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java39
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java119
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java343
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java646
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java733
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java817
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java426
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/AbstractNodeTests.java528
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/JptUtilityNodeTests.java29
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/test.xml40
1062 files changed, 0 insertions, 187590 deletions
diff --git a/assembly/features/org.eclipse.jpt.patch/.project b/assembly/features/org.eclipse.jpt.patch/.project
deleted file mode 100644
index b7a2bf552d..0000000000
--- a/assembly/features/org.eclipse.jpt.patch/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.patch</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/assembly/features/org.eclipse.jpt.patch/build.properties b/assembly/features/org.eclipse.jpt.patch/build.properties
deleted file mode 100644
index c381fb22bb..0000000000
--- a/assembly/features/org.eclipse.jpt.patch/build.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-bin.includes = feature.xml,\
- license.html,\
- feature.properties,\
- epl-v10.html,\
- eclipse_update_120.jpg
-src.includes = eclipse_update_120.jpg,\
- epl-v10.html,\
- feature.properties,\
- feature.xml,\
- license.html
diff --git a/assembly/features/org.eclipse.jpt.patch/buildnotes_org.eclipse.jpt.patch.html b/assembly/features/org.eclipse.jpt.patch/buildnotes_org.eclipse.jpt.patch.html
deleted file mode 100644
index 0d115f43fb..0000000000
--- a/assembly/features/org.eclipse.jpt.patch/buildnotes_org.eclipse.jpt.patch.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Build" content="Build">
- <title>Java Persistence Tools (JTP) 1.0.2 Patches</title>
-</head>
-
-<body>
-
-<h1>JTP 2.0.2 Patches</h1>
-
-<h2>Feature Patched: org.eclipse.jpt.patch</h2>
-<h3>Plugin(s) replaced:</h3>
-<ul><li>org.eclipse.jpt.gen</li></ul>
-<p>Bug <a href='https://bugs.eclipse.org/220297'>220297</a>. Entity generation creates Embeddables with compile errors in some cases.</p>
-
-
-</body></html> \ No newline at end of file
diff --git a/assembly/features/org.eclipse.jpt.patch/eclipse_update_120.jpg b/assembly/features/org.eclipse.jpt.patch/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/assembly/features/org.eclipse.jpt.patch/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/assembly/features/org.eclipse.jpt.patch/epl-v10.html b/assembly/features/org.eclipse.jpt.patch/epl-v10.html
deleted file mode 100644
index ed4b196655..0000000000
--- a/assembly/features/org.eclipse.jpt.patch/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html> \ No newline at end of file
diff --git a/assembly/features/org.eclipse.jpt.patch/feature.properties b/assembly/features/org.eclipse.jpt.patch/feature.properties
deleted file mode 100644
index a8457ea0cc..0000000000
--- a/assembly/features/org.eclipse.jpt.patch/feature.properties
+++ /dev/null
@@ -1,143 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-
-# "featureName" property - name of the feature
-featureName=Java Persistence Tools (JTP) Patches
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse.org
-
-# "updateSiteName" property - label for the update site
-updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site
-
-# "description" property - description of the feature
-description=\
-Patch(s) for Java Persistence API (JPA) Tools. \n\
-See bug 220297 (https://bugs.eclipse.org/bugs/220297) Entity generation creates Embeddables with compile errors in some cases \n\
-
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006-08 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\
-June 06, 2007\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public\n\
-License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\
-Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse.org CVS\n\
-repository ("Repository") in CVS modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-Features may also include other Features ("Included Features"). Files named\n\
-"feature.xml" may contain a list of the names and version numbers of\n\
-Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Eclipse Update Manager, you must agree to a license ("Feature Update\n\
-License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties". Such Abouts,\n\
-Feature Licenses and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your\n\
-use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
- - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use,\n\
-and re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n
-########### end of license property ##########################################
diff --git a/assembly/features/org.eclipse.jpt.patch/feature.xml b/assembly/features/org.eclipse.jpt.patch/feature.xml
deleted file mode 100644
index 4fae92b5fa..0000000000
--- a/assembly/features/org.eclipse.jpt.patch/feature.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.patch"
- label="%featureName"
- version="1.0.2.qualifier"
- provider-name="%providerName">
-
- <description url="http://download.eclipse.org/webtools/patches/">
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="%licenseURL">
- %license
- </license>
-
- <url>
- <update label="Web Tools Platform (WTP) Patches" url="http://download.eclipse.org/webtools/patches/"/>
- </url>
-
- <requires>
- <import feature="org.eclipse.jpt.feature" version="1.0.2.v200802140100-77-7_CYQCD2CaLYCHCD" patch="true"/>
- </requires>
-
- <plugin
- id="org.eclipse.jpt.gen"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
-</feature>
diff --git a/assembly/features/org.eclipse.jpt.patch/license.html b/assembly/features/org.eclipse.jpt.patch/license.html
deleted file mode 100644
index 2347060ef3..0000000000
--- a/assembly/features/org.eclipse.jpt.patch/license.html
+++ /dev/null
@@ -1,93 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0044)http://www.eclipse.org/legal/epl/notice.html -->
-<HTML><HEAD><TITLE>Eclipse.org Software User Agreement</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<META content="MSHTML 6.00.2800.1479" name=GENERATOR></HEAD>
-<BODY lang=EN-US vLink=purple link=blue>
-<H2>Eclipse Foundation Software User Agreement</H2>
-<P>January 28, 2005</P>
-<H3>Usage Of Content</H3>
-<P>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION
-AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF
-THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
-BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED
-BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY
-APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU
-MAY NOT USE THE CONTENT.</P>
-<H3>Applicable Licenses</H3>
-<P>Unless otherwise indicated, all Content made available by the Eclipse
-Foundation is provided to you under the terms and conditions of the Eclipse
-Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this
-Content and is also available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>Content includes, but is not limited to, source code, object code,
-documentation and other files maintained in the Eclipse.org CVS repository
-("Repository") in CVS modules ("Modules") and made available as downloadable
-archives ("Downloads").</P>
-<P>Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments
-("Fragments"), and features ("Features"). A Feature is a bundle of one or more
-Plug-ins and/or Fragments and associated material. Files named "feature.xml" may
-contain a list of the names and version numbers of the Plug-ins and/or Fragments
-associated with a Feature. Plug-ins and Fragments are located in directories
-named "plugins" and Features are located in directories named "features".</P>
-<P>Features may also include other Features ("Included Features"). Files named
-"feature.xml" may contain a list of the names and version numbers of Included
-Features.</P>
-<P>The terms and conditions governing Plug-ins and Fragments should be contained
-in files named "about.html" ("Abouts"). The terms and conditions governing
-Features and Included Features should be contained in files named "license.html"
-("Feature Licenses"). Abouts and Feature Licenses may be located in any
-directory of a Download or Module including, but not limited to the following
-locations:</P>
-<UL>
- <LI>The top-level (root) directory
- <LI>Plug-in and Fragment directories
- <LI>Subdirectories of the directory named "src" of certain Plug-ins
- <LI>Feature directories </LI></UL>
-<P>Note: if a Feature made available by the Eclipse Foundation is installed
-using the Eclipse Update Manager, you must agree to a license ("Feature Update
-License") during the installation process. If the Feature contains Included
-Features, the Feature Update License should either provide you with the terms
-and conditions governing the Included Features or inform you where you can
-locate them. Feature Update Licenses may be found in the "license" property of
-files named "feature.properties". Such Abouts, Feature Licenses and Feature
-Update Licenses contain the terms and conditions (or references to such terms
-and conditions) that govern your use of the associated Content in that
-directory.</P>
-<P>THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL
-OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</P>
-<UL>
- <LI>Common Public License Version 1.0 (available at <A
- href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</A>)
-
- <LI>Apache Software License 1.1 (available at <A
- href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</A>)
-
- <LI>Apache Software License 2.0 (available at <A
- href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</A>)
-
- <LI>IBM Public License 1.0 (available at <A
- href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</A>)
-
- <LI>Metro Link Public License 1.00 (available at <A
- href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</A>)
-
- <LI>Mozilla Public License Version 1.1 (available at <A
- href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</A>)
- </LI></UL>
-<P>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is
-provided, please contact the Eclipse Foundation to determine what terms and
-conditions govern that particular Content.</P>
-<H3>Cryptography</H3>
-<P>Content may contain encryption software. The country in which you are
-currently may have restrictions on the import, possession, and use, and/or
-re-export to another country, of encryption software. BEFORE using any
-encryption software, please check the country's laws, regulations and policies
-concerning the import, possession, or use, and re-export of encryption software,
-to see if this is permitted.</P></BODY></HTML>
diff --git a/assembly/features/org.eclipse.jpt.sdk/.cvsignore b/assembly/features/org.eclipse.jpt.sdk/.cvsignore
deleted file mode 100644
index bc2abf75c1..0000000000
--- a/assembly/features/org.eclipse.jpt.sdk/.cvsignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*.bin.dist.zip
-build.xml
-features
-plugins
diff --git a/assembly/features/org.eclipse.jpt.sdk/.project b/assembly/features/org.eclipse.jpt.sdk/.project
deleted file mode 100644
index 821d453136..0000000000
--- a/assembly/features/org.eclipse.jpt.sdk/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.sdk</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/assembly/features/org.eclipse.jpt.sdk/build.properties b/assembly/features/org.eclipse.jpt.sdk/build.properties
deleted file mode 100644
index 7200939aca..0000000000
--- a/assembly/features/org.eclipse.jpt.sdk/build.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-bin.includes = feature.xml,\
- eclipse_update_120.jpg,\
- epl-v10.html,\
- license.html,\
- feature.properties
diff --git a/assembly/features/org.eclipse.jpt.sdk/eclipse_update_120.jpg b/assembly/features/org.eclipse.jpt.sdk/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/assembly/features/org.eclipse.jpt.sdk/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/assembly/features/org.eclipse.jpt.sdk/epl-v10.html b/assembly/features/org.eclipse.jpt.sdk/epl-v10.html
deleted file mode 100644
index ed4b196655..0000000000
--- a/assembly/features/org.eclipse.jpt.sdk/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html> \ No newline at end of file
diff --git a/assembly/features/org.eclipse.jpt.sdk/feature.properties b/assembly/features/org.eclipse.jpt.sdk/feature.properties
deleted file mode 100644
index abb0c88d62..0000000000
--- a/assembly/features/org.eclipse.jpt.sdk/feature.properties
+++ /dev/null
@@ -1,145 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-# feature.properties
-# contains externalized strings for feature.xml
-# "%foo" in feature.xml corresponds to the key "foo" in this file
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file should be translated.
-
-# "featureName" property - name of the feature
-featureName=Dali Java Persistence API (JPA) project SDK
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse.org
-
-# "updateSiteName" property - label for the update site
-updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site
-
-# "description" property - description of the feature
-description=Dali Java Persistence API (JPA) project SDK
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\
-June 06, 2007\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public\n\
-License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\
-Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse.org CVS\n\
-repository ("Repository") in CVS modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-Features may also include other Features ("Included Features"). Files named\n\
-"feature.xml" may contain a list of the names and version numbers of\n\
-Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Eclipse Update Manager, you must agree to a license ("Feature Update\n\
-License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties". Such Abouts,\n\
-Feature Licenses and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your\n\
-use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
- - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use,\n\
-and re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n
-########### end of license property ##########################################
diff --git a/assembly/features/org.eclipse.jpt.sdk/feature.xml b/assembly/features/org.eclipse.jpt.sdk/feature.xml
deleted file mode 100644
index 8f348d7030..0000000000
--- a/assembly/features/org.eclipse.jpt.sdk/feature.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.sdk"
- label="%featureName"
- version="2.0.0.qualifier"
- provider-name="%providerName"
- plugin="org.eclipse.jpt"
- image="eclipse_update_120.jpg">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <url>
- <update label="%updateSiteName" url="http://download.eclipse.org/webtools/updates"/>
- <discovery label="Web Tools Platform (WTP) Updates" url="http://download.eclipse.org/webtools/updates"/>
- </url>
-
- <includes
- id="org.eclipse.jpt_sdk.feature"
- version="0.0.0"/>
-
- <includes
- id="org.eclipse.jpt.eclipselink_sdk.feature"
- version="0.0.0"/>
-
- <plugin
- id="org.eclipse.jpt"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
-</feature>
diff --git a/assembly/features/org.eclipse.jpt.sdk/license.html b/assembly/features/org.eclipse.jpt.sdk/license.html
deleted file mode 100644
index 76abfb4621..0000000000
--- a/assembly/features/org.eclipse.jpt.sdk/license.html
+++ /dev/null
@@ -1,98 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0044)http://www.eclipse.org/legal/epl/notice.html -->
-<HTML><HEAD><TITLE>Eclipse.org Software User Agreement</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<META content="MSHTML 6.00.2800.1479" name=GENERATOR></HEAD>
-<BODY lang=EN-US vLink=purple link=blue>
-<H2>Eclipse Foundation Software User Agreement</H2>
-<P>June 06, 2007</P>
-<H3>Usage Of Content</H3>
-<P>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION
-AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF
-THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
-BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED
-BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY
-APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU
-MAY NOT USE THE CONTENT.</P>
-<H3>Applicable Licenses</H3>
-<P>Unless otherwise indicated, all Content made available by the Eclipse
-Foundation is provided to you under the terms and conditions of the Eclipse
-Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this
-Content and is also available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>Content includes, but is not limited to, source code, object code,
-documentation and other files maintained in the Eclipse.org CVS repository
-("Repository") in CVS modules ("Modules") and made available as downloadable
-archives ("Downloads").</P>
-<P>Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments
-("Fragments"), and features ("Features"). A Feature is a bundle of one or more
-Plug-ins and/or Fragments and associated material. Files named "feature.xml" may
-contain a list of the names and version numbers of the Plug-ins and/or Fragments
-associated with a Feature. Plug-ins and Fragments are located in directories
-named "plugins" and Features are located in directories named "features".</P>
-<P>Features may also include other Features ("Included Features"). Files named
-"feature.xml" may contain a list of the names and version numbers of Included
-Features.</P>
-<P>The terms and conditions governing Plug-ins and Fragments should be contained
-in files named "about.html" ("Abouts"). The terms and conditions governing
-Features and Included Features should be contained in files named "license.html"
-("Feature Licenses"). Abouts and Feature Licenses may be located in any
-directory of a Download or Module including, but not limited to the following
-locations:</P>
-<UL>
- <LI>The top-level (root) directory
- <LI>Plug-in and Fragment directories
- <LI>Subdirectories of the directory named "src" of certain Plug-ins
- <LI>Feature directories </LI></UL>
-<P>Note: if a Feature made available by the Eclipse Foundation is installed
-using the Eclipse Update Manager, you must agree to a license ("Feature Update
-License") during the installation process. If the Feature contains Included
-Features, the Feature Update License should either provide you with the terms
-and conditions governing the Included Features or inform you where you can
-locate them. Feature Update Licenses may be found in the "license" property of
-files named "feature.properties". Such Abouts, Feature Licenses and Feature
-Update Licenses contain the terms and conditions (or references to such terms
-and conditions) that govern your use of the associated Content in that
-directory.</P>
-<P>THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL
-OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</P>
-<UL>
- <LI>Common Public License Version 1.0 (available at <A
- href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</A>)
-
- <LI>Apache Software License 1.1 (available at <A
- href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</A>)
-
- <LI>Apache Software License 2.0 (available at <A
- href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</A>)
-
- <LI>IBM Public License 1.0 (available at <A
- href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</A>)
-
- <LI>Metro Link Public License 1.00 (available at <A
- href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</A>)
-
- <LI>Mozilla Public License Version 1.1 (available at <A
- href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</A>)
- </LI>
-
- <LI>Common Development and Distribution License (CDDL) Version 1.0 (available at <A
- href="http://www.sun.com/cddl/cddl.html">http://www.sun.com/cddl/cddl.html)</A>
- </LI>
-</UL>
-<P>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is
-provided, please contact the Eclipse Foundation to determine what terms and
-conditions govern that particular Content.</P>
-<H3>Cryptography</H3>
-<P>Content may contain encryption software. The country in which you are
-currently may have restrictions on the import, possession, and use, and/or
-re-export to another country, of encryption software. BEFORE using any
-encryption software, please check the country's laws, regulations and policies
-concerning the import, possession, or use, and re-export of encryption software,
-to see if this is permitted.</P></BODY></HTML>
diff --git a/assembly/features/org.eclipse.jpt.tests/.cvsignore b/assembly/features/org.eclipse.jpt.tests/.cvsignore
deleted file mode 100644
index 2544693f86..0000000000
--- a/assembly/features/org.eclipse.jpt.tests/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*.bin.dist.zip
-build.xml
-org.eclipse.jpt.tests_1.0.0.* \ No newline at end of file
diff --git a/assembly/features/org.eclipse.jpt.tests/.project b/assembly/features/org.eclipse.jpt.tests/.project
deleted file mode 100644
index 3d1dde631a..0000000000
--- a/assembly/features/org.eclipse.jpt.tests/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/assembly/features/org.eclipse.jpt.tests/.settings/org.eclipse.core.resources.prefs b/assembly/features/org.eclipse.jpt.tests/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 17acb651a8..0000000000
--- a/assembly/features/org.eclipse.jpt.tests/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Sun May 27 15:11:05 EDT 2007
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/assembly/features/org.eclipse.jpt.tests/build.properties b/assembly/features/org.eclipse.jpt.tests/build.properties
deleted file mode 100644
index 7f47694aab..0000000000
--- a/assembly/features/org.eclipse.jpt.tests/build.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-bin.includes = feature.xml,\
- eclipse_update_120.jpg,\
- epl-v10.html,\
- license.html,\
- feature.properties
diff --git a/assembly/features/org.eclipse.jpt.tests/eclipse_update_120.jpg b/assembly/features/org.eclipse.jpt.tests/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/assembly/features/org.eclipse.jpt.tests/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/assembly/features/org.eclipse.jpt.tests/epl-v10.html b/assembly/features/org.eclipse.jpt.tests/epl-v10.html
deleted file mode 100644
index ed4b196655..0000000000
--- a/assembly/features/org.eclipse.jpt.tests/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html> \ No newline at end of file
diff --git a/assembly/features/org.eclipse.jpt.tests/feature.properties b/assembly/features/org.eclipse.jpt.tests/feature.properties
deleted file mode 100644
index 6b58fe6a33..0000000000
--- a/assembly/features/org.eclipse.jpt.tests/feature.properties
+++ /dev/null
@@ -1,145 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-# feature.properties
-# contains externalized strings for feature.xml
-# "%foo" in feature.xml corresponds to the key "foo" in this file
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file should be translated.
-
-# "featureName" property - name of the feature
-featureName=Dali Java Persistence API (JPA) project Tests
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse.org
-
-# "updateSiteName" property - label for the update site
-updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site
-
-# "description" property - description of the feature
-description=Dali Java Persistence API (JPA) project Tests
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\
-June 06, 2007\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public\n\
-License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\
-Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse.org CVS\n\
-repository ("Repository") in CVS modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-Features may also include other Features ("Included Features"). Files named\n\
-"feature.xml" may contain a list of the names and version numbers of\n\
-Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Eclipse Update Manager, you must agree to a license ("Feature Update\n\
-License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties". Such Abouts,\n\
-Feature Licenses and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your\n\
-use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
- - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use,\n\
-and re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n
-########### end of license property ##########################################
diff --git a/assembly/features/org.eclipse.jpt.tests/feature.xml b/assembly/features/org.eclipse.jpt.tests/feature.xml
deleted file mode 100644
index 957e7c2d52..0000000000
--- a/assembly/features/org.eclipse.jpt.tests/feature.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.tests"
- label="%featureName"
- version="2.0.0.qualifier"
- provider-name="%providerName">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <url>
- <update label="%updateSiteName" url="http://download.eclipse.org/webtools/updates/"/>
- </url>
-
- <includes
- id="org.eclipse.jpt.tests.feature"
- version="0.0.0"/>
-
-</feature>
diff --git a/assembly/features/org.eclipse.jpt.tests/license.html b/assembly/features/org.eclipse.jpt.tests/license.html
deleted file mode 100644
index 56445985d9..0000000000
--- a/assembly/features/org.eclipse.jpt.tests/license.html
+++ /dev/null
@@ -1,98 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0044)http://www.eclipse.org/legal/epl/notice.html -->
-<HTML><HEAD><TITLE>Eclipse.org Software User Agreement</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<META content="MSHTML 6.00.2800.1479" name=GENERATOR></HEAD>
-<BODY lang=EN-US vLink=purple link=blue>
-<H2>Eclipse Foundation Software User Agreement</H2>
-<P>June 06, 2007</P>
-<H3>Usage Of Content</H3>
-<P>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION
-AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF
-THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
-BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED
-BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY
-APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU
-MAY NOT USE THE CONTENT.</P>
-<H3>Applicable Licenses</H3>
-<P>Unless otherwise indicated, all Content made available by the Eclipse
-Foundation is provided to you under the terms and conditions of the Eclipse
-Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this
-Content and is also available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>Content includes, but is not limited to, source code, object code,
-documentation and other files maintained in the Eclipse.org CVS repository
-("Repository") in CVS modules ("Modules") and made available as downloadable
-archives ("Downloads").</P>
-<P>Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments
-("Fragments"), and features ("Features"). A Feature is a bundle of one or more
-Plug-ins and/or Fragments and associated material. Files named "feature.xml" may
-contain a list of the names and version numbers of the Plug-ins and/or Fragments
-associated with a Feature. Plug-ins and Fragments are located in directories
-named "plugins" and Features are located in directories named "features".</P>
-<P>Features may also include other Features ("Included Features"). Files named
-"feature.xml" may contain a list of the names and version numbers of Included
-Features.</P>
-<P>The terms and conditions governing Plug-ins and Fragments should be contained
-in files named "about.html" ("Abouts"). The terms and conditions governing
-Features and Included Features should be contained in files named "license.html"
-("Feature Licenses"). Abouts and Feature Licenses may be located in any
-directory of a Download or Module including, but not limited to the following
-locations:</P>
-<UL>
- <LI>The top-level (root) directory
- <LI>Plug-in and Fragment directories
- <LI>Subdirectories of the directory named "src" of certain Plug-ins
- <LI>Feature directories </LI></UL>
-<P>Note: if a Feature made available by the Eclipse Foundation is installed
-using the Eclipse Update Manager, you must agree to a license ("Feature Update
-License") during the installation process. If the Feature contains Included
-Features, the Feature Update License should either provide you with the terms
-and conditions governing the Included Features or inform you where you can
-locate them. Feature Update Licenses may be found in the "license" property of
-files named "feature.properties". Such Abouts, Feature Licenses and Feature
-Update Licenses contain the terms and conditions (or references to such terms
-and conditions) that govern your use of the associated Content in that
-directory.</P>
-<P>THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL
-OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</P>
-<UL>
- <LI>Common Public License Version 1.0 (available at <A
- href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</A>)
-
- <LI>Apache Software License 1.1 (available at <A
- href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</A>)
-
- <LI>Apache Software License 2.0 (available at <A
- href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</A>)
-
- <LI>IBM Public License 1.0 (available at <A
- href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</A>)
-
- <LI>Metro Link Public License 1.00 (available at <A
- href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</A>)
-
- <LI>Mozilla Public License Version 1.1 (available at <A
- href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</A>)
- </LI>
-
- <LI>Common Development and Distribution License (CDDL) Version 1.0 (available at <A
- href="http://www.sun.com/cddl/cddl.html">http://www.sun.com/cddl/cddl.html)</A>
- </LI>
-</UL>
-<P>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is
-provided, please contact the Eclipse Foundation to determine what terms and
-conditions govern that particular Content.</P>
-<H3>Cryptography</H3>
-<P>Content may contain encryption software. The country in which you are
-currently may have restrictions on the import, possession, and use, and/or
-re-export to another country, of encryption software. BEFORE using any
-encryption software, please check the country's laws, regulations and policies
-concerning the import, possession, or use, and re-export of encryption software,
-to see if this is permitted.</P></BODY></HTML>
diff --git a/assembly/features/org.eclipse.jpt/.cvsignore b/assembly/features/org.eclipse.jpt/.cvsignore
deleted file mode 100644
index de8b73fb72..0000000000
--- a/assembly/features/org.eclipse.jpt/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-build.xml
-org.eclipse.jpt_1.0.0.*
diff --git a/assembly/features/org.eclipse.jpt/.project b/assembly/features/org.eclipse.jpt/.project
deleted file mode 100644
index b7aaec2f54..0000000000
--- a/assembly/features/org.eclipse.jpt/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/assembly/features/org.eclipse.jpt/build.properties b/assembly/features/org.eclipse.jpt/build.properties
deleted file mode 100644
index 470b4bcb63..0000000000
--- a/assembly/features/org.eclipse.jpt/build.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-bin.includes = feature.xml,\
- eclipse_update_120.jpg,\
- epl-v10.html,\
- license.html,\
- feature.properties
- \ No newline at end of file
diff --git a/assembly/features/org.eclipse.jpt/eclipse_update_120.jpg b/assembly/features/org.eclipse.jpt/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/assembly/features/org.eclipse.jpt/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/assembly/features/org.eclipse.jpt/epl-v10.html b/assembly/features/org.eclipse.jpt/epl-v10.html
deleted file mode 100644
index ed4b196655..0000000000
--- a/assembly/features/org.eclipse.jpt/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html> \ No newline at end of file
diff --git a/assembly/features/org.eclipse.jpt/feature.properties b/assembly/features/org.eclipse.jpt/feature.properties
deleted file mode 100644
index 0ae42bbb56..0000000000
--- a/assembly/features/org.eclipse.jpt/feature.properties
+++ /dev/null
@@ -1,144 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-# feature.properties
-# contains externalized strings for feature.xml
-# "%foo" in feature.xml corresponds to the key "foo" in this file
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file should be translated.
-
-# "featureName" property - name of the feature
-featureName=Java Persistence API Tools
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse.org
-
-# "updateSiteName" property - label for the update site
-updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site
-
-# "description" property - description of the feature
-description=Java Persistence API Tools - Runtime
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\
-March 17, 2005\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public\n\
-License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\
-Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse.org CVS\n\
-repository ("Repository") in CVS modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-Features may also include other Features ("Included Features"). Files named\n\
-"feature.xml" may contain a list of the names and version numbers of\n\
-Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Eclipse Update Manager, you must agree to a license ("Feature Update\n\
-License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties". Such Abouts,\n\
-Feature Licenses and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your\n\
-use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use,\n\
-and re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n
-########### end of license property ##########################################
diff --git a/assembly/features/org.eclipse.jpt/feature.xml b/assembly/features/org.eclipse.jpt/feature.xml
deleted file mode 100644
index 2bc81cb8a9..0000000000
--- a/assembly/features/org.eclipse.jpt/feature.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt"
- label="%featureName"
- version="2.0.0.qualifier"
- provider-name="%providerName"
- plugin="org.eclipse.jpt"
- image="eclipse_update_120.jpg">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <url>
- <update label="%updateSiteName" url="http://download.eclipse.org/webtools/updates"/>
- <discovery label="Web Tools Platform (WTP) Updates" url="http://download.eclipse.org/webtools/updates"/>
- </url>
-
- <includes
- id="org.eclipse.jpt.feature"
- version="0.0.0"/>
-
- <includes
- id="org.eclipse.jpt.eclipselink.feature"
- version="0.0.0"/>
-
- <plugin
- id="org.eclipse.jpt"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
-</feature>
diff --git a/assembly/features/org.eclipse.jpt/license.html b/assembly/features/org.eclipse.jpt/license.html
deleted file mode 100644
index 2347060ef3..0000000000
--- a/assembly/features/org.eclipse.jpt/license.html
+++ /dev/null
@@ -1,93 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0044)http://www.eclipse.org/legal/epl/notice.html -->
-<HTML><HEAD><TITLE>Eclipse.org Software User Agreement</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<META content="MSHTML 6.00.2800.1479" name=GENERATOR></HEAD>
-<BODY lang=EN-US vLink=purple link=blue>
-<H2>Eclipse Foundation Software User Agreement</H2>
-<P>January 28, 2005</P>
-<H3>Usage Of Content</H3>
-<P>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION
-AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF
-THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
-BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED
-BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY
-APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU
-MAY NOT USE THE CONTENT.</P>
-<H3>Applicable Licenses</H3>
-<P>Unless otherwise indicated, all Content made available by the Eclipse
-Foundation is provided to you under the terms and conditions of the Eclipse
-Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this
-Content and is also available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>Content includes, but is not limited to, source code, object code,
-documentation and other files maintained in the Eclipse.org CVS repository
-("Repository") in CVS modules ("Modules") and made available as downloadable
-archives ("Downloads").</P>
-<P>Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments
-("Fragments"), and features ("Features"). A Feature is a bundle of one or more
-Plug-ins and/or Fragments and associated material. Files named "feature.xml" may
-contain a list of the names and version numbers of the Plug-ins and/or Fragments
-associated with a Feature. Plug-ins and Fragments are located in directories
-named "plugins" and Features are located in directories named "features".</P>
-<P>Features may also include other Features ("Included Features"). Files named
-"feature.xml" may contain a list of the names and version numbers of Included
-Features.</P>
-<P>The terms and conditions governing Plug-ins and Fragments should be contained
-in files named "about.html" ("Abouts"). The terms and conditions governing
-Features and Included Features should be contained in files named "license.html"
-("Feature Licenses"). Abouts and Feature Licenses may be located in any
-directory of a Download or Module including, but not limited to the following
-locations:</P>
-<UL>
- <LI>The top-level (root) directory
- <LI>Plug-in and Fragment directories
- <LI>Subdirectories of the directory named "src" of certain Plug-ins
- <LI>Feature directories </LI></UL>
-<P>Note: if a Feature made available by the Eclipse Foundation is installed
-using the Eclipse Update Manager, you must agree to a license ("Feature Update
-License") during the installation process. If the Feature contains Included
-Features, the Feature Update License should either provide you with the terms
-and conditions governing the Included Features or inform you where you can
-locate them. Feature Update Licenses may be found in the "license" property of
-files named "feature.properties". Such Abouts, Feature Licenses and Feature
-Update Licenses contain the terms and conditions (or references to such terms
-and conditions) that govern your use of the associated Content in that
-directory.</P>
-<P>THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL
-OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</P>
-<UL>
- <LI>Common Public License Version 1.0 (available at <A
- href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</A>)
-
- <LI>Apache Software License 1.1 (available at <A
- href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</A>)
-
- <LI>Apache Software License 2.0 (available at <A
- href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</A>)
-
- <LI>IBM Public License 1.0 (available at <A
- href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</A>)
-
- <LI>Metro Link Public License 1.00 (available at <A
- href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</A>)
-
- <LI>Mozilla Public License Version 1.1 (available at <A
- href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</A>)
- </LI></UL>
-<P>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is
-provided, please contact the Eclipse Foundation to determine what terms and
-conditions govern that particular Content.</P>
-<H3>Cryptography</H3>
-<P>Content may contain encryption software. The country in which you are
-currently may have restrictions on the import, possession, and use, and/or
-re-export to another country, of encryption software. BEFORE using any
-encryption software, please check the country's laws, regulations and policies
-concerning the import, possession, or use, and re-export of encryption software,
-to see if this is permitted.</P></BODY></HTML>
diff --git a/assembly/plugins/org.eclipse.jpt/.cvsignore b/assembly/plugins/org.eclipse.jpt/.cvsignore
deleted file mode 100644
index c9401a2c83..0000000000
--- a/assembly/plugins/org.eclipse.jpt/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-build.xml
-org.eclipse.jpt_1.0.0.* \ No newline at end of file
diff --git a/assembly/plugins/org.eclipse.jpt/.project b/assembly/plugins/org.eclipse.jpt/.project
deleted file mode 100644
index f51b04cc90..0000000000
--- a/assembly/plugins/org.eclipse.jpt/.project
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/assembly/plugins/org.eclipse.jpt/.settings/org.eclipse.core.resources.prefs b/assembly/plugins/org.eclipse.jpt/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 4aec29d1cd..0000000000
--- a/assembly/plugins/org.eclipse.jpt/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Sun May 27 15:10:09 EDT 2007
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/assembly/plugins/org.eclipse.jpt/META-INF/MANIFEST.MF b/assembly/plugins/org.eclipse.jpt/META-INF/MANIFEST.MF
deleted file mode 100644
index 293a9e0e63..0000000000
--- a/assembly/plugins/org.eclipse.jpt/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,7 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jpt; singleton:=true
-Bundle-Version: 2.0.0.qualifier
-Bundle-Localization: plugin
-Bundle-Vendor: %providerName
diff --git a/assembly/plugins/org.eclipse.jpt/about.html b/assembly/plugins/org.eclipse.jpt/about.html
deleted file mode 100644
index ca606b1bb5..0000000000
--- a/assembly/plugins/org.eclipse.jpt/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>June 06, 2007</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML> \ No newline at end of file
diff --git a/assembly/plugins/org.eclipse.jpt/about.ini b/assembly/plugins/org.eclipse.jpt/about.ini
deleted file mode 100644
index 588a325a8f..0000000000
--- a/assembly/plugins/org.eclipse.jpt/about.ini
+++ /dev/null
@@ -1,44 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-# about.ini
-# contains information about a feature
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# "%key" are externalized strings defined in about.properties
-# This file does not need to be translated.
-
-# Property "aboutText" contains blurb for "About" dialog (translated)
-aboutText=%blurb
-
-# Property "windowImage" contains path to window icon (16x16)
-# needed for primary features only
-
-# Property "featureImage" contains path to feature image (32x32)
-featureImage=eclipse32.gif
-
-# Property "aboutImage" contains path to product image (500x330 or 115x164)
-# needed for primary features only
-
-# Property "appName" contains name of the application (translated)
-# needed for primary features only
-
-# Property "welcomePage" contains path to welcome page (special XML-based format)
-# optional
-
-# Property "welcomePerspective" contains the id of the perspective in which the
-# welcome page is to be opened.
-# optional
-
-# Property "tipsAndTricksHref" contains the Help topic href to a tips and tricks page
-# optional
-tipsAndTricksHref=/org.eclipse.jpt.doc.user/tips_and_tricks.htm
-
-
diff --git a/assembly/plugins/org.eclipse.jpt/about.mappings b/assembly/plugins/org.eclipse.jpt/about.mappings
deleted file mode 100644
index bddaab4310..0000000000
--- a/assembly/plugins/org.eclipse.jpt/about.mappings
+++ /dev/null
@@ -1,6 +0,0 @@
-# about.mappings
-# contains fill-ins for about.properties
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file does not need to be translated.
-
-0=@build@ \ No newline at end of file
diff --git a/assembly/plugins/org.eclipse.jpt/about.properties b/assembly/plugins/org.eclipse.jpt/about.properties
deleted file mode 100644
index 159bfceeba..0000000000
--- a/assembly/plugins/org.eclipse.jpt/about.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-# about.properties
-# contains externalized strings for about.ini
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# fill-ins are supplied by about.mappings
-# This file should be translated.
-
-blurb=Java Persistence API Tools\n\
-\n\
-Version: {featureVersion}\n\
-Build id: {0}\n\
-\n\
-(c) Copyright Eclipse contributors and others 2006. All rights reserved.\n\
-Visit http://www.eclipse.org/webtools
diff --git a/assembly/plugins/org.eclipse.jpt/build.properties b/assembly/plugins/org.eclipse.jpt/build.properties
deleted file mode 100644
index 0ccfb0ebb8..0000000000
--- a/assembly/plugins/org.eclipse.jpt/build.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- about.ini,\
- about.html,\
- about.mappings,\
- about.properties,\
- eclipse32.gif,\
- eclipse32.png,\
- plugin.properties,\
- component.xml
diff --git a/assembly/plugins/org.eclipse.jpt/component.xml b/assembly/plugins/org.eclipse.jpt/component.xml
deleted file mode 100644
index 11f133f65a..0000000000
--- a/assembly/plugins/org.eclipse.jpt/component.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.jpt">
-<description url=""></description>
-<component-depends unrestricted="true"></component-depends>
-<plugin id="org.eclipse.jpt" fragment="false"/>
-<plugin id="org.eclipse.jpt.core" fragment="false"/>
-<plugin id="org.eclipse.jpt.db" fragment="false"/>
-<plugin id="org.eclipse.jpt.db.ui" fragment="false"/>
-<plugin id="org.eclipse.jpt.gen" fragment="false"/>
-<plugin id="org.eclipse.jpt.ui" fragment="false"/>
-<plugin id="org.eclipse.jpt.utility" fragment="false"/>
-</component> \ No newline at end of file
diff --git a/assembly/plugins/org.eclipse.jpt/eclipse32.gif b/assembly/plugins/org.eclipse.jpt/eclipse32.gif
deleted file mode 100644
index e6ad7ccd75..0000000000
--- a/assembly/plugins/org.eclipse.jpt/eclipse32.gif
+++ /dev/null
Binary files differ
diff --git a/assembly/plugins/org.eclipse.jpt/eclipse32.png b/assembly/plugins/org.eclipse.jpt/eclipse32.png
deleted file mode 100644
index 568fac1d05..0000000000
--- a/assembly/plugins/org.eclipse.jpt/eclipse32.png
+++ /dev/null
Binary files differ
diff --git a/assembly/plugins/org.eclipse.jpt/plugin.properties b/assembly/plugins/org.eclipse.jpt/plugin.properties
deleted file mode 100644
index f45a08d54e..0000000000
--- a/assembly/plugins/org.eclipse.jpt/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-pluginName = Java Persistence API Tools
-providerName = Eclipse.org
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/.cvsignore b/jpa/features/org.eclipse.jpt.eclipselink.feature/.cvsignore
deleted file mode 100644
index c14487ceac..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-build.xml
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/.project b/jpa/features/org.eclipse.jpt.eclipselink.feature/.project
deleted file mode 100644
index 93f19b18a8..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.eclipselink.feature</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/.settings/org.eclipse.core.resources.prefs b/jpa/features/org.eclipse.jpt.eclipselink.feature/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index dab5837cb6..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Sun May 27 15:10:47 EDT 2007
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/build.properties b/jpa/features/org.eclipse.jpt.eclipselink.feature/build.properties
deleted file mode 100644
index 7200939aca..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/build.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-bin.includes = feature.xml,\
- eclipse_update_120.jpg,\
- epl-v10.html,\
- license.html,\
- feature.properties
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt.eclipselink.feature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/epl-v10.html b/jpa/features/org.eclipse.jpt.eclipselink.feature/epl-v10.html
deleted file mode 100644
index ed4b196655..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html> \ No newline at end of file
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/feature.properties b/jpa/features/org.eclipse.jpt.eclipselink.feature/feature.properties
deleted file mode 100644
index 8c6e972b14..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/feature.properties
+++ /dev/null
@@ -1,140 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-
-# "featureName" property - name of the feature
-featureName=Java Persistence API EclipseLink Extension
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse.org
-
-# "updateSiteName" property - label for the update site
-updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site
-
-# "description" property - description of the feature
-description=Java Persistence API (JPA) EclipseLink Extension
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006-08 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\
-June 06, 2007\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public\n\
-License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\
-Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse.org CVS\n\
-repository ("Repository") in CVS modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-Features may also include other Features ("Included Features"). Files named\n\
-"feature.xml" may contain a list of the names and version numbers of\n\
-Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Eclipse Update Manager, you must agree to a license ("Feature Update\n\
-License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties". Such Abouts,\n\
-Feature Licenses and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your\n\
-use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
- - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use,\n\
-and re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n
-########### end of license property ##########################################
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/feature.xml b/jpa/features/org.eclipse.jpt.eclipselink.feature/feature.xml
deleted file mode 100644
index 366571318d..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/feature.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.eclipselink.feature"
- label="%featureName"
- version="2.0.0.qualifier"
- provider-name="%providerName"
- image="eclipse_update_120.jpg">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <url>
- <update label="Web Tools Platform (WTP) Updates" url="http://download.eclipse.org/webtools/updates"/>
- <discovery label="Web Tools Platform (WTP) Updates" url="http://download.eclipse.org/webtools/updates"/>
- <discovery label="Dali Java Persistence API Tools (JPA) Updates" url="http://download.eclipse.org/webtools/updates/"/>
- </url>
-
- <requires>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.emf.ecore"/>
- <import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.eclipse.jpt.db"/>
- <import plugin="org.eclipse.jpt.core"/>
- <import plugin="org.eclipse.jpt.utility"/>
- <import plugin="org.eclipse.wst.validation"/>
- <import plugin="org.eclipse.emf.edit.ui"/>
- <import plugin="org.eclipse.jpt.ui"/>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.ui.views.properties.tabbed"/>
- <import plugin="org.eclipse.jdt.ui"/>
- <import plugin="org.eclipse.debug.core"/>
- <import plugin="org.eclipse.jdt.launching"/>
- <import plugin="org.eclipse.ui.navigator"/>
- </requires>
-
- <plugin
- id="org.eclipse.jpt.eclipselink.core"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.jpt.eclipselink.ui"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
-</feature>
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/license.html b/jpa/features/org.eclipse.jpt.eclipselink.feature/license.html
deleted file mode 100644
index fc77372d46..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/license.html
+++ /dev/null
@@ -1,98 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0044)http://www.eclipse.org/legal/epl/notice.html -->
-<HTML><HEAD><TITLE>Eclipse.org Software User Agreement</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<META content="MSHTML 6.00.2800.1479" name=GENERATOR></HEAD>
-<BODY lang=EN-US vLink=purple link=blue>
-<H2>Eclipse Foundation Software User Agreement</H2>
-<P>June 06, 2007</P>
-<H3>Usage Of Content</H3>
-<P>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION
-AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF
-THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
-BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED
-BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY
-APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU
-MAY NOT USE THE CONTENT.</P>
-<H3>Applicable Licenses</H3>
-<P>Unless otherwise indicated, all Content made available by the Eclipse
-Foundation is provided to you under the terms and conditions of the Eclipse
-Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this
-Content and is also available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>Content includes, but is not limited to, source code, object code,
-documentation and other files maintained in the Eclipse.org CVS repository
-("Repository") in CVS modules ("Modules") and made available as downloadable
-archives ("Downloads").</P>
-<P>Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments
-("Fragments"), and features ("Features"). A Feature is a bundle of one or more
-Plug-ins and/or Fragments and associated material. Files named "feature.xml" may
-contain a list of the names and version numbers of the Plug-ins and/or Fragments
-associated with a Feature. Plug-ins and Fragments are located in directories
-named "plugins" and Features are located in directories named "features".</P>
-<P>Features may also include other Features ("Included Features"). Files named
-"feature.xml" may contain a list of the names and version numbers of Included
-Features.</P>
-<P>The terms and conditions governing Plug-ins and Fragments should be contained
-in files named "about.html" ("Abouts"). The terms and conditions governing
-Features and Included Features should be contained in files named "license.html"
-("Feature Licenses"). Abouts and Feature Licenses may be located in any
-directory of a Download or Module including, but not limited to the following
-locations:</P>
-<UL>
- <LI>The top-level (root) directory
- <LI>Plug-in and Fragment directories
- <LI>Subdirectories of the directory named "src" of certain Plug-ins
- <LI>Feature directories </LI></UL>
-<P>Note: if a Feature made available by the Eclipse Foundation is installed
-using the Eclipse Update Manager, you must agree to a license ("Feature Update
-License") during the installation process. If the Feature contains Included
-Features, the Feature Update License should either provide you with the terms
-and conditions governing the Included Features or inform you where you can
-locate them. Feature Update Licenses may be found in the "license" property of
-files named "feature.properties". Such Abouts, Feature Licenses and Feature
-Update Licenses contain the terms and conditions (or references to such terms
-and conditions) that govern your use of the associated Content in that
-directory.</P>
-<P>THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL
-OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</P>
-<UL>
- <LI>Common Public License Version 1.0 (available at <A
- href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</A>)
-
- <LI>Apache Software License 1.1 (available at <A
- href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</A>)
-
- <LI>Apache Software License 2.0 (available at <A
- href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</A>)
-
- <LI>IBM Public License 1.0 (available at <A
- href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</A>)
-
- <LI>Metro Link Public License 1.00 (available at <A
- href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</A>)
-
- <LI>Mozilla Public License Version 1.1 (available at <A
- href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</A>)
- </LI>
-
- <LI>Common Development and Distribution License (CDDL) Version 1.0 (available at <A
- href="http://www.sun.com/cddl/cddl.html">http://www.sun.com/cddl/cddl.html)</A>
- </LI>
-</UL>
-<P>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is
-provided, please contact the Eclipse Foundation to determine what terms and
-conditions govern that particular Content.</P>
-<H3>Cryptography</H3>
-<P>Content may contain encryption software. The country in which you are
-currently may have restrictions on the import, possession, and use, and/or
-re-export to another country, of encryption software. BEFORE using any
-encryption software, please check the country's laws, regulations and policies
-concerning the import, possession, or use, and re-export of encryption software,
-to see if this is permitted.</P></BODY></HTML>
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/build.properties b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/build.properties
deleted file mode 100644
index 997dd3f0c7..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/build.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-bin.includes =\
-epl-v10.html,\
-eclipse_update_120.jpg,\
-feature.xml,\
-feature.properties,\
-license.html
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/epl-v10.html b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/epl-v10.html
deleted file mode 100644
index 022ad2955b..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html>
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/feature.properties b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/feature.properties
deleted file mode 100644
index c0c0ef1758..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/feature.properties
+++ /dev/null
@@ -1,145 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# feature.properties
-# contains externalized strings for feature.xml
-# "%foo" in feature.xml corresponds to the key "foo" in this file
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file should be translated.
-
-# "featureName" property - name of the feature
-featureName=Dali Java Persistence API (JPA) EclipseLink Extension
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse.org
-
-# "updateSiteName" property - label for the update site
-updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site
-
-# "description" property - description of the feature
-description=Dali Java Persistence API (JPA) EclipseLink Extension
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006, 2008 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\
-June 06, 2007\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public\n\
-License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\
-Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse.org CVS\n\
-repository ("Repository") in CVS modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-Features may also include other Features ("Included Features"). Files named\n\
-"feature.xml" may contain a list of the names and version numbers of\n\
-Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Eclipse Update Manager, you must agree to a license ("Feature Update\n\
-License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties". Such Abouts,\n\
-Feature Licenses and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your\n\
-use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
- - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use,\n\
-and re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n
-########### end of license property ##########################################
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/license.html b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/license.html
deleted file mode 100644
index fec4a489ad..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplateFeature/license.html
+++ /dev/null
@@ -1,82 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<title>Eclipse.org Software User Agreement</title>
-</head>
-
-<body lang="EN-US" link=blue vlink=purple>
-<h2>Eclipse Foundation Software User Agreement</h2>
-<p>June 06, 2007</p>
-
-<h3>Usage Of Content</h3>
-
-<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
- (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
- CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
- OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
- NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
- CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
-
-<h3>Applicable Licenses</h3>
-
-<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
- (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
- For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository (&quot;Repository&quot;) in CVS
- modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
-
-<ul>
- <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
- <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
- <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
- and/or Fragments associated with that Feature.</li>
- <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
-</ul>
-
-<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
-Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
-including, but not limited to the following locations:</p>
-
-<ul>
- <li>The top-level (root) directory</li>
- <li>Plug-in and Fragment directories</li>
- <li>Inside Plug-ins and Fragments packaged as JARs</li>
- <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
- <li>Feature directories</li>
-</ul>
-
-<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license (&quot;Feature Update License&quot;) during the
-installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
-inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
-Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
-that directory.</p>
-
-<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
-
-<ul>
- <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
- <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
- <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
- <li>IBM Public License 1.0 (available at <a href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</a>)</li>
- <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
- <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
- <LI>Common Development and Distribution License (CDDL) Version 1.0 (available at <A
- href="http://www.sun.com/cddl/cddl.html">http://www.sun.com/cddl/cddl.html)</A>
- </LI>
-</UL>
-
-<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
-contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
-
-<h3>Cryptography</h3>
-
-<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
- another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
- possession, or use, and re-export of encryption software, to see if this is permitted.</p>
-
-<small>Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.</small>
-</body>
-</html>
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.html b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.html
deleted file mode 100644
index d4916df475..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 06, 2007</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
-
-<h3>Source Code</h3>
-<p>This plug-in contains source code zip files (&quot;Source Zips&quot;) that correspond to binary content in other plug-ins. These Source Zips may be distributed under different license
-agreements and/or notices. Details about these license agreements and notices are contained in &quot;about.html&quot; files (&quot;Abouts&quot;) located in sub-directories in the
-src/ directory of this plug-in. Such Abouts govern your use of the Source Zips in that directory, not the EPL.</p>
-
-</body>
-</html>
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.ini b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.ini
deleted file mode 100644
index 2dee36a2e2..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.ini
+++ /dev/null
@@ -1,31 +0,0 @@
-# about.ini
-# contains information about a feature
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# "%key" are externalized strings defined in about.properties
-# This file does not need to be translated.
-
-# Property "aboutText" contains blurb for "About" dialog (translated)
-aboutText=%blurb
-
-# Property "windowImage" contains path to window icon (16x16)
-# needed for primary features only
-
-# Property "featureImage" contains path to feature image (32x32)
-featureImage=eclipse32.gif
-
-# Property "aboutImage" contains path to product image (500x330 or 115x164)
-# needed for primary features only
-
-# Property "appName" contains name of the application (not translated)
-# needed for primary features only
-
-# Property "welcomePage" contains path to welcome page (special XML-based format)
-# optional
-
-# Property "welcomePerspective" contains the id of the perspective in which the
-# welcome page is to be opened.
-# optional
-
-
-
-
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.mappings b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.mappings
deleted file mode 100644
index a28390a75e..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.mappings
+++ /dev/null
@@ -1,6 +0,0 @@
-# about.mappings
-# contains fill-ins for about.properties
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file does not need to be translated.
-
-0=@build@
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.properties b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.properties
deleted file mode 100644
index 84a1f14a55..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/about.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2005 IBM Corporation 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# about.properties
-# contains externalized strings for about.ini
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# fill-ins are supplied by about.mappings
-# This file should be translated.
-#
-# Do not translate any values surrounded by {}
-
-blurb=Java Persistence API (JPA) EclipseLink Extension Source\n\
-\n\
-Version: {featureVersion}\n\
-Build id: {0}\n\
-\n\
-(c) Copyright Eclipse contributors and others 2005. All rights reserved.\n\
-Visit http://www.eclipse.org/webtools
-
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/build.properties b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/build.properties
deleted file mode 100644
index e3098b39b2..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/build.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-bin.includes =\
- about.html,\
- about.ini,\
- about.mappings,\
- about.properties,\
- eclipse32.gif,\
- plugin.properties,\
- plugin.xml,\
- src/**,\
- META-INF/
-sourcePlugin = true
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/eclipse32.gif b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/eclipse32.gif
deleted file mode 100644
index e6ad7ccd75..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/eclipse32.gif
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/eclipse32.png b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/eclipse32.png
deleted file mode 100644
index 50ae49de24..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/eclipse32.png
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/epl-v10.html b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/epl-v10.html
deleted file mode 100644
index 022ad2955b..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html>
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/license.html b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/license.html
deleted file mode 100644
index 14b1d50265..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/license.html
+++ /dev/null
@@ -1,83 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<title>Eclipse.org Software User Agreement</title>
-</head>
-
-<body lang="EN-US" link=blue vlink=purple>
-<h2>Eclipse Foundation Software User Agreement</h2>
-<p>June 06, 2007</p>
-
-<h3>Usage Of Content</h3>
-
-<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
- (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
- CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
- OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
- NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
- CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
-
-<h3>Applicable Licenses</h3>
-
-<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
- (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
- For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository (&quot;Repository&quot;) in CVS
- modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
-
-<ul>
- <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
- <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
- <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
- and/or Fragments associated with that Feature.</li>
- <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
-</ul>
-
-<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
-Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
-including, but not limited to the following locations:</p>
-
-<ul>
- <li>The top-level (root) directory</li>
- <li>Plug-in and Fragment directories</li>
- <li>Inside Plug-ins and Fragments packaged as JARs</li>
- <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
- <li>Feature directories</li>
-</ul>
-
-<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license (&quot;Feature Update License&quot;) during the
-installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
-inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
-Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
-that directory.</p>
-
-<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
-
-<ul>
- <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
- <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
- <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
- <li>IBM Public License 1.0 (available at <a href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</a>)</li>
- <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
- <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
-
- <LI>Common Development and Distribution License (CDDL) Version 1.0 (available at <A
- href="http://www.sun.com/cddl/cddl.html">http://www.sun.com/cddl/cddl.html)</A>
- </LI>
-</UL>
-
-<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
-contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
-
-<h3>Cryptography</h3>
-
-<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
- another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
- possession, or use, and re-export of encryption software, to see if this is permitted.</p>
-
-<small>Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.</small>
-</body>
-</html>
diff --git a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/plugin.properties b/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/plugin.properties
deleted file mode 100644
index fa61ed94b2..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink.feature/sourceTemplatePlugin/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-pluginName = Dali Java Persistence API (JPA) EclipseLink Extension
-providerName = Eclipse.org
diff --git a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/.cvsignore b/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/.cvsignore
deleted file mode 100644
index 6365d3dc51..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-feature.temp.folder
-build.xml
-org.eclipse.jpt_sdk.feature_1.0.1.*
diff --git a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/.project b/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/.project
deleted file mode 100644
index 15f9157901..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.eclipselink_sdk.feature</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/.settings/org.eclipse.core.resources.prefs b/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 6cc7d4b4cd..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Sun May 27 15:09:59 EDT 2007
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/build.properties b/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/build.properties
deleted file mode 100644
index d280992c44..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/build.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-bin.includes = feature.xml,\
- license.html,\
- feature.properties,\
- epl-v10.html,\
- eclipse_update_120.jpg
-
-src.includes = build.properties
-
-generate.feature@org.eclipse.jpt.eclipselink.feature.source=org.eclipse.jpt.eclipselink.feature
diff --git a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/epl-v10.html b/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/epl-v10.html
deleted file mode 100644
index ed4b196655..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html> \ No newline at end of file
diff --git a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/feature.properties b/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/feature.properties
deleted file mode 100644
index dbdb31ef90..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/feature.properties
+++ /dev/null
@@ -1,140 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2008 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-# "featureName" property - name of the feature
-featureName=Java Persistence API EclipseLink Extension Plug-in SDK
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse.org
-
-# "updateSiteName" property - label for the update site
-updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site
-
-# "description" property - description of the feature
-description=Source code zips for JPA EclipseLink Extension
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006-08 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\
-June 06, 2007\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public\n\
-License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\
-Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse.org CVS\n\
-repository ("Repository") in CVS modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-Features may also include other Features ("Included Features"). Files named\n\
-"feature.xml" may contain a list of the names and version numbers of\n\
-Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Eclipse Update Manager, you must agree to a license ("Feature Update\n\
-License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties". Such Abouts,\n\
-Feature Licenses and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your\n\
-use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
- - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use,\n\
-and re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n
-########### end of license property ##########################################
diff --git a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/feature.xml b/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/feature.xml
deleted file mode 100644
index 12b892938b..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/feature.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.eclipselink_sdk.feature"
- label="%featureName"
- version="2.0.0.qualifier"
- provider-name="%providerName">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <includes
- id="org.eclipse.jpt.eclipselink.feature"
- version="0.0.0"/>
-
- <includes
- id="org.eclipse.jpt.eclipselink.feature.source"
- version="0.0.0"/>
-
-</feature>
diff --git a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/license.html b/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/license.html
deleted file mode 100644
index fc77372d46..0000000000
--- a/jpa/features/org.eclipse.jpt.eclipselink_sdk.feature/license.html
+++ /dev/null
@@ -1,98 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0044)http://www.eclipse.org/legal/epl/notice.html -->
-<HTML><HEAD><TITLE>Eclipse.org Software User Agreement</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<META content="MSHTML 6.00.2800.1479" name=GENERATOR></HEAD>
-<BODY lang=EN-US vLink=purple link=blue>
-<H2>Eclipse Foundation Software User Agreement</H2>
-<P>June 06, 2007</P>
-<H3>Usage Of Content</H3>
-<P>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION
-AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF
-THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
-BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED
-BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY
-APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU
-MAY NOT USE THE CONTENT.</P>
-<H3>Applicable Licenses</H3>
-<P>Unless otherwise indicated, all Content made available by the Eclipse
-Foundation is provided to you under the terms and conditions of the Eclipse
-Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this
-Content and is also available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>Content includes, but is not limited to, source code, object code,
-documentation and other files maintained in the Eclipse.org CVS repository
-("Repository") in CVS modules ("Modules") and made available as downloadable
-archives ("Downloads").</P>
-<P>Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments
-("Fragments"), and features ("Features"). A Feature is a bundle of one or more
-Plug-ins and/or Fragments and associated material. Files named "feature.xml" may
-contain a list of the names and version numbers of the Plug-ins and/or Fragments
-associated with a Feature. Plug-ins and Fragments are located in directories
-named "plugins" and Features are located in directories named "features".</P>
-<P>Features may also include other Features ("Included Features"). Files named
-"feature.xml" may contain a list of the names and version numbers of Included
-Features.</P>
-<P>The terms and conditions governing Plug-ins and Fragments should be contained
-in files named "about.html" ("Abouts"). The terms and conditions governing
-Features and Included Features should be contained in files named "license.html"
-("Feature Licenses"). Abouts and Feature Licenses may be located in any
-directory of a Download or Module including, but not limited to the following
-locations:</P>
-<UL>
- <LI>The top-level (root) directory
- <LI>Plug-in and Fragment directories
- <LI>Subdirectories of the directory named "src" of certain Plug-ins
- <LI>Feature directories </LI></UL>
-<P>Note: if a Feature made available by the Eclipse Foundation is installed
-using the Eclipse Update Manager, you must agree to a license ("Feature Update
-License") during the installation process. If the Feature contains Included
-Features, the Feature Update License should either provide you with the terms
-and conditions governing the Included Features or inform you where you can
-locate them. Feature Update Licenses may be found in the "license" property of
-files named "feature.properties". Such Abouts, Feature Licenses and Feature
-Update Licenses contain the terms and conditions (or references to such terms
-and conditions) that govern your use of the associated Content in that
-directory.</P>
-<P>THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL
-OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</P>
-<UL>
- <LI>Common Public License Version 1.0 (available at <A
- href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</A>)
-
- <LI>Apache Software License 1.1 (available at <A
- href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</A>)
-
- <LI>Apache Software License 2.0 (available at <A
- href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</A>)
-
- <LI>IBM Public License 1.0 (available at <A
- href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</A>)
-
- <LI>Metro Link Public License 1.00 (available at <A
- href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</A>)
-
- <LI>Mozilla Public License Version 1.1 (available at <A
- href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</A>)
- </LI>
-
- <LI>Common Development and Distribution License (CDDL) Version 1.0 (available at <A
- href="http://www.sun.com/cddl/cddl.html">http://www.sun.com/cddl/cddl.html)</A>
- </LI>
-</UL>
-<P>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is
-provided, please contact the Eclipse Foundation to determine what terms and
-conditions govern that particular Content.</P>
-<H3>Cryptography</H3>
-<P>Content may contain encryption software. The country in which you are
-currently may have restrictions on the import, possession, and use, and/or
-re-export to another country, of encryption software. BEFORE using any
-encryption software, please check the country's laws, regulations and policies
-concerning the import, possession, or use, and re-export of encryption software,
-to see if this is permitted.</P></BODY></HTML>
diff --git a/jpa/features/org.eclipse.jpt.feature/.cvsignore b/jpa/features/org.eclipse.jpt.feature/.cvsignore
deleted file mode 100644
index c14487ceac..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-build.xml
diff --git a/jpa/features/org.eclipse.jpt.feature/.project b/jpa/features/org.eclipse.jpt.feature/.project
deleted file mode 100644
index c8eb2f0481..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.feature</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/features/org.eclipse.jpt.feature/.settings/org.eclipse.core.resources.prefs b/jpa/features/org.eclipse.jpt.feature/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index dab5837cb6..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Sun May 27 15:10:47 EDT 2007
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/features/org.eclipse.jpt.feature/build.properties b/jpa/features/org.eclipse.jpt.feature/build.properties
deleted file mode 100644
index 7200939aca..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/build.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-bin.includes = feature.xml,\
- eclipse_update_120.jpg,\
- epl-v10.html,\
- license.html,\
- feature.properties
diff --git a/jpa/features/org.eclipse.jpt.feature/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt.feature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt.feature/epl-v10.html b/jpa/features/org.eclipse.jpt.feature/epl-v10.html
deleted file mode 100644
index ed4b196655..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html> \ No newline at end of file
diff --git a/jpa/features/org.eclipse.jpt.feature/feature.properties b/jpa/features/org.eclipse.jpt.feature/feature.properties
deleted file mode 100644
index a2b39f3024..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/feature.properties
+++ /dev/null
@@ -1,140 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-
-# "featureName" property - name of the feature
-featureName=Java Persistence API Tools
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse.org
-
-# "updateSiteName" property - label for the update site
-updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site
-
-# "description" property - description of the feature
-description=Java Persistence API (JPA) Tools
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006-07 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\
-June 06, 2007\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public\n\
-License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\
-Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse.org CVS\n\
-repository ("Repository") in CVS modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-Features may also include other Features ("Included Features"). Files named\n\
-"feature.xml" may contain a list of the names and version numbers of\n\
-Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Eclipse Update Manager, you must agree to a license ("Feature Update\n\
-License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties". Such Abouts,\n\
-Feature Licenses and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your\n\
-use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
- - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use,\n\
-and re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n
-########### end of license property ##########################################
diff --git a/jpa/features/org.eclipse.jpt.feature/feature.xml b/jpa/features/org.eclipse.jpt.feature/feature.xml
deleted file mode 100644
index 51b12484b6..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/feature.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.feature"
- label="%featureName"
- version="2.0.0.qualifier"
- provider-name="%providerName"
- image="eclipse_update_120.jpg">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <url>
- <update label="Web Tools Platform (WTP) Updates" url="http://download.eclipse.org/webtools/updates"/>
- <discovery label="Web Tools Platform (WTP) Updates" url="http://download.eclipse.org/webtools/updates"/>
- <discovery label="Dali Java Persistence API Tools (JPA) Updates" url="http://download.eclipse.org/webtools/updates/"/>
- </url>
-
- <requires>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.ui"/>
- <import feature="org.eclipse.datatools.connectivity.feature"/>
- <import feature="org.eclipse.datatools.modelbase.feature"/>
- <import feature="org.eclipse.datatools.sqldevtools.feature"/>
- <import feature="org.eclipse.datatools.enablement.feature"/>
- <import plugin="org.eclipse.datatools.connectivity.db.generic.ui"/>
- <import plugin="org.eclipse.datatools.connectivity.db.generic"/>
- <import plugin="org.eclipse.datatools.doc.user"/>
- <import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.eclipse.core.commands"/>
- <import plugin="org.eclipse.core.expressions"/>
- <import plugin="org.eclipse.core.filebuffers"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.emf.ecore"/>
- <import plugin="org.eclipse.emf.ecore.xmi"/>
- <import plugin="org.eclipse.jem"/>
- <import plugin="org.eclipse.jem.util"/>
- <import plugin="org.eclipse.jem.workbench"/>
- <import plugin="org.eclipse.jst.j2ee"/>
- <import plugin="org.eclipse.jst.j2ee.core"/>
- <import plugin="org.eclipse.text"/>
- <import plugin="org.eclipse.wst.common.emf"/>
- <import plugin="org.eclipse.wst.common.frameworks"/>
- <import plugin="org.eclipse.wst.common.modulecore"/>
- <import plugin="org.eclipse.wst.common.project.facet.core"/>
- <import plugin="org.eclipse.wst.sse.core"/>
- <import plugin="org.eclipse.wst.validation"/>
- <import plugin="org.eclipse.wst.xml.core"/>
- <import plugin="org.eclipse.xsd"/>
- <import plugin="org.eclipse.draw2d"/>
- <import plugin="org.eclipse.emf.edit.ui"/>
- <import plugin="org.eclipse.jdt.ui"/>
- <import plugin="org.eclipse.jface.text"/>
- <import plugin="org.eclipse.jst.j2ee.ui"/>
- <import plugin="org.eclipse.ui.ide"/>
- <import plugin="org.eclipse.ui.views.properties.tabbed"/>
- <import plugin="org.eclipse.ui.workbench.texteditor"/>
- <import plugin="org.eclipse.wst.common.frameworks.ui"/>
- <import plugin="org.eclipse.wst.common.project.facet.ui"/>
- <import plugin="org.eclipse.wst.sse.ui"/>
- <import plugin="org.eclipse.wst.web.ui"/>
- </requires>
-
- <plugin
- id="org.eclipse.jpt.utility"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.jpt.db"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.jpt.db.ui"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.jpt.gen"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.jpt.core"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.jpt.ui"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.jpt.doc.user"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
-</feature>
diff --git a/jpa/features/org.eclipse.jpt.feature/license.html b/jpa/features/org.eclipse.jpt.feature/license.html
deleted file mode 100644
index fc77372d46..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/license.html
+++ /dev/null
@@ -1,98 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0044)http://www.eclipse.org/legal/epl/notice.html -->
-<HTML><HEAD><TITLE>Eclipse.org Software User Agreement</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<META content="MSHTML 6.00.2800.1479" name=GENERATOR></HEAD>
-<BODY lang=EN-US vLink=purple link=blue>
-<H2>Eclipse Foundation Software User Agreement</H2>
-<P>June 06, 2007</P>
-<H3>Usage Of Content</H3>
-<P>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION
-AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF
-THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
-BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED
-BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY
-APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU
-MAY NOT USE THE CONTENT.</P>
-<H3>Applicable Licenses</H3>
-<P>Unless otherwise indicated, all Content made available by the Eclipse
-Foundation is provided to you under the terms and conditions of the Eclipse
-Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this
-Content and is also available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>Content includes, but is not limited to, source code, object code,
-documentation and other files maintained in the Eclipse.org CVS repository
-("Repository") in CVS modules ("Modules") and made available as downloadable
-archives ("Downloads").</P>
-<P>Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments
-("Fragments"), and features ("Features"). A Feature is a bundle of one or more
-Plug-ins and/or Fragments and associated material. Files named "feature.xml" may
-contain a list of the names and version numbers of the Plug-ins and/or Fragments
-associated with a Feature. Plug-ins and Fragments are located in directories
-named "plugins" and Features are located in directories named "features".</P>
-<P>Features may also include other Features ("Included Features"). Files named
-"feature.xml" may contain a list of the names and version numbers of Included
-Features.</P>
-<P>The terms and conditions governing Plug-ins and Fragments should be contained
-in files named "about.html" ("Abouts"). The terms and conditions governing
-Features and Included Features should be contained in files named "license.html"
-("Feature Licenses"). Abouts and Feature Licenses may be located in any
-directory of a Download or Module including, but not limited to the following
-locations:</P>
-<UL>
- <LI>The top-level (root) directory
- <LI>Plug-in and Fragment directories
- <LI>Subdirectories of the directory named "src" of certain Plug-ins
- <LI>Feature directories </LI></UL>
-<P>Note: if a Feature made available by the Eclipse Foundation is installed
-using the Eclipse Update Manager, you must agree to a license ("Feature Update
-License") during the installation process. If the Feature contains Included
-Features, the Feature Update License should either provide you with the terms
-and conditions governing the Included Features or inform you where you can
-locate them. Feature Update Licenses may be found in the "license" property of
-files named "feature.properties". Such Abouts, Feature Licenses and Feature
-Update Licenses contain the terms and conditions (or references to such terms
-and conditions) that govern your use of the associated Content in that
-directory.</P>
-<P>THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL
-OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</P>
-<UL>
- <LI>Common Public License Version 1.0 (available at <A
- href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</A>)
-
- <LI>Apache Software License 1.1 (available at <A
- href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</A>)
-
- <LI>Apache Software License 2.0 (available at <A
- href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</A>)
-
- <LI>IBM Public License 1.0 (available at <A
- href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</A>)
-
- <LI>Metro Link Public License 1.00 (available at <A
- href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</A>)
-
- <LI>Mozilla Public License Version 1.1 (available at <A
- href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</A>)
- </LI>
-
- <LI>Common Development and Distribution License (CDDL) Version 1.0 (available at <A
- href="http://www.sun.com/cddl/cddl.html">http://www.sun.com/cddl/cddl.html)</A>
- </LI>
-</UL>
-<P>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is
-provided, please contact the Eclipse Foundation to determine what terms and
-conditions govern that particular Content.</P>
-<H3>Cryptography</H3>
-<P>Content may contain encryption software. The country in which you are
-currently may have restrictions on the import, possession, and use, and/or
-re-export to another country, of encryption software. BEFORE using any
-encryption software, please check the country's laws, regulations and policies
-concerning the import, possession, or use, and re-export of encryption software,
-to see if this is permitted.</P></BODY></HTML>
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/build.properties b/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/build.properties
deleted file mode 100644
index 997dd3f0c7..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/build.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-bin.includes =\
-epl-v10.html,\
-eclipse_update_120.jpg,\
-feature.xml,\
-feature.properties,\
-license.html
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/epl-v10.html b/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/epl-v10.html
deleted file mode 100644
index 022ad2955b..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html>
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/feature.properties b/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/feature.properties
deleted file mode 100644
index 0c1da15ce6..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/feature.properties
+++ /dev/null
@@ -1,145 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# feature.properties
-# contains externalized strings for feature.xml
-# "%foo" in feature.xml corresponds to the key "foo" in this file
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file should be translated.
-
-# "featureName" property - name of the feature
-featureName=Dali Java Persistence API (JPA) Tools
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse.org
-
-# "updateSiteName" property - label for the update site
-updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site
-
-# "description" property - description of the feature
-description=Dali Java Persistence API (JPA) Tools
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\
-June 06, 2007\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public\n\
-License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\
-Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse.org CVS\n\
-repository ("Repository") in CVS modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-Features may also include other Features ("Included Features"). Files named\n\
-"feature.xml" may contain a list of the names and version numbers of\n\
-Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Eclipse Update Manager, you must agree to a license ("Feature Update\n\
-License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties". Such Abouts,\n\
-Feature Licenses and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your\n\
-use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
- - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use,\n\
-and re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n
-########### end of license property ##########################################
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/license.html b/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/license.html
deleted file mode 100644
index fec4a489ad..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/license.html
+++ /dev/null
@@ -1,82 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<title>Eclipse.org Software User Agreement</title>
-</head>
-
-<body lang="EN-US" link=blue vlink=purple>
-<h2>Eclipse Foundation Software User Agreement</h2>
-<p>June 06, 2007</p>
-
-<h3>Usage Of Content</h3>
-
-<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
- (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
- CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
- OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
- NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
- CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
-
-<h3>Applicable Licenses</h3>
-
-<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
- (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
- For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository (&quot;Repository&quot;) in CVS
- modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
-
-<ul>
- <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
- <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
- <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
- and/or Fragments associated with that Feature.</li>
- <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
-</ul>
-
-<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
-Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
-including, but not limited to the following locations:</p>
-
-<ul>
- <li>The top-level (root) directory</li>
- <li>Plug-in and Fragment directories</li>
- <li>Inside Plug-ins and Fragments packaged as JARs</li>
- <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
- <li>Feature directories</li>
-</ul>
-
-<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license (&quot;Feature Update License&quot;) during the
-installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
-inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
-Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
-that directory.</p>
-
-<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
-
-<ul>
- <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
- <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
- <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
- <li>IBM Public License 1.0 (available at <a href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</a>)</li>
- <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
- <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
- <LI>Common Development and Distribution License (CDDL) Version 1.0 (available at <A
- href="http://www.sun.com/cddl/cddl.html">http://www.sun.com/cddl/cddl.html)</A>
- </LI>
-</UL>
-
-<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
-contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
-
-<h3>Cryptography</h3>
-
-<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
- another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
- possession, or use, and re-export of encryption software, to see if this is permitted.</p>
-
-<small>Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.</small>
-</body>
-</html>
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.html b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.html
deleted file mode 100644
index d4916df475..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 06, 2007</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
-
-<h3>Source Code</h3>
-<p>This plug-in contains source code zip files (&quot;Source Zips&quot;) that correspond to binary content in other plug-ins. These Source Zips may be distributed under different license
-agreements and/or notices. Details about these license agreements and notices are contained in &quot;about.html&quot; files (&quot;Abouts&quot;) located in sub-directories in the
-src/ directory of this plug-in. Such Abouts govern your use of the Source Zips in that directory, not the EPL.</p>
-
-</body>
-</html>
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.ini b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.ini
deleted file mode 100644
index 2dee36a2e2..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.ini
+++ /dev/null
@@ -1,31 +0,0 @@
-# about.ini
-# contains information about a feature
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# "%key" are externalized strings defined in about.properties
-# This file does not need to be translated.
-
-# Property "aboutText" contains blurb for "About" dialog (translated)
-aboutText=%blurb
-
-# Property "windowImage" contains path to window icon (16x16)
-# needed for primary features only
-
-# Property "featureImage" contains path to feature image (32x32)
-featureImage=eclipse32.gif
-
-# Property "aboutImage" contains path to product image (500x330 or 115x164)
-# needed for primary features only
-
-# Property "appName" contains name of the application (not translated)
-# needed for primary features only
-
-# Property "welcomePage" contains path to welcome page (special XML-based format)
-# optional
-
-# Property "welcomePerspective" contains the id of the perspective in which the
-# welcome page is to be opened.
-# optional
-
-
-
-
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.mappings b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.mappings
deleted file mode 100644
index a28390a75e..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.mappings
+++ /dev/null
@@ -1,6 +0,0 @@
-# about.mappings
-# contains fill-ins for about.properties
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file does not need to be translated.
-
-0=@build@
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.properties b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.properties
deleted file mode 100644
index 5e52cb277e..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2005 IBM Corporation 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# about.properties
-# contains externalized strings for about.ini
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# fill-ins are supplied by about.mappings
-# This file should be translated.
-#
-# Do not translate any values surrounded by {}
-
-blurb=JavaServer Faces Tooling Source\n\
-\n\
-Version: {featureVersion}\n\
-Build id: {0}\n\
-\n\
-(c) Copyright Eclipse contributors and others 2005. All rights reserved.\n\
-Visit http://www.eclipse.org/webtools
-
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/build.properties b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/build.properties
deleted file mode 100644
index e3098b39b2..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/build.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-bin.includes =\
- about.html,\
- about.ini,\
- about.mappings,\
- about.properties,\
- eclipse32.gif,\
- plugin.properties,\
- plugin.xml,\
- src/**,\
- META-INF/
-sourcePlugin = true
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.gif b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.gif
deleted file mode 100644
index e6ad7ccd75..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.gif
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.png b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.png
deleted file mode 100644
index 50ae49de24..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.png
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/epl-v10.html b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/epl-v10.html
deleted file mode 100644
index 022ad2955b..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html>
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/license.html b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/license.html
deleted file mode 100644
index 14b1d50265..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/license.html
+++ /dev/null
@@ -1,83 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<title>Eclipse.org Software User Agreement</title>
-</head>
-
-<body lang="EN-US" link=blue vlink=purple>
-<h2>Eclipse Foundation Software User Agreement</h2>
-<p>June 06, 2007</p>
-
-<h3>Usage Of Content</h3>
-
-<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
- (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
- CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
- OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
- NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
- CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
-
-<h3>Applicable Licenses</h3>
-
-<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
- (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
- For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository (&quot;Repository&quot;) in CVS
- modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
-
-<ul>
- <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
- <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
- <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
- and/or Fragments associated with that Feature.</li>
- <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
-</ul>
-
-<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
-Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
-including, but not limited to the following locations:</p>
-
-<ul>
- <li>The top-level (root) directory</li>
- <li>Plug-in and Fragment directories</li>
- <li>Inside Plug-ins and Fragments packaged as JARs</li>
- <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
- <li>Feature directories</li>
-</ul>
-
-<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license (&quot;Feature Update License&quot;) during the
-installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
-inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
-Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
-that directory.</p>
-
-<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
-
-<ul>
- <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
- <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
- <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
- <li>IBM Public License 1.0 (available at <a href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</a>)</li>
- <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
- <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
-
- <LI>Common Development and Distribution License (CDDL) Version 1.0 (available at <A
- href="http://www.sun.com/cddl/cddl.html">http://www.sun.com/cddl/cddl.html)</A>
- </LI>
-</UL>
-
-<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
-contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
-
-<h3>Cryptography</h3>
-
-<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
- another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
- possession, or use, and re-export of encryption software, to see if this is permitted.</p>
-
-<small>Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.</small>
-</body>
-</html>
diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/plugin.properties b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/plugin.properties
deleted file mode 100644
index 088161f801..0000000000
--- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-pluginName = Dali Java Persistence API (JPA) Tools
-providerName = Eclipse.org
diff --git a/jpa/features/org.eclipse.jpt.tests.feature/.cvsignore b/jpa/features/org.eclipse.jpt.tests.feature/.cvsignore
deleted file mode 100644
index c14487ceac..0000000000
--- a/jpa/features/org.eclipse.jpt.tests.feature/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-build.xml
diff --git a/jpa/features/org.eclipse.jpt.tests.feature/.project b/jpa/features/org.eclipse.jpt.tests.feature/.project
deleted file mode 100644
index 91760f21b4..0000000000
--- a/jpa/features/org.eclipse.jpt.tests.feature/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.tests.feature</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/features/org.eclipse.jpt.tests.feature/.settings/org.eclipse.core.resources.prefs b/jpa/features/org.eclipse.jpt.tests.feature/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 235b84ae83..0000000000
--- a/jpa/features/org.eclipse.jpt.tests.feature/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Sun May 27 15:11:17 EDT 2007
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/features/org.eclipse.jpt.tests.feature/build.properties b/jpa/features/org.eclipse.jpt.tests.feature/build.properties
deleted file mode 100644
index d6a4dce096..0000000000
--- a/jpa/features/org.eclipse.jpt.tests.feature/build.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-bin.includes = feature.xml,\
- eclipse_update_120.jpg,\
- epl-v10.html,\
- license.html,\
- feature.properties
-src.includes = license.html,\
- feature.xml,\
- epl-v10.html,\
- eclipse_update_120.jpg,\
- build.properties
diff --git a/jpa/features/org.eclipse.jpt.tests.feature/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt.tests.feature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/jpa/features/org.eclipse.jpt.tests.feature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt.tests.feature/epl-v10.html b/jpa/features/org.eclipse.jpt.tests.feature/epl-v10.html
deleted file mode 100644
index ed4b196655..0000000000
--- a/jpa/features/org.eclipse.jpt.tests.feature/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html> \ No newline at end of file
diff --git a/jpa/features/org.eclipse.jpt.tests.feature/feature.properties b/jpa/features/org.eclipse.jpt.tests.feature/feature.properties
deleted file mode 100644
index 33ec536d55..0000000000
--- a/jpa/features/org.eclipse.jpt.tests.feature/feature.properties
+++ /dev/null
@@ -1,145 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# feature.properties
-# contains externalized strings for feature.xml
-# "%foo" in feature.xml corresponds to the key "foo" in this file
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file should be translated.
-
-# "featureName" property - name of the feature
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse.org
-
-# "updateSiteName" property - label for the update site
-# TOREVIEW - updateSiteName
-updateSiteName=Web Tools Platform (WTP) Updates
-
-# "description" property - description of the feature
-description=Dali Java Persistence API (JPA) Tools
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\
-June 06, 2007\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public\n\
-License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\
-Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse.org CVS\n\
-repository ("Repository") in CVS modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-Features may also include other Features ("Included Features"). Files named\n\
-"feature.xml" may contain a list of the names and version numbers of\n\
-Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Eclipse Update Manager, you must agree to a license ("Feature Update\n\
-License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties". Such Abouts,\n\
-Feature Licenses and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your\n\
-use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
- - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use,\n\
-and re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n
-########### end of license property ##########################################
diff --git a/jpa/features/org.eclipse.jpt.tests.feature/feature.xml b/jpa/features/org.eclipse.jpt.tests.feature/feature.xml
deleted file mode 100644
index 2ec6d17d4c..0000000000
--- a/jpa/features/org.eclipse.jpt.tests.feature/feature.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.tests.feature"
- label="Dali Java Persistence API Tools (JPA) JUnit Tests"
- version="2.0.0.qualifier"
- provider-name="Eclipse.org">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <plugin
- id="org.eclipse.jpt.utility.tests"
- download-size="0"
- install-size="0"
- version="0.0.0"/>
-
- <plugin
- id="org.eclipse.jpt.core.tests"
- download-size="0"
- install-size="0"
- version="0.0.0"/>
-
- <plugin
- id="org.eclipse.jpt.core.tests.extension.resource"
- download-size="0"
- install-size="0"
- version="0.0.0"/>
-
- <plugin
- id="org.eclipse.jpt.eclipselink.core.tests"
- download-size="0"
- install-size="0"
- version="0.0.0"/>
-
-</feature>
diff --git a/jpa/features/org.eclipse.jpt.tests.feature/license.html b/jpa/features/org.eclipse.jpt.tests.feature/license.html
deleted file mode 100644
index 56445985d9..0000000000
--- a/jpa/features/org.eclipse.jpt.tests.feature/license.html
+++ /dev/null
@@ -1,98 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0044)http://www.eclipse.org/legal/epl/notice.html -->
-<HTML><HEAD><TITLE>Eclipse.org Software User Agreement</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<META content="MSHTML 6.00.2800.1479" name=GENERATOR></HEAD>
-<BODY lang=EN-US vLink=purple link=blue>
-<H2>Eclipse Foundation Software User Agreement</H2>
-<P>June 06, 2007</P>
-<H3>Usage Of Content</H3>
-<P>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION
-AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF
-THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
-BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED
-BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY
-APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU
-MAY NOT USE THE CONTENT.</P>
-<H3>Applicable Licenses</H3>
-<P>Unless otherwise indicated, all Content made available by the Eclipse
-Foundation is provided to you under the terms and conditions of the Eclipse
-Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this
-Content and is also available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>Content includes, but is not limited to, source code, object code,
-documentation and other files maintained in the Eclipse.org CVS repository
-("Repository") in CVS modules ("Modules") and made available as downloadable
-archives ("Downloads").</P>
-<P>Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments
-("Fragments"), and features ("Features"). A Feature is a bundle of one or more
-Plug-ins and/or Fragments and associated material. Files named "feature.xml" may
-contain a list of the names and version numbers of the Plug-ins and/or Fragments
-associated with a Feature. Plug-ins and Fragments are located in directories
-named "plugins" and Features are located in directories named "features".</P>
-<P>Features may also include other Features ("Included Features"). Files named
-"feature.xml" may contain a list of the names and version numbers of Included
-Features.</P>
-<P>The terms and conditions governing Plug-ins and Fragments should be contained
-in files named "about.html" ("Abouts"). The terms and conditions governing
-Features and Included Features should be contained in files named "license.html"
-("Feature Licenses"). Abouts and Feature Licenses may be located in any
-directory of a Download or Module including, but not limited to the following
-locations:</P>
-<UL>
- <LI>The top-level (root) directory
- <LI>Plug-in and Fragment directories
- <LI>Subdirectories of the directory named "src" of certain Plug-ins
- <LI>Feature directories </LI></UL>
-<P>Note: if a Feature made available by the Eclipse Foundation is installed
-using the Eclipse Update Manager, you must agree to a license ("Feature Update
-License") during the installation process. If the Feature contains Included
-Features, the Feature Update License should either provide you with the terms
-and conditions governing the Included Features or inform you where you can
-locate them. Feature Update Licenses may be found in the "license" property of
-files named "feature.properties". Such Abouts, Feature Licenses and Feature
-Update Licenses contain the terms and conditions (or references to such terms
-and conditions) that govern your use of the associated Content in that
-directory.</P>
-<P>THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL
-OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</P>
-<UL>
- <LI>Common Public License Version 1.0 (available at <A
- href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</A>)
-
- <LI>Apache Software License 1.1 (available at <A
- href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</A>)
-
- <LI>Apache Software License 2.0 (available at <A
- href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</A>)
-
- <LI>IBM Public License 1.0 (available at <A
- href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</A>)
-
- <LI>Metro Link Public License 1.00 (available at <A
- href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</A>)
-
- <LI>Mozilla Public License Version 1.1 (available at <A
- href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</A>)
- </LI>
-
- <LI>Common Development and Distribution License (CDDL) Version 1.0 (available at <A
- href="http://www.sun.com/cddl/cddl.html">http://www.sun.com/cddl/cddl.html)</A>
- </LI>
-</UL>
-<P>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is
-provided, please contact the Eclipse Foundation to determine what terms and
-conditions govern that particular Content.</P>
-<H3>Cryptography</H3>
-<P>Content may contain encryption software. The country in which you are
-currently may have restrictions on the import, possession, and use, and/or
-re-export to another country, of encryption software. BEFORE using any
-encryption software, please check the country's laws, regulations and policies
-concerning the import, possession, or use, and re-export of encryption software,
-to see if this is permitted.</P></BODY></HTML>
diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/.cvsignore b/jpa/features/org.eclipse.jpt_sdk.feature/.cvsignore
deleted file mode 100644
index 6365d3dc51..0000000000
--- a/jpa/features/org.eclipse.jpt_sdk.feature/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-feature.temp.folder
-build.xml
-org.eclipse.jpt_sdk.feature_1.0.1.*
diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/.project b/jpa/features/org.eclipse.jpt_sdk.feature/.project
deleted file mode 100644
index 33da750336..0000000000
--- a/jpa/features/org.eclipse.jpt_sdk.feature/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt_sdk.feature</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/.settings/org.eclipse.core.resources.prefs b/jpa/features/org.eclipse.jpt_sdk.feature/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 6cc7d4b4cd..0000000000
--- a/jpa/features/org.eclipse.jpt_sdk.feature/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Sun May 27 15:09:59 EDT 2007
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/build.properties b/jpa/features/org.eclipse.jpt_sdk.feature/build.properties
deleted file mode 100644
index 28724c6843..0000000000
--- a/jpa/features/org.eclipse.jpt_sdk.feature/build.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-bin.includes = feature.xml,\
- license.html,\
- feature.properties,\
- epl-v10.html,\
- eclipse_update_120.jpg
-
-src.includes = build.properties
-
-generate.feature@org.eclipse.jpt.feature.source=org.eclipse.jpt.feature
diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt_sdk.feature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/jpa/features/org.eclipse.jpt_sdk.feature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/epl-v10.html b/jpa/features/org.eclipse.jpt_sdk.feature/epl-v10.html
deleted file mode 100644
index ed4b196655..0000000000
--- a/jpa/features/org.eclipse.jpt_sdk.feature/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html> \ No newline at end of file
diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/feature.properties b/jpa/features/org.eclipse.jpt_sdk.feature/feature.properties
deleted file mode 100644
index a14204ac5e..0000000000
--- a/jpa/features/org.eclipse.jpt_sdk.feature/feature.properties
+++ /dev/null
@@ -1,140 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-# "featureName" property - name of the feature
-featureName=Java Persistence API Tools Plug-in SDK
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse.org
-
-# "updateSiteName" property - label for the update site
-updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site
-
-# "description" property - description of the feature
-description=Source code zips for JPA Tools
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006-07 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\
-June 06, 2007\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public\n\
-License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\
-Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse.org CVS\n\
-repository ("Repository") in CVS modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-Features may also include other Features ("Included Features"). Files named\n\
-"feature.xml" may contain a list of the names and version numbers of\n\
-Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Eclipse Update Manager, you must agree to a license ("Feature Update\n\
-License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties". Such Abouts,\n\
-Feature Licenses and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your\n\
-use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
- - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use,\n\
-and re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n
-########### end of license property ##########################################
diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/feature.xml b/jpa/features/org.eclipse.jpt_sdk.feature/feature.xml
deleted file mode 100644
index b2b4f96606..0000000000
--- a/jpa/features/org.eclipse.jpt_sdk.feature/feature.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt_sdk.feature"
- label="%featureName"
- version="2.0.0.qualifier"
- provider-name="%providerName">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <includes
- id="org.eclipse.jpt.feature"
- version="0.0.0"/>
-
- <includes
- id="org.eclipse.jpt.feature.source"
- version="0.0.0"/>
-
-</feature>
diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/license.html b/jpa/features/org.eclipse.jpt_sdk.feature/license.html
deleted file mode 100644
index fc77372d46..0000000000
--- a/jpa/features/org.eclipse.jpt_sdk.feature/license.html
+++ /dev/null
@@ -1,98 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0044)http://www.eclipse.org/legal/epl/notice.html -->
-<HTML><HEAD><TITLE>Eclipse.org Software User Agreement</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<META content="MSHTML 6.00.2800.1479" name=GENERATOR></HEAD>
-<BODY lang=EN-US vLink=purple link=blue>
-<H2>Eclipse Foundation Software User Agreement</H2>
-<P>June 06, 2007</P>
-<H3>Usage Of Content</H3>
-<P>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION
-AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF
-THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
-BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED
-BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY
-APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU
-MAY NOT USE THE CONTENT.</P>
-<H3>Applicable Licenses</H3>
-<P>Unless otherwise indicated, all Content made available by the Eclipse
-Foundation is provided to you under the terms and conditions of the Eclipse
-Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this
-Content and is also available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>Content includes, but is not limited to, source code, object code,
-documentation and other files maintained in the Eclipse.org CVS repository
-("Repository") in CVS modules ("Modules") and made available as downloadable
-archives ("Downloads").</P>
-<P>Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments
-("Fragments"), and features ("Features"). A Feature is a bundle of one or more
-Plug-ins and/or Fragments and associated material. Files named "feature.xml" may
-contain a list of the names and version numbers of the Plug-ins and/or Fragments
-associated with a Feature. Plug-ins and Fragments are located in directories
-named "plugins" and Features are located in directories named "features".</P>
-<P>Features may also include other Features ("Included Features"). Files named
-"feature.xml" may contain a list of the names and version numbers of Included
-Features.</P>
-<P>The terms and conditions governing Plug-ins and Fragments should be contained
-in files named "about.html" ("Abouts"). The terms and conditions governing
-Features and Included Features should be contained in files named "license.html"
-("Feature Licenses"). Abouts and Feature Licenses may be located in any
-directory of a Download or Module including, but not limited to the following
-locations:</P>
-<UL>
- <LI>The top-level (root) directory
- <LI>Plug-in and Fragment directories
- <LI>Subdirectories of the directory named "src" of certain Plug-ins
- <LI>Feature directories </LI></UL>
-<P>Note: if a Feature made available by the Eclipse Foundation is installed
-using the Eclipse Update Manager, you must agree to a license ("Feature Update
-License") during the installation process. If the Feature contains Included
-Features, the Feature Update License should either provide you with the terms
-and conditions governing the Included Features or inform you where you can
-locate them. Feature Update Licenses may be found in the "license" property of
-files named "feature.properties". Such Abouts, Feature Licenses and Feature
-Update Licenses contain the terms and conditions (or references to such terms
-and conditions) that govern your use of the associated Content in that
-directory.</P>
-<P>THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL
-OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</P>
-<UL>
- <LI>Common Public License Version 1.0 (available at <A
- href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</A>)
-
- <LI>Apache Software License 1.1 (available at <A
- href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</A>)
-
- <LI>Apache Software License 2.0 (available at <A
- href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</A>)
-
- <LI>IBM Public License 1.0 (available at <A
- href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</A>)
-
- <LI>Metro Link Public License 1.00 (available at <A
- href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</A>)
-
- <LI>Mozilla Public License Version 1.1 (available at <A
- href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</A>)
- </LI>
-
- <LI>Common Development and Distribution License (CDDL) Version 1.0 (available at <A
- href="http://www.sun.com/cddl/cddl.html">http://www.sun.com/cddl/cddl.html)</A>
- </LI>
-</UL>
-<P>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR
-TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is
-provided, please contact the Eclipse Foundation to determine what terms and
-conditions govern that particular Content.</P>
-<H3>Cryptography</H3>
-<P>Content may contain encryption software. The country in which you are
-currently may have restrictions on the import, possession, and use, and/or
-re-export to another country, of encryption software. BEFORE using any
-encryption software, please check the country's laws, regulations and policies
-concerning the import, possession, or use, and re-export of encryption software,
-to see if this is permitted.</P></BODY></HTML>
diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/.classpath b/jpa/plugins/org.eclipse.jpt.db.ui/.classpath
deleted file mode 100644
index 304e86186a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db.ui/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/.cvsignore b/jpa/plugins/org.eclipse.jpt.db.ui/.cvsignore
deleted file mode 100644
index a196dd7686..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db.ui/.cvsignore
+++ /dev/null
@@ -1,6 +0,0 @@
-bin
-@dot
-temp.folder
-build.xml
-javaCompiler...args
-javaCompiler...args.* \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/.project b/jpa/plugins/org.eclipse.jpt.db.ui/.project
deleted file mode 100644
index 88ea5da610..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db.ui/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.db.ui</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.core.resources.prefs b/jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 8fa7db1fac..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tue Jan 15 11:11:22 EST 2008
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.jdt.core.prefs b/jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 842c286bb1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Sun May 27 14:59:42 EDT 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.db.ui/META-INF/MANIFEST.MF
deleted file mode 100644
index 65ba480869..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db.ui/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,14 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.db.ui
-Bundle-Version: 1.0.1.qualifier
-Bundle-ClassPath: .
-Bundle-Localization: plugin
-Export-Package: org.eclipse.jpt.db.ui.internal; x-friends:="org.eclipse.jpt.ui"
-Require-Bundle: org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jpt.db;bundle-version="[1.1.1,2.0.0)",
- org.eclipse.datatools.connectivity.ui;bundle-version="[1.1.0,1.2.0)",
- org.eclipse.datatools.sqltools.editor.core;bundle-version="[1.0.0,2.0.0)"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/about.html b/jpa/plugins/org.eclipse.jpt.db.ui/about.html
deleted file mode 100644
index 9e73bdabb6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db.ui/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>June 06, 2007</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/build.properties b/jpa/plugins/org.eclipse.jpt.db.ui/build.properties
deleted file mode 100644
index 0d56981f21..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db.ui/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- about.html,\
- plugin.properties
-jars.compile.order = .
diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/component.xml b/jpa/plugins/org.eclipse.jpt.db.ui/component.xml
deleted file mode 100644
index bf648aaa4f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db.ui/component.xml
+++ /dev/null
@@ -1 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.jpt.db.ui"><description url=""></description><component-depends unrestricted="true"></component-depends><plugin id="org.eclipse.jpt.db.ui" fragment="false"/></component> \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/plugin.properties b/jpa/plugins/org.eclipse.jpt.db.ui/plugin.properties
deleted file mode 100644
index 2b0e5835b1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db.ui/plugin.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName = Java Persistence API Tools - DB UI
-providerName = Eclipse.org
-
diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/src/org/eclipse/jpt/db/ui/internal/DTPUiTools.java b/jpa/plugins/org.eclipse.jpt.db.ui/src/org/eclipse/jpt/db/ui/internal/DTPUiTools.java
deleted file mode 100644
index 13b277f200..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db.ui/src/org/eclipse/jpt/db/ui/internal/DTPUiTools.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007, 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.db.ui.internal;
-
-import org.eclipse.datatools.connectivity.ICategory;
-import org.eclipse.datatools.connectivity.IConnectionProfile;
-import org.eclipse.datatools.connectivity.IProfileListener;
-import org.eclipse.datatools.connectivity.ProfileManager;
-import org.eclipse.datatools.connectivity.internal.ConnectionProfileManager;
-import org.eclipse.datatools.connectivity.internal.ui.wizards.CPWizardNode;
-import org.eclipse.datatools.connectivity.internal.ui.wizards.NewCPWizard;
-import org.eclipse.datatools.connectivity.internal.ui.wizards.ProfileWizardProvider;
-import org.eclipse.datatools.connectivity.ui.wizards.IWizardCategoryProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * ConnectionProfileUiTools
- */
-public class DTPUiTools {
-
- private static final String DATABASE_CATEGORY_ID = "org.eclipse.datatools.connectivity.db.category"; //$NON-NLS-1$
-
-
- /**
- * Launch the DTP New Connection Profile wizard to create a new database connection profile.
- *
- * Returns the name of the added profile, or null if the wizard is cancelled. ConnectionProfileRepository
- * can be used to retrieve the added connection profile.
- */
- public static String createNewProfile() {
- NewCPWizard wizard;
- WizardDialog wizardDialog;
-
- // Filter datasource category
- ViewerFilter viewerFilter = new ViewerFilter() {
-
- @Override
- public boolean select( Viewer viewer, Object parentElement, Object element) {
-
- CPWizardNode wizardNode = ( CPWizardNode) element;
- if( !( wizardNode.getProvider() instanceof IWizardCategoryProvider)) {
- ICategory cat = ConnectionProfileManager.getInstance().getProvider(
- (( ProfileWizardProvider) wizardNode.getProvider()).getProfile()).getCategory();
-
- // Only display wizards belong to database category
- while( cat != null) {
- if( cat.getId().equals(DATABASE_CATEGORY_ID))
- return true;
- cat = cat.getParent();
- }
- }
- return false;
- }
- };
- wizard = new NewCPWizard( viewerFilter, null);
- Shell currentShell = Display.getCurrent().getActiveShell();
- wizardDialog = new WizardDialog( currentShell, wizard);
- wizardDialog.setBlockOnOpen( true);
-
- LocalProfileListener listener = new LocalProfileListener();
- ProfileManager.getInstance().addProfileListener( listener);
-
- if( wizardDialog.open() == Window.CANCEL) {
- ProfileManager.getInstance().removeProfileListener( listener);
- return null;
- }
- IConnectionProfile addedProfile = listener.addedProfile;
- ProfileManager.getInstance().removeProfileListener( listener);
-
- return addedProfile.getName();
- }
-
- static class LocalProfileListener implements IProfileListener {
- IConnectionProfile addedProfile;
-
- public void profileAdded( IConnectionProfile profile) {
- addedProfile = profile;
- }
-
- public void profileChanged( IConnectionProfile profile) {
- // do nothing
- }
-
- public void profileDeleted( IConnectionProfile profile) {
- // do nothing
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/.classpath b/jpa/plugins/org.eclipse.jpt.db/.classpath
deleted file mode 100644
index 304e86186a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/plugins/org.eclipse.jpt.db/.cvsignore b/jpa/plugins/org.eclipse.jpt.db/.cvsignore
deleted file mode 100644
index a196dd7686..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/.cvsignore
+++ /dev/null
@@ -1,6 +0,0 @@
-bin
-@dot
-temp.folder
-build.xml
-javaCompiler...args
-javaCompiler...args.* \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.db/.project b/jpa/plugins/org.eclipse.jpt.db/.project
deleted file mode 100644
index 5675a48e3a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.db</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.core.resources.prefs b/jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 84ebb5c739..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tue Jan 15 11:11:02 EST 2008
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.jdt.core.prefs b/jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 929d54536d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Sun May 27 14:59:18 EDT 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/jpa/plugins/org.eclipse.jpt.db/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.db/META-INF/MANIFEST.MF
deleted file mode 100644
index 63e6c0fc9d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,17 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.db
-Bundle-Version: 1.1.1.qualifier
-Bundle-Activator: org.eclipse.jpt.db.JptDbPlugin
-Bundle-ClassPath: .
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Bundle-ActivationPolicy: lazy
-Eclipse-LazyStart: true
-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.datatools.sqltools.editor.core;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.jpt.utility;bundle-version="[1.2.0,2.0.0)"
-Export-Package: org.eclipse.jpt.db,
- org.eclipse.jpt.db.internal;x-internal:=true
diff --git a/jpa/plugins/org.eclipse.jpt.db/about.html b/jpa/plugins/org.eclipse.jpt.db/about.html
deleted file mode 100644
index 9e73bdabb6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>June 06, 2007</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/jpa/plugins/org.eclipse.jpt.db/build.properties b/jpa/plugins/org.eclipse.jpt.db/build.properties
deleted file mode 100644
index 974eadac6b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/build.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-javacSource=1.5
-javacTarget=1.5
-source.. = src/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- about.html,\
- plugin.properties
-jars.compile.order = .
diff --git a/jpa/plugins/org.eclipse.jpt.db/component.xml b/jpa/plugins/org.eclipse.jpt.db/component.xml
deleted file mode 100644
index 644c396149..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/component.xml
+++ /dev/null
@@ -1 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.jpt.db"><description url=""></description><component-depends unrestricted="true"></component-depends><plugin id="org.eclipse.jpt.db" fragment="false"/></component> \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.db/plugin.properties b/jpa/plugins/org.eclipse.jpt.db/plugin.properties
deleted file mode 100644
index e87a2d3972..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/plugin.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName = Java Persistence API Tools - DB
-providerName = Eclipse.org
-
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Catalog.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Catalog.java
deleted file mode 100644
index 2db19a83af..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Catalog.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-/**
- * Database catalog
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface Catalog extends Comparable<Catalog> {
-
- /**
- * Return the catalog's name.
- */
- String getName();
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Column.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Column.java
deleted file mode 100644
index 99af66db0e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Column.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-import org.eclipse.jpt.utility.JavaType;
-
-/**
- * Database column
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface Column extends Comparable<Column> {
-
- /**
- * Return the column's name.
- */
- String getName();
-
- /**
- * Return the name of the column's datatype.
- */
- String getDataTypeName();
-
- /**
- * Return a Java-appropriate version of the column's name.
- */
- String getJavaFieldName();
-
- /**
- * Return whether the column's name matches the specified Java identifier,
- * respecting the database's case-sensitivity.
- */
- boolean matchesJavaFieldName(String javaFieldName);
-
- /**
- * Return a Java type declaration that is reasonably
- * similar to the column's data type and suitable for use as a
- * primary key field.
- */
- String getPrimaryKeyJavaTypeDeclaration();
-
- /**
- * Return a Java type that is reasonably
- * similar to the column's data type and suitable for use as a
- * primary key field.
- */
- JavaType getPrimaryKeyJavaType();
-
- /**
- * Return a Java type declaration that is reasonably
- * similar to the column's data type.
- */
- String getJavaTypeDeclaration();
-
- /**
- * Return a Java type that is reasonably
- * similar to the column's data type.
- */
- JavaType getJavaType();
-
- /**
- * Return whether the column's datatype is a LOB type
- * (i.e. BLOB, CLOB, or NCLOB).
- */
- boolean dataTypeIsLOB();
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionAdapter.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionAdapter.java
deleted file mode 100644
index 972848965c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionAdapter.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-
-/**
- * An empty implementation of ConnectionListener.
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class ConnectionAdapter implements ConnectionListener {
-
- public void aboutToClose(ConnectionProfile profile) {
- // do nothing
- }
-
- public void closed(ConnectionProfile profile) {
- // do nothing
- }
-
- public void databaseChanged(ConnectionProfile profile, Database database) {
- // do nothing
- }
-
- public void modified(ConnectionProfile profile) {
- // do nothing
- }
-
- public boolean okToClose(ConnectionProfile profile) {
- return true;
- }
-
- public void opened(ConnectionProfile profile) {
- // do nothing
- }
-
- public void catalogChanged(ConnectionProfile profile, Catalog catalog) {
- // do nothing
- }
-
- public void schemaChanged(ConnectionProfile profile, Schema schema) {
- // do nothing
- }
-
- public void sequenceChanged(ConnectionProfile profile, Sequence sequence) {
- // do nothing
- }
-
- public void tableChanged(ConnectionProfile profile, Table table) {
- // do nothing
- }
-
- public void columnChanged(ConnectionProfile profile, Column column) {
- // do nothing
- }
-
- public void foreignKeyChanged(ConnectionProfile profile, ForeignKey foreignKey) {
- // do nothing
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionListener.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionListener.java
deleted file mode 100644
index 879ba1bedd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-
-/**
- * A ConnectionListener is notified of any changes to a connection.
- *
- * @see org.eclipse.datatools.connectivity.IManagedConnectionListener
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ConnectionListener {
-
- public void opened(ConnectionProfile profile);
- public void modified(ConnectionProfile profile);
- public boolean okToClose(ConnectionProfile profile);
- public void aboutToClose(ConnectionProfile profile);
- public void closed(ConnectionProfile profile);
-
- public void databaseChanged(ConnectionProfile profile, Database database);
- public void catalogChanged(ConnectionProfile profile, Catalog catalog);
- public void schemaChanged(ConnectionProfile profile, Schema schema);
- public void sequenceChanged(ConnectionProfile profile, Sequence sequence);
- public void tableChanged(ConnectionProfile profile, Table table);
- public void columnChanged(ConnectionProfile profile, Column column);
- public void foreignKeyChanged(ConnectionProfile profile, ForeignKey foreignKey);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfile.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfile.java
deleted file mode 100644
index 8388f58ed4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfile.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
-
-/**
- * Database connection profile
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface ConnectionProfile extends Comparable<ConnectionProfile> {
-
- /**
- * Return the connection profile's name.
- */
- String getName();
-
- /**
- * Return the connection profile's database.
- * Return a "null" database if the connection profile is inactive.
- */
- Database getDatabase();
-
- /**
- * Return the connection profile's "default" catalog.
- * Return null if the connection profile's database does not support
- * catalogs.
- */
- Catalog getDefaultCatalog();
-
- /**
- * Return the connection profile's default schema.
- * In most cases the default schema's name will match the user name.
- * It may be null.
- */
- Schema getDefaultSchema();
-
- /**
- * Return ID of the provider managing the DTP profile.
- */
- String getProviderID();
-
- /**
- * Return the connection profile's static ID.
- */
- String getInstanceID();
-
- /**
- * Return the default database name.
- */
- String getDatabaseName();
-
- /**
- * Return the database product name.
- */
- String getDatabaseProduct();
-
- /**
- * Return the database vendor.
- */
- String getDatabaseVendor();
-
- /**
- * Return the database version.
- */
- String getDatabaseVersion();
-
- /**
- * Return the driver class name.
- */
- String getDriverClassName();
-
- /**
- * Return the default connection URL.
- */
- String getUrl();
-
- /**
- * Return the default user name.
- */
- String getUserName();
-
- /**
- * Return the default user password.
- */
- String getUserPassword();
-
- /**
- * Return the driver definition ID.
- */
- String getDriverDefinitionID();
-
- /**
- * Return the jar list for the driver instance as a
- * comma-delimited string.
- */
- String getDriverJarList();
-
- /**
- * Return whether the profile is either connected to a live database
- * session or working off-line (i.e. it has access to meta-data).
- * @see isConnected()
- * @see isWorkingOfflin()
- */
- boolean isActive();
-
- /**
- * Return whether the profile is connected to a live database session
- * (i.e. the meta-data comes from the database), as opposed to working
- * off-line.
- * @see #isActive()
- */
- boolean isConnected();
-
- /**
- * Connect to the database.
- */
- void connect();
-
- /**
- * Disconnect from the database.
- */
- void disconnect();
-
- /**
- * Return whether the profile is working off-line (i.e. the meta-data
- * comes from a local cache), as opposed to connected to a live
- * database session.
- * @see #isActive()
- */
- boolean isWorkingOffline();
-
- /**
- * Return whether the connection factories associated with the
- * connection profile's provider support working offline.
- */
- boolean supportsWorkOfflineMode();
-
- /**
- * Save the state of the connection profile for working in an offline mode.
- * If the connection profile does not support working in an offline mode, no
- * exception is thrown and the method will return immediately.
- */
- IStatus saveWorkOfflineData();
-
- /**
- * Return whether the connection profile supports working offline and data
- * has been saved for working offline.
- */
- boolean canWorkOffline();
-
- /**
- * Begin working off-line.
- */
- IStatus workOffline();
-
- /**
- * Return whether the connection profile is a "null" connection profile.
- */
- boolean isNull();
-
- /**
- * Add the specified connection listener to the connection profile.
- */
- void addConnectionListener(ConnectionListener listener);
-
- /**
- * Remove the specified connection listener from the connection profile.
- */
- void removeConnectionListener(ConnectionListener listener);
-
- String CONNECTION_PROFILE_TYPE = "org.eclipse.datatools.connectivity.db.generic.connectionProfile"; //$NON-NLS-1$
- String DRIVER_DEFINITION_PROP_ID = "org.eclipse.datatools.connectivity.driverDefinitionID"; //$NON-NLS-1$
- String DRIVER_DEFINITION_TYPE_PROP_ID = "org.eclipse.datatools.connectivity.drivers.defnType"; //$NON-NLS-1$
- String DRIVER_JAR_LIST_PROP_ID = "jarList"; //$NON-NLS-1$
- String DATABASE_SAVE_PWD_PROP_ID = IJDBCDriverDefinitionConstants.PROP_PREFIX + "savePWD"; //$NON-NLS-1$
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfileAdapter.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfileAdapter.java
deleted file mode 100644
index fb5c601a25..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfileAdapter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-/**
- * An empty implementation of ProfileListener.
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class ConnectionProfileAdapter implements ConnectionProfileListener {
-
- public void connectionProfileChanged(ConnectionProfile profile) {
- // do nothing
- }
-
- public void connectionProfileReplaced(ConnectionProfile oldProfile, ConnectionProfile newProfile) {
- // do nothing
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfileListener.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfileListener.java
deleted file mode 100644
index 89f6207998..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfileListener.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-/**
- * A ProfileListener is notified of any changes to the connection profiles.
- *
- * @see org.eclipse.datatools.connectivity.IProfileListener
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ConnectionProfileListener {
-
- /**
- * The specified old profile has been replaced with the specified
- * new profile. The old profile is a "null" profile when a profile is
- * added. The new profile is a "null" profile when a profile is
- * removed.
- */
- public void connectionProfileReplaced(ConnectionProfile oldProfile, ConnectionProfile newProfile);
-
- /**
- * The specified profile has been modified. Modification includes
- * changes to any properties, the name, auto-connect flag, etc.
- */
- public void connectionProfileChanged(ConnectionProfile profile);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfileRepository.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfileRepository.java
deleted file mode 100644
index 8f37291f78..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ConnectionProfileRepository.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-import java.util.Iterator;
-
-/**
- * Database connection profile repository
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface ConnectionProfileRepository {
-
- /**
- * Return the repository's connection profiles.
- */
- Iterator<ConnectionProfile> connectionProfiles();
-
- /**
- * Return the number of connection profiles in the repository.
- */
- int connectionProfilesSize();
-
- /**
- * Return the repository's connection profile names.
- */
- Iterator<String> connectionProfileNames();
-
- /**
- * Return whether the repository contains a connection profile
- * with the specified name.
- */
- boolean containsConnectionProfileNamed(String name);
-
- /**
- * Return the connection profile with the specified name.
- * Return a "null" connection profile if the repository does not
- * have a connection profile with the specified name.
- */
- ConnectionProfile connectionProfileNamed(String name);
-
- /**
- * Add a listener that will be notified of changes to the repository's
- * connection profiles.
- */
- void addConnectionProfileListener(ConnectionProfileListener listener);
-
- /**
- * Remove the specified listener.
- */
- void removeConnectionProfileListener(ConnectionProfileListener listener);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Database.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Database.java
deleted file mode 100644
index e4e19babc3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Database.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-import java.util.Iterator;
-import org.eclipse.datatools.connectivity.sqm.core.definition.DatabaseDefinition;
-
-/**
- * Database
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface Database extends SchemaContainer, Comparable<Database> {
-
- /**
- * Return the database's name.
- */
- String getName();
-
- /**
- * Return the database's vendor.
- */
- String getVendor();
-
- /**
- * Return the database's version.
- */
- String getVersion();
-
- /**
- * Return whether the database's identifiers are case-sensitive.
- */
- boolean isCaseSensitive();
-
- /**
- * Return the database's DTP database definition.
- */
- DatabaseDefinition getDtpDefinition();
-
- /**
- * Return whether the database supports catalogs.
- */
- boolean supportsCatalogs();
-
- /**
- * Return the database's catalogs.
- */
- Iterator<Catalog> catalogs();
-
- /**
- * Return the number of catalogs the database contains.
- */
- int catalogsSize();
-
- /**
- * Return the names of the database's catalogs.
- */
- Iterator<String> catalogNames();
-
- /**
- * Return whether the database contains a catalog with the specified name,
- * respecting the database's case-sensitivity.
- */
- boolean containsCatalogNamed(String name);
-
- /**
- * Return the catalog in the database with the specified name,
- * respecting the database's case-sensitivity.
- */
- Catalog catalogNamed(String name);
-
- /**
- * Return the database's "default" catalog.
- */
- Catalog getDefaultCatalog();
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ForeignKey.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ForeignKey.java
deleted file mode 100644
index 3215cfdfd4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/ForeignKey.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-import java.util.Iterator;
-
-/**
- * Database foreign key
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface ForeignKey extends Comparable<ForeignKey> {
-
- /**
- * Return the foreign key's name.
- */
- String getName();
-
- /**
- * Return the foreign key's "base" table.
- */
- Table getBaseTable();
-
- /**
- * Return the foreign key's "referenced" table.
- */
- Table getReferencedTable();
-
- /**
- * Return the foreign key's column pairs.
- * @see ColumnPair
- */
- Iterator<ColumnPair> columnPairs();
-
- /**
- * Return the foreign key's single column pair. Throw an
- * IllegalStateException if the foreign key has more than one column pair.
- */
- ColumnPair columnPair();
-
- /**
- * Return the size of the foreign key's column pairs.
- * @see ColumnPair
- */
- int columnPairsSize();
-
- /**
- * Return the foreign key's "base" columns.
- * @see ColumnPair
- */
- Iterator<Column> baseColumns();
-
- /**
- * Return the foreign key's "base" columns that are not part of
- * the base table's primary key.
- * @see ColumnPair
- */
- Iterator<Column> nonPrimaryKeyBaseColumns();
-
- /**
- * Return the foreign key's "referenced" columns.
- * @see ColumnPair
- */
- Iterator<Column> referencedColumns();
-
- /**
- * Return a Java-appropriate name for a field that holds the entity
- * mapped to the foreign key's "referenced" table.
- */
- String getJavaFieldName();
-
- /**
- * Return whether the foreign key's default Java field name matches the
- * specified Java identifier, respecting the database's case-sensitivity.
- */
- boolean defaultMatchesJavaFieldName(String javaFieldName);
-
- /**
- * Return whether the foreign key is the default for the specified Java
- * field name, respecting the database's case-sensitivity.
- */
- boolean isDefaultFor(String javaFieldName);
-
- /**
- * Return whether the foreign key references the primary key of the
- * "referenced" table and that primary key has only a single column.
- */
- boolean referencesSingleColumnPrimaryKey();
-
-
- /**
- * Pair up the foreign key's column pairs, matching each "base" column with
- * the appropriate "referenced" column.
- * @see #columnPairs()
- */
- interface ColumnPair extends Comparable<ColumnPair> {
-
- /**
- * Return the column pair's "base" column.
- */
- Column baseColumn();
-
- /**
- * Return the column pair's "referenced" column.
- */
- Column referencedColumn();
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/JptDbPlugin.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/JptDbPlugin.java
deleted file mode 100644
index 00aa478fb9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/JptDbPlugin.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.jpt.db.internal.DTPConnectionProfileRepository;
-import org.osgi.framework.BundleContext;
-
-/**
- * The JPT DB plug-in lifecycle implementation.
- * Globally available connection profile repository.
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class JptDbPlugin extends Plugin {
- private DTPConnectionProfileRepository connectionProfileRepository;
-
- private static JptDbPlugin INSTANCE; // sorta-final
-
- /**
- * Return the singleton JPT DB plug-in.
- */
- public static JptDbPlugin instance() {
- return INSTANCE;
- }
-
- /**
- * The constructor
- */
- public JptDbPlugin() {
- super();
- INSTANCE = this;
- }
-
- /**
- * This method is called upon plug-in activation
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- this.connectionProfileRepository = DTPConnectionProfileRepository.instance();
- this.connectionProfileRepository.start();
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- this.connectionProfileRepository.stop();
- this.connectionProfileRepository = null;
- INSTANCE = null;
- super.stop(context);
- }
-
- public ConnectionProfileRepository getConnectionProfileRepository() {
- return this.connectionProfileRepository;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Schema.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Schema.java
deleted file mode 100644
index 2b13ecede0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Schema.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-import java.util.Iterator;
-
-
-/**
- * Database schema
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface Schema extends Comparable<Schema> {
-
- /**
- * Return the schema's name.
- */
- String getName();
-
- /**
- * Return the schema's tables.
- */
- Iterator<Table> tables();
-
- /**
- * Return the number of tables the schema contains.
- */
- int tablesSize();
-
- /**
- * Return the names of the schema's tables.
- */
- Iterator<String> tableNames();
-
- /**
- * Return whether the schema contains a table with the specified name,
- * respecting the database's case-sensitivity.
- */
- boolean containsTableNamed(String name);
-
- /**
- * Return the table in the schema with the specified name,
- * respecting the database's case-sensitivity.
- */
- Table tableNamed(String name);
-
- /**
- * Return the schema's sequences.
- */
- Iterator<Sequence> sequences();
-
- /**
- * Return the number of sequences the schema contains.
- */
- int sequencesSize();
-
- /**
- * Return the names of the schema's sequences.
- */
- Iterator<String> sequenceNames();
-
- /**
- * Return whether the schema contains a sequence with the specified name,
- * respecting the database's case-sensitivity.
- */
- boolean containsSequenceNamed(String name);
-
- /**
- * Return the sequence in the schema with the specified name,
- * respecting the database's case-sensitivity.
- */
- Sequence sequenceNamed(String name);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/SchemaContainer.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/SchemaContainer.java
deleted file mode 100644
index 52895619bf..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/SchemaContainer.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-import java.util.Iterator;
-
-/**
- * Schema "container" (i.e. Database or Catalog)
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface SchemaContainer {
-
- /**
- * Return the container's schemata.
- */
- Iterator<Schema> schemata();
-
- /**
- * Return the number of schemata in the container.
- */
- int schemataSize();
-
- /**
- * Return the names of the container's schemata.
- */
- Iterator<String> schemaNames();
-
- /**
- * Return whether the container contains a schema with the specified name,
- * respecting the database's case-sensitivity.
- */
- boolean containsSchemaNamed(String name);
-
- /**
- * Return the schema in the container with the specified name,
- * respecting the database's case-sensitivity.
- */
- Schema schemaNamed(String name);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Sequence.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Sequence.java
deleted file mode 100644
index bd024a03a6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Sequence.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-/**
- * Database sequence
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface Sequence extends Comparable<Sequence> {
-
- /**
- * Return the sequence's name.
- */
- String getName();
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Table.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Table.java
deleted file mode 100644
index 2273973de3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Table.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db;
-
-import java.util.Iterator;
-
-/**
- * Database table
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface Table extends Comparable<Table> {
-
- /**
- * Return the table's name.
- */
- String getName();
-
- /**
- * Return the table's columns.
- */
- Iterator<Column> columns();
-
- /**
- * Return the number of columns the table contains.
- */
- int columnsSize();
-
- /**
- * Return the names of the table's columns.
- */
- Iterator<String> columnNames();
-
- /**
- * Return whether the table contains a column with the specified name,
- * respecting the database's case-sensitivity.
- */
- boolean containsColumnNamed(String name);
-
- /**
- * Return the column in the table with the specified name,
- * respecting the database's case-sensitivity.
- */
- Column columnNamed(String name);
-
- /**
- * Return the table's primary key columns.
- */
- Iterator<Column> primaryKeyColumns();
-
- /**
- * Return the table's single primary key column. Throw an
- * IllegalStateException if the table has more than one primary key column.
- */
- Column primaryKeyColumn();
-
- /**
- * Return the number of primary key columns the table contains.
- */
- int primaryKeyColumnsSize();
-
- /**
- * Return whether the specified column is one of the table's primary key
- * columns.
- */
- boolean primaryKeyColumnsContains(Column column);
-
- /**
- * Return the table's foreign keys.
- */
- Iterator<ForeignKey> foreignKeys();
-
- /**
- * Return the number of foreign keys the table contains.
- */
- int foreignKeysSize();
-
- /**
- * Return whether the specified column is a "base" column
- * for any of the table's foreign keys.
- */
- boolean foreignKeyBaseColumnsContains(Column column);
-
- /**
- * Return the table's name, converted to a Java-appropriate class
- * identifier, respecting the database's case-sensitivity.
- */
- String getShortJavaClassName();
-
- /**
- * Return whether the table's name matches the specified Java-appropriate
- * identifier, respecting the database's case-sensitivity.
- */
- boolean matchesShortJavaClassName(String shortJavaClassName);
-
- /**
- * Return the table's name, converted to a Java-appropriate field
- * identifier, respecting the database's case-sensitivity.
- */
- public String getJavaFieldName();
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileHolder.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileHolder.java
deleted file mode 100644
index f106e91b4d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileHolder.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-/**
- * Provide a way for clients to access the connection profile.
- */
-interface ConnectionProfileHolder {
- DTPConnectionProfileWrapper getConnectionProfile();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPCatalogWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPCatalogWrapper.java
deleted file mode 100644
index 1319675ade..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPCatalogWrapper.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import java.text.Collator;
-import java.util.List;
-
-import org.eclipse.jpt.db.Catalog;
-
-/**
- * Wrap a DTP Catalog
- */
-final class DTPCatalogWrapper
- extends DTPSchemaContainerWrapper
- implements Catalog
-{
- // backpointer to parent
- private final DTPDatabaseWrapper database;
-
- // the wrapped DTP catalog
- private final org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog;
-
-
- // ********** constructor **********
-
- DTPCatalogWrapper(DTPDatabaseWrapper database, org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog) {
- super(database, dtpCatalog);
- this.database = database;
- this.dtpCatalog = dtpCatalog;
- }
-
-
- // ********** DTPWrapper implementation **********
-
- @Override
- synchronized void catalogObjectChanged(int eventType) {
- super.catalogObjectChanged(eventType);
- this.getConnectionProfile().catalogChanged(this, eventType);
- }
-
-
- // ********** Catalog implementation **********
-
- @Override
- public String getName() {
- return this.dtpCatalog.getName();
- }
-
-
- // ***** schemata
-
- @Override
- @SuppressWarnings("unchecked")
- List<org.eclipse.datatools.modelbase.sql.schema.Schema> dtpSchemata() {
- return this.dtpCatalog.getSchemas();
- }
-
-
- // ********** internal methods **********
-
- boolean wraps(org.eclipse.datatools.modelbase.sql.schema.Catalog catalog) {
- return this.dtpCatalog == catalog;
- }
-
- @Override
- boolean isCaseSensitive() {
- return this.database.isCaseSensitive();
- }
-
- @Override
- DTPDatabaseWrapper database() {
- return this.database;
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(Catalog catalog) {
- return Collator.getInstance().compare(this.getName(), catalog.getName());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPColumnWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPColumnWrapper.java
deleted file mode 100644
index 2c32477588..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPColumnWrapper.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import java.text.Collator;
-
-import org.eclipse.datatools.modelbase.dbdefinition.PredefinedDataTypeDefinition;
-import org.eclipse.datatools.modelbase.sql.datatypes.DataType;
-import org.eclipse.datatools.modelbase.sql.datatypes.PredefinedDataType;
-import org.eclipse.datatools.modelbase.sql.datatypes.PrimitiveType;
-import org.eclipse.jpt.db.Column;
-import org.eclipse.jpt.utility.JavaType;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.NameTools;
-import org.eclipse.jpt.utility.internal.SimpleJavaType;
-
-/**
- * Wrap a DTP Column
- */
-final class DTPColumnWrapper
- extends DTPWrapper
- implements Column
-{
- // backpointer to parent
- private final DTPTableWrapper table;
-
- // the wrapped DTP column
- private final org.eclipse.datatools.modelbase.sql.tables.Column dtpColumn;
-
-
- // ***** some constants used when converting the column to a Java field
- // TODO Object is the default?
- private static final JavaType DEFAULT_JAVA_TYPE = new SimpleJavaType(java.lang.Object.class);
-
- private static final JavaType BLOB_JAVA_TYPE = new SimpleJavaType(java.sql.Blob.class);
- private static final JavaType BYTE_ARRAY_JAVA_TYPE = new SimpleJavaType(byte[].class);
-
- private static final JavaType CLOB_JAVA_TYPE = new SimpleJavaType(java.sql.Clob.class);
- private static final JavaType STRING_JAVA_TYPE = new SimpleJavaType(java.lang.String.class);
-
- private static final JavaType UTIL_DATE_JAVA_TYPE = new SimpleJavaType(java.util.Date.class);
- private static final JavaType SQL_DATE_JAVA_TYPE = new SimpleJavaType(java.sql.Date.class);
- private static final JavaType SQL_TIME_JAVA_TYPE = new SimpleJavaType(java.sql.Time.class);
- private static final JavaType SQL_TIMESTAMP_JAVA_TYPE = new SimpleJavaType(java.sql.Timestamp.class);
-
- private static final JavaType BIG_DECIMAL_JAVA_TYPE = new SimpleJavaType(java.math.BigDecimal.class);
- private static final JavaType LONG_JAVA_TYPE = new SimpleJavaType(long.class);
-
-
- // ********** constructor **********
-
- DTPColumnWrapper(DTPTableWrapper table, org.eclipse.datatools.modelbase.sql.tables.Column dtpColumn) {
- super(table, dtpColumn);
- this.table = table;
- this.dtpColumn = dtpColumn;
- }
-
-
- // ********** DTPWrapper implementation **********
-
- @Override
- synchronized void catalogObjectChanged(int eventType) {
- this.getConnectionProfile().columnChanged(this, eventType);
- }
-
-
- // ********** Column implementation **********
-
- @Override
- public String getName() {
- return this.dtpColumn.getName();
- }
-
- public String getDataTypeName() {
- DataType dataType = this.dtpColumn.getDataType();
- return (dataType == null) ? null : dataType.getName();
- }
-
- public String getJavaFieldName() {
- String jName = this.getName();
- if ( ! this.isCaseSensitive()) {
- jName = jName.toLowerCase();
- }
- return NameTools.convertToJavaIdentifier(jName);
- }
-
- public boolean matchesJavaFieldName(String javaFieldName) {
- return this.isCaseSensitive() ?
- this.getName().equals(javaFieldName)
- :
- this.getName().equalsIgnoreCase(javaFieldName);
- }
-
- public String getPrimaryKeyJavaTypeDeclaration() {
- return this.getPrimaryKeyJavaType().declaration();
- }
-
- public JavaType getPrimaryKeyJavaType() {
- return this.jpaSpecCompliantPrimaryKeyJavaType(this.getJavaType());
- }
-
- /**
- * The JPA spec [2.1.4] says only the following types are allowed in
- * primary key fields:
- * [variable] primitives
- * [variable] primitive wrappers
- * java.lang.String
- * java.util.Date
- * java.sql.Date
- */
- private JavaType jpaSpecCompliantPrimaryKeyJavaType(JavaType javaType) {
- if (javaType.isVariablePrimitive()
- || javaType.isVariablePrimitiveWrapper()
- || javaType.equals(STRING_JAVA_TYPE)
- || javaType.equals(UTIL_DATE_JAVA_TYPE)
- || javaType.equals(SQL_DATE_JAVA_TYPE)) {
- return javaType;
- }
- if (javaType.equals(BIG_DECIMAL_JAVA_TYPE)) {
- return LONG_JAVA_TYPE; // ??
- }
- if (javaType.equals(SQL_TIME_JAVA_TYPE)) {
- return UTIL_DATE_JAVA_TYPE; // ???
- }
- if (javaType.equals(SQL_TIMESTAMP_JAVA_TYPE)) {
- return UTIL_DATE_JAVA_TYPE; // ???
- }
- // all the other typical types are pretty much un-mappable - return String(?)
- return STRING_JAVA_TYPE;
- }
-
- public String getJavaTypeDeclaration() {
- return this.getJavaType().declaration();
- }
-
- public JavaType getJavaType() {
- DataType dataType = this.dtpColumn.getDataType();
- return (dataType instanceof PredefinedDataType) ?
- this.jpaSpecCompliantJavaType(this.javaType((PredefinedDataType) dataType))
- :
- DEFAULT_JAVA_TYPE;
- }
-
- private JavaType javaType(PredefinedDataType dataType) {
- // this is just a bit hacky: moving from a type declaration to a class name to a type declaration...
- String dtpJavaClassName = this.predefinedDataTypeDefinition(dataType).getJavaClassName();
- return new SimpleJavaType(ClassTools.classNameForTypeDeclaration(dtpJavaClassName));
- }
-
- private PredefinedDataTypeDefinition predefinedDataTypeDefinition(PredefinedDataType dataType) {
- return this.database().getDtpDefinition().getPredefinedDataTypeDefinition(dataType.getName());
- }
-
- /**
- * The JDBC spec says JDBC drivers should be able to map BLOBs and CLOBs
- * directly, but the JPA spec does not allow them.
- */
- private JavaType jpaSpecCompliantJavaType(JavaType javaType) {
- if (javaType.equals(BLOB_JAVA_TYPE)) {
- return BYTE_ARRAY_JAVA_TYPE;
- }
- if (javaType.equals(CLOB_JAVA_TYPE)) {
- return STRING_JAVA_TYPE;
- }
- return javaType;
- }
-
- public boolean dataTypeIsLOB() {
- DataType dataType = this.dtpColumn.getDataType();
- return (dataType instanceof PredefinedDataType) ?
- this.primitiveTypeIsLob(((PredefinedDataType) dataType).getPrimitiveType())
- :
- false;
- }
-
- private boolean primitiveTypeIsLob(PrimitiveType primitiveType) {
- return (primitiveType == PrimitiveType.BINARY_LARGE_OBJECT_LITERAL)
- || (primitiveType == PrimitiveType.CHARACTER_LARGE_OBJECT_LITERAL)
- || (primitiveType == PrimitiveType.NATIONAL_CHARACTER_LARGE_OBJECT_LITERAL);
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(Column column) {
- return Collator.getInstance().compare(this.getName(), column.getName());
- }
-
-
- // ********** internal methods **********
-
- boolean wraps(org.eclipse.datatools.modelbase.sql.tables.Column column) {
- return this.dtpColumn == column;
- }
-
- boolean isCaseSensitive() {
- return this.table.isCaseSensitive();
- }
-
- DTPDatabaseWrapper database() {
- return this.table.database();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileRepository.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileRepository.java
deleted file mode 100644
index 694ae57176..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileRepository.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.eclipse.datatools.connectivity.IConnectionProfile;
-import org.eclipse.datatools.connectivity.IProfileListener;
-import org.eclipse.datatools.connectivity.ProfileManager;
-import org.eclipse.jpt.db.ConnectionProfile;
-import org.eclipse.jpt.db.ConnectionProfileRepository;
-import org.eclipse.jpt.db.ConnectionProfileListener;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-/**
- * Wrap the DTP ProfileManager.
- */
-public final class DTPConnectionProfileRepository
- implements ConnectionProfileRepository
-{
- private ProfileManager dtpProfileManager;
-
- private LocalProfileListener profileListener;
-
- private final Vector<DTPConnectionProfileWrapper> connectionProfiles = new Vector<DTPConnectionProfileWrapper>();
-
-
- // ********** singleton **********
-
- private static final DTPConnectionProfileRepository INSTANCE = new DTPConnectionProfileRepository();
-
- public static DTPConnectionProfileRepository instance() {
- return INSTANCE;
- }
-
- /**
- * 'private' to ensure singleton
- */
- private DTPConnectionProfileRepository() {
- super();
- }
-
-
- // ********** lifecycle **********
-
- /**
- * called by plug-in
- */
- public synchronized void start() {
- this.dtpProfileManager = ProfileManager.getInstance();
- this.profileListener = new LocalProfileListener();
- this.dtpProfileManager.addProfileListener(this.profileListener);
- for (IConnectionProfile dtpProfile : this.dtpProfileManager.getProfiles()) {
- this.connectionProfiles.add(new DTPConnectionProfileWrapper(dtpProfile));
- }
- }
-
- /**
- * called by plug-in
- */
- public synchronized void stop() {
- for (DTPConnectionProfileWrapper profile : this.connectionProfiles) {
- profile.dispose();
- }
- this.connectionProfiles.clear();
- this.dtpProfileManager.removeProfileListener(this.profileListener);
- this.profileListener = null;
- this.dtpProfileManager = null;
- }
-
-
- // ********** profiles **********
-
- public synchronized Iterator<ConnectionProfile> connectionProfiles() {
- return new CloneIterator<ConnectionProfile>(this.connectionProfiles); // read-only
- }
-
- private synchronized Iterator<DTPConnectionProfileWrapper> connectionProfileWrappers() {
- return new CloneIterator<DTPConnectionProfileWrapper>(this.connectionProfiles); // read-only
- }
-
- public int connectionProfilesSize() {
- return this.connectionProfiles.size();
- }
-
- public Iterator<String> connectionProfileNames() {
- return new TransformationIterator<DTPConnectionProfileWrapper, String>(this.connectionProfileWrappers()) {
- @Override
- protected String transform(DTPConnectionProfileWrapper profile) {
- return profile.getName();
- }
- };
- }
-
- public boolean containsConnectionProfileNamed(String name) {
- return ! this.connectionProfileNamed(name).isNull();
- }
-
- public ConnectionProfile connectionProfileNamed(String name) {
- for (Iterator<DTPConnectionProfileWrapper> stream = this.connectionProfileWrappers(); stream.hasNext(); ) {
- DTPConnectionProfileWrapper profile = stream.next();
- if (profile.getName().equals(name)) {
- return profile;
- }
- }
- return NullConnectionProfile.instance();
- }
-
- synchronized DTPConnectionProfileWrapper addConnectionProfile(IConnectionProfile dtpConnectionProfile) {
- for (DTPConnectionProfileWrapper wrapper : this.connectionProfiles) {
- if (wrapper.wraps(dtpConnectionProfile)) {
- throw new IllegalStateException("duplicate connection profile: " + dtpConnectionProfile.getName()); //$NON-NLS-1$
- }
- }
- DTPConnectionProfileWrapper wrapper = new DTPConnectionProfileWrapper(dtpConnectionProfile);
- this.connectionProfiles.add(wrapper);
- return wrapper;
- }
-
- synchronized DTPConnectionProfileWrapper removeConnectionProfile(IConnectionProfile dtpConnectionProfile) {
- for (Iterator<DTPConnectionProfileWrapper> stream = this.connectionProfiles.iterator(); stream.hasNext(); ) {
- DTPConnectionProfileWrapper wrapper = stream.next();
- if (wrapper.wraps(dtpConnectionProfile)) {
- stream.remove();
- return wrapper;
- }
- }
- throw new IllegalStateException("invalid connection profile: " + dtpConnectionProfile.getName()); //$NON-NLS-1$
- }
-
- synchronized DTPConnectionProfileWrapper connectionProfile(IConnectionProfile dtpConnectionProfile) {
- for (DTPConnectionProfileWrapper wrapper : this.connectionProfiles) {
- if (wrapper.wraps(dtpConnectionProfile)) {
- return wrapper;
- }
- }
- throw new IllegalStateException("invalid connection profile: " + dtpConnectionProfile.getName()); //$NON-NLS-1$
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(ClassTools.toStringClassNameForObject(this));
- sb.append((this.connectionProfiles != null) ? this.connectionProfiles : "<'connectionProfiles' uninitialized>"); //$NON-NLS-1$
- return sb.toString();
- }
-
-
- // ********** listeners **********
-
- public void addConnectionProfileListener(ConnectionProfileListener listener) {
- this.profileListener.addConnectionProfileListener(listener);
- }
-
- public void removeConnectionProfileListener(ConnectionProfileListener listener) {
- this.profileListener.removeConnectionProfileListener(listener);
- }
-
-
- // ********** listener **********
-
- /**
- * Keep the repository in synch with the DTP profile manager
- * and forward events to the repository's listeners.
- */
- private class LocalProfileListener implements IProfileListener {
- private Vector<ConnectionProfileListener> listeners = new Vector<ConnectionProfileListener>();
-
- LocalProfileListener() {
- super();
- }
-
- void addConnectionProfileListener(ConnectionProfileListener listener) {
- this.listeners.add(listener);
- }
-
- void removeConnectionProfileListener(ConnectionProfileListener listener) {
- this.listeners.remove(listener);
- }
-
- private Iterator<ConnectionProfileListener> listeners() {
- return new CloneIterator<ConnectionProfileListener>(this.listeners);
- }
-
- // ********** IProfileListener implementation **********
-
- public void profileAdded(IConnectionProfile dtpProfile) {
- // synch the repository then notify listeners
- DTPConnectionProfileWrapper profile = DTPConnectionProfileRepository.this.addConnectionProfile(dtpProfile);
- for (Iterator<ConnectionProfileListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().connectionProfileReplaced(NullConnectionProfile.instance(), profile);
- }
- }
-
- public void profileChanged(IConnectionProfile dtpProfile) {
- DTPConnectionProfileWrapper profile = DTPConnectionProfileRepository.this.connectionProfile(dtpProfile);
- for (Iterator<ConnectionProfileListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().connectionProfileChanged(profile);
- }
- }
-
- public void profileDeleted(IConnectionProfile dtpProfile) {
- // synch the repository then notify listeners
- DTPConnectionProfileWrapper profile = DTPConnectionProfileRepository.this.removeConnectionProfile(dtpProfile);
- for (Iterator<ConnectionProfileListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().connectionProfileReplaced(profile, NullConnectionProfile.instance());
- }
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java
deleted file mode 100644
index fdf1f0c774..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java
+++ /dev/null
@@ -1,479 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import java.text.Collator;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.datatools.connectivity.ConnectEvent;
-import org.eclipse.datatools.connectivity.IConnectionProfile;
-import org.eclipse.datatools.connectivity.IManagedConnection;
-import org.eclipse.datatools.connectivity.IManagedConnectionOfflineListener;
-import org.eclipse.datatools.connectivity.drivers.DriverManager;
-import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
-import org.eclipse.datatools.connectivity.sqm.core.connection.ConnectionInfo;
-import org.eclipse.datatools.sqltools.core.DatabaseIdentifier;
-import org.eclipse.datatools.sqltools.core.profile.ProfileUtil;
-import org.eclipse.jpt.db.ConnectionListener;
-import org.eclipse.jpt.db.ConnectionProfile;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-
-/**
- * Wrap a DTP ConnectionProfile
- */
-final class DTPConnectionProfileWrapper
- implements ConnectionProfile, ConnectionProfileHolder
-{
- // the wrapped DTP connection profile
- private final IConnectionProfile dtpConnectionProfile;
-
- // the DTP managed connection we listen to
- private final IManagedConnection dtpManagedConnection;
-
- // forward events from the DTP connection profile's managed connections
- private final LocalConnectionListener connectionListener;
-
- // lazy-initialized - can be a "null" database
- private InternalDatabase database;
-
-
- // ********** constants **********
-
- public static final String LIVE_DTP_CONNECTION_TYPE = "java.sql.Connection"; //$NON-NLS-1$
-
- public static final String OFFLINE_DTP_CONNECTION_TYPE = ConnectionInfo.class.getName();
-
- public static final String DATABASE_PRODUCT_PROP_ID = "org.eclipse.datatools.connectivity.server.version"; //$NON-NLS-1$
-
- public static final String POSTGRESQL_VENDOR = "postgres"; //$NON-NLS-1$
-
- public static final String POSTGRESQL_DEFAULT_SCHEMA_NAME = "public"; //$NON-NLS-1$
-
-
- // ********** constructor **********
-
- DTPConnectionProfileWrapper(IConnectionProfile dtpConnectionProfile) {
- super();
- this.dtpConnectionProfile = dtpConnectionProfile;
- this.dtpManagedConnection = this.buildDTPManagedConnection();
- this.connectionListener = new LocalConnectionListener();
- this.dtpManagedConnection.addConnectionListener(this.connectionListener);
- }
-
- private IManagedConnection buildDTPManagedConnection() {
- String connectionType = this.dtpConnectionProfile.supportsWorkOfflineMode() ?
- OFFLINE_DTP_CONNECTION_TYPE : LIVE_DTP_CONNECTION_TYPE;
- return this.dtpConnectionProfile.getManagedConnection(connectionType);
- }
-
-
- // ********** ConnectionProfileHolder implementation **********
-
- public DTPConnectionProfileWrapper getConnectionProfile() {
- return this;
- }
-
-
- // ********** ConnectionProfile implementation **********
-
- public String getName() {
- return this.dtpConnectionProfile.getName();
- }
-
- public boolean isNull() {
- return false;
- }
-
- public void connect() {
- if (this.isDisconnected()) {
- this.checkStatus(this.dtpConnectionProfile.connect());
- }
- }
-
- public void disconnect() {
- this.checkStatus(this.dtpConnectionProfile.disconnect());
- }
-
- public boolean isActive() {
- return this.isConnected() || this.isWorkingOffline();
- }
-
- public boolean isInactive() {
- return ! this.isActive();
- }
-
- public boolean isConnected() {
- return this.dtpManagedConnection.isConnected()
- && ! this.dtpManagedConnection.isWorkingOffline();
- }
-
- public boolean isDisconnected() {
- return ! this.isConnected();
- }
-
- public boolean isWorkingOffline() {
- return this.dtpManagedConnection.isWorkingOffline();
- }
-
- public boolean supportsWorkOfflineMode() {
- return this.dtpConnectionProfile.supportsWorkOfflineMode();
- }
-
- public boolean canWorkOffline() {
- return this.dtpConnectionProfile.canWorkOffline();
- }
-
- public IStatus saveWorkOfflineData() {
- return this.dtpConnectionProfile.saveWorkOfflineData();
- }
-
- public IStatus workOffline() {
- return this.dtpConnectionProfile.workOffline();
- }
-
- public String getDatabaseVendor() {
- return this.getProperty(IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID);
- }
-
- public String getDatabaseName() {
- return this.getProperty(IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID);
- }
-
- public String getDatabaseProduct() {
- return this.getProperty(DATABASE_PRODUCT_PROP_ID);
- }
-
- public String getDatabaseVersion() {
- return this.getProperty(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID);
- }
-
- public String getUserName() {
- return this.getProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID);
- }
-
- public String getUserPassword() {
- return this.getProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID);
- }
-
- public synchronized InternalDatabase getDatabase() {
- if (this.database == null) {
- this.database = this.buildDatabase();
- }
- return this.database;
- }
-
- public DTPCatalogWrapper getDefaultCatalog() {
- return this.getDatabase().getDefaultCatalog();
- }
-
- public void addConnectionListener(ConnectionListener listener) {
- this.connectionListener.addConnectionListener(listener);
- }
-
- public void removeConnectionListener(ConnectionListener listener) {
- this.connectionListener.removeConnectionListener(listener);
- }
-
- public Schema getDefaultSchema() {
- return this.getDatabase().schemaNamed(this.getDefaultSchemaName());
- }
-
- public String getDriverClassName() {
- return this.getProperty(IJDBCDriverDefinitionConstants.DRIVER_CLASS_PROP_ID);
- }
-
- public String getUrl() {
- return this.getProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID);
- }
-
- public String getInstanceID() {
- return this.dtpConnectionProfile.getInstanceID();
- }
-
- public String getProviderID() {
- return this.dtpConnectionProfile.getProviderId();
- }
-
- public String getDriverDefinitionID() {
- return this.getProperty(DRIVER_DEFINITION_PROP_ID);
- }
-
- public String getDriverJarList() {
- return DriverManager.getInstance().getDriverInstanceByID(this.getDriverDefinitionID()).getJarList();
- }
-
-
- // ********** internal methods **********
-
- private void checkStatus(IStatus status) {
- if (status.isOK()) {
- return;
- }
- if (status.isMultiStatus()) {
- status = status.getChildren()[0]; // take the first one?
- }
- throw new RuntimeException(status.getMessage(), status.getException());
- }
-
- private InternalDatabase buildDatabase() {
- if (this.isInactive()) {
- return NullDatabase.instance();
- }
-
- if (this.isWorkingOffline()) {
- ConnectionInfo connectionInfo = (ConnectionInfo) this.dtpManagedConnection.getConnection().getRawConnection();
- return new DTPDatabaseWrapper(this, connectionInfo.getSharedDatabase());
- }
-
- // TODO see DTP bug 202306
- // pass connect=true in to ProfileUtil.getDatabase()
- // there is a bug mentioned in a comment:
- // "during the profile connected event notification,
- // IManagedConnection is connected while IConnectionProfile is not"
- // so, some hackery here to handle hackery there
- return new DTPDatabaseWrapper(this, ProfileUtil.getDatabase(new DatabaseIdentifier(this.getName(), this.getDatabaseName()), true));
- }
-
- boolean wraps(IConnectionProfile dtpCP) {
- return this.dtpConnectionProfile == dtpCP;
- }
-
- void databaseChanged(DTPDatabaseWrapper db, int eventType) {
- this.connectionListener.databaseChanged(db, eventType);
- }
-
- void catalogChanged(DTPCatalogWrapper catalog, int eventType) {
- this.connectionListener.catalogChanged(catalog, eventType);
- }
-
- void schemaChanged(DTPSchemaWrapper schema, int eventType) {
- this.connectionListener.schemaChanged(schema, eventType);
- }
-
- void sequenceChanged(DTPSequenceWrapper sequence, int eventType) {
- this.connectionListener.sequenceChanged(sequence, eventType);
- }
-
- void tableChanged(DTPTableWrapper table, int eventType) {
- this.connectionListener.tableChanged(table, eventType);
- }
-
- void columnChanged(DTPColumnWrapper column, int eventType) {
- this.connectionListener.columnChanged(column, eventType);
- }
-
- void foreignKeyChanged(DTPForeignKeyWrapper foreignKey, int eventType) {
- this.connectionListener.foreignKeyChanged(foreignKey, eventType);
- }
-
- /**
- * private - use #getDefaultSchema() : Schema instead
- */
- private String getDefaultSchemaName() {
- if (this.getDatabase().getVendor().equalsIgnoreCase(POSTGRESQL_VENDOR)) {
- return POSTGRESQL_DEFAULT_SCHEMA_NAME;
- }
- return this.getUserName();
- }
-
- private String getProperty(String propertyName) {
- return this.dtpConnectionProfile.getBaseProperties().getProperty(propertyName);
- }
-
-
- // ********** disposal **********
-
- synchronized void dispose() {
- this.disposeDatabase();
- this.dtpManagedConnection.removeConnectionListener(this.connectionListener);
- }
-
- synchronized void disposeDatabase() {
- if (this.database != null) {
- this.database.dispose();
- this.database = null;
- }
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(ConnectionProfile connectionProfile) {
- return Collator.getInstance().compare(this.getName(), connectionProfile.getName());
- }
-
-
- // ********** overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.getName());
- }
-
-
- // ********** DTP connection listener **********
-
- /**
- * This listener translates and forwards IManagedConnectionListener and
- * IManagedConnectionOfflineListener events to ConnectionListeners.
- */
- private class LocalConnectionListener implements IManagedConnectionOfflineListener {
- private Vector<ConnectionListener> listeners = new Vector<ConnectionListener>();
-
- LocalConnectionListener() {
- super();
- }
-
- void addConnectionListener(ConnectionListener listener) {
- this.listeners.add(listener);
- }
-
- void removeConnectionListener(ConnectionListener listener) {
- this.listeners.remove(listener);
- }
-
- private Iterator<ConnectionListener> listeners() {
- return new CloneIterator<ConnectionListener>(this.listeners);
- }
-
-
- // ********** IManagedConnectionListener implementation **********
-
- public void opened(ConnectEvent event) {
- // clear the (possibly "null") database so it will be rebuilt with the "live" data
- DTPConnectionProfileWrapper.this.disposeDatabase();
- // forward event to listeners
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().opened(DTPConnectionProfileWrapper.this);
- }
- }
-
- /**
- * This method is never called from the base DTP code.
- * Perhaps DTP extenders call it....
- * @see ManagedConnection#fireModifiedEvent(Object)
- * which is never called...
- */
- public void modified(ConnectEvent event) {
- // forward event to listeners
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().modified(DTPConnectionProfileWrapper.this);
- }
- }
-
- public boolean okToClose(ConnectEvent event) {
- // forward event to listeners
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- if ( ! stream.next().okToClose(DTPConnectionProfileWrapper.this)) {
- return false;
- }
- }
- return true;
- }
-
- public void aboutToClose(ConnectEvent event) {
- // forward event to listeners
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().aboutToClose(DTPConnectionProfileWrapper.this);
- }
- }
-
- public void closed(ConnectEvent event) {
- // clear the database
- DTPConnectionProfileWrapper.this.disposeDatabase();
- // forward event to listeners
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().closed(DTPConnectionProfileWrapper.this);
- }
- }
-
-
- // ********** IManagedConnectionOfflineListener implementation **********
-
- // live => off-line
- public boolean okToDetach(ConnectEvent event) {
- // don't forward the event to listeners (?)
- return true;
- }
-
- // live => off-line
- public void aboutToDetach(ConnectEvent event) {
- // don't forward the event; the database will be cleared and
- // listeners will be notified once the "offline" connection is "opened/workingOffline"
- }
-
- // live => off-line
- public void workingOffline(ConnectEvent event) {
- // clear the (possibly null) database so it will be rebuilt with the "off-line" data
- DTPConnectionProfileWrapper.this.disposeDatabase();
- // convert the event to an "open" event and forward it to listeners
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().opened(DTPConnectionProfileWrapper.this);
- }
- }
-
- // off-line => live
- public void aboutToAttach(ConnectEvent event) {
- // don't forward the event; the database will be cleared and
- // listeners will be notified once the "live" connection is "opened"
- }
-
-
- // ********** internal methods **********
-
- void databaseChanged(DTPDatabaseWrapper db, int eventType) {
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().databaseChanged(DTPConnectionProfileWrapper.this, db);
- }
- }
-
- void catalogChanged(DTPCatalogWrapper catalog, int eventType) {
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().catalogChanged(DTPConnectionProfileWrapper.this, catalog);
- }
- }
-
- void schemaChanged(DTPSchemaWrapper schema, int eventType) {
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().schemaChanged(DTPConnectionProfileWrapper.this, schema);
- }
- }
-
- void sequenceChanged(DTPSequenceWrapper sequence, int eventType) {
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().sequenceChanged(DTPConnectionProfileWrapper.this, sequence);
- }
- }
-
- void tableChanged(DTPTableWrapper table, int eventType) {
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().tableChanged(DTPConnectionProfileWrapper.this, table);
- }
- }
-
- void columnChanged(DTPColumnWrapper column, int eventType) {
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().columnChanged(DTPConnectionProfileWrapper.this, column);
- }
- }
-
- void foreignKeyChanged(DTPForeignKeyWrapper foreignKey, int eventType) {
- for (Iterator<ConnectionListener> stream = this.listeners(); stream.hasNext(); ) {
- stream.next().foreignKeyChanged(DTPConnectionProfileWrapper.this, foreignKey);
- }
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java
deleted file mode 100644
index 911d334423..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import java.text.Collator;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.datatools.connectivity.sqm.core.definition.DatabaseDefinition;
-import org.eclipse.datatools.connectivity.sqm.internal.core.RDBCorePlugin;
-import org.eclipse.jpt.db.Catalog;
-import org.eclipse.jpt.db.Database;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-/**
- * Wrap a DTP Database.
- * Sometimes the database will directly hold schemata; but if the database
- * supports catalogs, it will not hold the schemata directly, but will delegate
- * to the "default" catalog.
- */
-final class DTPDatabaseWrapper
- extends DTPSchemaContainerWrapper
- implements InternalDatabase
-{
- // backpointer to parent
- private final DTPConnectionProfileWrapper connectionProfile;
-
- // the wrapped DTP database
- private final org.eclipse.datatools.modelbase.sql.schema.Database dtpDatabase;
-
- // lazy-initialized
- private DTPCatalogWrapper[] catalogs;
-
- // lazy-initialized
- private DTPCatalogWrapper defaultCatalog;
- private boolean defaultCatalogCalculated = false;
-
- // TODO allow user to configure?
- private boolean caseSensitive = false;
-
-
- private static final DTPCatalogWrapper[] EMPTY_CATALOGS = new DTPCatalogWrapper[0];
-
-
- // ********** constructor **********
-
- DTPDatabaseWrapper(DTPConnectionProfileWrapper connectionProfile, org.eclipse.datatools.modelbase.sql.schema.Database dtpDatabase) {
- super(connectionProfile, dtpDatabase);
- this.connectionProfile = connectionProfile;
- this.dtpDatabase = dtpDatabase;
- }
-
-
- // ********** DTPWrapper implementation **********
-
- @Override
- synchronized void catalogObjectChanged(int eventType) {
- super.catalogObjectChanged(eventType);
- this.getConnectionProfile().databaseChanged(this, eventType);
- }
-
-
- // ********** Database implementation **********
-
- @Override
- public String getName() {
- return this.dtpDatabase.getName();
- }
-
- public String getVendor() {
- return this.dtpDatabase.getVendor();
- }
-
- public String getVersion() {
- return this.dtpDatabase.getVersion();
- }
-
- public DatabaseDefinition getDtpDefinition() {
- return RDBCorePlugin.getDefault().getDatabaseDefinitionRegistry().getDefinition(this.dtpDatabase);
- }
-
- // ***** caseSensitive
-
- @Override
- public boolean isCaseSensitive() {
- return this.caseSensitive;
- }
-
- // TODO
- public void setCaseSensitive(boolean caseSensitive) {
- this.caseSensitive = caseSensitive;
- }
-
- // ***** catalogs
-
- public boolean supportsCatalogs() {
- // if the DTP database does not have any schemata, it must have catalogs...
- List<org.eclipse.datatools.modelbase.sql.schema.Schema> dtpSchemata = this.dtpSchemata();
- return (dtpSchemata == null) || dtpSchemata.isEmpty();
- }
-
- public Iterator<Catalog> catalogs() {
- return new ArrayIterator<Catalog>(this.catalogs_());
- }
-
- private Iterator<DTPCatalogWrapper> catalogWrappers() {
- return new ArrayIterator<DTPCatalogWrapper>(this.catalogs_());
- }
-
- private synchronized DTPCatalogWrapper[] catalogs_() {
- if (this.catalogs == null) {
- this.catalogs = this.buildCatalogs();
- }
- return this.catalogs;
- }
-
- private DTPCatalogWrapper[] buildCatalogs() {
- List<org.eclipse.datatools.modelbase.sql.schema.Catalog> dtpCatalogs = this.dtpCatalogs();
- if ((dtpCatalogs == null) || dtpCatalogs.isEmpty()) {
- return EMPTY_CATALOGS;
- }
- DTPCatalogWrapper[] result = new DTPCatalogWrapper[dtpCatalogs.size()];
- for (int i = result.length; i-- > 0;) {
- result[i] = new DTPCatalogWrapper(this, dtpCatalogs.get(i));
- }
- return result;
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private List<org.eclipse.datatools.modelbase.sql.schema.Catalog> dtpCatalogs() {
- return this.dtpDatabase.getCatalogs();
- }
-
- public int catalogsSize() {
- return this.catalogs_().length;
- }
-
- public Iterator<String> catalogNames() {
- return new TransformationIterator<DTPCatalogWrapper, String>(this.catalogWrappers()) {
- @Override
- protected String transform(DTPCatalogWrapper catalog) {
- return catalog.getName();
- }
- };
- }
-
- public boolean containsCatalogNamed(String name) {
- return this.catalogNamed(name) != null;
- }
-
- public DTPCatalogWrapper catalogNamed(String name) {
- return this.isCaseSensitive() ? this.catalogNamedCaseSensitive(name) : this.catalogNamedIgnoreCase(name);
- }
-
- private DTPCatalogWrapper catalogNamedCaseSensitive(String name) {
- for (Iterator<DTPCatalogWrapper> stream = this.catalogWrappers(); stream.hasNext(); ) {
- DTPCatalogWrapper catalog = stream.next();
- if (catalog.getName().equals(name)) {
- return catalog;
- }
- }
- return null;
- }
-
- private DTPCatalogWrapper catalogNamedIgnoreCase(String name) {
- for (Iterator<DTPCatalogWrapper> stream = this.catalogWrappers(); stream.hasNext(); ) {
- DTPCatalogWrapper catalog = stream.next();
- if (StringTools.stringsAreEqualIgnoreCase(catalog.getName(), name)) {
- return catalog;
- }
- }
- return null;
- }
-
- public synchronized DTPCatalogWrapper getDefaultCatalog() {
- if ( ! this.defaultCatalogCalculated) {
- this.defaultCatalogCalculated = true;
- this.defaultCatalog = this.buildDefaultCatalog();
- }
- return this.defaultCatalog;
- }
-
- private DTPCatalogWrapper buildDefaultCatalog() {
- if ( ! this.supportsCatalogs()) {
- return null;
- }
- String userName = this.connectionProfile.getUserName();
- for (Iterator<DTPCatalogWrapper> stream = this.catalogWrappers(); stream.hasNext(); ) {
- DTPCatalogWrapper catalog = stream.next();
- if (catalog.getName().length() == 0) {
- return catalog; // special catalog that contains all schemata
- }
- if (catalog.getName().equals(userName)) {
- return catalog; // user name is default catalog
- }
- if (catalog.getName().equals(this.getName())) {
- return catalog; // special catalog with same name as DB (PostgreSQL)
- }
- }
- throw new IllegalStateException("unknown default catalog"); //$NON-NLS-1$
- }
-
- /**
- * return the catalog for the specified DTP catalog
- */
- DTPCatalogWrapper catalog(org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog) {
- for (Iterator<DTPCatalogWrapper> stream = this.catalogWrappers(); stream.hasNext(); ) {
- DTPCatalogWrapper catalog = stream.next();
- if (catalog.wraps(dtpCatalog)) {
- return catalog;
- }
- }
- throw new IllegalArgumentException("invalid DTP catalog: " + dtpCatalog); //$NON-NLS-1$
- }
-
- // ***** schemata
-
- @Override
- @SuppressWarnings("unchecked")
- List<org.eclipse.datatools.modelbase.sql.schema.Schema> dtpSchemata() {
- return this.dtpDatabase.getSchemas();
- }
-
- @Override
- synchronized DTPSchemaWrapper[] schemata_() {
- return (this.supportsCatalogs()) ?
- this.getDefaultCatalog().schemata_()
- :
- super.schemata_();
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(Database database) {
- return Collator.getInstance().compare(this.getName(), database.getName());
- }
-
-
- // ********** internal methods **********
-
- boolean wraps(org.eclipse.datatools.modelbase.sql.schema.Database database) {
- return this.dtpDatabase == database;
- }
-
- /**
- * return the table for the specified DTP table
- */
- DTPTableWrapper table(org.eclipse.datatools.modelbase.sql.tables.Table dtpTable) {
- return this.schema(dtpTable.getSchema()).table(dtpTable);
- }
-
- /**
- * return the column for the specified DTP column
- */
- DTPColumnWrapper column(org.eclipse.datatools.modelbase.sql.tables.Column dtpColumn) {
- return this.table(dtpColumn.getTable()).column(dtpColumn);
- }
-
- @Override
- DTPDatabaseWrapper database() {
- return this;
- }
-
-
- // ********** disposal **********
-
- // must be public because it is defined in InternalDatabase interface
- @Override
- public synchronized void dispose() {
- super.dispose();
- }
-
- @Override
- void dispose_() {
- this.defaultCatalogCalculated = false;
- this.defaultCatalog = null;
- this.disposeCatalogs();
- super.dispose_();
- }
-
- private void disposeCatalogs() {
- if (this.catalogs != null) {
- for (DTPCatalogWrapper catalog : this.catalogs) {
- catalog.dispose();
- }
- this.catalogs = null;
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPForeignKeyWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPForeignKeyWrapper.java
deleted file mode 100644
index 74478aed5b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPForeignKeyWrapper.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import java.text.Collator;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.db.Column;
-import org.eclipse.jpt.db.ForeignKey;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-/**
- * Wrap a DTP ForeignKey
- */
-final class DTPForeignKeyWrapper
- extends DTPWrapper
- implements ForeignKey
-{
- // backpointer to parent
- private final DTPTableWrapper baseTable;
-
- // the wrapped DTP foreign key
- private final org.eclipse.datatools.modelbase.sql.constraints.ForeignKey dtpForeignKey;
-
- // lazy-initialized
- private DTPTableWrapper referencedTable;
-
- // lazy-initialized
- private LocalColumnPair[] columnPairs;
-
- // lazy-initialized
- private String defaultEntityFieldName;
- private boolean defaultEntityFieldNameCalculated = false;
-
-
- // ********** constructor **********
-
- DTPForeignKeyWrapper(DTPTableWrapper baseTable, org.eclipse.datatools.modelbase.sql.constraints.ForeignKey dtpForeignKey) {
- super(baseTable, dtpForeignKey);
- this.baseTable = baseTable;
- this.dtpForeignKey = dtpForeignKey;
- }
-
-
- // ********** DTPWrapper implementation **********
-
- @Override
- synchronized void catalogObjectChanged(int eventType) {
- // clear stuff so it will be rebuilt
- this.dispose_();
- this.getConnectionProfile().foreignKeyChanged(this, eventType);
- }
-
-
- // ********** ForeignKey implementation **********
-
- @Override
- public String getName() {
- return this.dtpForeignKey.getName();
- }
-
- public DTPTableWrapper getBaseTable() {
- return this.baseTable;
- }
-
- public synchronized DTPTableWrapper getReferencedTable() {
- if (this.referencedTable == null) {
- this.referencedTable = this.baseTable.table(this.dtpForeignKey.getUniqueConstraint().getBaseTable());
- }
- return this.referencedTable;
- }
-
- // ***** column pairs
-
- public Iterator<ColumnPair> columnPairs() {
- return new ArrayIterator<ColumnPair>(this.columnPairs_());
- }
-
- public LocalColumnPair columnPair() {
- LocalColumnPair[] pairs = this.columnPairs_();
- if (pairs.length != 1) {
- throw new IllegalStateException("multiple column pairs: " + pairs.length); //$NON-NLS-1$
- }
- return pairs[0];
- }
-
- private Iterator<LocalColumnPair> localColumnPairs() {
- return new ArrayIterator<LocalColumnPair>(this.columnPairs_());
- }
-
- private synchronized LocalColumnPair[] columnPairs_() {
- if (this.columnPairs == null) {
- this.columnPairs = this.buildColumnPairs();
- }
- return this.columnPairs;
- }
-
- private LocalColumnPair[] buildColumnPairs() {
- List<org.eclipse.datatools.modelbase.sql.tables.Column> baseColumns = this.dtpBaseColumns();
- int size = baseColumns.size();
- List<org.eclipse.datatools.modelbase.sql.tables.Column> refColumns = this.dtpRefColumns();
- if (refColumns.size() != size) {
- throw new IllegalStateException(this.getBaseTable().getName() + "." + this.getName() + //$NON-NLS-1$
- " - mismatched sizes: " + size + " vs. " + refColumns.size()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- LocalColumnPair[] result = new LocalColumnPair[baseColumns.size()];
- for (int i = baseColumns.size(); i-- > 0; ) {
- DTPColumnWrapper baseColumn = this.baseTable.column(baseColumns.get(i));
- DTPColumnWrapper refColumn = this.baseTable.column(refColumns.get(i));
- result[i] = new LocalColumnPair(baseColumn, refColumn);
- }
- return result;
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private List<org.eclipse.datatools.modelbase.sql.tables.Column> dtpBaseColumns() {
- return this.dtpForeignKey.getMembers();
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private List<org.eclipse.datatools.modelbase.sql.tables.Column> dtpRefColumns() {
- return this.dtpForeignKey.getUniqueConstraint().getMembers();
- }
-
- public int columnPairsSize() {
- return this.columnPairs_().length;
- }
-
- public Iterator<Column> baseColumns() {
- return new TransformationIterator<LocalColumnPair, Column>(this.localColumnPairs()) {
- @Override
- protected Column transform(LocalColumnPair pair) {
- return pair.baseColumn();
- }
- };
- }
-
- boolean baseColumnsContains(Column column) {
- return CollectionTools.contains(this.baseColumns(), column);
- }
-
- public Iterator<Column> nonPrimaryKeyBaseColumns() {
- return new FilteringIterator<Column, Column>(this.baseColumns()) {
- @Override
- protected boolean accept(Column column) {
- return ! DTPForeignKeyWrapper.this.getBaseTable().primaryKeyColumnsContains(column);
- }
- };
- }
-
- public Iterator<Column> referencedColumns() {
- return new TransformationIterator<LocalColumnPair, Column>(this.localColumnPairs()) {
- @Override
- protected Column transform(LocalColumnPair columnPair) {
- return columnPair.referencedColumn();
- }
- };
- }
-
- // ***** default entity field name
-
- /**
- * If the name of the "base" column adheres to the EJB standard for a
- * default mapping (i.e. it ends with an underscore followed by the name
- * of the "referenced" column, and the "referenced" column is the single
- * primary key column of the "referenced" table), return the corresponding
- * default entity field name:
- * ForeignKey(EMP.CUBICLE_ID => CUBICLE.ID) => "CUBICLE"
- * Return a null if it does not adhere to the EJB standard:
- * ForeignKey(EMP.CUBICLE_ID => CUBICLE.CUBICLE_ID) => null
- */
- private synchronized String defaultEntityFieldName() {
- if ( ! this.defaultEntityFieldNameCalculated) {
- this.defaultEntityFieldNameCalculated = true;
- this.defaultEntityFieldName = this.buildDefaultEntityFieldName();
- }
- return this.defaultEntityFieldName;
- }
-
- /**
- * @see #defaultEntityFieldName()
- */
- private String buildDefaultEntityFieldName() {
- if ( ! this.referencesSingleColumnPrimaryKey()) {
- return null;
- }
- LocalColumnPair columnPair = this.columnPairs_()[0];
- String baseColName = columnPair.baseColumn().getName();
- String refColName = columnPair.referencedColumn().getName();
- if (baseColName.length() <= (refColName.length() + 1)) {
- return null;
- }
- if ( ! baseColName.endsWith(refColName)) {
- return null;
- }
- int _index = baseColName.length() - refColName.length() - 1;
- if (baseColName.charAt(_index) != '_') {
- return null;
- }
- String name = baseColName.substring(0, _index);
- return this.isCaseSensitive() ? name : name.toLowerCase();
- }
-
- // ***** miscellaneous
-
- public String getJavaFieldName() {
- String fieldName = this.defaultEntityFieldName();
- return (fieldName != null) ? fieldName : this.nonDefaultEntityFieldName();
- }
-
- public boolean defaultMatchesJavaFieldName(String javaFieldName) {
- return this.isCaseSensitive() ?
- javaFieldName.equals(this.defaultEntityFieldName())
- :
- javaFieldName.equalsIgnoreCase(this.defaultEntityFieldName());
- }
-
- public boolean isDefaultFor(String javaFieldName) {
- if (this.columnPairsSize() != 1) {
- return false;
- }
-
- if (this.getReferencedTable().primaryKeyColumnsSize() != 1) {
- return false;
- }
-
- LocalColumnPair columnPair = this.columnPairs_()[0];
- Column pkColumn = this.getReferencedTable().primaryKeyColumn();
- if (columnPair.referencedColumn() != pkColumn) {
- return false;
- }
-
- return columnPair.baseColumn().matchesJavaFieldName(javaFieldName + "_" + pkColumn.getName()); //$NON-NLS-1$
- }
-
- public boolean referencesSingleColumnPrimaryKey() {
- if (this.columnPairsSize() != 1) {
- return false;
- }
- if (this.getReferencedTable().primaryKeyColumnsSize() != 1) {
- return false;
- }
-
- return this.columnPair().referencedColumn() == this.getReferencedTable().primaryKeyColumn();
- }
-
- /**
- * If this is a simple (single-column) foreign key, return the java field
- * name of the single base column. If this is a compound foreign key,
- * return the java field name of the referenced table.
- */
- // TODO if there is only one FK to a given table, use the table's name instead of the column's name?
- // TODO if the FK column name ends with the PK column name, strip the PK column name?
- private String nonDefaultEntityFieldName() {
- return (this.columnPairsSize() == 1) ?
- this.columnPair().baseColumn().getJavaFieldName()
- :
- this.getReferencedTable().getJavaFieldName();
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(ForeignKey foreignKey) {
- return Collator.getInstance().compare(this.getName(), foreignKey.getName());
- }
-
-
- // ********** internal methods **********
-
- boolean wraps(org.eclipse.datatools.modelbase.sql.constraints.ForeignKey foreignKey) {
- return this.dtpForeignKey == foreignKey;
- }
-
- boolean isCaseSensitive() {
- return this.baseTable.isCaseSensitive();
- }
-
- DTPDatabaseWrapper database() {
- return this.baseTable.database();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.getName() + ": " + Arrays.asList(this.columnPairs_())); //$NON-NLS-1$
- }
-
-
- // ********** disposal **********
-
- @Override
- synchronized void dispose() {
- this.dispose_();
- super.dispose();
- }
-
- private void dispose_() {
- // the foreign key does not "contain" any other objects,
- // so we don't need to forward the #dispose()
- this.defaultEntityFieldNameCalculated = false;
- this.defaultEntityFieldName = null;
- this.columnPairs = null;
- this.referencedTable = null;
- }
-
-
- // ********** column pair implementation **********
-
- private static class LocalColumnPair implements ColumnPair {
- private final DTPColumnWrapper baseColumn;
- private final DTPColumnWrapper referencedColumn;
-
- LocalColumnPair(DTPColumnWrapper baseColumn, DTPColumnWrapper referencedColumn) {
- super();
- this.baseColumn = baseColumn;
- this.referencedColumn = referencedColumn;
- }
-
-
- // ********** ColumnPair implementation **********
-
- public DTPColumnWrapper baseColumn() {
- return this.baseColumn;
- }
-
- public DTPColumnWrapper referencedColumn() {
- return this.referencedColumn;
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(ColumnPair columnPair) {
- return Collator.getInstance().compare(this.baseColumn().getName(), columnPair.baseColumn().getName());
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.baseColumn.getName() + "=>" + this.referencedColumn.getName()); //$NON-NLS-1$
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSchemaContainerWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSchemaContainerWrapper.java
deleted file mode 100644
index 21a13551ad..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSchemaContainerWrapper.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.db.SchemaContainer;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-/**
- * Coalesce behavior for a schema container (i.e. database or catalog).
- */
-abstract class DTPSchemaContainerWrapper
- extends DTPWrapper
- implements SchemaContainer
-{
- // lazy-initialized
- private DTPSchemaWrapper[] schemata;
-
-
- // ********** constructor **********
-
- DTPSchemaContainerWrapper(ConnectionProfileHolder connectionProfileHolder, Object dtpObject) {
- super(connectionProfileHolder, dtpObject);
- }
-
-
- // ********** DTPWrapper implementation **********
-
- @Override
- synchronized void catalogObjectChanged(int eventType) {
- // clear stuff so it will be rebuilt
- this.dispose_();
- }
-
-
- // ********** abstract methods **********
-
- abstract DTPDatabaseWrapper database();
-
- abstract boolean isCaseSensitive();
-
- abstract List<org.eclipse.datatools.modelbase.sql.schema.Schema> dtpSchemata();
-
-
- // ********** schemata **********
-
- public Iterator<Schema> schemata() {
- return new ArrayIterator<Schema>(this.schemata_());
- }
-
- private Iterator<DTPSchemaWrapper> schemaWrappers() {
- return new ArrayIterator<DTPSchemaWrapper>(this.schemata_());
- }
-
- synchronized DTPSchemaWrapper[] schemata_() {
- if (this.schemata == null) {
- this.schemata = this.buildSchemata();
- }
- return this.schemata;
- }
-
- private DTPSchemaWrapper[] buildSchemata() {
- List<org.eclipse.datatools.modelbase.sql.schema.Schema> dtpSchemata = this.dtpSchemata();
- DTPSchemaWrapper[] result = new DTPSchemaWrapper[dtpSchemata.size()];
- for (int i = result.length; i-- > 0;) {
- result[i] = new DTPSchemaWrapper(this, dtpSchemata.get(i));
- }
- return result;
- }
-
- public int schemataSize() {
- return this.schemata_().length;
- }
-
- public Iterator<String> schemaNames() {
- return new TransformationIterator<DTPSchemaWrapper, String>(this.schemaWrappers()) {
- @Override
- protected String transform(DTPSchemaWrapper schema) {
- return schema.getName();
- }
- };
- }
-
- public boolean containsSchemaNamed(String name) {
- return this.schemaNamed(name) != null;
- }
-
- public DTPSchemaWrapper schemaNamed(String name) {
- return this.isCaseSensitive() ? this.schemaNamedCaseSensitive(name) : this.schemaNamedIgnoreCase(name);
- }
-
- private DTPSchemaWrapper schemaNamedCaseSensitive(String name) {
- for (Iterator<DTPSchemaWrapper> stream = this.schemaWrappers(); stream.hasNext(); ) {
- DTPSchemaWrapper schema = stream.next();
- if (schema.getName().equals(name)) {
- return schema;
- }
- }
- return null;
- }
-
- private DTPSchemaWrapper schemaNamedIgnoreCase(String name) {
- for (Iterator<DTPSchemaWrapper> stream = this.schemaWrappers(); stream.hasNext(); ) {
- DTPSchemaWrapper schema = stream.next();
- if (StringTools.stringsAreEqualIgnoreCase(schema.getName(), name)) {
- return schema;
- }
- }
- return null;
- }
-
- /**
- * return the schema for the specified DTP schema
- */
- DTPSchemaWrapper schema(org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema) {
- for (Iterator<DTPSchemaWrapper> stream = this.schemaWrappers(); stream.hasNext(); ) {
- DTPSchemaWrapper schema = stream.next();
- if (schema.wraps(dtpSchema)) {
- return schema;
- }
- }
- throw new IllegalArgumentException("invalid DTP schema: " + dtpSchema); //$NON-NLS-1$
- }
-
-
- // ********** disposal **********
-
- @Override
- synchronized void dispose() {
- this.dispose_();
- super.dispose();
- }
-
- void dispose_() {
- this.disposeSchemata();
- }
-
- private void disposeSchemata() {
- if (this.schemata != null) {
- for (DTPSchemaWrapper schema : this.schemata) {
- schema.dispose();
- }
- this.schemata = null;
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSchemaWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSchemaWrapper.java
deleted file mode 100644
index 270f3d711c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSchemaWrapper.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import java.text.Collator;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.db.Sequence;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-/**
- * Wrap a DTP Schema
- */
-final class DTPSchemaWrapper
- extends DTPWrapper
- implements Schema
-{
- // backpointer to parent
- private final DTPSchemaContainerWrapper container;
-
- // the wrapped DTP schema
- private final org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema;
-
- // lazy-initialized
- private DTPTableWrapper[] tables;
-
- // lazy-initialized
- private DTPSequenceWrapper[] sequences;
-
-
- // ********** constructor **********
-
- DTPSchemaWrapper(DTPSchemaContainerWrapper container, org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema) {
- super(container, dtpSchema);
- this.container = container;
- this.dtpSchema = dtpSchema;
- }
-
-
- // ********** DTPWrapper implementation **********
-
- @Override
- synchronized void catalogObjectChanged(int eventType) {
- // clear stuff so it can be rebuilt
- this.dispose_();
- this.getConnectionProfile().schemaChanged(this, eventType);
- }
-
-
- // ********** Schema implementation **********
-
- @Override
- public String getName() {
- return this.dtpSchema.getName();
- }
-
- // ***** tables
-
- public Iterator<Table> tables() {
- return new ArrayIterator<Table>(this.tables_());
- }
-
- private Iterator<DTPTableWrapper> tableWrappers() {
- return new ArrayIterator<DTPTableWrapper>(this.tables_());
- }
-
- private synchronized DTPTableWrapper[] tables_() {
- if (this.tables == null) {
- this.tables = this.buildTables();
- }
- return this.tables;
- }
-
- private DTPTableWrapper[] buildTables() {
- List<org.eclipse.datatools.modelbase.sql.tables.Table> dtpTables = this.dtpTables();
- DTPTableWrapper[] result = new DTPTableWrapper[dtpTables.size()];
- for (int i = result.length; i-- > 0;) {
- result[i] = new DTPTableWrapper(this, dtpTables.get(i));
- }
- return result;
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private List<org.eclipse.datatools.modelbase.sql.tables.Table> dtpTables() {
- return this.dtpSchema.getTables();
- }
-
- public int tablesSize() {
- return this.tables_().length;
- }
-
- public Iterator<String> tableNames() {
- return new TransformationIterator<DTPTableWrapper, String>(this.tableWrappers()) {
- @Override
- protected String transform(DTPTableWrapper table) {
- return table.getName();
- }
- };
- }
-
- public boolean containsTableNamed(String name) {
- return this.tableNamed(name) != null;
- }
-
- public DTPTableWrapper tableNamed(String name) {
- return this.isCaseSensitive() ? this.tableNamedCaseSensitive(name) : this.tableNamedIgnoreCase(name);
- }
-
- private DTPTableWrapper tableNamedCaseSensitive(String name) {
- for (Iterator<DTPTableWrapper> stream = this.tableWrappers(); stream.hasNext(); ) {
- DTPTableWrapper table = stream.next();
- if (table.getName().equals(name)) {
- return table;
- }
- }
- return null;
- }
-
- private DTPTableWrapper tableNamedIgnoreCase(String name) {
- for (Iterator<DTPTableWrapper> stream = this.tableWrappers(); stream.hasNext(); ) {
- DTPTableWrapper table = stream.next();
- if (StringTools.stringsAreEqualIgnoreCase(table.getName(), name)) {
- return table;
- }
- }
- return null;
- }
-
- /**
- * return the table for the specified DTP table
- */
- DTPTableWrapper table(org.eclipse.datatools.modelbase.sql.tables.Table dtpTable) {
- if (dtpTable.getSchema() != this.dtpSchema) {
- return this.database().table(dtpTable);
- }
- for (Iterator<DTPTableWrapper> stream = this.tableWrappers(); stream.hasNext(); ) {
- DTPTableWrapper table = stream.next();
- if (table.wraps(dtpTable)) {
- return table;
- }
- }
- throw new IllegalArgumentException("invalid DTP table: " + dtpTable); //$NON-NLS-1$
- }
-
- // ***** sequences
-
- public Iterator<Sequence> sequences() {
- return new ArrayIterator<Sequence>(this.sequences_());
- }
-
- private Iterator<DTPSequenceWrapper> sequenceWrappers() {
- return new ArrayIterator<DTPSequenceWrapper>(this.sequences_());
- }
-
- private synchronized DTPSequenceWrapper[] sequences_() {
- if (this.sequences == null) {
- this.sequences = this.buildSequences();
- }
- return this.sequences;
- }
-
- private DTPSequenceWrapper[] buildSequences() {
- List<org.eclipse.datatools.modelbase.sql.schema.Sequence> dtpSequences = this.dtpSequences();
- DTPSequenceWrapper[] result = new DTPSequenceWrapper[dtpSequences.size()];
- for (int i = result.length; i-- > 0;) {
- result[i] = new DTPSequenceWrapper(this, dtpSequences.get(i));
- }
- return result;
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private List<org.eclipse.datatools.modelbase.sql.schema.Sequence> dtpSequences() {
- return this.dtpSchema.getSequences();
- }
-
- public int sequencesSize() {
- return this.sequences_().length;
- }
-
- public Iterator<String> sequenceNames() {
- return new TransformationIterator<DTPSequenceWrapper, String>(this.sequenceWrappers()) {
- @Override
- protected String transform(DTPSequenceWrapper sequence) {
- return sequence.getName();
- }
- };
- }
-
- public boolean containsSequenceNamed(String name) {
- return this.sequenceNamed(name) != null;
- }
-
- public DTPSequenceWrapper sequenceNamed(String name) {
- return this.isCaseSensitive() ? this.sequenceNamedCaseSensitive(name) : this.sequenceNamedIgnoreCase(name);
- }
-
- private DTPSequenceWrapper sequenceNamedCaseSensitive(String name) {
- for (Iterator<DTPSequenceWrapper> stream = this.sequenceWrappers(); stream.hasNext(); ) {
- DTPSequenceWrapper sequence = stream.next();
- if (sequence.getName().equals(name)) {
- return sequence;
- }
- }
- return null;
- }
-
- private DTPSequenceWrapper sequenceNamedIgnoreCase(String name) {
- for (Iterator<DTPSequenceWrapper> stream = this.sequenceWrappers(); stream.hasNext(); ) {
- DTPSequenceWrapper sequence = stream.next();
- if (sequence.getName().equalsIgnoreCase(name)) {
- return sequence;
- }
- }
- return null;
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(Schema schema) {
- return Collator.getInstance().compare(this.getName(), schema.getName());
- }
-
-
- // ********** internal methods **********
-
- boolean wraps(org.eclipse.datatools.modelbase.sql.schema.Schema schema) {
- return this.dtpSchema == schema;
- }
-
- boolean isCaseSensitive() {
- return this.database().isCaseSensitive();
- }
-
- DTPColumnWrapper column(org.eclipse.datatools.modelbase.sql.tables.Column dtpColumn) {
- return this.database().column(dtpColumn);
- }
-
- DTPDatabaseWrapper database() {
- return this.container.database();
- }
-
-
- // ********** disposal **********
-
- @Override
- synchronized void dispose() {
- this.dispose_();
- super.dispose();
- }
-
- private void dispose_() {
- this.disposeSequences();
- this.disposeTables();
- }
-
- private void disposeSequences() {
- if (this.sequences != null) {
- for (DTPSequenceWrapper sequence : this.sequences) {
- sequence.dispose();
- }
- this.sequences = null;
- }
- }
-
- private void disposeTables() {
- if (this.tables != null) {
- for (DTPTableWrapper table : this.tables) {
- table.dispose();
- }
- this.tables = null;
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSequenceWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSequenceWrapper.java
deleted file mode 100644
index b1e546bd07..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSequenceWrapper.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import java.text.Collator;
-
-import org.eclipse.jpt.db.Sequence;
-
-/**
- * Wrap a DTP Sequence
- */
-final class DTPSequenceWrapper
- extends DTPWrapper
- implements Sequence
-{
- // backpointer to parent
- private final DTPSchemaWrapper schema;
-
- // the wrapped DTP sequence
- private final org.eclipse.datatools.modelbase.sql.schema.Sequence dtpSequence;
-
-
- // ********** constructor **********
-
- DTPSequenceWrapper(DTPSchemaWrapper schema, org.eclipse.datatools.modelbase.sql.schema.Sequence dtpSequence) {
- super(schema, dtpSequence);
- this.schema = schema;
- this.dtpSequence = dtpSequence;
- }
-
-
- // ********** DTPWrapper implementation **********
-
- @Override
- synchronized void catalogObjectChanged(int eventType) {
- this.getConnectionProfile().sequenceChanged(this, eventType);
- }
-
-
- // ********** Sequence implementation **********
-
- @Override
- public String getName() {
- return this.dtpSequence.getName();
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(Sequence sequence) {
- return Collator.getInstance().compare(this.getName(), sequence.getName());
- }
-
-
- // ********** internal methods **********
-
- boolean wraps(org.eclipse.datatools.modelbase.sql.schema.Sequence sequence) {
- return this.dtpSequence == sequence;
- }
-
- boolean isCaseSensitive() {
- return this.schema.isCaseSensitive();
- }
-
- DTPDatabaseWrapper database() {
- return this.schema.database();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTableWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTableWrapper.java
deleted file mode 100644
index f5db4d69cd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTableWrapper.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import java.text.Collator;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.datatools.modelbase.sql.constraints.PrimaryKey;
-import org.eclipse.datatools.modelbase.sql.tables.BaseTable;
-import org.eclipse.jpt.db.Column;
-import org.eclipse.jpt.db.ForeignKey;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.NameTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-/**
- * Wrap a DTP Table
- */
-final class DTPTableWrapper
- extends DTPWrapper
- implements Table
-{
- // backpointer to parent
- private final DTPSchemaWrapper schema;
-
- // the wrapped DTP table
- private final org.eclipse.datatools.modelbase.sql.tables.Table dtpTable;
-
- // lazy-initialized
- private DTPColumnWrapper[] columns;
-
- // lazy-initialized
- private DTPColumnWrapper[] primaryKeyColumns;
-
- // lazy-initialized
- private DTPForeignKeyWrapper[] foreignKeys;
-
-
- private static final DTPColumnWrapper[] EMPTY_COLUMNS = new DTPColumnWrapper[0];
- private static final DTPForeignKeyWrapper[] EMPTY_FOREIGN_KEYS = new DTPForeignKeyWrapper[0];
-
-
- // ********** constructor **********
-
- DTPTableWrapper(DTPSchemaWrapper schema, org.eclipse.datatools.modelbase.sql.tables.Table dtpTable) {
- super(schema, dtpTable);
- this.schema = schema;
- this.dtpTable = dtpTable;
- }
-
-
- // ********** DTPWrapper implementation **********
-
- @Override
- synchronized void catalogObjectChanged(int eventType) {
- // clear stuff so it can be rebuilt
- this.dispose_();
- this.getConnectionProfile().tableChanged(this, eventType);
- }
-
-
- // ********** Table implementation **********
-
- @Override
- public String getName() {
- return this.dtpTable.getName();
- }
-
- public String getShortJavaClassName() {
- String jName = this.getName();
- if ( ! this.isCaseSensitive()) {
- jName = StringTools.capitalize(jName.toLowerCase());
- }
- return NameTools.convertToJavaIdentifier(jName);
- }
-
- public boolean matchesShortJavaClassName(String shortJavaClassName) {
- return this.isCaseSensitive() ?
- this.getName().equals(shortJavaClassName)
- :
- this.getName().equalsIgnoreCase(shortJavaClassName);
- }
-
- public String getJavaFieldName() {
- String jName = this.getName();
- if ( ! this.isCaseSensitive()) {
- jName = jName.toLowerCase();
- }
- return NameTools.convertToJavaIdentifier(jName);
- }
-
- // ***** columns
-
- public Iterator<Column> columns() {
- return new ArrayIterator<Column>(this.columns_());
- }
-
- private Iterator<DTPColumnWrapper> columnWrappers() {
- return new ArrayIterator<DTPColumnWrapper>(this.columns_());
- }
-
- private synchronized DTPColumnWrapper[] columns_() {
- if (this.columns == null) {
- this.columns = this.buildColumns();
- }
- return this.columns;
- }
-
- private DTPColumnWrapper[] buildColumns() {
- List<org.eclipse.datatools.modelbase.sql.tables.Column> dtpColumns = this.dtpColumns();
- DTPColumnWrapper[] result = new DTPColumnWrapper[dtpColumns.size()];
- for (int i = result.length; i-- > 0;) {
- result[i] = new DTPColumnWrapper(this, dtpColumns.get(i));
- }
- return result;
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private List<org.eclipse.datatools.modelbase.sql.tables.Column> dtpColumns() {
- return this.dtpTable.getColumns();
- }
-
- public int columnsSize() {
- return this.columns_().length;
- }
-
- public Iterator<String> columnNames() {
- return new TransformationIterator<DTPColumnWrapper, String>(this.columnWrappers()) {
- @Override
- protected String transform(DTPColumnWrapper next) {
- return next.getName();
- }
- };
- }
-
- public boolean containsColumnNamed(String name) {
- return this.columnNamed(name) != null;
- }
-
- public DTPColumnWrapper columnNamed(String name) {
- return this.isCaseSensitive() ? this.columnNamedCaseSensitive(name) : this.columnNamedIgnoreCase(name);
- }
-
- private DTPColumnWrapper columnNamedCaseSensitive(String name) {
- for (Iterator<DTPColumnWrapper> stream = this.columnWrappers(); stream.hasNext(); ) {
- DTPColumnWrapper column = stream.next();
- if (column.getName().equals(name)) {
- return column;
- }
- }
- return null;
- }
-
- private DTPColumnWrapper columnNamedIgnoreCase(String name) {
- for (Iterator<DTPColumnWrapper> stream = this.columnWrappers(); stream.hasNext(); ) {
- DTPColumnWrapper column = stream.next();
- if (StringTools.stringsAreEqualIgnoreCase(column.getName(), name)) {
- return column;
- }
- }
- return null;
- }
-
- /**
- * return the column for the specified DTP column
- */
- DTPColumnWrapper column(org.eclipse.datatools.modelbase.sql.tables.Column dtpColumn) {
- if (dtpColumn.getTable() != this.dtpTable) {
- return this.schema.column(dtpColumn);
- }
- for (DTPColumnWrapper column : this.columns_()) {
- if (column.wraps(dtpColumn)) {
- return column;
- }
- }
- throw new IllegalArgumentException("invalid DTP column: " + dtpColumn); //$NON-NLS-1$
- }
-
- // ***** primaryKeyColumns
-
- public Iterator<Column> primaryKeyColumns() {
- return new ArrayIterator<Column>(this.primaryKeyColumns_());
- }
-
- public DTPColumnWrapper primaryKeyColumn() {
- DTPColumnWrapper[] pkColumns = this.primaryKeyColumns_();
- if (pkColumns.length != 1) {
- throw new IllegalStateException("multiple primary key columns: " + pkColumns.length); //$NON-NLS-1$
- }
- return pkColumns[0];
- }
-
- private synchronized DTPColumnWrapper[] primaryKeyColumns_() {
- if (this.primaryKeyColumns == null) {
- this.primaryKeyColumns = this.buildPrimaryKeyColumns();
- }
- return this.primaryKeyColumns;
- }
-
- private DTPColumnWrapper[] buildPrimaryKeyColumns() {
- if ( ! (this.dtpTable instanceof BaseTable)) {
- return EMPTY_COLUMNS;
- }
- PrimaryKey pk = ((BaseTable) this.dtpTable).getPrimaryKey();
- if (pk == null) {
- // no PK was defined
- return EMPTY_COLUMNS;
- }
- List<org.eclipse.datatools.modelbase.sql.tables.Column> pkColumns = this.columns(pk);
- DTPColumnWrapper[] result = new DTPColumnWrapper[pkColumns.size()];
- for (int i = result.length; i-- > 0;) {
- result[i] = this.column(pkColumns.get(i));
- }
- return result;
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private List<org.eclipse.datatools.modelbase.sql.tables.Column> columns(PrimaryKey pk) {
- return pk.getMembers();
- }
-
- public int primaryKeyColumnsSize() {
- return this.primaryKeyColumns_().length;
- }
-
- public boolean primaryKeyColumnsContains(Column column) {
- return CollectionTools.contains(this.primaryKeyColumns_(), column);
- }
-
- // ***** foreignKeys
-
- public Iterator<ForeignKey> foreignKeys() {
- return new ArrayIterator<ForeignKey>(this.foreignKeys_());
- }
-
- private Iterator<DTPForeignKeyWrapper> foreignKeyWrappers() {
- return new ArrayIterator<DTPForeignKeyWrapper>(this.foreignKeys_());
- }
-
- private synchronized DTPForeignKeyWrapper[] foreignKeys_() {
- if (this.foreignKeys == null) {
- this.foreignKeys = this.buildForeignKeys();
- }
- return this.foreignKeys;
- }
-
- private DTPForeignKeyWrapper[] buildForeignKeys() {
- if ( ! (this.dtpTable instanceof BaseTable)) {
- return EMPTY_FOREIGN_KEYS;
- }
- List<org.eclipse.datatools.modelbase.sql.constraints.ForeignKey> dtpForeignKeys = this.dtpForeignKeys();
- DTPForeignKeyWrapper[] result = new DTPForeignKeyWrapper[dtpForeignKeys.size()];
- for (int i = result.length; i-- > 0;) {
- result[i] = new DTPForeignKeyWrapper(this, dtpForeignKeys.get(i));
- }
- return result;
- }
-
- @SuppressWarnings("unchecked")
- private List<org.eclipse.datatools.modelbase.sql.constraints.ForeignKey> dtpForeignKeys() {
- return ((BaseTable) this.dtpTable).getForeignKeys();
- }
-
- public int foreignKeysSize() {
- return this.foreignKeys_().length;
- }
-
- public boolean foreignKeyBaseColumnsContains(Column column) {
- for (Iterator<DTPForeignKeyWrapper> stream = this.foreignKeyWrappers(); stream.hasNext(); ) {
- DTPForeignKeyWrapper foreignKey = stream.next();
- if (foreignKey.baseColumnsContains(column)) {
- return true;
- }
- }
- return false;
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(Table table) {
- return Collator.getInstance().compare(this.getName(), table.getName());
- }
-
-
- // ********** internal methods **********
-
- boolean wraps(org.eclipse.datatools.modelbase.sql.tables.Table table) {
- return this.dtpTable == table;
- }
-
- boolean isCaseSensitive() {
- return this.schema.isCaseSensitive();
- }
-
- DTPTableWrapper table(org.eclipse.datatools.modelbase.sql.tables.Table table) {
- return this.schema.table(table);
- }
-
- DTPDatabaseWrapper database() {
- return this.schema.database();
- }
-
-
- // ********** disposal **********
-
- @Override
- synchronized void dispose() {
- this.dispose_();
- super.dispose();
- }
-
- private void dispose_() {
- this.disposeForeignKeys();
- // the table does not "contain" the pk columns, so no need to forward #dispose()
- this.primaryKeyColumns = null;
- this.disposeColumns();
- }
-
- private void disposeForeignKeys() {
- if (this.foreignKeys != null) {
- for (DTPForeignKeyWrapper foreignKey : this.foreignKeys) {
- foreignKey.dispose();
- }
- this.foreignKeys = null;
- }
- }
-
- private void disposeColumns() {
- if (this.columns != null) {
- for (DTPColumnWrapper column : this.columns) {
- column.dispose();
- }
- this.columns = null;
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java
deleted file mode 100644
index cbe702a597..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject;
-import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener;
-import org.eclipse.datatools.connectivity.sqm.core.rte.RefreshManager;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * DTP Catalog Object Wrapper base class
- */
-abstract class DTPWrapper
- implements ConnectionProfileHolder
-{
- // we need a way to get to the connection profile
- private final ConnectionProfileHolder connectionProfileHolder;
-
- // listen for the "catalog object" being refreshed
- private final ICatalogObjectListener catalogObjectListener;
-
- // we only listen to "live" connections
- private final boolean connectionIsLive;
-
- // listen for this to refresh
- final ICatalogObject catalogObject;
-
-
- DTPWrapper(ConnectionProfileHolder connectionProfileHolder, Object dtpObject) {
- super();
- this.connectionProfileHolder = connectionProfileHolder;
- this.connectionIsLive = this.getConnectionProfile().isConnected();
- if (this.connectionIsLive) {
- this.catalogObject = (ICatalogObject) dtpObject;
- this.catalogObjectListener = this.buildCatalogObjectListener();
- RefreshManager.getInstance().AddListener(this.catalogObject, this.catalogObjectListener);
- } else {
- this.catalogObject = null;
- this.catalogObjectListener = null;
- }
- }
-
- private ICatalogObjectListener buildCatalogObjectListener() {
- return new ICatalogObjectListener() {
- public void notifyChanged(ICatalogObject dmElement, int eventType) {
- if (dmElement == DTPWrapper.this.catalogObject) {
- DTPWrapper.this.catalogObjectChanged(eventType);
- }
- }
- };
- }
-
- // typically, notify the connection profile something has changed
- abstract void catalogObjectChanged(int eventType);
-
- public DTPConnectionProfileWrapper getConnectionProfile() {
- return this.connectionProfileHolder.getConnectionProfile();
- }
-
- void dispose() {
- if (this.connectionIsLive) {
- RefreshManager.getInstance().removeListener(this.catalogObject, this.catalogObjectListener);
- }
- }
-
- // all the subclasses can implement this method
- abstract String getName();
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.getName());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/InternalDatabase.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/InternalDatabase.java
deleted file mode 100644
index aa61c6043f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/InternalDatabase.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import org.eclipse.jpt.db.Database;
-
-/**
- * "internal" database
- */
-interface InternalDatabase extends Database {
- DTPCatalogWrapper getDefaultCatalog();
- void dispose();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java
deleted file mode 100644
index 5673dfb5d9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.db.Catalog;
-import org.eclipse.jpt.db.ConnectionListener;
-import org.eclipse.jpt.db.ConnectionProfile;
-import org.eclipse.jpt.db.Database;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.utility.internal.ClassTools;
-
-/**
- * "null" connection profile
- */
-final class NullConnectionProfile
- implements ConnectionProfile
-{
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
-
- // ********** singleton **********
-
- private static final NullConnectionProfile INSTANCE = new NullConnectionProfile();
-
- static ConnectionProfile instance() {
- return INSTANCE;
- }
-
- /**
- * 'private' to ensure singleton
- */
- private NullConnectionProfile() {
- super();
- }
-
-
- // ********** ConnectionProfile implementation **********
-
- public void connect() {
- // do nothing
- }
-
- public void disconnect() {
- // do nothing
- }
-
- public IStatus saveWorkOfflineData() {
- return Status.CANCEL_STATUS;
- }
-
- public IStatus workOffline() {
- return Status.CANCEL_STATUS;
- }
-
- public Database getDatabase() {
- return NullDatabase.instance();
- }
-
- public String getName() {
- return ClassTools.shortClassNameForObject(this);
- }
-
- public String getDatabaseName() {
- return EMPTY_STRING;
- }
-
- public String getDatabaseProduct() {
- return EMPTY_STRING;
- }
-
- public String getDatabaseVendor() {
- return EMPTY_STRING;
- }
-
- public String getDatabaseVersion() {
- return EMPTY_STRING;
- }
-
- public String getUserName() {
- return EMPTY_STRING;
- }
-
- public String getUserPassword() {
- return EMPTY_STRING;
- }
-
- public String getDriverClassName() {
- return EMPTY_STRING;
- }
-
- public String getUrl() {
- return EMPTY_STRING;
- }
-
- public String getInstanceID() {
- return EMPTY_STRING;
- }
-
- public String getProviderID() {
- return EMPTY_STRING;
- }
-
- public String getDriverDefinitionID() {
- return EMPTY_STRING;
- }
-
- public String getDriverJarList() {
- return EMPTY_STRING;
- }
-
- public boolean isActive() {
- return false;
- }
-
- public boolean isWorkingOffline() {
- return false;
- }
-
- public boolean isConnected() {
- return false;
- }
-
- public boolean supportsWorkOfflineMode() {
- return false;
- }
-
- public boolean canWorkOffline() {
- return false;
- }
-
- public void addConnectionListener( ConnectionListener listener) {
- // do nothing
- }
-
- public void removeConnectionListener( ConnectionListener listener) {
- // do nothing
- }
-
- public Schema getDefaultSchema() {
- return null;
- }
-
- public Catalog getDefaultCatalog() {
- return null;
- }
-
- public boolean isNull() {
- return true;
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(ConnectionProfile o) {
- throw new UnsupportedOperationException("the \"null\" connection profile should not be in a sorted list"); //$NON-NLS-1$
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return ClassTools.toStringClassNameForObject(this);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java
deleted file mode 100644
index 8ff4139cfd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.internal;
-
-import java.util.Iterator;
-
-import org.eclipse.datatools.connectivity.sqm.core.definition.DatabaseDefinition;
-import org.eclipse.jpt.db.Catalog;
-import org.eclipse.jpt.db.Database;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-
-/**
- * "null" database
- * This is used when the connection profile is inactive (i.e. it is neither
- * connected to the database nor working off-line).
- */
-final class NullDatabase
- implements InternalDatabase
-{
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
-
- // ********** singleton **********
-
- private static final NullDatabase INSTANCE = new NullDatabase();
-
- static synchronized InternalDatabase instance() {
- return INSTANCE;
- }
-
- /**
- * 'private' to ensure singleton
- */
- private NullDatabase() {
- super();
- }
-
-
- // ********** Database implementation **********
-
- public String getName() {
- return ClassTools.shortClassNameForObject(this);
- }
-
- public String getVendor() {
- return EMPTY_STRING;
- }
-
- public String getVersion() {
- return EMPTY_STRING;
- }
-
- public boolean isCaseSensitive() {
- return false;
- }
-
- public DatabaseDefinition getDtpDefinition() {
- return null;
- }
-
- // ***** catalogs
-
- public boolean supportsCatalogs() {
- return false;
- }
-
- public Iterator<Catalog> catalogs() {
- return EmptyIterator.<Catalog>instance();
- }
-
- public int catalogsSize() {
- return 0;
- }
-
- public Iterator<String> catalogNames() {
- return EmptyIterator.<String>instance();
- }
-
- public boolean containsCatalogNamed(String name) {
- return false;
- }
-
- public Catalog catalogNamed(String name) {
- return null;
- }
-
- public String defaultCatalogName() {
- return EMPTY_STRING;
- }
-
- public DTPCatalogWrapper getDefaultCatalog() {
- return null;
- }
-
- // ***** schemata
-
- public Iterator<Schema> schemata() {
- return EmptyIterator.<Schema>instance();
- }
-
- public int schemataSize() {
- return 0;
- }
-
- public Iterator<String> schemaNames() {
- return EmptyIterator.<String>instance();
- }
-
- public boolean containsSchemaNamed(String name) {
- return false;
- }
-
- public Schema schemaNamed(String name) {
- return null;
- }
-
-
- // ********** InternalDatabase implementation **********
-
- public void dispose() {
- // do nothing
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(Database o) {
- throw new UnsupportedOperationException("the \"null\" database should not be in a sorted list"); //$NON-NLS-1$
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return ClassTools.toStringClassNameForObject(this);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/.project b/jpa/plugins/org.eclipse.jpt.doc.user/.project
deleted file mode 100644
index 61670ff4fc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/.project
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.doc.user</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.doc.user/META-INF/MANIFEST.MF
deleted file mode 100644
index 4babcd71a8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,8 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.doc.user;singleton:=true
-Bundle-Version: 1.0.100.qualifier
-Bundle-Localization: plugin
-Eclipse-LazyStart: true
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/about.htm b/jpa/plugins/org.eclipse.jpt.doc.user/about.htm
deleted file mode 100644
index 851ab7ce54..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/about.htm
+++ /dev/null
@@ -1,42 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:27 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>About this content</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="About this content" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<div class="sect1"><!-- infolevel="all" infotype="General" --><a id="sthref249" name="sthref249"></a>
-<h1>About this content</h1>
-<p>January, 2008</p>
-<a id="sthref250" name="sthref250"></a>
-<p class="subhead2">License</p>
-<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at <code><a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a></code>. For purposes of the EPL, "Program" will mean the Content.</p>
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <code><a href="http://www.eclipse.org">http://www.eclipse.org</a></code>.</p>
-</div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/build.properties b/jpa/plugins/org.eclipse.jpt.doc.user/build.properties
deleted file mode 100644
index 5e089a32e6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/build.properties
+++ /dev/null
@@ -1,102 +0,0 @@
-bin.includes = cheatsheets/,\
- dcommon/,\
- img/,\
- META-INF/,\
- about.htm,\
- build.properties,\
- concept_mapping.htm,\
- concept_persistence.htm,\
- concepts.htm,\
- concepts001.htm,\
- concepts002.htm,\
- concepts003.htm,\
- contexts.xml,\
- getting_started.htm,\
- getting_started001.htm,\
- getting_started002.htm,\
- getting_started003.htm,\
- getting_started004.htm,\
- getting_started005.htm,\
- getting_started006.htm,\
- getting_started007.htm,\
- getting_started008.htm,\
- getting_started009.htm,\
- getting_started010.htm,\
- getting_started011.htm,\
- getting_started012.htm,\
- getting_started013.htm,\
- getting_started014.htm,\
- getting_started015.htm,\
- getting_started016.htm,\
- getting_started017.htm,\
- getting_started018.htm,\
- getting_started019.htm,\
- index.xml,\
- legal.htm,\
- plugin.properties,\
- plugin.xml,\
- ref_details_orm.htm,\
- ref_jpa_facet.htm,\
- ref_mapping_general.htm,\
- ref_new_jpa_project.htm,\
- ref_new_jpa_project_wizard.htm,\
- ref_persistence_map_view.htm,\
- ref_persistence_outline.htm,\
- ref_persistence_perspective.htm,\
- ref_persistence_prop_view.htm,\
- ref_primary_key.htm,\
- ref_project_properties.htm,\
- reference.htm,\
- reference001.htm,\
- reference002.htm,\
- reference003.htm,\
- reference004.htm,\
- reference005.htm,\
- reference006.htm,\
- reference007.htm,\
- reference008.htm,\
- reference009.htm,\
- reference010.htm,\
- reference011.htm,\
- reference012.htm,\
- reference013.htm,\
- reference014.htm,\
- reference015.htm,\
- reference016.htm,\
- reference017.htm,\
- task_add_persistence.htm,\
- task_additonal_tables.htm,\
- task_create_new_project.htm,\
- task_generate_entities.htm,\
- task_inheritance.htm,\
- task_manage_orm.htm,\
- task_manage_persistence.htm,\
- task_mapping.htm,\
- tasks.htm,\
- tasks001.htm,\
- tasks002.htm,\
- tasks003.htm,\
- tasks004.htm,\
- tasks005.htm,\
- tasks006.htm,\
- tasks007.htm,\
- tasks008.htm,\
- tasks009.htm,\
- tasks010.htm,\
- tasks011.htm,\
- tasks012.htm,\
- tasks013.htm,\
- tasks014.htm,\
- tasks015.htm,\
- tasks016.htm,\
- tasks017.htm,\
- tasks018.htm,\
- tasks019.htm,\
- tasks020.htm,\
- tasks021.htm,\
- tips_and_tricks.htm,\
- toc.xml,\
- whats_new.htm,\
- whats_new001.htm,\
- whats_new002.htm,\
- whats_new003.htm
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/add_persistence.xml b/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/add_persistence.xml
deleted file mode 100644
index 6dbeedbeca..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/add_persistence.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<cheatsheet title="Create a JPA Project">
- <intro href="/org.eclipse.platform.doc.user/reference/ref-cheatsheets.htm">
- <description>
- This cheat sheet will automatically launch wizards, perform actions, and guide you through the steps to create a JPA project.
-
-To learn more about using cheat sheets, or to see a list of available cheat sheets, click Help (?).
-To start work working on this cheat sheet click the &quot;Click to Begin&quot; button below.
-
-Let&apos;s get started!
- </description>
- </intro>
- <item title="Setup the Environment" dialog="false" skip="true" href="/org.eclipse.datatools.doc.user/c_database_development_setup.html">
- <description>
- Your environment must be set up before you can perform the steps in this cheat sheet.
-
-Create a database profile and connect to the database.
-
-The Database Connection dialog automatically appears when you click the &quot;Click to Perform&quot; button.
- </description>
- <command serialization="org.eclipse.datatools.sqltools.sqleditor.attachProfileAction" confirm="false">
- </command>
- </item>
- <item title="Create a JPA Project" dialog="false" skip="false" href="/org.eclipse.jpt.doc.user/task_create_new_project.htm">
- <description>
- Use the New Project Wizard to create a JPA project.
-Select <b>File-&gt;New-&gt;Project...</b> and choose <b>JPA-&gt;JPA Project</b> in the list.
-
-On the first page of the wizard, enter a project name and location, select your target runtime, and select a predefined project configuration.
-
-Click <b>Next</b> to display the next page of the wizard.
-
-The &quot;New JPA Project&quot; wizard is automatically displayed when you click the &quot;Click to Perform&quot; button.
- </description>
- <action class="org.eclipse.jdt.internal.ui.wizards.OpenProjectWizardAction" pluginId="org.eclipse.jdt.ui" confirm="false">
- </action>
- </item>
- <item title="Select Project Facet" dialog="false" skip="false" href="/org.eclipse.jst.j2ee.doc.user/topics/ph-projects.html">
- <description>
- Use the Project Facet page to select a predefined project configuration or specific specific facets to include in the project.
-
-Click &quot;Next&quot; to display the next page of the wizard.
- </description>
- </item>
- <item title="Specify the JPA Facet" dialog="false" skip="false" href="/org.eclipse.jdt.doc.user/ref_jpa_facet.htm">
- <description>
- Use the JPA Facet page to specify the the vendor-specific JPA platform, the database connection to use, and the specific JPA implementation library.
-
-You can also specify if Dali should create an orm.xml file.
-
-If you do not have an active database connection, click <b>Add Connections</b> to create one.
-
-If you do not have a defined JPA implementation library, click <b>Configure default JPA implementation library</b> or <b>Configure user libraries</b> to define one.
-
-Click <b>Finish</b> to complete the wizard and open the open the project.
- </description>
- </item>
- <item title="Finish" dialog="false" skip="false">
- <description>
- Congratulations! You have successfully created a JPA project. Complete the additional cheat sheets to add Java persistent entities and map those entities to database tables.
- </description>
- </item>
-</cheatsheet>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/create_entity.xml b/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/create_entity.xml
deleted file mode 100644
index b64e8afdee..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/create_entity.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<cheatsheet title="Create a Persistent Entity">
- <intro href="/org.eclipse.platform.doc.user/reference/ref-cheatsheets.htm">
- <description>
-This cheat sheet will automatically launch wizards, perform actions, and guide you through the steps to add a Java persistent entity to your Java project.
-To learn more about using cheat sheets or to see a list of available cheat sheets, click Help (?).
-To start work working on this cheat sheet, click the <b>Click to Begin</b> button below.
-Let's get started!
- </description>
- </intro>
- <item title="Create a JPA Project" skip="true">
- <description>
-To create a Persistent entity, you must create a JPA project. If you already have a JPA project, you may skip this step by clicking the "Click to Skip" button.
-If not, select <b>File->New->Project...</b> and choose <b>JPA->JPA Project</b> in the list. Complete each page of the Create JPA Project wizard to create a new JPA project.
- </description>
- </item>
- <item title="Open the JPA Development Perspective" skip="true" href="/org.eclipse.jpt.doc.user/ref_persistence_perspective.htm">
- <action pluginId="org.eclipse.ui.cheatsheets" class="org.eclipse.ui.internal.cheatsheets.actions.OpenPerspective" param1="org.eclipse.jpt.ui.PersistencePerspective"/>
- <description>
-When working with JPA persistence, you should use the Persistence perspective. If you already have the Persistence perspective active, you may skip this step by clicking the "Click to Skip" button.
-If not, select <b>Window->Open Perspective->Other</b> in the menubar at the top of the workbench. In the Select Perspectives dialog, select <b>JPA Development</b> and click OK. This step changes the perspective to set up the Eclipse workbench for JPA development.
-You can click the "Click to Perform" button to have the "Persistence" perspective opened automatically.
- </description>
- </item>
- <item title="Create a Java Class">
- <description>
-The next step is to create a new Java class. In the main toolbar again, click on <b>New Java Class</b> button (or the link below).
-The Java editor will automatically open showing your new class.
- </description>
- </item>
- <item title="Create a Persistent Entity">
- <description>
-Finally we will make the Java class a persistent entity.
-In the JPA Structure view select the Java class.
-In the JPA Details view, use the "Map As" field to select <b>Entity</b>. Dali automatically adds the @Entity annotation to the class in the Java editor.
-Use the Table, Catalog, and Schema fields to associate the entity with a specific table in the database.
- </description>
- </item>
- <item title="Finish">
- <description>
-Congratulations! You have successfully added a JPA entity to your JPA project. Complete the additional cheat sheets to map the entity's fields to database tables.
- </description>
- </item>
-</cheatsheet>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/map_entity.xml b/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/map_entity.xml
deleted file mode 100644
index 63307f226e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/map_entity.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<cheatsheet title="Map a Java Persistent Entity">
- <intro href="/org.eclipse.platform.doc.user/reference/ref-cheatsheets.htm">
- <description>
- This cheat sheet will automatically launch wizards, perform actions, and guide you through the steps to map the fields of a JPA entity entity to your database.
-
-To learn more about using cheat sheets or to see a list of available cheat sheets, click Help (?).
-To start work working on this cheat sheet, click the &quot;Click to Begin&quot; button below.
-
-Let&apos;s get started!
- </description>
- </intro>
- <item title="Setup the Environment" dialog="false" skip="true" href="/org.eclipse.datatools.doc.user/c_database_development_setup.html">
- <description>
- Your environment must be set up before you can perform the steps in this cheat sheet.
-
-Create a database profile and connect to the database.
-
-If you already have (and are connected to) a database connection, you may skip this step by clicking the &quot;Click to Skip&quot; button.
-
-The Database Connection dialog automatically appears when you click the &quot;Click to Perform&quot; button.
- </description>
- <command serialization="org.eclipse.datatools.sqltools.sqleditor.attachProfileAction" confirm="false">
- </command>
- </item>
- <item title="Create a JPA Project" dialog="false" skip="true" href="/org.eclipse.jpt.doc.user/task_create_new_project.htm">
- <description>
- Use the New Project Wizard to create a JPA project.
-Select <b>File-&gt;New-&gt;Project...</b> and choose <b>JPA-&gt;JPA Project</b> in the list.
-
-Complete each page of the wizard to create a new JPA project.
-
-The &quot;New JPA Project&quot; wizard is automatically displayed when you click the &quot;Click to Perform&quot; button.
-
-If you already have a JPA project, you may skip this step by clicking the &quot;Click to Skip&quot; button.
- </description>
- <action class="org.eclipse.jdt.internal.ui.wizards.OpenProjectWizardAction" pluginId="org.eclipse.jdt.ui" confirm="false">
- </action>
- </item>
- <item title="Open the JPA Development Perspective" dialog="false" skip="true" href="/org.eclipse.jpt.doc.user/ref_persistence_perspective.htm">
- <description>
- When working with JPA persistence, you should use the Persistence perspective. If you already have the Persistence perspective active, you may skip this step by clicking the &quot;Click to Skip&quot; button.
-If not, select <b>Window-&gt;Open Perspective-&gt;Other</b> in the menubar at the top of the workbench. In the Select Perspectives dialog, select <b>JPA Development</b> and click OK. This step changes the perspective to set up the Eclipse workbench for JPA development.
-You can click the &quot;Click to Perform&quot; button to have the &quot;Persistence&quot; perspective opened automatically.
- </description>
- <action class="org.eclipse.ui.internal.cheatsheets.actions.OpenPerspective" pluginId="org.eclipse.ui.cheatsheets" confirm="false" param1="org.eclipse.jpt.ui.PersistencePerspective">
- </action>
- </item>
- <item title="Create a Java Class" dialog="false" skip="false">
- <description>
- The next step is to create a new Java class. In the main toolbar again, click on <b>New Java Class</b> button (or the link below).
-The Java editor will automatically open showing your new class.
- </description>
- </item>
- <item title="Create a Persistent Entity" dialog="false" skip="false">
- <description>
- Finally we will make the Java class a persistent entity.
-In the JPA Structure view select the Java class.
-In the JPA Details view, use the &quot;Map As&quot; field to select <b>Entity</b>. Dali automatically adds the @Entity annotation to the class in the Java editor.
-Use the Table, Catalog, and Schema fields to associate the entity with a specific table in the database.
- </description>
- </item>
- <item title="Add Fields to the Class" dialog="false" skip="true">
- <description>
- Now you will add some fields to the entity to map to rows in the database table.
-
-If your persistent entity already has fields to map, you may skip this step by clicking the &quot;Click to Skip&quot; button. If not, use the Java editor to add fields to the entity.
- </description>
- <action class="org.eclipse.ui.internal.cheatsheets.actions.OpenPerspective" pluginId="org.eclipse.ui.cheatsheets" confirm="false" param1="org.eclipse.dali.ui.PersistencePerspective">
- </action>
- </item>
- <item title="Create the Mapping" dialog="false" skip="false" href="/org.eclipse.dali.doc.user/ref_entity_page.htm">
- <description>
- Now you are ready to map the entity fields to columns in the database table. In the Package Explorer, select the Java class.
-
-In the JPA Structure view, expand the persistent entity to display the fields. Select a field.
-
-The JPA Details view displays the information for the field. Use the Map As field to select the Basic mapping. Use the Column field to select a column from the database table.
- </description>
- <action class="org.eclipse.ui.internal.cheatsheets.actions.OpenPerspective" pluginId="org.eclipse.ui.cheatsheets" confirm="false" param1="org.eclipse.dali.ui.PersistencePerspective">
- </action>
- </item>
- <item title="Finish" dialog="false" skip="false">
- <description>
- Congratulations! You have successfully mapped the fields from a Java persistent entity to a column in a database table.
- </description>
- </item>
-</cheatsheet>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm
deleted file mode 100644
index 593f1bdb15..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm
+++ /dev/null
@@ -1,45 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:15 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Understanding OR mappings</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Understanding OR mappings" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABBDJFI" name="BABBDJFI"></a></p>
-<div class="sect1">
-<h1>Understanding OR mappings</h1>
-<p><a id="sthref44" name="sthref44"></a><a id="sthref45" name="sthref45"></a>The Dali OR (object-relational) Mapping Tool allows you to describe how your entity objects <span class="italic">map</span> to the data source (or other objects). This approach isolates persistence information from the object model&ndash;developers are free to design their ideal object model, and DBAs are free to design their ideal schema.</p>
-<p>These mappings transform an object data member type to a corresponding relational database data source representation. These OR mappings can also transform object data members that reference other domain objects stored in other tables in the database and are related through foreign keys.</p>
-<p>You can use these mappings to map simple data types including primitives (such as <code>int</code>), JDK classes (such as <code>String</code>), and large object (LOB) values. You can also use them to transform object data members that reference other domain objects by way of association where data source representations require object identity maintenance (such as sequencing and back references) and possess various types of multiplicity and navigability. The appropriate mapping class is chosen primarily by the cardinality of the relationship.</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-</div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concept_persistence.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concept_persistence.htm
deleted file mode 100644
index 65e30ba97f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/concept_persistence.htm
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:15 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Understanding Java persistence</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Understanding Java persistence" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABCAHIC" name="BABCAHIC"></a></p>
-<div class="sect1">
-<h1>Understanding Java persistence</h1>
-<p><a id="sthref42" name="sthref42"></a><span class="italic">Persistence</span> refers to the ability to store objects in a database and use those objects with transactional integrity. In a J2EE application, data is typically stored and persisted in the data tier, in a relational database.</p>
-<p><a id="sthref43" name="sthref43"></a><span class="italic">Entity beans</span> are enterprise beans that contain persistent data and that can be saved in various persistent data stores. The entity beans represent data from a database; each entity bean carries its own identity. Entity beans can be deployed using <span class="italic">application-managed persistence</span> or <span class="italic">container-managed persistence</span>.</p>
-</div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm
deleted file mode 100644
index 4251d3763d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm
+++ /dev/null
@@ -1,59 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:15 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Concepts</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content=" Concepts" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="sthref41" name="sthref41"></a></p>
-<h1>Concepts</h1>
-<p>This section contains an overview of concepts you should be familiar with when using Dali to create mappings for Java persistent entities.</p>
-<ul>
-<li>
-<p><a href="concept_persistence.htm#BABCAHIC">Understanding Java persistence</a></p>
-</li>
-<li>
-<p><a href="concept_mapping.htm#BABBDJFI">Understanding OR mappings</a></p>
-</li>
-<li>
-<p><a href="concepts001.htm#BABBGFJG">Understanding EJB 3.0 Java Persistence API</a></p>
-</li>
-</ul>
-<p>In addition to these sections, you should review the following resources for additional information:</p>
-<ul>
-<li>
-<p>Eclipse Dali project: <code><a href="http://www.eclipse.org/webtools/dali">http://www.eclipse.org/webtools/dali</a></code></p>
-</li>
-<li>
-<p>Eclipse Web Tools Platform project: <code><a href="http://www.eclipse.org/webtools">http://www.eclipse.org/webtools</a></code></p>
-</li>
-<li>
-<p>JSR 220 EJB 3.0 specification: <code><a href="http://www.jcp.org/en/jsr/detail?id=220">http://www.jcp.org/en/jsr/detail?id=220</a></code></p>
-</li>
-</ul>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm
deleted file mode 100644
index 86b3b7ffa2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm
+++ /dev/null
@@ -1,42 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:16 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Understanding EJB 3.0 Java Persistence API</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Understanding EJB 3.0 Java Persistence API" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABBGFJG" name="BABBGFJG"></a></p>
-<div class="sect1">
-<h1>Understanding EJB 3.0 Java Persistence API</h1>
-<p>The Java 2 Enterprise Edition(J2EE) Enterprise JavaBeans (EJB) are a component architecture that you use to develop and deploy object-oriented, distributed, enterprise-scale applications. An application written according to the Enterprise JavaBeans architecture is scalable, transactional, and secure.</p>
-<p>The EJB 3.0 Java Persistence API (JPA) improves the EJB architecture by reducing its complexity through the use of metadata (annotations) and specifying programmatic defaults of that metadata.</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm
deleted file mode 100644
index cde700e769..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm
+++ /dev/null
@@ -1,44 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:16 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>The persistence.xml file</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="The persistence.xml file" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CHDHAGIH" name="CHDHAGIH"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1><a id="sthref46" name="sthref46"></a>The persistence.xml file</h1>
-<p>The JPA specification requires the use of a <code>persistence.xml</code> file for deployment. This file defines the database and entity manager options, and may contain more than one persistence unit. Dali can use the Eclipse XML Editor to create and maintain this information. See <a href="task_manage_persistence.htm#CIHDAJID">"Managing the persistence.xml file"</a> for more information.</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_manage_persistence.htm#CIHDAJID">Managing the persistence.xml file</a><br />
-<a href="task_create_new_project.htm#CIHHEJCJ">Creating a new JPA project</a>
-<p>&nbsp;</p>
-</div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm
deleted file mode 100644
index 8e67467c8d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm
+++ /dev/null
@@ -1,45 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:16 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>The orm.xml file</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="The orm.xml file" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CHDBIJAC" name="CHDBIJAC"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1><a id="sthref47" name="sthref47"></a>The orm.xml file</h1>
-<p>Although the JPA specification emphasizes the use of annotations to specify persistence, you can also the <code>orm.xml</code> file to store this metadata. Dali can use the Eclipse XML Editor to create and maintain this information. The metadata must match the XSD specification of your selected JPA implementation. See <a href="task_manage_orm.htm#CIHDGDCD">"Managing the orm.xml file"</a> for more information.</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_manage_orm.htm#CIHDGDCD">Managing the orm.xml file</a><br />
-<a href="task_create_new_project.htm#CIHHEJCJ">Creating a new JPA project</a>
-<p>&nbsp;</p>
-</div>
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/contexts.xml b/jpa/plugins/org.eclipse.jpt.doc.user/contexts.xml
deleted file mode 100644
index 34de0ef6d1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/contexts.xml
+++ /dev/null
@@ -1,422 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?NLS TYPE="org.eclipse.help.contexts"?>
-<contexts>
- <context id="entity_accessType">
- <description>Specify how the variable is accessed: Property (default) or Field.</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Adding persistence to a class" href="task_add_persistence.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="entity_name">
- <description>The name of this entity. By default, the class name is used as the entity name.</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Adding persistence to a class" href="task_add_persistence.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="entity_table">
- <description>The database table assigned to this entity. By default, the class name is used as the database table name.</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Adding persistence to a class" href="task_add_persistence.htm"/>
- <topic label="Adding persistence to a class" href="task_add_persistence.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="entity_attributeOverrides">
- <description>Specify a property or field to be overridden (from the default mappings).</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Adding persistence to a class" href="task_add_persistence.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="entity_attributeOverridesName">
- <description>Name of the database column.</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Adding persistence to a class" href="task_add_persistence.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="entity_attributeOverridesColumn">
- <description>The database column that overrides a property or field.</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Adding persistence to a class" href="task_add_persistence.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="entity_attributeOverridesInsertable">
- <description>Specifies if the column is always included in SQL INSERT statements.</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Adding persistence to a class" href="task_add_persistence.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="entity_attributeOverridesUpdatable">
- <description>Specifies if the column is always included in SQL UPDATE statements.</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Adding persistence to a class" href="task_add_persistence.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="mapping_mapAs">
- <description>Specify how this attribute maps to the database.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_column">
- <description>The database column that contains the value for the attribute.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_columnTable">
- <description>Name of the database table that contains the selected column.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_columnInsertable">
- <description>Specifies if the column is always included in SQL INSERT statements.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_columnUpdatable">
- <description>Specifies if the column is always included in SQL UPDATE statements.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_fetchType">
- <description>Defines how data is loaded from the database: Eager (default) or Lazy</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_optional">
- <description>Specifies if this field is can be null.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_generatedValueStrategy">
- <description>Determines how the primary key is generated: Auto (default), Sequence, Identity, or Table.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_generatedValueGeneratorName">
- <description>Unique name of the generator.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_targetEntity">
- <description>The entity to which this attribute is mapped. </description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_cascadeType">
- <description>Specify which operations are propagated throughout the entity: All, Persist, Merge, or Move.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_mappedBy">
- <description>The field in the database table that owns the relationship.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_joinColumnName">
- <description>The name of the database column that contains the foreign key reference for the entity association.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_joinReferencedColumn">
- <description>Name of the join table that contains the foreign key column.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_embeddedAttributeOverrides">
- <description>Specify to override the default mapping of an entity’s attribute.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="mapping_embeddedAttributeOverridesColumn">
- <description>The database column that is being mapped to the entity’s attribute.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- <topic label="Understanding OR mappings" href="concept_mapping.htm"/>
- </context>
- <context id="entity_mapAs">
- <description>Specify the type of persistent domain object for the Java class: Persistent, Embedded, or Mapped Superclass.</description>
- <topic label="Adding persistence to a class" href="task_add_persistence.htm"/>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="entity_inheritanceStrategy">
- <description>Specify how an entity may inherit properties from other entities: Single table, One table per class, or Joined tables.</description>
- <topic label="Specifying inheritance" href="task_inheritance.htm"/>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- </context>
- <context id="entity_inheritanceDiscriminatorColumn">
- <description>Use to specify the name of the discriminator column when using a Single or Joined inheritance strategy.</description>
- <topic label="Specifying inheritance" href="task_inheritance.htm"/>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- </context>
- <context id="entity_inheritanceDiscriminatorType">
- <description>Use this field to set the discriminator type to CHAR or INTEGER (instead of its default: String). The discriminator value must conform to this type.</description>
- <topic label="Specifying inheritance" href="task_inheritance.htm"/>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- </context>
- <context id="entity_inheritanceDiscriminatorValue">
- <description>Specify the discriminator value used to differentiate an entity in this inheritance hierarchy. The value must conform to the specified discriminator type.</description>
- <topic label="Specifying inheritance" href="task_inheritance.htm"/>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- </context>
- <context id="mapping_orderBy">
- <description>Specify the default order for objects returned from a query.</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Mapping an Entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_joinTableName">
- <description>Specify the name of the database table that defines the foreign key for a many-to-many or a unidirectional one-to-many association. You can configure the join table with a specific catalog or schema, configure one or more join table columns with a unique constraint, and use multiple join columns per entity.</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_joinTableJoinColumns">
- <description>Specify two or more join columns (that is, a composite primary key).</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_joinTableInverseJoinColumns">
- <description>Specify the join column on the owned (or inverse side) of the association: the owned entity's primary key column. </description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="properties_javaPersistence">
- <description>Use the Java Persistence options on the Properties page to select the database connection to use with the project.</description>
- <topic label="Project properties" href="ref_project_properties"/>
- <topic label="Adding persistence" href="ref_add_persistence.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="properties_javaPersistenceConnection">
- <description>The database connection used to map the persistent entities.</description>
- <topic label="Project properties" href="ref_project_properties"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="properties_javaPersistenceSchema">
- <description>The database schema used to map the persistent entities.</description>
- <topic label="Project properties" href="ref_project_properties"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="dialog_addPersistence">
- <description>Use the Add Persistence dialog to define the database connection use to store the persistence entities.</description>
- <topic label="Adding persistence" href="ref_add_persistence.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="persistenceOutline">
- <description>The JPA Structure view displays an outline of the structure (its attributes and mappings) of the entity that is currently selected or opened in the editor.</description>
- <topic label="JPA Structure view" href="ref_persistence_outline.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="dialog_generateEntities">
- <description>Use the Generate Entities dialog to create Java persistent entities based on your database tables.</description>
- <topic label="Generating entities from tables" href="task_generate_entities.htm.htm" />
- <topic label="Project properties" href="ref_project_properties"/>
- </context>
- <context id="dialog_generateEntities_source">
- <description>The project folder name in which to generate the Java persistent entities. Click Browse to select an existing folder.</description>
- <topic label="Generating entities from tables" href="task_generate_entities.htm"/>
- </context>
- <context id="dialog_generateEntities_package">
- <description>The package in which to generate the Java persistent entities, or click Browse to select an existing package.</description>
- <topic label="Generating entities from tables" href="task_generate_entities.htm"/>
- </context>
- <context id="dialog_generateEntities_tables">
- <description>Select the tables from which to create Java persistent entities.</description>
- <topic label="Generating entities from tables" href="task_generate_entities.htm"/>
- <topic label="Project properties" href="ref_project_properties"/>
- </context>
- <context id="dialog_addJavaPersistence">
- <description>Use this dialog to define the database connection used to store the persistence entities and to create the persistence.xml file.</description>
- <topic label="Add Persistence dialog" href="ref_add_persistence.htm" />
- <topic label="Adding persistence to a project" href="task_add_persistence" />
- <topic label="Managing the persistence.xml file" href="task_manage_persistence.htm" />
- </context>
- <context id="dialog_newJPAProject">
- <description>Use this dialog to define the new JPA project name, its location, target runtime, and other configuration settings.</description>
- <topic label="New JPA Project page" href="ref_new_jpa_project.htm" />
- <topic label="New JPA Project wizard" href="ref_new_jpa_project_wizard" />
- <topic label="Adding persistence to a project" href="task_add_persistence" />
- <topic label="Creating a new JPA project" href="task_create_new_project.htm" />
- </context>
- <context id="dialog_addJavaPersistence_database">
- <description>Use these fields to define the database connection used to store the persistent entities.</description>
- <topic label="Add Persistence dialog" href="ref_add_persistence.htm" />
- <topic label="Adding persistence to a project" href="task_add_persistence" />
- </context>
- <context id="dialog_addJavaPersistence_classpath">
- <description>Use this option to add libraries or JARs that contain the Java Persistence API (JPA) and entities to the project’s Java Build Path.</description>
- <topic label="Add Persistence dialog" href="ref_add_persistence.htm" />
- <topic label="Adding persistence to a project" href="task_add_persistence" />
- </context>
- <context id="dialog_addJavaPersistence_packaging">
- <description>Use these fields to create the persistence.xml file. Select the persistence version, the name of the JPA provider, and a unique name to identify the persistence unit.</description>
- <topic label="Add Persistence dialog" href="ref_add_persistence.htm" />
- <topic label="Managing the persistence.xml file" href="task_manage_persistence.htm" />
- </context>
- <context id="wizard_generateDDL_options ">
- <description>Use this page to select which script options will be included in the generated script.</description>
- <topic label="Generating tables (DDL) from entities " href="task_generate_ddl.htm" />
- <topic label="Options page " href="ref_options.htm" />
- </context>
- <context id="wizard_generateDDL_objects ">
- <description>Use this page to select which elements will be included in the generated script.</description>
- <topic label="Generating tables (DDL) from entities " href="task_generate_ddl.htm" />
- <topic label="Objects page " href="ref_objects.htm" />
- </context>
- <context id="wizard_generateDDL_save ">
- <description>Use this page to select the filename and location of the generated script. You can also preview the script and specify to run or continue editing the script after generation.</description>
- <topic label="Generating tables (DDL) from entities " href="task_generate_ddl.htm" />
- <topic label="Save and Run DDL page " href="ref_save_and_run.htm" />
- </context>
- <context id="wizard_generateDDL_summary ">
- <description>This page shows the settings that you selected for the generated DDL. To change any option click "Back" or click "Finish" to continue.</description>
- <topic label="Generating tables (DDL) from entities " href="task_generate_ddl.htm" />
- </context>
- <context id="mapping_tableGeneratorName">
- <description>The name of the table sequence generator. This name is global to to the persistence unit (across all generator types).</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_tableGeneratorTable">
- <description>The database table that stores the generated ID values. </description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_tableGeneratorPrimaryKeyColumn">
- <description>The database column of the generator table that stores the generated ID values.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_tableGeneratorValueColumn">
- <description>The name for the column that stores the generated ID values.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_tableGeneratorPrimaryKeyColumnValue">
- <description>The database column of the generator table that defines the primary key value.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="dialog_databaseAuthorization">
- <description>Use to connect (log in) to a database connection to use with your Java persistent entities.
- You must have a defined database connection (and be connected) to add persistence. </description>
- <topic label="Add persistence to a Java project" href="task_add_persistence_project.htm"/>
- </context>
- <context id="mapping_temporal">
- <description>Specify if the mapped field contains a Date (java.sql.Date), Time (java.sql.Time), or Timestamp (java.sql.Timestamp) value.</description>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_primaryKeyGeneration">
- <description>Define how the primary key is generated</description>
- <topic label="Primary Key Generation information" href="ref_primary_key.htm"/>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_tableGenerator">
- <description>Specify to use a specific database table for generating the primary key.</description>
- <topic label="Primary Key Generation information" href="ref_primary_key.htm"/>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_sequenceGenerator">
- <description>Specify to use a specific sequence for generating the primary key.</description>
- <topic label="Primary Key Generation information" href="ref_primary_key.htm"/>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_sequenceGeneratorName">
- <description>Name of the sequence.</description>
- <topic label="Primary Key Generation information" href="ref_primary_key.htm"/>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_sequenceGeneratorSequence">
- <description> </description>
- <topic label="Primary Key Generation information" href="ref_primary_key.htm"/>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_lob">
- <description>Specify if the field is mapped to java.sql.Clob or java.sql.Blob.</description>
- <topic label="General information" href="ref_mapping_general.htm"/>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="mapping_enumerated">
- <description>Specify how to persist enumerated constraints if the String value suits your application requirements or to match an existing database schema.</description>
- <topic label="General information" href="ref_mapping_general.htm"/>
- <topic label="JPA Details" href="ref_persistence_map_view.htm"/>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="dialog_editInverseJoinColumn">
- <description>.</description>
- <topic label="Mapping an entity" href="task_mapping.htm"/>
- </context>
- <context id="entity_catalog">
- <description>The database catalog that contains the Table. This field overrides the defaults in the orm.xml file.</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Adding persistence to a class" href="task_add_persistence.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="entity_schema">
- <description>The database schema that contains the Table. This field overrides the defaults in the orm.xml file.</description>
- <topic label="JPA Details" href="ref_persistence_prop_view.htm"/>
- <topic label="Adding persistence to a class" href="task_add_persistence.htm"/>
- <topic label="Understanding persistence" href="concept_persistence.htm"/>
- </context>
- <context id="orm_package">
- <description>The Java package that contains the persistent entities to which the orm.xml file applies.</description>
- <topic label="Managing the orm.xml file" href="task_manage_orm.htm"/>
- <topic label="JPA Details" href="ref_details_orm.htm"/>
- </context>
- <context id="orm_schema">
- <description>The database schema to use as the default for all entities managed by this persistence unit.</description>
- <topic label="Managing the orm.xml file" href="task_manage_orm.htm"/>
- <topic label="JPA Details" href="ref_details_orm.htm"/>
- </context>
- <context id="orm_catalog">
- <description>The database catalog to use as the default for all entities managed by this persistence unit.</description>
- <topic label="Managing the orm.xml file" href="task_manage_orm.htm"/>
- <topic label="JPA Details" href="ref_details_orm.htm"/>
- </context>
- <context id="orm_access">
- <description>The default access method for variables in this project: Property or Field.</description>
- <topic label="Managing the orm.xml file" href="task_manage_orm.htm"/>
- <topic label="JPA Details" href="ref_details_orm.htm"/>
- </context>
- <context id="orm_cascade">
- <description>Adds cascade-persist to the set of cascade options in entity relationships of the persistence unit.</description>
- <topic label="Managing the orm.xml file" href="task_manage_orm.htm"/>
- <topic label="JPA Details" href="ref_details_orm.htm"/>
- </context>
- <context id="orm_xml">
- <description>Specifies that the Java classes in this persistence unit are fully specified by their metadata. Any annotations will be ignored.</description>
- <topic label="Managing the orm.xml file" href="task_manage_orm.htm"/>
- <topic label="JPA Details" href="ref_details_orm.htm"/>
- </context>
- <context id="dialog_JPAPlatform">
- <description>Specify the vendor-specific JPA implementation.Default is Generic..</description>
- <topic label="JPA Facet page" href="ref_jpa_facet.htm"/>
- </context>
- <context id="dialog_createORM">
- <description>Create an initial orm.xml file. Use this file to specify project and persistence unit defaults.</description>
- <topic label="Managing the orm.xml file" href="task_manage_orm.htm"/>
- <topic label="JPA Facet page" href="ref_jpa_facet.htm"/>
- </context>
-
-
-
-
-</contexts>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/css/blafdoc.css b/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/css/blafdoc.css
deleted file mode 100644
index 4fa017b8b0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/css/blafdoc.css
+++ /dev/null
@@ -1,21 +0,0 @@
-@import "../../../PRODUCT_PLUGIN/book.css";
-
-span.control, span.gui-object-action, p.subhead2, span.bold, p.notep1 {
- font-weight: bold;
-}
-
-span.name, p.titleinfigure, span.italic {
- font-style: italic;
-}
-
-p.titleinfigure, p.subhead2 {
- padding-top: 10px;
-}
-
-span.code {
- font-family: monospace;
-}
-
-span.copyrightlogo {font-size: 75%}
-
-.footer {padding-top: 2em;} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/html/cpyr.htm b/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/html/cpyr.htm
deleted file mode 100644
index fe52e9587f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/html/cpyr.htm
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<!-- <meta http-equiv="refresh" content="0;url=../../legal.htm"> -->
-</head>
-<body>
-<p><a href="../../legal.htm">License Information</a></p>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm
deleted file mode 100644
index ad83e5975c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm
+++ /dev/null
@@ -1,49 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:13 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Getting started</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content=" Getting started" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="sthref2" name="sthref2"></a></p>
-<h1>Getting started</h1>
-<p>This section provides information on getting started with the Java Persistence Tools.</p>
-<ul>
-<li>
-<p><a href="getting_started001.htm#BABEFHCD">Requirements and installation</a></p>
-</li>
-<li>
-<p><a href="getting_started002.htm#BABIGCJA">Dali quick start</a></p>
-</li>
-<li>
-<p><a href="getting_started006.htm#BABCDECJ">Dali basic tutorial</a></p>
-</li>
-</ul>
-<p>For additional information, please visit the Dali home page at:</p>
-<p><code><a href="http://www.eclipse.org/webtools/dali/main.php">http://www.eclipse.org/webtools/dali/main.php</a></code>.</p>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started001.htm
deleted file mode 100644
index 32cca6f06a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started001.htm
+++ /dev/null
@@ -1,59 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:13 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Requirements and installation</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Requirements and installation" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABEFHCD" name="BABEFHCD"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Requirements and installation<a id="sthref3" name="sthref3"></a><a id="sthref4" name="sthref4"></a></h1>
-<p>Before installing Dali, ensure that your environment meets the following <span class="italic">minimum</span> requirements:</p>
-<ul>
-<li>
-<p>Eclipse 3.3 (<code><a href="http://www.eclipse.org/downloads">http://www.eclipse.org/downloads</a></code>)</p>
-</li>
-<li>
-<p>Java Runtime Environment (JRE) 1.5 (<code><a href="http://java.com">http://java.com</a></code>)</p>
-</li>
-<li>
-<p>Eclipse Web Tools Platform (WTP) 2.0 (<code><a href="http://www.eclipse.org/webtools">http://www.eclipse.org/webtools</a></code>)</p>
-</li>
-<li>
-<p>Java Persistence API (JPA) for Java EE 5. The reference implementation can be obtained from:</p>
-</li>
-</ul>
-<pre xml:space="preserve" class="oac_no_warn">
-<code><a href="https://glassfish.dev.java.net/downloads/persistence/JavaPersistence.html">https://glassfish.dev.java.net/downloads/persistence/JavaPersistence.html</a></code>
-</pre>
-<p>Refer to <code><a href="http://www.eclipse.org/webtools/dali/gettingstarted_main.html">http://www.eclipse.org/webtools/dali/gettingstarted_main.html</a></code> for additional installation information.</p>
-<p>Dali is included as part of WTP 2.0. No additional installation or configuration is required.</p>
-<p>Review the <a href="getting_started002.htm#BABIGCJA">Dali quick start</a> and <a href="getting_started006.htm#BABCDECJ">Dali basic tutorial</a> to build your first Dali project.</p>
-</div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started002.htm
deleted file mode 100644
index 81303aebd5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started002.htm
+++ /dev/null
@@ -1,53 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:13 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Dali quick start</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Dali quick start" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABIGCJA" name="BABIGCJA"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Dali quick start</h1>
-<p><a id="sthref5" name="sthref5"></a>This section includes information to help you quickly start using Dali to create relational mappings between Java persistent entities and database tables.</p>
-<ul>
-<li>
-<p><a href="getting_started003.htm#BABDFHDA">Creating a new project</a></p>
-</li>
-<li>
-<p><a href="getting_started004.htm#BABFGDDG">Creating a Java persistent entity</a></p>
-</li>
-<li>
-<p><a href="getting_started005.htm#BABHACAF">Mapping an entity</a></p>
-</li>
-</ul>
-<p>The <a href="getting_started006.htm#BABCDECJ">Dali basic tutorial</a> contains detailed procedures for building you first Dali project.</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="getting_started006.htm#BABCDECJ">Dali basic tutorial</a><br />
-<a href="tips_and_tricks.htm#CHDHGHBF">Tips and tricks</a><br />
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started003.htm
deleted file mode 100644
index e30bf42f31..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started003.htm
+++ /dev/null
@@ -1,84 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:13 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Creating a new project</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Creating a new project" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABDFHDA" name="BABDFHDA"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Creating a new project</h1>
-<p><a id="sthref6" name="sthref6"></a>This quick start shows how to create a new JPA project.</p>
-<ol start="1">
-<li>
-<p>Select <span class="gui-object-action">File &gt; New &gt; Project</span>. The New Project dialog appears.</p>
-</li>
-<li>
-<p>On the <span class="gui-object-title">New Project</span> dialog, select <span class="gui-object-action">JPA &gt; JPA Project</span> and click <span class="gui-object-action">Next</span>. The New JPA Project dialog appears.</p>
-<div class="figure"><a id="sthref7" name="sthref7"></a>
-<p class="titleinfigure">New JPA Project</p>
-<img src="img/new_jpa_project_dialog.png" alt="New JPA Project dialog." title="New JPA Project dialog." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>On the <span class="gui-object-title">New JPA Project</span> dialog, enter a <span class="gui-object-action">Project name</span> (such as <code>QuickStart</code>).</p>
-</li>
-<li>
-<p>Select your <span class="bold">Target Runtime</span> (such as <code>Apache Tomcat</code>) and click <span class="bold">Next</span>. The Project Facets dialog appears.</p>
-</li>
-<li>
-<p>Verify that the <span class="bold">Java Persistence 1.0</span> facet is selected and click <span class="bold">Next</span>. The JPA Facet dialog appears.</p>
-<div align="center">
-<div class="inftblnote"><br />
-<table class="Note oac_no_warn" summary="" cellpadding="3" cellspacing="0">
-<tbody>
-<tr>
-<td align="left">
-<p class="notep1">Note:</p>
-You must configure your project to use Java version 5.0 (or higher). See <a href="getting_started001.htm#BABEFHCD">"Requirements and installation"</a> for more information.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblnote" --></div>
-</li>
-<li>
-<p>On the JPA Facet dialog, select your vendor-specific JPA platform (or select <span class="bold">Generic</span>), database connection (or create a new connection), JPA implementation library (such as TopLink Essentials), define how Dali should manage persistent classes, and click <span class="bold">Finish</span>.</p>
-<div class="figure"><a id="sthref8" name="sthref8"></a>
-<p class="titleinfigure">JPA Facet Dialog</p>
-<img src="img/jpa_facet_dialog.png" alt="JPA Facet dialog." title="JPA Facet dialog." /><br /></div>
-<!-- class="figure" --></li>
-</ol>
-<p>Eclipse adds the project to the workbench and opens the JPA perspective.</p>
-<div class="figure"><a id="sthref9" name="sthref9"></a>
-<p class="titleinfigure">Project in Package Explorer</p>
-<img src="img/quickstart_project.png" alt="Package Explorer showing the JPA project." title="Package Explorer showing the JPA project." /><br /></div>
-<!-- class="figure" -->
-<p>Now that you have created a project with persistence, you can continue with <a href="getting_started004.htm#BABFGDDG">Creating a Java persistent entity</a>.</p>
-</div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started004.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started004.htm
deleted file mode 100644
index 11e1724e79..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started004.htm
+++ /dev/null
@@ -1,105 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:13 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Creating a Java persistent entity</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Creating a Java persistent entity" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABFGDDG" name="BABFGDDG"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Creating a Java persistent entity</h1>
-<p><a id="sthref10" name="sthref10"></a>This quick start shows how to create a new persistent Java entity. We will create an entity to associate with a database table. You will also need to add the ADDRESS table to your database.</p>
-<ol start="1">
-<li>
-<p>Right-click the project in the Package Explorer and select <span class="bold">New &gt; Class</span>. The New Java Class page appears.</p>
-</li>
-<li>
-<p>On the Java Class page, enter a package name (such as <code>quickstart.demo.model</code>), class name (such as <code>Address</code>), and click <span class="bold">Finish</span>.</p>
-</li>
-<li>
-<p>Right-click the <code>Address.java</code> file in the Package Explorer and select <span class="bold">Open</span>.</p>
-<div class="figure"><a id="sthref11" name="sthref11"></a>
-<p class="titleinfigure">Open Address.java</p>
-<img src="img/address_java_open.png" alt="Opening a Java class." title="Opening a Java class." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>Select the <code>Address</code> entity in the JPA Structure view.</p>
-<div class="figure"><a id="sthref12" name="sthref12"></a>
-<p class="titleinfigure">Address Class in JPA Structure View</p>
-<img src="img/address_jpa_structure.png" alt="Address class in JPA Structure view." title="Address class in JPA Structure view." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>In the JPA Details view, in the Map As field, select <span class="bold">Entity</span>. In the Table field, select the <span class="bold">ADDRESS</span> database table.</p>
-<div class="figure"><a id="sthref13" name="sthref13"></a>
-<p class="titleinfigure">Address Entity in JPA Details View</p>
-<img src="img/address_jpa_details.png" alt="JPA Details view." title="JPA Details view." /><br /></div>
-<!-- class="figure" --></li>
-</ol>
-<p>Eclipse creates the persistent entity and adds the <code>@Entity</code> annotation to the class.</p>
-<div class="figure"><a id="sthref14" name="sthref14"></a>
-<p class="titleinfigure">Address Entity</p>
-<img src="img/java_editor_address.png" alt="Java editor with the Address entity." title="Java editor with the Address entity." /><br /></div>
-<!-- class="figure" -->
-<p>Eclipse also displays the <span class="bold">Address</span> entity in the JPA Structure view:</p>
-<div class="figure"><a id="sthref15" name="sthref15"></a>
-<p class="titleinfigure">Address Entity</p>
-<img src="img/persistence_outline_entity.png" alt="Address entity in the JPA Structure view." title="Address entity in the JPA Structure view." /><br /></div>
-<!-- class="figure" -->
-<p>After creating the entity, you must associate it with a database table.</p>
-<ol start="1">
-<li>
-<p>Select the <span class="gui-object-action">Address</span> class in the Explorer view.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">JPA Details</span> view, notice that Dali has automatically associated the ADDRESS database table with the entity because they are named identically.</p>
-<div align="center">
-<div class="inftblnote"><br />
-<table class="Note oac_no_warn" summary="" cellpadding="3" cellspacing="0">
-<tbody>
-<tr>
-<td align="left">
-<p class="notep1">Note:</p>
-Depending on your database connection type, you may need to specify the <span class="bold">Schema</span>.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblnote" --></div>
-<div class="figure"><a id="sthref16" name="sthref16"></a>
-<p class="titleinfigure">JPA Details View for Address Entity</p>
-<img src="img/persistence_view_address.png" alt="Address entity in the JPA Details view." title="Address entity in the JPA Details view." /><br /></div>
-<!-- class="figure" --></li>
-</ol>
-<p>After associating the entity with the database table, you must update the <code>persistence.xml</code> file to include this JPA entity.</p>
-<p>Right-click the <code>persistence.xml</code> file in the Package Explorer and select <span class="bold">JPA Tools &gt; Synchronize Classes</span>. Dali adds the following to the <code>persistence.xml</code> file:</p>
-<p><code>&lt;class&gt;quickstart.demo.model.Address&lt;/class&gt;</code></p>
-<p>&nbsp;</p>
-<p>Now that you have created a persistent entity, you can continue with <a href="getting_started005.htm#BABHACAF">Mapping an entity</a> to map the entity's fields to columns on the database table.</p>
-</div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started005.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started005.htm
deleted file mode 100644
index 9be388b911..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started005.htm
+++ /dev/null
@@ -1,132 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:14 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Mapping an entity</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Mapping an entity" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABHACAF" name="BABHACAF"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Mapping an entity</h1>
-<p><a id="sthref17" name="sthref17"></a><a id="sthref18" name="sthref18"></a>This quick start shows how to map fields in a Java persistent entity. Before beginning, add the following fields to the Address class:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-private Long id;
-private String city;
-private String country;
-private String stateOrProvince;
-private String postalCode;
-private String street;
-</pre>
-<p>Eclipse updates the Address entity in the JPA Structure view to show its fields:</p>
-<div class="figure"><a id="sthref19" name="sthref19"></a>
-<p class="titleinfigure">Address Entity and Fields</p>
-<img src="img/persistence_outline_fields.png" alt="Address entity and its fields in the JPA Structure view." title="Address entity and its fields in the JPA Structure view." /><br /></div>
-<!-- class="figure" -->
-<p>You will also need to add the following columns to the ADDRESS database table:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-NUMBER(10,0) ADDRESS_ID (primary key)
-VARCHAR2(80) PROVINCE
-VARCHAR2(80) COUNTRY
-VARCHAR2(20) P_CODE
-VARCHAR2(80) STREET
-VARCHAR2(80) CITY
-</pre>
-<pre xml:space="preserve" class="oac_no_warn">
-</pre>
-<p>Now we are ready to map each fields in the Address class to a column in the database table.</p>
-<ol start="1">
-<li>
-<p>Select the <span class="gui-object-action">id</span> field in the JPA Details view.</p>
-</li>
-<li>
-<p>In the JPA Details view:</p>
-<ul>
-<li>
-<p>For the Map As field, select <span class="bold">Id</span></p>
-</li>
-<li>
-<p>For the Column field, select <span class="bold">ADDRESS_ID</span>.</p>
-</li>
-</ul>
-<div class="figure"><a id="sthref20" name="sthref20"></a>
-<p class="titleinfigure">JPA Details View for addressId Field</p>
-<img src="img/persistence_view_addressid.png" alt="JPA Details view for the id field." title="JPA Details view for the id field." /><br /></div>
-<!-- class="figure" -->
-<p>Eclipse adds the following annotations to the Address entity:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@Id
-@Column(name="ADDRESS_ID")
-</pre></li>
-<li>
-<p>Map each of the following fields (as <span class="bold">Basic</span> mappings) to the appropriate database column:</p>
-<div class="inftblhruleinformal">
-<table class="HRuleInformal" title="This table describes the mappings for each of the fields in the Address entity." summary="This table describes the mappings for each of the fields in the Address entity." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t4">Field</th>
-<th align="left" valign="bottom" id="r1c2-t4">Map As</th>
-<th align="left" valign="bottom" id="r1c3-t4">Database Column</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t4" headers="r1c1-t4">city</td>
-<td align="left" headers="r2c1-t4 r1c2-t4">Basic</td>
-<td align="left" headers="r2c1-t4 r1c3-t4">CITY</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t4" headers="r1c1-t4">country</td>
-<td align="left" headers="r3c1-t4 r1c2-t4">Basic</td>
-<td align="left" headers="r3c1-t4 r1c3-t4">COUNTRY</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t4" headers="r1c1-t4">postalCode</td>
-<td align="left" headers="r4c1-t4 r1c2-t4">Basic</td>
-<td align="left" headers="r4c1-t4 r1c3-t4">P_CODE</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t4" headers="r1c1-t4">provinceOrState</td>
-<td align="left" headers="r5c1-t4 r1c2-t4">Basic</td>
-<td align="left" headers="r5c1-t4 r1c3-t4">PROVINCE</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r6c1-t4" headers="r1c1-t4">street</td>
-<td align="left" headers="r6c1-t4 r1c2-t4">Basic</td>
-<td align="left" headers="r6c1-t4 r1c3-t4">STREET</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblhruleinformal" --></li>
-</ol>
-<p>Notice that Dali will automatically map some fields to the correct database column (such as the <span class="bold">city</span> field to the CITY column) if the names are identical.</p>
-<p>Refer to the <a href="getting_started006.htm#BABCDECJ">Dali basic tutorial</a> to map a complete object model using basic and relational mappings.</p>
-</div>
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started006.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started006.htm
deleted file mode 100644
index d3fefcfa8a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started006.htm
+++ /dev/null
@@ -1,42 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:14 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Dali basic tutorial</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Dali basic tutorial" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABCDECJ" name="BABCDECJ"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Dali basic tutorial<a id="sthref21" name="sthref21"></a></h1>
-<p>In this tutorial, you will use Dali to map the object model of a company's HR application to track its employees. <a href="#BABIDCBA">Figure: Tutorial Object Model</a> illustrates the object model for the tutorial.</p>
-<div class="figure"><a id="BABIDCBA" name="BABIDCBA"></a>
-<p class="titleinfigure">Tutorial Object Model</p>
-<img src="img/tutorial_object_model.png" alt="This figure shows the object model for the tutorial." title="This figure shows the object model for the tutorial." /><br /></div>
-<!-- class="figure" -->
-<p>Next, you will <a href="getting_started007.htm#BABBBBID">Generate the tutorial database schema</a>.</p>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started007.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started007.htm
deleted file mode 100644
index cd6a14382f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started007.htm
+++ /dev/null
@@ -1,209 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:14 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Generate the tutorial database schema</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Generate the tutorial database schema" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABBBBID" name="BABBBBID"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Generate the tutorial database schema</h1>
-<p>The tutorial application uses three database tables to store each employee's information: EMPLOYEE, ADDRESS and PHONE. <a href="#BABDEFDF">Table: Tutorial Database Schema</a> describes the columns for each table.</p>
-<p>You can download SQL scripts to build and populate the database tables with sample data from <code><a href="http://www.eclipse.org/webtools/dali/docs/dbscripts.zip">http://www.eclipse.org/webtools/dali/docs/dbscripts.zip</a></code>.</p>
-<div class="tblhruleformal"><a id="sthref22" name="sthref22"></a><a id="BABDEFDF" name="BABDEFDF"></a>
-<p class="titleintable">Tutorial Database Schema</p>
-<table class="HRuleFormal" title="Tutorial Database Schema" summary="This table lists the database schema." dir="ltr" border="1" width="100%" frame="hsides" rules="rows" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t5">Table</th>
-<th align="left" valign="bottom" id="r1c2-t5">Column</th>
-<th align="left" valign="bottom" id="r1c3-t5">Type</th>
-<th align="left" valign="bottom" id="r1c4-t5">Details</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t5" headers="r1c1-t5" rowspan="5">
-<p>EMPLOYEE</p>
-</td>
-<td align="left" headers="r2c1-t5 r1c2-t5">
-<p>EMP_ID</p>
-</td>
-<td align="left" headers="r2c1-t5 r1c3-t5">
-<p>NUMBER(15)</p>
-</td>
-<td align="left" headers="r2c1-t5 r1c4-t5">
-<p>Primary Key</p>
-</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t5" headers="r2c1-t5 r1c1-t5">
-<p>F_NAME</p>
-</td>
-<td align="left" headers="r2c1-t5 r3c1-t5 r1c2-t5">
-<p>VARCHAR(40)</p>
-</td>
-<td align="left" headers="r2c1-t5 r3c1-t5 r1c3-t5"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t5" headers="r2c1-t5 r1c1-t5">
-<p>L_NAME</p>
-</td>
-<td align="left" headers="r2c1-t5 r4c1-t5 r1c2-t5">
-<p>VARCHAR(40)</p>
-</td>
-<td align="left" headers="r2c1-t5 r4c1-t5 r1c3-t5"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t5" headers="r2c1-t5 r1c1-t5">
-<p>ADDR_ID</p>
-</td>
-<td align="left" headers="r2c1-t5 r5c1-t5 r1c2-t5">
-<p>NUMBER(15)</p>
-</td>
-<td align="left" headers="r2c1-t5 r5c1-t5 r1c3-t5">
-<p>Foreign Key, references ADDRESS.ADDRES_ID</p>
-</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r6c1-t5" headers="r2c1-t5 r1c1-t5">
-<p>VERSION</p>
-</td>
-<td align="left" headers="r2c1-t5 r6c1-t5 r1c2-t5">
-<p>NUMBER(15)</p>
-</td>
-<td align="left" headers="r2c1-t5 r6c1-t5 r1c3-t5"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r7c1-t5" headers="r1c1-t5" rowspan="6">
-<p>ADDRESS</p>
-</td>
-<td align="left" headers="r7c1-t5 r1c2-t5">
-<p>ADDRESS_ID</p>
-</td>
-<td align="left" headers="r7c1-t5 r1c3-t5">
-<p>NUMBER(15)</p>
-</td>
-<td align="left" headers="r7c1-t5 r1c4-t5">
-<p>Primary Key</p>
-</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r8c1-t5" headers="r7c1-t5 r1c1-t5">
-<p>PROVINCE</p>
-</td>
-<td align="left" headers="r7c1-t5 r8c1-t5 r1c2-t5">
-<p>VARCHAR(80)</p>
-</td>
-<td align="left" headers="r7c1-t5 r8c1-t5 r1c3-t5"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r9c1-t5" headers="r7c1-t5 r1c1-t5">
-<p>COUNTRY</p>
-</td>
-<td align="left" headers="r7c1-t5 r9c1-t5 r1c2-t5">
-<p>VARCHAR(80)</p>
-</td>
-<td align="left" headers="r7c1-t5 r9c1-t5 r1c3-t5"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r10c1-t5" headers="r7c1-t5 r1c1-t5">
-<p>STREET</p>
-</td>
-<td align="left" headers="r7c1-t5 r10c1-t5 r1c2-t5">
-<p>VARCHAR(80)</p>
-</td>
-<td align="left" headers="r7c1-t5 r10c1-t5 r1c3-t5"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r11c1-t5" headers="r7c1-t5 r1c1-t5">
-<p>P_CODE</p>
-</td>
-<td align="left" headers="r7c1-t5 r11c1-t5 r1c2-t5">
-<p>VARCHAR(20)</p>
-</td>
-<td align="left" headers="r7c1-t5 r11c1-t5 r1c3-t5"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r12c1-t5" headers="r7c1-t5 r1c1-t5">
-<p>CITY</p>
-</td>
-<td align="left" headers="r7c1-t5 r12c1-t5 r1c2-t5">
-<p>VARCHAR(80)</p>
-</td>
-<td align="left" headers="r7c1-t5 r12c1-t5 r1c3-t5"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r13c1-t5" headers="r1c1-t5" rowspan="4">
-<p>PHONE</p>
-</td>
-<td align="left" headers="r13c1-t5 r1c2-t5">
-<p>EMP_ID</p>
-</td>
-<td align="left" headers="r13c1-t5 r1c3-t5">
-<p>NUMBER(15)</p>
-</td>
-<td align="left" headers="r13c1-t5 r1c4-t5">
-<p>Foreign Key, reference to EMPLOYEE.EMP_ID</p>
-</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r14c1-t5" headers="r13c1-t5 r1c1-t5">
-<p>AREA_CODE</p>
-</td>
-<td align="left" headers="r13c1-t5 r14c1-t5 r1c2-t5">
-<p>VARCHAR(3)</p>
-</td>
-<td align="left" headers="r13c1-t5 r14c1-t5 r1c3-t5"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r15c1-t5" headers="r13c1-t5 r1c1-t5">
-<p>P_NUMBER</p>
-</td>
-<td align="left" headers="r13c1-t5 r15c1-t5 r1c2-t5">
-<p>VARCHAR(7)</p>
-</td>
-<td align="left" headers="r13c1-t5 r15c1-t5 r1c3-t5">
-<p>Primary key</p>
-</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r16c1-t5" headers="r13c1-t5 r1c1-t5">
-<p>TYPE</p>
-</td>
-<td align="left" headers="r13c1-t5 r16c1-t5 r1c2-t5">
-<p>VARCHAR(15)</p>
-</td>
-<td align="left" headers="r13c1-t5 r16c1-t5 r1c3-t5"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="tblhruleformal" -->
-<p>Next, you will <a href="getting_started008.htm#BABDHFCD">Create a database connection</a>.</p>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started008.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started008.htm
deleted file mode 100644
index 111d7ad3c1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started008.htm
+++ /dev/null
@@ -1,46 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:14 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create a database connection</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Create a database connection" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABDHFCD" name="BABDHFCD"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Create a database connection</h1>
-<p>After creating the database you will need to create a database connection to use with the tutorial application. An active database connection is required to complete tutorial application.</p>
-<p>Use the <a href="../org.eclipse.wst.datatools.connection.ui.doc.user/topics/tconnecting_wiz.html">New Connection wizard</a> to create a database connection.</p>
-<div class="figure"><a id="sthref23" name="sthref23"></a>
-<p class="titleinfigure">Database Explorer</p>
-<img src="img/database_explorer.png" alt="This figure shows the Database Explorer." title="This figure shows the Database Explorer." /><br /></div>
-<!-- class="figure" -->
-<p>Now you're ready to <a href="getting_started009.htm#BABBBAIG">Create a JPA project</a>.</p>
-</div>
-<!-- class="sect3" -->
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started009.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started009.htm
deleted file mode 100644
index 8ee078a1b1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started009.htm
+++ /dev/null
@@ -1,62 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:14 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create a JPA project</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Create a JPA project" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABBBAIG" name="BABBBAIG"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Create a JPA project</h1>
-<p>In order to begin, you must create a new Java project.</p>
-<ol start="1">
-<li>
-<p>Select <span class="gui-object-action">File &gt; New &gt; Project</span>. The New Project dialog appears.</p>
-</li>
-<li>
-<p>On the <span class="gui-object-title">New Project</span> dialog, select <span class="gui-object-action">JPA &gt; JPA Project</span> and click <span class="gui-object-action">OK</span>. The New JPA Project dialog appears.</p>
-</li>
-<li>
-<p>On the <span class="gui-object-title">New JPA Project</span> dialog, enter <code>Employee</code> as the <span class="gui-object-action">Project name</span> and click <span class="gui-object-action">Next</span>. The Project Facets page appears.</p>
-</li>
-<li>
-<p>Verify that you have selected a Java 5.0 (or higher) and JPA 1.0 facet, and click <span class="bold">Next</span>. The JPA Facet page appears.</p>
-</li>
-<li>
-<p>Select your vender-specific platform, database connection, and JPA implementation library, and click <span class="bold">Finish</span>.</p>
-</li>
-</ol>
-<p>Eclipse adds the project to the workbench and opens the Java perspective.</p>
-<div class="figure"><a id="sthref24" name="sthref24"></a>
-<p class="titleinfigure">Persistence Perspective</p>
-<img src="img/persistence_perspective.png" alt="This figure shows the main parts of the JPA Development Perspective: The JPA Structure and JPA Details views." title="This figure shows the main parts of the JPA Development Perspective: The JPA Structure and JPA Details views." /><br /></div>
-<!-- class="figure" -->
-<p>The next step is to <a href="getting_started010.htm#BABIJIGF">Create persistent Java entities</a>.</p>
-</div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started010.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started010.htm
deleted file mode 100644
index 647ff4362a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started010.htm
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:14 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create persistent Java entities</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Create persistent Java entities" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABIJIGF" name="BABIJIGF"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Create persistent Java entities</h1>
-<p>The <a href="getting_started006.htm#BABIDCBA">Tutorial Object Model</a> contains three entities: <span class="bold">Employee</span>, <span class="bold">Address</span>, and <span class="bold">PhoneNumber</span>. Use this procedure to add the entities to the project.</p>
-<ol start="1">
-<li>
-<p>Right-click the <span class="bold">Employee</span> project in the <span class="gui-object-title">Package Explorer</span> and select <span class="gui-object-action">New &gt; Class</span>. The New Java Class dialog appears.</p>
-</li>
-<li>
-<p>On the <span class="gui-object-title">Java Class</span> dialog, enter a package name (such as <code>dali.tutorial.model</code>), class name (such as <code>Employee</code>), and click <span class="gui-object-action">Finish</span>. Eclipse adds the Employee entity to the Package Explorer.</p>
-</li>
-<li>
-<p>Select the <code>Employee</code> entity in the JPA Structure view.</p>
-</li>
-<li>
-<p>In the JPA Details view, in the Map As field, select <span class="bold">Entity</span>. In the Table field, select the <span class="bold">EMPLOYEE</span> database table.</p>
-<div class="figure"><a id="sthref25" name="sthref25"></a>
-<p class="titleinfigure">Employee Entity in JPA Details View</p>
-<img src="img/jpa_details_employee.png" alt="Employee entity in JPA Details view." title="Employee entity in JPA Details view." /><br /></div>
-<!-- class="figure" --></li>
-</ol>
-<p>Eclipse adds the <code>@Entity</code> annotation to the class. Repeat this procedure to add the <span class="bold">PhoneNumber</span> and <span class="bold">Address</span> entities.</p>
-<p>Notice that the Problems view reports several errors for each entity. We'll address these shortly.</p>
-<p>Next, you will <a href="getting_started011.htm#BABDCBDD">Add fields to the entities</a>.</p>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started011.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started011.htm
deleted file mode 100644
index 24dea89a30..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started011.htm
+++ /dev/null
@@ -1,76 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:14 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Add fields to the entities</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Add fields to the entities" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABDCBDD" name="BABDCBDD"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Add fields to the entities</h1>
-<p>Before mapping the entities to the database, you must add the necessary fields to each entity.</p>
-<ol start="1">
-<li>
-<p>Add the following fields to the <span class="bold">Employee</span> entity:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-private Long id;
-private String firstNname;
-private String lastName;
-private String address;
-private List&lt;PhoneNumber&gt; phoneNumbers;
-private Long version;
-</pre></li>
-<li>
-<p>Import <span class="bold">java.util.List</span>.</p>
-</li>
-<li>
-<p>Generate Getters and Setters for each field.</p>
-</li>
-<li>
-<p>Add the following fields to the <span class="bold">Address</span> entity:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-private Long id;
-private String street;
-private String city;
-private String stateOrProvince;
-private String country;
-private String postalCode;
-</pre></li>
-<li>
-<p>Add the following fields to the <span class="bold">PhoneNumber</span> entity:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-private String type;
-private String areaCode;
-private String number;
-private Employee owner;
-</pre></li>
-</ol>
-<p>Next, you will <a href="getting_started012.htm#BABIHGGD">Associate the entity with a database table</a>.</p>
-</div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started012.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started012.htm
deleted file mode 100644
index 28be4336ad..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started012.htm
+++ /dev/null
@@ -1,54 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:14 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Associate the entity with a database table</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Associate the entity with a database table" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABIHGGD" name="BABIHGGD"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Associate the entity with a database table</h1>
-<p>Now you must associate each entity with its primary database table.</p>
-<ol start="1">
-<li>
-<p>Select the <span class="gui-object-action">Employee</span> class in the Explorer view.</p>
-</li>
-<li>
-<p>In the JPA Details view, notice that Dali has automatically selected the EMPLOYEE table as the table name.</p>
-<div class="figure"><a id="sthref26" name="sthref26"></a>
-<p class="titleinfigure">JPA Details View for the Employee Entity</p>
-<img src="img/persistence_view_employee.png" alt="JPA Details view for the Employee entity." title="JPA Details view for the Employee entity." /><br /></div>
-<!-- class="figure" --></li>
-</ol>
-<p>By default, Dali attempts to associate each entity with a similarly named database table. Notice that although you have not explicitly associated the <span class="bold">Address</span> entity yet, there is no error in the Problems view because the entity name, Address, is identical to the table name (ADDRESS).</p>
-<p>For the <span class="bold">PhoneNumber</span> entity, however, there is an error. This is because the entity name (PhoneNumber) is different than the database table (PHONE). You must explicitly associate the entity with the PHONE table. Dali adds the <code>@Table(name="PHONE")</code> annotation to the entity.</p>
-<p>Now you are ready to <a href="getting_started013.htm#BABEBGBC">Create OR mappings</a>.</p>
-</div>
-<!-- class="sect3" -->
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started013.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started013.htm
deleted file mode 100644
index ded417ade2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started013.htm
+++ /dev/null
@@ -1,58 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:14 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create OR mappings</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Create OR mappings" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABEBGBC" name="BABEBGBC"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Create OR mappings</h1>
-<p>Now you're ready to map the attributes of each persistent entity to columns in the appropriate database table. For the tutorial application, you will use the following mapping types:</p>
-<ul>
-<li>
-<p>ID mappings</p>
-</li>
-<li>
-<p>Basic mappings</p>
-</li>
-<li>
-<p>One-to-one mappings</p>
-</li>
-<li>
-<p>Many-to-one mappings</p>
-</li>
-<li>
-<p>One-to-many mappings</p>
-</li>
-<li>
-<p>Version mappings</p>
-</li>
-</ul>
-<p>Next, you will <a href="getting_started014.htm#BABGEFDI">Create ID mappings</a>.</p>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started014.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started014.htm
deleted file mode 100644
index f1833c7663..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started014.htm
+++ /dev/null
@@ -1,126 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:14 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create ID mappings</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Create ID mappings" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABGEFDI" name="BABGEFDI"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Create ID mappings</h1>
-<p>Use an <span class="bold">ID Mapping</span> to specify the primary key of an entity. Each persistent entity must have an ID. Notice that the Problems view reports that each entity is missing an ID.</p>
-<ol start="1">
-<li>
-<p>Select the <span class="bold">Employee</span> entity in the Package Explorer view.</p>
-</li>
-<li>
-<p>Expand the <span class="bold">Employee</span> entity in the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a> and select the <span class="bold">id</span> field. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the field.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">ID</span>.</p>
-<div class="figure"><a id="sthref27" name="sthref27"></a>
-<p class="titleinfigure">ID Mapping for emp_id Field</p>
-<img src="img/persistence_view_empid.png" alt="JPA Details view for the emp_id field." title="JPA Details view for the emp_id field." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>Use this table to complete the remaining fields in the <span class="gui-object-title">JPA Details</span> view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Persistence Properties view for this mapping." summary="This table lists the fields in the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t6">Property</th>
-<th align="left" valign="bottom" id="r1c2-t6">Description</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t6" headers="r1c1-t6">Map As</td>
-<td align="left" headers="r2c1-t6 r1c2-t6">Defines this mapping as an <span class="bold">ID Mapping</span>. Dali adds the <code>@Id</code> annotation to the entity.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t6" headers="r1c1-t6">Column</td>
-<td align="left" headers="r3c1-t6 r1c2-t6">The database column for the primary key of the table associated with the entity. Select <span class="bold">EMP_ID</span>.
-<p>Because the database column (EMP_ID) is named differently than the entity field (id), Dali adds the <code>@Column(name="EMP_ID"</code>) annotation.</p>
-</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-<li>
-<p>Leave all other fields on the tab as their defaults. Expand the <span class="bold">Primary Key Generation</span> area.</p>
-<div class="figure"><a id="sthref28" name="sthref28"></a>
-<p class="titleinfigure">Primary Key Generation for emp_id Field</p>
-<img src="img/persistence_view_empid_pk.png" alt="JPA Details view (with Primary Key options) for the emp_id field." title="JPA Details view (with Primary Key options) for the emp_id field." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>Use this table to complete the Primary Key Generation fields in the <span class="gui-object-title">JPA Details</span> view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Persistence Properties view for this mapping." summary="This table lists the fields in the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t7">Property</th>
-<th align="left" valign="bottom" id="r1c2-t7">Description</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t7" headers="r1c1-t7">Generated Value</td>
-<td align="left" headers="r2c1-t7 r1c2-t7">These fields define how the primary key is generated.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t7" headers="r1c1-t7">&nbsp;&nbsp;Strategy</td>
-<td align="left" headers="r3c1-t7 r1c2-t7">For the tutorial project, use the <span class="bold">Auto</span> option.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t7" headers="r1c1-t7">&nbsp;&nbsp;Generator&nbsp;Name</td>
-<td align="left" headers="r4c1-t7 r1c2-t7">Leave this field blank.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-</ol>
-<p>In the JPA Structure view, the <span class="bold">id</span> field is identified as the primary key by the following icon:</p>
-<div class="figure"><a id="sthref29" name="sthref29"></a>
-<p class="titleinfigure">JPA Structure for Employee Entity</p>
-<img src="img/persistence_outline_empid.png" alt="emp_id attribute of the Employee entity in the JPA Structure view." title="emp_id attribute of the Employee entity in the JPA Structure view." /><br /></div>
-<!-- class="figure" -->
-<p>Repeat this procedure to map the following primary keys (as shown in <a href="getting_started007.htm#BABDEFDF">Table: Tutorial Database Schema</a>):</p>
-<ul>
-<li>
-<p>The <span class="bold">id</span> field of the <span class="bold">Address</span> entity to the ADDRESS_ID column of the ADDRESS table.</p>
-</li>
-<li>
-<p>The <span class="bold">number</span> field of the <span class="bold">PhoneNumber</span> entity to the P_NUMBER column of the PHONE table.</p>
-</li>
-</ul>
-<p>Next, you will <a href="getting_started015.htm#BABEEFJA">Create basic mappings</a>.</p>
-</div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started015.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started015.htm
deleted file mode 100644
index f84eb027cd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started015.htm
+++ /dev/null
@@ -1,127 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:15 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create basic mappings</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Create basic mappings" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABEEFJA" name="BABEEFJA"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Create basic mappings</h1>
-<p>Use a <span class="bold">Basic Mapping</span> to map an attribute directly to a database column. In the <a href="getting_started006.htm#BABIDCBA">Tutorial Object Model</a>, the <span class="bold">firstName</span> field of the <span class="bold">Employee</span> class maps directly to the F_NAME column of the EMPLOYEE database table.</p>
-<ol start="1">
-<li>
-<p>Select the <span class="bold">Employee</span> entity in the Package Explorer view.</p>
-</li>
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the <span class="bold">firstName</span> field of the <span class="bold">Employee</span> entity. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the field.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">Basic</span>. In the Column field, select <span class="bold">F_NAME</span>.</p>
-<div class="figure"><a id="sthref30" name="sthref30"></a>
-<p class="titleinfigure">Basic Mapping for firstName</p>
-<img src="img/persistence_view_firstname.png" alt="JPA Details view for the firstName field." title="JPA Details view for the firstName field." /><br /></div>
-<!-- class="figure" --></li>
-</ol>
-<p>Dali adds the <code>@Column(name="F_NAME")</code> annotation to the entity. In the JPA Structure, the <span class="bold">firstName</span> field is identified as a basic mapping as shown in the following figure:</p>
-<div class="figure"><a id="sthref31" name="sthref31"></a>
-<p class="titleinfigure">JPA Structure for Employee Entity</p>
-<img src="img/persistence_outline_fname.png" alt="The firstName attribute of the Employee entity in the JPA Structure view." title="The firstName attribute of the Employee entity in the JPA Structure view." /><br /></div>
-<!-- class="figure" -->
-<p>Repeat this procedure to map each of the following fields as <span class="bold">Basic</span> mappings:</p>
-<ul>
-<li>
-<p>Employee entity</p>
-<ul>
-<li>
-<p><span class="bold">lastName</span> field to L_NAME column</p>
-</li>
-</ul>
-</li>
-<li>
-<p>Address Entity</p>
-<ul>
-<li>
-<p><span class="bold">city</span> field to CITY column</p>
-</li>
-<li>
-<p><span class="bold">country</span> field to COUNTRY column</p>
-</li>
-<li>
-<p><span class="bold">postalCode</span> field to P_CODE column</p>
-</li>
-<li>
-<p><span class="bold">stateOrProvice</span> field to PROVINCE column</p>
-</li>
-<li>
-<p><span class="bold">street</span> field to STREET column</p>
-</li>
-</ul>
-<div align="center">
-<div class="inftblnote"><br />
-<table class="Note oac_no_warn" summary="" cellpadding="3" cellspacing="0">
-<tbody>
-<tr>
-<td align="left">
-<p class="notep1">Note:</p>
-Because the <span class="bold">city</span>, <span class="bold">country</span>, and <span class="bold">street</span> fields are named identically to their database columns, Dali automatically maps the fields; no annotations are required.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblnote" --></div>
-</li>
-<li>
-<p>Phone Entity</p>
-<ul>
-<li>
-<p><span class="bold">areaCode</span> field to AREA_CODE column</p>
-</li>
-<li>
-<p><span class="bold">type</span> field to TYPE column</p>
-</li>
-</ul>
-<div align="center">
-<div class="inftblnote"><br />
-<table class="Note oac_no_warn" summary="" cellpadding="3" cellspacing="0">
-<tbody>
-<tr>
-<td align="left">
-<p class="notep1">Note:</p>
-Because the <span class="bold">type</span> field is named identically to its database column, Dali automatically maps the field. No annotation is required.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblnote" --></div>
-</li>
-</ul>
-<p>Next, you will <a href="getting_started016.htm#BABGBGHF">Create one-to-one mappings</a>.</p>
-</div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started016.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started016.htm
deleted file mode 100644
index 0f604093dd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started016.htm
+++ /dev/null
@@ -1,83 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:15 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create one-to-one mappings</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Create one-to-one mappings" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABGBGHF" name="BABGBGHF"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Create one-to-one mappings</h1>
-<p>Use a <span class="bold">One-to-One Mapping</span> to define a relationship from an attribute to another class, with one-to-one multiplicity to a database column. In the <a href="getting_started006.htm#BABIDCBA">Tutorial Object Model</a>, the <span class="bold">address</span> field of the <span class="bold">Employee</span> class has a one-to-one relationship to the <span class="bold">Address</span> class; each employee may have a single address.</p>
-<ol start="1">
-<li>
-<p>Select the <span class="bold">Employee</span> entity in the Package Explorer view.</p>
-</li>
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the <span class="bold">address</span> field of the <span class="bold">Employee</span> entity. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the field.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">One-to-One</span>.</p>
-<div class="figure"><a id="sthref32" name="sthref32"></a>
-<p class="titleinfigure">One-to-one Mapping for address</p>
-<img src="img/persistence_view_onetoone.png" alt="JPA Details view for the address field." title="JPA Details view for the address field." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>For the Target Entity, click <span class="bold">Browse</span> and select the <span class="bold">Address</span> persistent entity. Dali adds the <code>@OneToOne(targetEntity=dali.tutorial.model.Address.class)</code> entity to the class.</p>
-<p>Leave the other fields with their default values.</p>
-</li>
-<li>
-<p>Select the <span class="bold">Override Default</span> option to specify the relationship between the Employee and Address entities. Because you had to explicitly define the ID field for the Address entity in its ID mapping, you will need to edit the default join relationship.</p>
-</li>
-<li>
-<p>Select the <span class="bold">address_ADDRESS_ID -&gt; ADDRESS_ID</span> relationship in the <span class="gui-object-title">Join Columns</span> area and click <span class="bold">Edit</span>.</p>
-</li>
-<li>
-<p>In the Edit Join Column dialog, select the following options and click <span class="bold">OK</span>.</p>
-<ul>
-<li>
-<p>Name: <span class="bold">ADDR_ID</span> (from the EMPLOYEE table)</p>
-</li>
-<li>
-<p>Referenced Column Name: <span class="bold">ADDRESS_ID</span> (from the ADDRESS table)</p>
-</li>
-</ul>
-<div class="figure"><a id="sthref33" name="sthref33"></a>
-<p class="titleinfigure">Editing Join Column for Address Mapping</p>
-<img src="img/edit_join_column_dialog.png" alt="Edit Join Column dialog for the address 1:1 mapping." title="Edit Join Column dialog for the address 1:1 mapping." /><br /></div>
-<!-- class="figure" --></li>
-</ol>
-<p>In the JPA Structure, the <span class="bold">address</span> field is identified as a one-to-one mapping, as shown in the following figure:</p>
-<div class="figure"><a id="sthref34" name="sthref34"></a>
-<p class="titleinfigure">JPA Structure for Employee Entity</p>
-<img src="img/persistence_outline_address.png" alt="The address attribute of the Employee entity in the JPA Structure view." title="The address attribute of the Employee entity in the JPA Structure view." /><br /></div>
-<!-- class="figure" -->
-<p>Next, you will <a href="getting_started017.htm#BABBEHEG">Create one-to-many mappings</a>.</p>
-</div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started017.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started017.htm
deleted file mode 100644
index f0f394ba4b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started017.htm
+++ /dev/null
@@ -1,65 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:15 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create one-to-many mappings</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Create one-to-many mappings" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABBEHEG" name="BABBEHEG"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Create one-to-many mappings</h1>
-<p>Use a <span class="bold">One-to-Many Mapping</span> to define a relationship from an attribute to another class, with one-to-many multiplicity to a database column. In the <a href="getting_started006.htm#BABIDCBA">Tutorial Object Model</a>, the <span class="bold">phoneNumbers</span> field of the <span class="bold">Employee</span> class has a one-to-many relationship to the <span class="bold">Phone</span> class; each employee may have many phone numbers.</p>
-<ol start="1">
-<li>
-<p>Select the <span class="bold">Employee</span> entity in the Package Explorer view.</p>
-</li>
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the <span class="bold">phoneNumber</span> field of the <span class="bold">Employee</span> entity. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the field.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">One-to-Many</span>.</p>
-<div class="figure"><a id="sthref35" name="sthref35"></a>
-<p class="titleinfigure">One-to-many Mapping for phoneNumbers</p>
-<img src="img/persistence_view_onetomany.png" alt="JPA Details view for the phoneNumbers field." title="JPA Details view for the phoneNumbers field." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>Select <span class="bold">PhoneNumber</span> as the Target Entity. Leave the other fields with their default values.</p>
-</li>
-<li>
-<p>In the Join Table area, notice that Dali has selected the correct joins, based on the foreign key associations in the database tables.</p>
-</li>
-</ol>
-<p>In the JPA Structure, the <span class="bold">phoneNumbers</span> field is identified as a one-to-many mapping as shown in the following figure:</p>
-<div class="figure"><a id="sthref36" name="sthref36"></a>
-<p class="titleinfigure">JPA Structure for Employee Entity</p>
-<img src="img/persistence_outline_phone.png" alt="The phoneNumbers attribute of the Employee entity in the JPA Structure view." title="The phoneNumbers attribute of the Employee entity in the JPA Structure view." /><br /></div>
-<!-- class="figure" -->
-<p>Next, you will <a href="getting_started018.htm#BABCHIHI">Create many-to-one mappings</a>.</p>
-</div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started018.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started018.htm
deleted file mode 100644
index 819702c138..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started018.htm
+++ /dev/null
@@ -1,83 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:15 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create many-to-one mappings</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Create many-to-one mappings" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABCHIHI" name="BABCHIHI"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Create many-to-one mappings</h1>
-<p>Use a <span class="bold">May-to-One Mapping</span> to define a relationship from an attribute to another class, with many-to-one multiplicity to a database column. In the <a href="getting_started006.htm#BABIDCBA">Tutorial Object Model</a>, the <span class="bold">owner</span> field of the <span class="bold">PhoneNumber</span> class has a one-to-many relationship to the <span class="bold">Employee</span> class; there are many phone numbers that each employee may have.</p>
-<p>This is the "back mapping" of the one-to-many mapping you previously defined.</p>
-<ol start="1">
-<li>
-<p>Select the <span class="bold">PhoneNumber</span> entity in the Package Explorer view.</p>
-</li>
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the <span class="bold">owner</span> field of the <span class="bold">PhoneNumber</span> entity. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the field.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">Many to One</span>.</p>
-<div class="figure"><a id="sthref37" name="sthref37"></a>
-<p class="titleinfigure">Many to One Mapping for owner</p>
-<img src="img/persistence_view_manytoone.png" alt="The JPA Details view for the owner field." title="The JPA Details view for the owner field." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>Leave the other fields with their default values. Dali correctly completes the information based on the database structure and previously defined mappings.</p>
-</li>
-<li>
-<p>Use the <span class="bold">Join Columns</span> area to specify the relationship between the PhoneNumber and Employee entities. Because you had to explicitly define the ID field for the Employee entity in its ID mapping, you will need to edit the default join relationship.</p>
-</li>
-<li>
-<p>Select the <span class="bold">Override Default</span> option.</p>
-</li>
-<li>
-<p>Select the <span class="bold">owner_EMP_ID -&gt; EMP_ID</span> relationship in the <span class="gui-object-title">Join Columns</span> area and click <span class="bold">Edit</span>.</p>
-</li>
-<li>
-<p>In the Edit Join Column dialog, select the following options and click <span class="bold">OK</span>.</p>
-<ul>
-<li>
-<p>Name: <span class="bold">EMP_ID</span> (from the PHONE table)</p>
-</li>
-<li>
-<p>Referenced Column Name: <span class="bold">EMP_ID</span> (from the EMPLOYEE table)</p>
-</li>
-</ul>
-</li>
-</ol>
-<p>In the JPA Structure, the <span class="bold">owner</span> field is identified as a many-to-one mapping as shown in the following figure:</p>
-<div class="figure"><a id="sthref38" name="sthref38"></a>
-<p class="titleinfigure">JPA Structure for PhoneNumber Entity</p>
-<img src="img/persistence_outline_owner.png" alt="The owner attribute of the PhoneNumber entity in the JPA Structure view." title="The owner attribute of the PhoneNumber entity in the JPA Structure view." /><br /></div>
-<!-- class="figure" -->
-<p>Next, you will <a href="getting_started019.htm#BABIDFFG">Create version mappings</a></p>
-</div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started019.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started019.htm
deleted file mode 100644
index 634a50bc23..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started019.htm
+++ /dev/null
@@ -1,61 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:15 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create version mappings</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Create version mappings" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABIDFFG" name="BABIDFFG"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Create version mappings</h1>
-<p>Use a <span class="bold">Version Mapping</span> to specify the database field used by a persistent entity for optimistic locking.</p>
-<ol start="1">
-<li>
-<p>Select the <span class="bold">Employee</span> entity in the Package Explorer view.</p>
-</li>
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the <span class="bold">version</span> field of the <span class="bold">Employee</span> entity. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the field.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">Version</span>.</p>
-<div class="figure"><a id="sthref39" name="sthref39"></a>
-<p class="titleinfigure">Version Mapping for version</p>
-<img src="img/persistence_view_version.png" alt="JPA Details view for the version field." title="JPA Details view for the version field." /><br /></div>
-<!-- class="figure" --></li>
-</ol>
-<p>Dali automatically selects the Version column in the EMPLOYEE database table. In the JPA Structure, the <span class="bold">Version</span> field is identified as a version mapping, as shown in the following figure:</p>
-<div class="figure"><a id="sthref40" name="sthref40"></a>
-<p class="titleinfigure">JPA Structure for Employee Entity</p>
-<img src="img/persistence_outline_version.png" alt="The version attribute of the Employee entity in the JPA Structure view." title="The version attribute of the Employee entity in the JPA Structure view." /><br /></div>
-<!-- class="figure" -->
-<p>Congratulations! All of the entities have been successfully mapped.</p>
-</div>
-<!-- class="sect3" -->
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/address_java_open.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/address_java_open.png
deleted file mode 100644
index 7da0417133..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/address_java_open.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_details.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_details.png
deleted file mode 100644
index f96cc3f8b8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_details.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_structure.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_structure.png
deleted file mode 100644
index a18a65652c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_structure.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/button_jpa_perspective.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/button_jpa_perspective.png
deleted file mode 100644
index e0a957185e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/button_jpa_perspective.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/database_explorer.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/database_explorer.png
deleted file mode 100644
index 435be3dcc1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/database_explorer.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/details_entitymappings.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/details_entitymappings.png
deleted file mode 100644
index 5bd48850fd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/details_entitymappings.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/edit_join_column_dialog.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/edit_join_column_dialog.png
deleted file mode 100644
index 9cc32cf47c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/edit_join_column_dialog.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/error_sample.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/error_sample.png
deleted file mode 100644
index 3a4964632c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/error_sample.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/generate_entities.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/generate_entities.png
deleted file mode 100644
index e3cb22b69a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/generate_entities.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_11mapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_11mapping.png
deleted file mode 100644
index 6944826370..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_11mapping.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_1mmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_1mmapping.png
deleted file mode 100644
index 69d3193a5e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_1mmapping.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_basicmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_basicmapping.png
deleted file mode 100644
index b193753e98..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_basicmapping.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddable.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddable.png
deleted file mode 100644
index 645922c306..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddable.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedidmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedidmapping.png
deleted file mode 100644
index 0587544e2d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedidmapping.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedmapping.png
deleted file mode 100644
index 4bef3567ed..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedmapping.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_idmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_idmapping.png
deleted file mode 100644
index 2b2a94becd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_idmapping.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_m1mapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_m1mapping.png
deleted file mode 100644
index a77a01ba6d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_m1mapping.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_mmmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_mmmapping.png
deleted file mode 100644
index 5d5fd1c145..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_mmmapping.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_nonpersistent.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_nonpersistent.png
deleted file mode 100644
index 001ef86ee2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_nonpersistent.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_persistent.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_persistent.png
deleted file mode 100644
index 7ea0b1d53e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_persistent.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_superclass.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_superclass.png
deleted file mode 100644
index 952f11d131..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_superclass.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_transientmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_transientmapping.png
deleted file mode 100644
index 1a70dd9e68..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_transientmapping.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_versionmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_versionmapping.png
deleted file mode 100644
index aa7e0a6f15..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_versionmapping.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_join.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_join.png
deleted file mode 100644
index 22b6875f4d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_join.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_single.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_single.png
deleted file mode 100644
index 3146482609..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_single.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_tab.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_tab.png
deleted file mode 100644
index a9d721fcc4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_tab.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/java_editor_address.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/java_editor_address.png
deleted file mode 100644
index ff7eaa63b0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/java_editor_address.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_details_employee.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_details_employee.png
deleted file mode 100644
index d2c21ce726..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_details_employee.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_facet_dialog.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_facet_dialog.png
deleted file mode 100644
index 81bcf317e0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_facet_dialog.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/new_jpa_project_dialog.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/new_jpa_project_dialog.png
deleted file mode 100644
index 0fb14b17e1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/new_jpa_project_dialog.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/new_project_2.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/new_project_2.png
deleted file mode 100644
index ad3ab04aa9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/new_project_2.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelc.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelc.png
deleted file mode 100644
index 88381a5a80..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelc.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelr.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelr.png
deleted file mode 100644
index 4bbc744806..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelr.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelt.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelt.png
deleted file mode 100644
index 60af21f5ea..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelt.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/open_persistence_editor.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/open_persistence_editor.png
deleted file mode 100644
index b37937c5b4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/open_persistence_editor.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_address.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_address.png
deleted file mode 100644
index bd9351ce90..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_address.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_empid.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_empid.png
deleted file mode 100644
index 90d889fb4f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_empid.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_entity.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_entity.png
deleted file mode 100644
index bbcbb52d28..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_entity.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fields.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fields.png
deleted file mode 100644
index 5a41682f77..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fields.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fname.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fname.png
deleted file mode 100644
index 3b8b032dc2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fname.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_owner.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_owner.png
deleted file mode 100644
index f24fe486b9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_owner.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_phone.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_phone.png
deleted file mode 100644
index 25aca17350..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_phone.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_version.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_version.png
deleted file mode 100644
index 4ba483ed2a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_version.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_view.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_view.png
deleted file mode 100644
index 769aa825e5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_view.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_perspective.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_perspective.png
deleted file mode 100644
index f92ea6422b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_perspective.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_address.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_address.png
deleted file mode 100644
index c186d3fef6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_address.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_addressid.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_addressid.png
deleted file mode 100644
index a7e71ad7ca..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_addressid.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_embedded.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_embedded.png
deleted file mode 100644
index 91affa5e47..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_embedded.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid.png
deleted file mode 100644
index 9c2811abd5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid_pk.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid_pk.png
deleted file mode 100644
index 46fcc69d4f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid_pk.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_employee.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_employee.png
deleted file mode 100644
index 01337ffab0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_employee.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_entity.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_entity.png
deleted file mode 100644
index 0a7685ae3f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_entity.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_firstname.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_firstname.png
deleted file mode 100644
index 67670ff6f0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_firstname.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_manytoone.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_manytoone.png
deleted file mode 100644
index c9f02200b9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_manytoone.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_mappedsprc.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_mappedsprc.png
deleted file mode 100644
index ceb79d9623..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_mappedsprc.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetomany.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetomany.png
deleted file mode 100644
index 148c735293..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetomany.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetoone.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetoone.png
deleted file mode 100644
index 3e2b739dcd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetoone.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_version.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_version.png
deleted file mode 100644
index fea937d9b6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_version.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_xml_editor.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_xml_editor.png
deleted file mode 100644
index b14dc15936..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_xml_editor.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/properties_persistence.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/properties_persistence.png
deleted file mode 100644
index fcc9886484..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/properties_persistence.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/quickstart_project.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/quickstart_project.png
deleted file mode 100644
index c7c066427e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/quickstart_project.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/secondary_tables.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/secondary_tables.png
deleted file mode 100644
index e6a9159fd8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/secondary_tables.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/synchornize_classes.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/synchornize_classes.png
deleted file mode 100644
index bede63b968..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/synchornize_classes.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/table_entity.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/table_entity.png
deleted file mode 100644
index 1aa1dbe059..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/table_entity.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/tutorial_object_model.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/tutorial_object_model.png
deleted file mode 100644
index eb25d7d6fb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/img/tutorial_object_model.png
+++ /dev/null
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/index.xml b/jpa/plugins/org.eclipse.jpt.doc.user/index.xml
deleted file mode 100644
index 53f4f73873..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/index.xml
+++ /dev/null
@@ -1,555 +0,0 @@
-<?xml version='1.0' encoding='iso-8859-1'?>
-<index version="1.0">
- <entry keyword="@Basic">
- <entry keyword="Basic mapping"><topic href="tasks007.htm#sthref116" /></entry>
- </entry>
- <entry keyword="@Column">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref201" /></entry>
- </entry>
- <entry keyword="@DiscriminatorColumn">
- <entry keyword="Specifying entity inheritance"><topic href="task_inheritance.htm#sthref103" /></entry>
- </entry>
- <entry keyword="@DiscriminatorValue">
- <entry keyword="Specifying entity inheritance"><topic href="task_inheritance.htm#sthref105" /></entry>
- </entry>
- <entry keyword="@Embeddable">
- <entry keyword="Embeddable"><topic href="tasks005.htm#sthref86" /></entry>
- </entry>
- <entry keyword="@Embedded">
- <entry keyword="Embedded mapping"><topic href="tasks008.htm#sthref120" /></entry>
- </entry>
- <entry keyword="@EmbeddedId">
- <entry keyword="Embedded ID mapping"><topic href="tasks009.htm#sthref124" /></entry>
- </entry>
- <entry keyword="@Entity">
- <entry keyword="Entity"><topic href="tasks004.htm#sthref80" /></entry>
- </entry>
- <entry keyword="@Enumerated">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref211" /></entry>
- </entry>
- <entry keyword="@GeneratedValue">
- <entry keyword="Primary Key Generation information"><topic href="ref_primary_key.htm#sthref220" /></entry>
- </entry>
- <entry keyword="@Id">
- <entry keyword="ID mapping"><topic href="tasks010.htm#sthref128" /></entry>
- </entry>
- <entry keyword="@Inheritance">
- <entry keyword="Specifying additional tables"><topic href="task_additonal_tables.htm#sthref98" /></entry>
- <entry keyword="Specifying entity inheritance"><topic href="task_inheritance.htm#sthref101" /></entry>
- </entry>
- <entry keyword="@JoinColumn">
- <entry keyword="Many-to-one mapping"><topic href="tasks012.htm#sthref139" /></entry>
- <entry keyword="One-to-one mapping"><topic href="tasks014.htm#sthref149" /></entry>
- <entry keyword="Join Table Information"><topic href="reference007.htm#sthref217" /></entry>
- <entry keyword="Join Columns Information"><topic href="reference008.htm#sthref219" /></entry>
- </entry>
- <entry keyword="@Lob">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref206" /></entry>
- </entry>
- <entry keyword="@ManyToMany">
- <entry keyword="Many-to-many mapping"><topic href="tasks011.htm#sthref132" /></entry>
- </entry>
- <entry keyword="@ManyToOne">
- <entry keyword="Many-to-one mapping"><topic href="tasks012.htm#sthref137" /></entry>
- </entry>
- <entry keyword="@MappedSuperclass">
- <entry keyword="Mapped superclass"><topic href="tasks006.htm#sthref93" /></entry>
- </entry>
- <entry keyword="@OneToMany">
- <entry keyword="One-to-many mapping"><topic href="tasks013.htm#sthref142" /></entry>
- </entry>
- <entry keyword="@OneToOne">
- <entry keyword="One-to-one mapping"><topic href="tasks014.htm#sthref146" /></entry>
- </entry>
- <entry keyword="@OrderBy">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref214" /></entry>
- </entry>
- <entry keyword="@SequenceGenerator">
- <entry keyword="Primary Key Generation information"><topic href="ref_primary_key.htm#sthref222" /></entry>
- </entry>
- <entry keyword="@Temporal">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref208" /></entry>
- </entry>
- <entry keyword="@Transient">
- <entry keyword="Transient mapping"><topic href="tasks015.htm#sthref152" /></entry>
- </entry>
- <entry keyword="@Version">
- <entry keyword="Version mapping"><topic href="tasks016.htm#sthref156" /></entry>
- </entry>
- <entry keyword="architecture of Dali feature">
- <entry keyword="Dali Developer Documentation"><topic href="reference018.htm#sthref244" /></entry>
- </entry>
- <entry keyword="attribute overrides">
- <entry keyword="Attribute overrides"><topic href="reference004.htm#sthref189" /></entry>
- </entry>
- <entry keyword="Attribute Overrides - in Java Details view">
- <entry keyword="Attribute overrides"><topic href="reference004.htm#sthref191" /></entry>
- </entry>
- <entry keyword="attributes">
- <entry keyword="JPA Details view">
- <entry keyword="JPA Details view (for attributes)"><topic href="ref_persistence_map_view.htm#sthref200" /></entry>
- </entry>
- <entry keyword="mapping">
- <entry keyword="Understanding OR mappings"><topic href="concept_mapping.htm#sthref44" /></entry>
- </entry>
- </entry>
- <entry keyword="basic mapping">
- <entry keyword="@Basic">
- <entry keyword="Basic mapping"><topic href="tasks007.htm#sthref117" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="Basic mapping"><topic href="tasks007.htm#sthref115" /></entry>
- </entry>
- <entry keyword="(See also mappings)"></entry>
- </entry>
- <entry keyword="classes">
- <entry keyword="adding persistence to">
- <entry keyword="Adding persistence to a class"><topic href="task_add_persistence.htm#sthref75" /></entry>
- </entry>
- <entry keyword="embeddable">
- <entry keyword="Embeddable"><topic href="tasks005.htm#sthref85" /></entry>
- </entry>
- <entry keyword="entity">
- <entry keyword="Entity"><topic href="tasks004.htm#sthref78" /></entry>
- </entry>
- <entry keyword="mapped superclass">
- <entry keyword="Mapped superclass"><topic href="tasks006.htm#sthref91" /></entry>
- </entry>
- <entry keyword="synchronizing">
- <entry keyword="Synchronizing classes"><topic href="tasks002.htm#sthref65" /></entry>
- </entry>
- </entry>
- <entry keyword="columns">
- <entry keyword="discriminator">
- <entry keyword="Specifying entity inheritance"><topic href="task_inheritance.htm#sthref104" /></entry>
- </entry>
- <entry keyword="join">
- <entry keyword="Many-to-one mapping"><topic href="tasks012.htm#sthref138" /></entry>
- <entry keyword="One-to-one mapping"><topic href="tasks014.htm#sthref148" /></entry>
- <entry keyword="Join Table Information"><topic href="reference007.htm#sthref216" /></entry>
- <entry keyword="Join Columns Information"><topic href="reference008.htm#sthref218" /></entry>
- </entry>
- <entry keyword="mapping to">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref202" /></entry>
- </entry>
- <entry keyword="value">
- <entry keyword="Specifying entity inheritance"><topic href="task_inheritance.htm#sthref106" /></entry>
- </entry>
- </entry>
- <entry keyword="database tables">
- <entry keyword="generating entities from">
- <entry keyword="Generating entities from tables"><topic href="tasks017.htm#sthref162" /></entry>
- </entry>
- </entry>
- <entry keyword="database - persistence">
- <entry keyword="connection">
- <entry keyword="Project Properties page - JPA Options"><topic href="ref_project_properties.htm#sthref231" /></entry>
- </entry>
- <entry keyword="schema">
- <entry keyword="Project Properties page - JPA Options"><topic href="ref_project_properties.htm#sthref233" /></entry>
- </entry>
- </entry>
- <entry keyword="developer documentation - Dali">
- <entry keyword="Dali Developer Documentation"><topic href="reference018.htm#sthref243" /></entry>
- </entry>
- <entry keyword="eager fetch">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref204" /></entry>
- </entry>
- <entry keyword="embeddable class">
- <entry keyword="@Embeddable">
- <entry keyword="Embeddable"><topic href="tasks005.htm#sthref87" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="Embeddable"><topic href="tasks005.htm#sthref84" /></entry>
- </entry>
- </entry>
- <entry keyword="embedded ID mapping">
- <entry keyword="@EmbeddedId">
- <entry keyword="Embedded ID mapping"><topic href="tasks009.htm#sthref125" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="Embedded ID mapping"><topic href="tasks009.htm#sthref123" /></entry>
- </entry>
- </entry>
- <entry keyword="embedded mapping">
- <entry keyword="@Embedded">
- <entry keyword="Embedded mapping"><topic href="tasks008.htm#sthref121" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="Embedded mapping"><topic href="tasks008.htm#sthref119" /></entry>
- </entry>
- </entry>
- <entry keyword="entities">
- <entry keyword="@Entity annotation">
- <entry keyword="Entity"><topic href="tasks004.htm#sthref81" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="Understanding Java persistence"><topic href="concept_persistence.htm#sthref43" /></entry>
- </entry>
- <entry keyword="embeddable">
- <entry keyword="Embeddable"><topic href="tasks005.htm#sthref88" /></entry>
- </entry>
- <entry keyword="from tables">
- <entry keyword="Generating entities from tables"><topic href="tasks017.htm#sthref158" /></entry>
- <entry keyword="Generate Entities from Tables dialog"><topic href="task_generate_entities.htm#sthref237" /></entry>
- </entry>
- <entry keyword="JPA Details view">
- <entry keyword="JPA Details view (for entities)"><topic href="ref_persistence_prop_view.htm#sthref188" /></entry>
- </entry>
- <entry keyword="mapped superclass">
- <entry keyword="Mapped superclass"><topic href="tasks006.htm#sthref94" /></entry>
- </entry>
- <entry keyword="mapping">
- <entry keyword="Mapping an entity"><topic href="getting_started005.htm#sthref18" /></entry>
- </entry>
- <entry keyword="persistence">
- <entry keyword="Creating a Java persistent entity"><topic href="getting_started004.htm#sthref10" /></entry>
- </entry>
- <entry keyword="persistent">
- <entry keyword="Entity"><topic href="tasks004.htm#sthref76" /></entry>
- <entry keyword="Entity"><topic href="tasks004.htm#sthref82" /></entry>
- </entry>
- <entry keyword="secondary tables">
- <entry keyword="Secondary table information"><topic href="reference005.htm#sthref194" /></entry>
- </entry>
- </entry>
- <entry keyword="enumerated">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref210" /></entry>
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref212" /></entry>
- </entry>
- <entry keyword="error messages - Dali">
- <entry keyword="Validating mappings and reporting problems"><topic href="tasks019.htm#sthref163" /></entry>
- <entry keyword="Error messages"><topic href="tasks020.htm#sthref168" /></entry>
- </entry>
- <entry keyword="extension points - Dali feature">
- <entry keyword="Dali Developer Documentation"><topic href="reference018.htm#sthref245" /></entry>
- </entry>
- <entry keyword="fetch type">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref203" /></entry>
- </entry>
- <entry keyword="Generate Entities from Tables dialog">
- <entry keyword="Generating entities from tables"><topic href="tasks017.htm#sthref161" /></entry>
- <entry keyword="Generate Entities from Tables dialog"><topic href="task_generate_entities.htm#sthref236" /></entry>
- </entry>
- <entry keyword="generated values">
- <entry keyword="ID mappings">
- <entry keyword="Primary Key Generation information"><topic href="ref_primary_key.htm#sthref221" /></entry>
- </entry>
- <entry keyword="sequence">
- <entry keyword="Primary Key Generation information"><topic href="ref_primary_key.htm#sthref223" /></entry>
- </entry>
- </entry>
- <entry keyword="ID mapping">
- <entry keyword="@Id">
- <entry keyword="ID mapping"><topic href="tasks010.htm#sthref129" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="ID mapping"><topic href="tasks010.htm#sthref127" /></entry>
- </entry>
- </entry>
- <entry keyword="inheritance">
- <entry keyword="entity">
- <entry keyword="Specifying additional tables"><topic href="task_additonal_tables.htm#sthref97" /></entry>
- <entry keyword="Specifying entity inheritance"><topic href="task_inheritance.htm#sthref100" /></entry>
- <entry keyword="Inheritance information"><topic href="reference006.htm#sthref197" /></entry>
- </entry>
- <entry keyword="joined tables">
- <entry keyword="Specifying entity inheritance"><topic href="task_inheritance.htm#sthref112" /></entry>
- </entry>
- <entry keyword="single table">
- <entry keyword="Specifying entity inheritance"><topic href="task_inheritance.htm#sthref107" /></entry>
- </entry>
- </entry>
- <entry keyword="Inheritance - in Java Details view">
- <entry keyword="Inheritance information"><topic href="reference006.htm#sthref196" /></entry>
- </entry>
- <entry keyword="installation - Dali">
- <entry keyword="Requirements and installation"><topic href="getting_started001.htm#sthref3" /></entry>
- </entry>
- <entry keyword="joined tables - inheritance">
- <entry keyword="Specifying entity inheritance"><topic href="task_inheritance.htm#sthref113" /></entry>
- </entry>
- <entry keyword="JPA Details view">
- <entry keyword="attributes">
- <entry keyword="JPA Details view (for attributes)"><topic href="ref_persistence_map_view.htm#sthref198" /></entry>
- </entry>
- <entry keyword="entities">
- <entry keyword="JPA Details view (for entities)"><topic href="ref_persistence_prop_view.htm#sthref186" /></entry>
- </entry>
- </entry>
- <entry keyword="JPA Development perspective">
- <entry keyword="JPA Development perspective"><topic href="ref_persistence_perspective.htm#sthref239" /></entry>
- </entry>
- <entry keyword="JPA Facet dialog">
- <entry keyword="Creating a new JPA project"><topic href="task_create_new_project.htm#sthref56" /></entry>
- </entry>
- <entry keyword="JPA project">
- <entry keyword="creating new">
- <entry keyword="Creating a new JPA project"><topic href="task_create_new_project.htm#sthref50" /></entry>
- </entry>
- <entry keyword="platform">
- <entry keyword="Project Properties page - JPA Options"><topic href="ref_project_properties.htm#sthref230" /></entry>
- </entry>
- </entry>
- <entry keyword="JPA Project dialog">
- <entry keyword="Creating a new JPA project"><topic href="task_create_new_project.htm#sthref54" /></entry>
- </entry>
- <entry keyword="JPA Structure view">
- <entry keyword="JPA Structure view"><topic href="ref_persistence_outline.htm#sthref225" /></entry>
- </entry>
- <entry keyword="lazy fetch">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref205" /></entry>
- </entry>
- <entry keyword="many-to-many mapping">
- <entry keyword="@ManyToMany">
- <entry keyword="Many-to-many mapping"><topic href="tasks011.htm#sthref133" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="Many-to-many mapping"><topic href="tasks011.htm#sthref131" /></entry>
- </entry>
- </entry>
- <entry keyword="many-to-one mapping">
- <entry keyword="@ManyToOne">
- <entry keyword="Many-to-one mapping"><topic href="tasks012.htm#sthref136" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="Many-to-one mapping"><topic href="tasks012.htm#sthref135" /></entry>
- </entry>
- </entry>
- <entry keyword="mapped superclass">
- <entry keyword="@MappedSuperclass">
- <entry keyword="Mapped superclass"><topic href="tasks006.htm#sthref92" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="Mapped superclass"><topic href="tasks006.htm#sthref90" /></entry>
- </entry>
- </entry>
- <entry keyword="mapping entities">
- <entry keyword="Mapping an entity"><topic href="getting_started005.htm#sthref17" /></entry>
- </entry>
- <entry keyword="mappings">
- <entry keyword="about">
- <entry keyword="Understanding OR mappings"><topic href="concept_mapping.htm#sthref45" /></entry>
- </entry>
- <entry keyword="basic">
- <entry keyword="Basic mapping"><topic href="tasks007.htm#sthref114" /></entry>
- </entry>
- <entry keyword="embedded">
- <entry keyword="Embedded mapping"><topic href="tasks008.htm#sthref118" /></entry>
- </entry>
- <entry keyword="embedded ID">
- <entry keyword="Embedded ID mapping"><topic href="tasks009.htm#sthref122" /></entry>
- </entry>
- <entry keyword="ID">
- <entry keyword="ID mapping"><topic href="tasks010.htm#sthref126" /></entry>
- </entry>
- <entry keyword="many-to-many">
- <entry keyword="Many-to-many mapping"><topic href="tasks011.htm#sthref130" /></entry>
- </entry>
- <entry keyword="many-to-one">
- <entry keyword="Many-to-one mapping"><topic href="tasks012.htm#sthref134" /></entry>
- </entry>
- <entry keyword="one-to-many">
- <entry keyword="One-to-many mapping"><topic href="tasks013.htm#sthref140" /></entry>
- </entry>
- <entry keyword="one-to-one">
- <entry keyword="One-to-one mapping"><topic href="tasks014.htm#sthref144" /></entry>
- </entry>
- <entry keyword="problems">
- <entry keyword="Validating mappings and reporting problems"><topic href="tasks019.htm#sthref166" /></entry>
- </entry>
- <entry keyword="transient">
- <entry keyword="Transient mapping"><topic href="tasks015.htm#sthref150" /></entry>
- </entry>
- <entry keyword="version">
- <entry keyword="Version mapping"><topic href="tasks016.htm#sthref154" /></entry>
- </entry>
- </entry>
- <entry keyword="New JPA Project wizard">
- <entry keyword="Creating a new JPA project"><topic href="task_create_new_project.htm#sthref52" /></entry>
- </entry>
- <entry keyword="nonpersistent">
- <entry keyword="classes">
- <entry keyword="Adding persistence to a class"><topic href="task_add_persistence.htm#sthref74" /></entry>
- </entry>
- <entry keyword="fields. See transient"></entry>
- </entry>
- <entry keyword="one-to-many mapping">
- <entry keyword="@OneToMany">
- <entry keyword="One-to-many mapping"><topic href="tasks013.htm#sthref143" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="One-to-many mapping"><topic href="tasks013.htm#sthref141" /></entry>
- </entry>
- </entry>
- <entry keyword="one-to-one mapping">
- <entry keyword="@OneToOne">
- <entry keyword="One-to-one mapping"><topic href="tasks014.htm#sthref147" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="One-to-one mapping"><topic href="tasks014.htm#sthref145" /></entry>
- </entry>
- </entry>
- <entry keyword="@OrderBy">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref215" /></entry>
- </entry>
- <entry keyword="ordering">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref213" /></entry>
- </entry>
- <entry keyword="orm.xml file">
- <entry keyword="about">
- <entry keyword="The orm.xml file"><topic href="concepts003.htm#sthref47" /></entry>
- </entry>
- <entry keyword="managing">
- <entry keyword="Managing the orm.xml file"><topic href="task_manage_orm.htm#sthref68" /></entry>
- </entry>
- <entry keyword="sample">
- <entry keyword="Managing the orm.xml file"><topic href="task_manage_orm.htm#sthref69" /></entry>
- </entry>
- </entry>
- <entry keyword="overrides - JPA attributes">
- <entry keyword="Attribute overrides"><topic href="reference004.htm#sthref190" /></entry>
- </entry>
- <entry keyword="persistence">
- <entry keyword="about">
- <entry keyword="Understanding Java persistence"><topic href="concept_persistence.htm#sthref42" /></entry>
- </entry>
- <entry keyword="database connection">
- <entry keyword="Project Properties page - JPA Options"><topic href="ref_project_properties.htm#sthref232" /></entry>
- </entry>
- <entry keyword="database schema">
- <entry keyword="Project Properties page - JPA Options"><topic href="ref_project_properties.htm#sthref235" /></entry>
- </entry>
- <entry keyword="entity class">
- <entry keyword="Adding persistence to a class"><topic href="task_add_persistence.htm#sthref73" /></entry>
- </entry>
- <entry keyword="options">
- <entry keyword="Project Properties page - JPA Options"><topic href="ref_project_properties.htm#sthref227" /></entry>
- </entry>
- </entry>
- <entry keyword="Persistence XML Editor">
- <entry keyword="Working with persistence.xml file"><topic href="tasks001.htm#sthref62" /></entry>
- </entry>
- <entry keyword="persistence.xml file">
- <entry keyword="about">
- <entry keyword="The persistence.xml file"><topic href="concepts002.htm#sthref46" /></entry>
- </entry>
- <entry keyword="editor">
- <entry keyword="Working with persistence.xml file"><topic href="tasks001.htm#sthref63" /></entry>
- </entry>
- <entry keyword="managing">
- <entry keyword="Managing the persistence.xml file"><topic href="task_manage_persistence.htm#sthref57" /></entry>
- <entry keyword="Working with persistence.xml file"><topic href="tasks001.htm#sthref60" /></entry>
- <entry keyword="Working with orm.xml file"><topic href="tasks003.htm#sthref71" /></entry>
- </entry>
- <entry keyword="sample">
- <entry keyword="Managing the persistence.xml file"><topic href="task_manage_persistence.htm#sthref58" /></entry>
- </entry>
- <entry keyword="synchronizing with classes">
- <entry keyword="Synchronizing classes"><topic href="tasks002.htm#sthref66" /></entry>
- </entry>
- </entry>
- <entry keyword="persistent entity">
- <entry keyword="Entity"><topic href="tasks004.htm#sthref77" /></entry>
- </entry>
- <entry keyword="perspective - JPA Development">
- <entry keyword="JPA Development perspective"><topic href="ref_persistence_perspective.htm#sthref240" /></entry>
- </entry>
- <entry keyword="platform - JPA">
- <entry keyword="Project Properties page - JPA Options"><topic href="ref_project_properties.htm#sthref229" /></entry>
- </entry>
- <entry keyword="problems">
- <entry keyword="Validating mappings and reporting problems"><topic href="tasks019.htm#sthref165" /></entry>
- </entry>
- <entry keyword="projects - JPA">
- <entry keyword="creating new">
- <entry keyword="Creating a new project"><topic href="getting_started003.htm#sthref6" /></entry>
- <entry keyword="Creating a new JPA project"><topic href="task_create_new_project.htm#sthref49" /></entry>
- </entry>
- <entry keyword="options">
- <entry keyword="Project Properties page - JPA Options"><topic href="ref_project_properties.htm#sthref228" /></entry>
- </entry>
- </entry>
- <entry keyword="quick start - Dali">
- <entry keyword="Dali quick start"><topic href="getting_started002.htm#sthref5" /></entry>
- </entry>
- <entry keyword="requirements">
- <entry keyword="Dali Java Persistence Tools">
- <entry keyword="Requirements and installation"><topic href="getting_started001.htm#sthref4" /></entry>
- </entry>
- <entry keyword="persistent entities">
- <entry keyword="Entity"><topic href="tasks004.htm#sthref79" /></entry>
- </entry>
- </entry>
- <entry keyword="schema - database">
- <entry keyword="Project Properties page - JPA Options"><topic href="ref_project_properties.htm#sthref234" /></entry>
- </entry>
- <entry keyword="secondary tables">
- <entry keyword="Secondary table information"><topic href="reference005.htm#sthref192" /></entry>
- </entry>
- <entry keyword="Secondary Tables - in Java Details view">
- <entry keyword="Secondary table information"><topic href="reference005.htm#sthref195" /></entry>
- </entry>
- <entry keyword="single table inheritance">
- <entry keyword="Specifying entity inheritance"><topic href="task_inheritance.htm#sthref108" /></entry>
- </entry>
- <entry keyword="superclass">
- <entry keyword="Mapped superclass"><topic href="tasks006.htm#sthref95" /></entry>
- </entry>
- <entry keyword="tables">
- <entry keyword="creating entities from">
- <entry keyword="Generating entities from tables"><topic href="tasks017.htm#sthref159" /></entry>
- <entry keyword="Generate Entities from Tables dialog"><topic href="task_generate_entities.htm#sthref238" /></entry>
- </entry>
- <entry keyword="inheritance">
- <entry keyword="Specifying entity inheritance"><topic href="task_inheritance.htm#sthref109" /></entry>
- </entry>
- <entry keyword="secondary">
- <entry keyword="Secondary table information"><topic href="reference005.htm#sthref193" /></entry>
- </entry>
- </entry>
- <entry keyword="temporal">
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref207" /></entry>
- <entry keyword="General information"><topic href="ref_mapping_general.htm#sthref209" /></entry>
- </entry>
- <entry keyword="transient mapping">
- <entry keyword="@Transient">
- <entry keyword="Transient mapping"><topic href="tasks015.htm#sthref153" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="Transient mapping"><topic href="tasks015.htm#sthref151" /></entry>
- </entry>
- </entry>
- <entry keyword="tutorial - Dali">
- <entry keyword="Dali basic tutorial"><topic href="getting_started006.htm#sthref21" /></entry>
- </entry>
- <entry keyword="version mapping">
- <entry keyword="@Version">
- <entry keyword="Version mapping"><topic href="tasks016.htm#sthref157" /></entry>
- </entry>
- <entry keyword="about">
- <entry keyword="Version mapping"><topic href="tasks016.htm#sthref155" /></entry>
- </entry>
- </entry>
- <entry keyword="views">
- <entry keyword="JPA Details view">
- <entry keyword="JPA Details view (for entities)"><topic href="ref_persistence_prop_view.htm#sthref187" /></entry>
- <entry keyword="JPA Details view (for attributes)"><topic href="ref_persistence_map_view.htm#sthref199" /></entry>
- </entry>
- <entry keyword="JPA Structure view">
- <entry keyword="JPA Structure view"><topic href="ref_persistence_outline.htm#sthref224" /></entry>
- </entry>
- </entry>
- <entry keyword="warning messages - Dali">
- <entry keyword="Validating mappings and reporting problems"><topic href="tasks019.htm#sthref164" /></entry>
- </entry>
- <entry keyword="wizards">
- <entry keyword="New JPA Project wizard">
- <entry keyword="Creating a new JPA project"><topic href="task_create_new_project.htm#sthref51" /></entry>
- </entry>
- </entry>
- <entry keyword="XML editor">
- <entry keyword="Working with persistence.xml file"><topic href="tasks001.htm#sthref59" /></entry>
- <entry keyword="Working with orm.xml file"><topic href="tasks003.htm#sthref70" /></entry>
- </entry>
-</index>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/legal.htm b/jpa/plugins/org.eclipse.jpt.doc.user/legal.htm
deleted file mode 100644
index 2aba14978c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/legal.htm
+++ /dev/null
@@ -1,39 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:27 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Legal</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content=" Legal" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="sthref247" name="sthref247"></a></p>
-<h1>Legal</h1>
-<p><a id="sthref248" name="sthref248"></a></p>
-<p class="subhead2">Notices</p>
-<p>The material in this guide is copyright &copy; 2006, 2008 by Oracle.</p>
-<p><a href="about.htm">Terms and conditions regarding the use of this guide.</a></p>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/plugin.properties b/jpa/plugins/org.eclipse.jpt.doc.user/plugin.properties
deleted file mode 100644
index 865c0824a8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/plugin.properties
+++ /dev/null
@@ -1,32 +0,0 @@
-###############################################################################
-# Copyright (c) 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName = Java Persistence Documentation - Doc
-providerName = Eclipse.org
-
-jpaDevelopment=JPA Development
-createAJpaProject=Create a JPA project
-createAJpaProjectDescription=This cheat sheet helps you create a JPA project.
-createAPersistentEntity=Create a persistent entity
-createAPersistentEntityDescription=This cheat sheet helps you create a Java persistent entity.
-MapAPersistentEntity=Map a persistent entity
-MapAPersistentEntityDescription=This cheat sheet helps you map the a Java persistent entity to a database table.
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml b/jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml
deleted file mode 100644
index 2f308f3991..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin name="JPA Documentation Plug-in" id="org.eclipse.jpt.doc.user" version="2.0.0" provider-name="Oracle">
- <!-- =========== -->
- <!-- Define TOC -->
- <!-- =========== -->
- <extension point="org.eclipse.help.toc">
- <toc file="toc.xml" primary="true"/>
- </extension>
- <!-- =========== -->
- <!-- Define F1 -->
- <!-- =========== -->
- <extension point="org.eclipse.help.contexts">
- <contexts file="contexts.xml" plugin="org.eclipse.jpt.ui"/>
- </extension>
- <!-- ==================== -->
- <!-- Define Keyword Index -->
- <!-- ==================== -->
- <extension point="org.eclipse.help.index">
- <index file="index.xml"/>
- </extension>
- <!-- =========== -->
- <!-- Cheatsheets -->
- <!-- =========== -->
- <extension point="org.eclipse.ui.cheatsheets.cheatSheetContent">
- <category name="%jpaDevelopment" id="com.jpa.category"/>
- <cheatsheet name="%createAJpaProject" category="com.jpa.category" contentFile="$nl$/cheatsheets/add_persistence.xml" id="org.eclipse.jpa.cheatsheet.createproject1">
- <description>%createAJpaProjectDescription</description>
- </cheatsheet>
- <cheatsheet name="%createAPersistentEntity" category="com.jpa.category" contentFile="$nl$/cheatsheets/create_entity.xml" id="org.eclipse.jpa.cheatsheet.addentity">
- <description>%createAPersistentEntityDescription</description>
- </cheatsheet>
- <cheatsheet name="%MapAPersistentEntity" category="com.jpa.category" contentFile="$nl$/cheatsheets/map_entity.xml" id="org.eclipse.jpa.cheatsheet.mapentity">
- <description>%MapAPersistentEntityDescription</description>
- </cheatsheet>
- </extension>
-</plugin>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_details_orm.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_details_orm.htm
deleted file mode 100644
index db57f7c447..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_details_orm.htm
+++ /dev/null
@@ -1,46 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:23 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>JPA Details view (for orm.xml)</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="JPA Details view (for orm.xml)" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACGDGHC" name="CACGDGHC"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>JPA Details view (for orm.xml)</h1>
-<p>The <span class="gui-object-title">JPA Details</span> view displays the default mapping and persistence information for the project and contains the following areas:</p>
-<ul>
-<li>
-<p><a href="reference009.htm#CACCACGH">General information</a></p>
-</li>
-<li>
-<p><a href="reference010.htm#CACEAGBG">Persistence Unit information</a></p>
-</li>
-</ul>
-<p>These defaults can be overridden by the settings on a specific entity or mapping.</p>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_jpa_facet.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_jpa_facet.htm
deleted file mode 100644
index 6856b16155..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_jpa_facet.htm
+++ /dev/null
@@ -1,85 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:22 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>JPA Facet page</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="JPA Facet page" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACIFDIF" name="CACIFDIF"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>JPA Facet page</h1>
-<p>This table lists the properties available on the JPA Facet page of the <a href="ref_new_jpa_project_wizard.htm#CACBJGBG">Create New JPA Project wizard</a>.</p>
-<div class="inftblinformal">
-<table class="Informal" title="This table describes the options on the Generate DDL - Objects page." summary="This table describes the options on the Generate DDL - Objects page." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t3">Property</th>
-<th align="left" valign="bottom" id="r1c2-t3">Description</th>
-<th align="left" valign="bottom" id="r1c3-t3">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t3" headers="r1c1-t3">Platform</td>
-<td align="left" headers="r2c1-t3 r1c2-t3">Vendor-specific JPA implementation.</td>
-<td align="left" headers="r2c1-t3 r1c3-t3">Generic</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t3" headers="r1c1-t3">Connection</td>
-<td align="left" headers="r3c1-t3 r1c2-t3">Select the database connection to use with the project. Dali requires an active database connection to use and validate the persistent entities and mappings.
-<p>Click <span class="bold">Add connection</span> to create a new database connection.</p>
-</td>
-<td align="left" headers="r3c1-t3 r1c3-t3"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t3" headers="r1c1-t3">JPA Implementation</td>
-<td align="left" headers="r4c1-t3 r1c2-t3">Select to use the <span class="bold">JPA implementation provided by the server at runtime</span>, or select a specific <span class="bold">implementation library</span> that contain the Java Persistence API (JPA) and entities to be added to the project's Java Build Path.
-<p>Click <span class="bold">Configure default JPA implementation library</span> to create a default library for the project or click <span class="bold">Configure user libraries</span> to define additional libraries.</p>
-</td>
-<td align="left" headers="r4c1-t3 r1c3-t3">Determined by server.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t3" headers="r1c1-t3">Persistent class management</td>
-<td align="left" headers="r5c1-t3 r1c2-t3">Specify if Dali will <span class="bold">discover annotated classes automatically</span>, or if the <span class="bold">annotated classes must be listed in the persistence.xml</span> file.
-<p><span class="bold">Note</span>: To insure application portability, you should explicitly list the managed persistence classes that are included in the persistence unit.</p>
-</td>
-<td align="left" headers="r5c1-t3 r1c3-t3">Determined by server.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r6c1-t3" headers="r1c1-t3">Create orm.xml</td>
-<td align="left" headers="r6c1-t3 r1c2-t3">Specify if Dali should create a default <code>orm.xml</code> file for your entity mappings and persistence unit defaults.</td>
-<td align="left" headers="r6c1-t3 r1c3-t3">Selected</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblinformal" --></div>
-<!-- class="sect3" -->
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_mapping_general.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_mapping_general.htm
deleted file mode 100644
index 80bc4813a5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_mapping_general.htm
+++ /dev/null
@@ -1,225 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:23 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>General information</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="General information" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACBHFIJ" name="CACBHFIJ"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>General information</h1>
-<p>This table lists the General properties available in the <span class="gui-object-title">Java Details view</span> for each mapping type.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table describes the options on the Persistence Properties view." summary="This table describes the options on the Persistence Properties view." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t7">Property</th>
-<th align="left" valign="bottom" id="r1c2-t7">Description</th>
-<th align="left" valign="bottom" id="r1c3-t7">Default</th>
-<th align="left" valign="bottom" id="r1c4-t7">Available for Mapping Type</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t7" headers="r1c1-t7">Map As</td>
-<td align="left" headers="r2c1-t7 r1c2-t7">Define the mapping type for the attribute</td>
-<td align="left" headers="r2c1-t7 r1c3-t7">Basic</td>
-<td align="left" headers="r2c1-t7 r1c4-t7">All mapping types</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t7" headers="r1c1-t7"><a id="CACGCBHB" name="CACGCBHB"></a>Column</td>
-<td align="left" headers="r3c1-t7 r1c2-t7"><a id="sthref201" name="sthref201"></a><a id="sthref202" name="sthref202"></a>The database column that contains the value for the attribute. This field corresponds to the <code>@Column</code> annotation.</td>
-<td align="left" headers="r3c1-t7 r1c3-t7">By default, the Column is assumed to be named identically to the attribute.</td>
-<td align="left" headers="r3c1-t7 r1c4-t7"><a href="tasks007.htm#BABBABCE">Basic mapping</a>, <a href="tasks008.htm#BABCBHDF">Embedded mapping</a>, <a href="tasks010.htm#BABGCBHG">ID mapping</a>, <a href="tasks016.htm#BABHIBII">Version mapping</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t7" headers="r1c1-t7">&nbsp;&nbsp;Name</td>
-<td align="left" headers="r4c1-t7 r1c2-t7">Name of the database column.
-<p>This field corresponds to the <code>@Column</code> annotation.</p>
-</td>
-<td align="left" headers="r4c1-t7 r1c3-t7"><br /></td>
-<td align="left" headers="r4c1-t7 r1c4-t7"><a href="tasks007.htm#BABBABCE">Basic mapping</a>, <a href="tasks008.htm#BABCBHDF">Embedded mapping</a>, <a href="tasks010.htm#BABGCBHG">ID mapping</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t7" headers="r1c1-t7">&nbsp;&nbsp;Table</td>
-<td align="left" headers="r5c1-t7 r1c2-t7">Name of the database table that contains the selected column.</td>
-<td align="left" headers="r5c1-t7 r1c3-t7"><br /></td>
-<td align="left" headers="r5c1-t7 r1c4-t7"><a href="tasks007.htm#BABBABCE">Basic mapping</a>, <a href="tasks008.htm#BABCBHDF">Embedded mapping</a>, <a href="tasks010.htm#BABGCBHG">ID mapping</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r6c1-t7" headers="r1c1-t7">&nbsp;&nbsp;Insertable</td>
-<td align="left" headers="r6c1-t7 r1c2-t7">Specifies if the column is always included in <code>SQL INSERT</code> statements.</td>
-<td align="left" headers="r6c1-t7 r1c3-t7">True</td>
-<td align="left" headers="r6c1-t7 r1c4-t7"><a href="tasks007.htm#BABBABCE">Basic mapping</a>, <a href="tasks008.htm#BABCBHDF">Embedded mapping</a>, <a href="tasks010.htm#BABGCBHG">ID mapping</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r7c1-t7" headers="r1c1-t7">&nbsp;&nbsp;Updatable</td>
-<td align="left" headers="r7c1-t7 r1c2-t7">Specifies if this column is always included in <code>SQL UPDATE</code> statements.</td>
-<td align="left" headers="r7c1-t7 r1c3-t7">True</td>
-<td align="left" headers="r7c1-t7 r1c4-t7"><a href="tasks007.htm#BABBABCE">Basic mapping</a>, <a href="tasks008.htm#BABCBHDF">Embedded mapping</a>, <a href="tasks010.htm#BABGCBHG">ID mapping</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r8c1-t7" headers="r1c1-t7"><a id="CACGGGHB" name="CACGGGHB"></a><a id="sthref203" name="sthref203"></a><a id="sthref204" name="sthref204"></a><a id="sthref205" name="sthref205"></a>Fetch Type</td>
-<td align="left" headers="r8c1-t7 r1c2-t7">Defines how data is loaded from the database:
-<ul>
-<li>
-<p>Eager &ndash; Data is loaded in before it is actually needed.</p>
-</li>
-<li>
-<p>Lazy &ndash; Data is loaded only when required by the transaction.</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r8c1-t7 r1c3-t7">Eager</td>
-<td align="left" headers="r8c1-t7 r1c4-t7"><a href="tasks007.htm#BABBABCE">Basic mapping</a>, <a href="tasks014.htm#BABFHBCJ">One-to-one mapping</a>, <a href="tasks011.htm#BABEIEGD">Many-to-many mapping</a>, <a href="tasks012.htm#BABHFAFJ">Many-to-one mapping</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r9c1-t7" headers="r1c1-t7">Optional</td>
-<td align="left" headers="r9c1-t7 r1c2-t7">Specifies if this field is can be null.</td>
-<td align="left" headers="r9c1-t7 r1c3-t7">Yes</td>
-<td align="left" headers="r9c1-t7 r1c4-t7"><a href="tasks007.htm#BABBABCE">Basic mapping</a>, <a href="tasks014.htm#BABFHBCJ">One-to-one mapping</a>, <a href="tasks012.htm#BABHFAFJ">Many-to-one mapping</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r10c1-t7" headers="r1c1-t7"><a id="CACBBIBI" name="CACBBIBI"></a><a id="sthref206" name="sthref206"></a>Lob</td>
-<td align="left" headers="r10c1-t7 r1c2-t7">Specify if the field is mapped to <code>java.sql.Clob</code> or <code>java.sql.Blob</code>.
-<p>This field corresponds to the <code>@Lob</code> annotation.</p>
-</td>
-<td align="left" headers="r10c1-t7 r1c3-t7"><br /></td>
-<td align="left" headers="r10c1-t7 r1c4-t7"><a href="tasks007.htm#BABBABCE">Basic mapping</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r11c1-t7" headers="r1c1-t7"><a id="CACEAJGD" name="CACEAJGD"></a><a id="sthref207" name="sthref207"></a><a id="sthref208" name="sthref208"></a><a id="sthref209" name="sthref209"></a>Temporal</td>
-<td align="left" headers="r11c1-t7 r1c2-t7">Specifies if this field is one of the following:
-<ul>
-<li>
-<p>Date &ndash; <code>java.sql.Date</code></p>
-</li>
-<li>
-<p>Time &ndash; <code>java.sql.Time</code></p>
-</li>
-<li>
-<p>Timestamp &ndash; <code>java.sql.Timestamp</code></p>
-</li>
-</ul>
-<p>This field corresponds to the <code>@Temporal</code> annotation.</p>
-</td>
-<td align="left" headers="r11c1-t7 r1c3-t7"><br /></td>
-<td align="left" headers="r11c1-t7 r1c4-t7"><a href="tasks007.htm#BABBABCE">Basic mapping</a>, <a href="tasks010.htm#BABGCBHG">ID mapping</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r12c1-t7" headers="r1c1-t7"><a id="sthref210" name="sthref210"></a><a id="sthref211" name="sthref211"></a><a id="sthref212" name="sthref212"></a>Enumerated</td>
-<td align="left" headers="r12c1-t7 r1c2-t7">Specify how to persist enumerated constraints if the <code>String</code> value suits your application requirements or to match an existing database schema.
-<ul>
-<li>
-<p>ordinal</p>
-</li>
-<li>
-<p><code>String</code></p>
-</li>
-</ul>
-<p>This field corresponds to the <code>@Enumerated</code> annotation.</p>
-</td>
-<td align="left" headers="r12c1-t7 r1c3-t7">Ordinal</td>
-<td align="left" headers="r12c1-t7 r1c4-t7"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r13c1-t7" headers="r1c1-t7">Target Entity</td>
-<td align="left" headers="r13c1-t7 r1c2-t7">The persistent entity to which the attribute is mapped.</td>
-<td align="left" headers="r13c1-t7 r1c3-t7"><br /></td>
-<td align="left" headers="r13c1-t7 r1c4-t7"><a href="tasks014.htm#BABFHBCJ">One-to-one mapping</a>, <a href="tasks013.htm#BABHGEBD">One-to-many mapping</a> <a href="tasks011.htm#BABEIEGD">Many-to-many mapping</a>, <a href="tasks012.htm#BABHFAFJ">Many-to-one mapping</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r14c1-t7" headers="r1c1-t7"><a id="CACJAIHB" name="CACJAIHB"></a>Cascade Type</td>
-<td align="left" headers="r14c1-t7 r1c2-t7">Specify which operations are propagated throughout the entity.
-<ul>
-<li>
-<p>All &ndash; All operations</p>
-</li>
-<li>
-<p>Persist</p>
-</li>
-<li>
-<p>Merge</p>
-</li>
-<li>
-<p>Move</p>
-</li>
-<li>
-<p>Remove</p>
-</li>
-<li>
-<p>Refresh</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r14c1-t7 r1c3-t7"><br /></td>
-<td align="left" headers="r14c1-t7 r1c4-t7"><a href="tasks014.htm#BABFHBCJ">One-to-one mapping</a>, <a href="tasks013.htm#BABHGEBD">One-to-many mapping</a>, <a href="tasks011.htm#BABEIEGD">Many-to-many mapping</a>, <a href="tasks012.htm#BABHFAFJ">Many-to-one mapping</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r15c1-t7" headers="r1c1-t7"><a id="CACJDJJA" name="CACJDJJA"></a>Mapped By</td>
-<td align="left" headers="r15c1-t7 r1c2-t7">The field in the database table that "owns" the relationship. This field is required only on the non-owning side of the relationship.</td>
-<td align="left" headers="r15c1-t7 r1c3-t7"><br /></td>
-<td align="left" headers="r15c1-t7 r1c4-t7"><a href="tasks014.htm#BABFHBCJ">One-to-one mapping</a>, <a href="tasks013.htm#BABHGEBD">One-to-many mapping</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r16c1-t7" headers="r1c1-t7"><a id="CACDADIH" name="CACDADIH"></a><a id="sthref213" name="sthref213"></a><a id="sthref214" name="sthref214"></a><a id="sthref215" name="sthref215"></a>Order By</td>
-<td align="left" headers="r16c1-t7 r1c2-t7">Specify the default order for objects returned from a query:
-<ul>
-<li>
-<p>No ordering</p>
-</li>
-<li>
-<p>Primary key</p>
-</li>
-<li>
-<p>Custom ordering</p>
-</li>
-</ul>
-<p>This field corresponds to the <code>@OrderBy</code> annotation.</p>
-</td>
-<td align="left" headers="r16c1-t7 r1c3-t7">Primary key</td>
-<td align="left" headers="r16c1-t7 r1c4-t7"><a href="tasks013.htm#BABHGEBD">One-to-many mapping</a>. <a href="tasks011.htm#BABEIEGD">Many-to-many mapping</a>, <a href="tasks012.htm#BABHFAFJ">Many-to-one mapping</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r17c1-t7" headers="r1c1-t7">Attribute Overrides</td>
-<td align="left" headers="r17c1-t7 r1c2-t7">Overrides <span class="bold">Basic</span> mappings of a mapped superclass (for example, if the inherited column name is incompatible with a pre-existing data model, or invalid as a column name in your database).</td>
-<td align="left" headers="r17c1-t7 r1c3-t7"><br /></td>
-<td align="left" headers="r17c1-t7 r1c4-t7"><a href="tasks008.htm#BABCBHDF">Embedded mapping</a>
-<p><a href="tasks008.htm#BABCBHDF">Embedded mapping</a></p>
-<br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" -->
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a></div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project.htm
deleted file mode 100644
index 13e1e4a5c5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project.htm
+++ /dev/null
@@ -1,85 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:22 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>New JPA Project page</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="New JPA Project page" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACBJAGC" name="CACBJAGC"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>New JPA Project page</h1>
-<p>This table lists the properties available on the New JPA Project page of the <a href="ref_new_jpa_project_wizard.htm#CACBJGBG">Create New JPA Project wizard</a>.</p>
-<div class="inftblinformal">
-<table class="Informal" title="This table describes the options on the Generate DDL - Objects page." summary="This table describes the options on the Generate DDL - Objects page." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t2">Property</th>
-<th align="left" valign="bottom" id="r1c2-t2">Description</th>
-<th align="left" valign="bottom" id="r1c3-t2">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t2" headers="r1c1-t2">Project name</td>
-<td align="left" headers="r2c1-t2 r1c2-t2">Name of the Eclipse JPA project.</td>
-<td align="left" headers="r2c1-t2 r1c3-t2"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t2" headers="r1c1-t2">Project contents</td>
-<td align="left" headers="r3c1-t2 r1c2-t2">Location of the workspace in which to save the project.
-<p>Unselect The <span class="bold">Use Default</span> option and click <span class="bold">Browse</span> to select a new location.</p>
-</td>
-<td align="left" headers="r3c1-t2 r1c3-t2">Current workspace</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t2" headers="r1c1-t2">Target runtime</td>
-<td align="left" headers="r4c1-t2 r1c2-t2">Select a pre-defined target for the project.
-<p>Click <span class="bold">New</span> to create a new environment with the New Server Runtime wizard.</p>
-</td>
-<td align="left" headers="r4c1-t2 r1c3-t2"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t2" headers="r1c1-t2">Configurations</td>
-<td align="left" headers="r5c1-t2 r1c2-t2">Select a project configuration with pre-defined facets.
-<p>Select <span class="bold">&lt;custom&gt;</span> to manually select the facets for this project.</p>
-</td>
-<td align="left" headers="r5c1-t2 r1c3-t2">Utility JPA project with Java 5.0</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r6c1-t2" headers="r1c1-t2">EAR membership</td>
-<td align="left" headers="r6c1-t2 r1c2-t2">Specify if this project should be included in an EAR file for deployment.
-<p>Select the <span class="bold">EAR Project Name</span>, or click <span class="bold">New</span> to create a new EAR project.</p>
-</td>
-<td align="left" headers="r6c1-t2 r1c3-t2"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblinformal" --></div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project_wizard.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project_wizard.htm
deleted file mode 100644
index 5c9e07f901..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project_wizard.htm
+++ /dev/null
@@ -1,48 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:22 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create New JPA Project wizard</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Create New JPA Project wizard" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACBJGBG" name="CACBJGBG"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Create New JPA Project wizard</h1>
-<p>The Create New JPA Project wizard allows you to create a new Java project using JPA. The wizard consists of the following pages:</p>
-<ul>
-<li>
-<p><a href="ref_new_jpa_project.htm#CACBJAGC">New JPA Project page</a></p>
-</li>
-<li>
-<p>Project Facets page</p>
-</li>
-<li>
-<p><a href="ref_jpa_facet.htm#CACIFDIF">JPA Facet page</a></p>
-</li>
-</ul>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_map_view.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_map_view.htm
deleted file mode 100644
index e67cc91f6d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_map_view.htm
+++ /dev/null
@@ -1,51 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:23 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>JPA Details view (for attributes)</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="JPA Details view (for attributes)" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABIFBAF" name="BABIFBAF"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>JPA Details view (for attributes)</h1>
-<p><a id="sthref198" name="sthref198"></a><a id="sthref199" name="sthref199"></a><a id="sthref200" name="sthref200"></a>The <span class="gui-object-title">JPA Details</span> view displays the persistence information for the currently selected mapped attribute and contains the following areas:</p>
-<ul>
-<li>
-<p><a href="ref_mapping_general.htm#CACBHFIJ">General information</a></p>
-</li>
-<li>
-<p><a href="reference007.htm#CACBAEBC">Join Table Information</a></p>
-</li>
-<li>
-<p><a href="reference008.htm#CACFCEJC">Join Columns Information</a></p>
-</li>
-<li>
-<p><a href="ref_primary_key.htm#CACFCCAB">Primary Key Generation information</a></p>
-</li>
-</ul>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_outline.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_outline.htm
deleted file mode 100644
index 3fb1a5b75f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_outline.htm
+++ /dev/null
@@ -1,49 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:24 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>JPA Structure view</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="JPA Structure view" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABEGGFE" name="BABEGGFE"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>JPA Structure view</h1>
-<p><a id="sthref224" name="sthref224"></a><a id="sthref225" name="sthref225"></a>The <span class="gui-object-title">JPA Structure</span> view displays an outline of the structure (its attributes and mappings) of the entity that is currently selected or opened in the editor. The structural elements shown in the outline are the entity and its fields.</p>
-<div class="figure"><a id="sthref226" name="sthref226"></a>
-<p class="titleinfigure">Sample JPA Structure View</p>
-<img src="img/persistence_outline_view.png" alt="Sample JPA Structure view for an entity." title="Sample JPA Structure view for an entity." /><br /></div>
-<!-- class="figure" -->
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_perspective.htm#BABIFBDB">JPA Development perspective</a>
-<p>&nbsp;</p>
-</div>
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_perspective.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_perspective.htm
deleted file mode 100644
index 90d5375605..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_perspective.htm
+++ /dev/null
@@ -1,59 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:24 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>JPA Development perspective</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="JPA Development perspective" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABIFBDB" name="BABIFBDB"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>JPA Development perspective</h1>
-<p><a id="sthref239" name="sthref239"></a><a id="sthref240" name="sthref240"></a>The <span class="bold">JPA Development perspective</span> defines the initial set and layout of views in the Workbench window when using Dali. By default, the <span class="gui-object-title">JPA Development perspective</span> includes the following vies:</p>
-<ul>
-<li>
-<p><a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a></p>
-</li>
-<li>
-<p><a href="ref_persistence_prop_view.htm#BABFAEBB">JPA Details view (for entities)</a></p>
-</li>
-<li>
-<p><a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a></p>
-</li>
-<li>
-<p><a href="ref_details_orm.htm#CACGDGHC">JPA Details view (for orm.xml)</a></p>
-</li>
-</ul>
-<div class="figure"><a id="sthref241" name="sthref241"></a>
-<p class="titleinfigure">Sample JPA Development Perspective</p>
-<img src="img/persistence_perspective.png" alt="JPA Development perspective with the JPA Structure and JPA Details views." title="JPA Development perspective with the JPA Structure and JPA Details views." /><br /></div>
-<!-- class="figure" -->
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<p><a href="../org.eclipse.platform.doc.user/concepts/concepts-4.htm">Perspectives</a></p>
-</div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_prop_view.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_prop_view.htm
deleted file mode 100644
index 5ca6c45250..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_prop_view.htm
+++ /dev/null
@@ -1,51 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:22 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>JPA Details view (for entities)</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="JPA Details view (for entities)" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABFAEBB" name="BABFAEBB"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>JPA Details view (for entities)</h1>
-<p><a id="sthref186" name="sthref186"></a><a id="sthref187" name="sthref187"></a><a id="sthref188" name="sthref188"></a>The <span class="gui-object-title">JPA Details</span> view displays the persistence information for the currently selected entity and contains the following tabs:</p>
-<ul>
-<li>
-<p><a href="reference003.htm#CACCAGGC">General information</a></p>
-</li>
-<li>
-<p><a href="reference004.htm#CACIJBGH">Attribute overrides</a></p>
-</li>
-<li>
-<p><a href="reference005.htm#CACBHIDA">Secondary table information</a></p>
-</li>
-<li>
-<p><a href="reference006.htm#CACFHGHE">Inheritance information</a></p>
-</li>
-</ul>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_primary_key.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_primary_key.htm
deleted file mode 100644
index 36c6e5c6d1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_primary_key.htm
+++ /dev/null
@@ -1,138 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:23 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Primary Key Generation information</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Primary Key Generation information" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACFCCAB" name="CACFCCAB"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Primary Key Generation information</h1>
-<p>This table lists the fields available in the <span class="gui-object-title">Primary Key Generation</span> area in JPA Details view for <a href="tasks010.htm#BABGCBHG">ID mapping</a> types.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table describes the options on the Join Columns tab." summary="This table describes the options on the Join Columns tab." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t10">Property</th>
-<th align="left" valign="bottom" id="r1c2-t10">Description</th>
-<th align="left" valign="bottom" id="r1c3-t10">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t10" headers="r1c1-t10"><a id="CACBAJBC" name="CACBAJBC"></a>Primary Key Generation</td>
-<td align="left" headers="r2c1-t10 r1c2-t10"><a id="sthref220" name="sthref220"></a><a id="sthref221" name="sthref221"></a>These fields define how the primary key is generated. These fields correspond to the <code>@GeneratedValue</code> annotation.</td>
-<td align="left" headers="r2c1-t10 r1c3-t10">Generated Value</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t10" headers="r1c1-t10"><a id="CACJEEEC" name="CACJEEEC"></a>&nbsp;&nbsp;&nbsp;Strategy</td>
-<td align="left" headers="r3c1-t10 r1c2-t10">
-<ul>
-<li>Auto</li>
-<li>
-<p>Identity &ndash; Values are assigned by the database's <span class="bold">Identity</span> column.</p>
-</li>
-<li>
-<p>Sequence &ndash; Values are assigned by a sequence table (see <a href="#CACFFHEH">Sequence&nbsp;Generator</a>).</p>
-</li>
-<li>
-<p>Table &ndash; Values are assigned by a database table (see <a href="#CACGFEAH">Table Generator</a>).</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r3c1-t10 r1c3-t10">Auto</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t10" headers="r1c1-t10"><a id="BABEEAHJ" name="BABEEAHJ"></a>&nbsp;&nbsp;Generator Name</td>
-<td align="left" headers="r4c1-t10 r1c2-t10">Unique name of the generated value.</td>
-<td align="left" headers="r4c1-t10 r1c3-t10"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t10" headers="r1c1-t10"><a id="CACGFEAH" name="CACGFEAH"></a>Table Generator</td>
-<td align="left" headers="r5c1-t10 r1c2-t10">These fields define the database table used for generating the primary key and correspond to the <code>@TableGenerator</code> annotation.
-<p>These fields apply only when <span class="bold">Strategy</span>&nbsp;=&nbsp;<span class="bold">Table</span>.</p>
-</td>
-<td align="left" headers="r5c1-t10 r1c3-t10"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r6c1-t10" headers="r1c1-t10">&nbsp;&nbsp;Name</td>
-<td align="left" headers="r6c1-t10 r1c2-t10">Unique name of the generator.</td>
-<td align="left" headers="r6c1-t10 r1c3-t10"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r7c1-t10" headers="r1c1-t10">&nbsp;&nbsp;Table</td>
-<td align="left" headers="r7c1-t10 r1c2-t10">Database table that stores the generated ID values.</td>
-<td align="left" headers="r7c1-t10 r1c3-t10"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r8c1-t10" headers="r1c1-t10">&nbsp;&nbsp;Primary Key Column</td>
-<td align="left" headers="r8c1-t10 r1c2-t10">The column in the table generator's <span class="bold">Table</span> that contains the primary key.</td>
-<td align="left" headers="r8c1-t10 r1c3-t10"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r9c1-t10" headers="r1c1-t10">&nbsp;&nbsp;Value Column</td>
-<td align="left" headers="r9c1-t10 r1c2-t10">The column that stores the generated ID values.</td>
-<td align="left" headers="r9c1-t10 r1c3-t10"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r10c1-t10" headers="r1c1-t10">&nbsp;&nbsp;Primary Key Column Value</td>
-<td align="left" headers="r10c1-t10 r1c2-t10">The value for the <span class="bold">Primary Key Column</span> in the generator table.</td>
-<td align="left" headers="r10c1-t10 r1c3-t10"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r11c1-t10" headers="r1c1-t10"><a id="CACFFHEH" name="CACFFHEH"></a>Sequence&nbsp;Generator</td>
-<td align="left" headers="r11c1-t10 r1c2-t10"><a id="sthref222" name="sthref222"></a><a id="sthref223" name="sthref223"></a>These fields define the specific sequence used for generating the primary key and correspond to the <code>@SequenceGenerator</code> annotation.
-<p>These fields apply only when <span class="bold">Strategy</span> = <span class="bold">Sequence</span>.</p>
-</td>
-<td align="left" headers="r11c1-t10 r1c3-t10"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r12c1-t10" headers="r1c1-t10">&nbsp;&nbsp;Name</td>
-<td align="left" headers="r12c1-t10 r1c2-t10">Name of the sequence table to use for defining primary key values.</td>
-<td align="left" headers="r12c1-t10 r1c3-t10"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r13c1-t10" headers="r1c1-t10">&nbsp;&nbsp;Sequence</td>
-<td align="left" headers="r13c1-t10 r1c2-t10">Unique name of the sequence.</td>
-<td align="left" headers="r13c1-t10 r1c3-t10"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" -->
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="tasks010.htm#BABGCBHG">ID mapping</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a></div>
-<!-- class="sect3" -->
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_project_properties.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_project_properties.htm
deleted file mode 100644
index a4466e5c12..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_project_properties.htm
+++ /dev/null
@@ -1,80 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:24 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Project Properties page - JPA Options</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Project Properties page - JPA Options" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABJHBCI" name="BABJHBCI"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Project Properties page &ndash; JPA Options</h1>
-<p><a id="sthref227" name="sthref227"></a><a id="sthref228" name="sthref228"></a>Use the <span class="gui-object-title">JPA</span> options on the <span class="gui-object-title">Properties</span> page to select the database connection to use with the project.</p>
-<p>This table lists the properties available in the <span class="gui-object-title">JPA Details page</span>.</p>
-<div class="inftblinformal">
-<table class="Informal" title="This table describes the options on the Persistence Properties page." summary="This table describes the options on the Persistence Properties page." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t13">Property</th>
-<th align="left" valign="bottom" id="r1c2-t13">Description</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t13" headers="r1c1-t13"><a id="sthref229" name="sthref229"></a><a id="sthref230" name="sthref230"></a><a id="sthref231" name="sthref231"></a><a id="sthref232" name="sthref232"></a>Platform</td>
-<td align="left" headers="r2c1-t13 r1c2-t13">Select the vendor-specific platform.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t13" headers="r1c1-t13"><a id="sthref233" name="sthref233"></a><a id="sthref234" name="sthref234"></a><a id="sthref235" name="sthref235"></a>Connection</td>
-<td align="left" headers="r3c1-t13 r1c2-t13">The database connection used to map the persistent entities.
-<ul>
-<li>
-<p>To create a new connection, click <span class="bold">Add Connections</span>.</p>
-</li>
-<li>
-<p>To reconnect to an existing connection, click <span class="bold">Reconnect</span>.</p>
-</li>
-</ul>
-</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t13" headers="r1c1-t13">Persistent Class Management</td>
-<td align="left" headers="r4c1-t13 r1c2-t13">Specify if Dali will <span class="bold">discover annotated classes automatically</span>, or if the <span class="bold">annotated classes must be listed in the persistence.xml</span> file.
-<p><span class="bold">Note</span>: To insure application portability, you should explicitly list the managed persistence classes that are included in the persistence unit.</p>
-</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblinformal" -->
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="tasks022.htm#BABDBCBI">Modifying persistent project properties</a></div>
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference.htm
deleted file mode 100644
index 3466f0aa26..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference.htm
+++ /dev/null
@@ -1,59 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:22 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Reference</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content=" Reference" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="sthref185" name="sthref185"></a></p>
-<h1>Reference</h1>
-<p>This section includes detailed help information for each of the following elements in the Dali OR Mapping Tool:</p>
-<ul>
-<li>
-<p><a href="reference001.htm#CACJJJJH">Wizards</a></p>
-</li>
-<li>
-<p><a href="reference002.htm#CACDJIIG">Property pages</a></p>
-</li>
-<li>
-<p><a href="reference011.htm#CACDEIEE">Preferences</a></p>
-</li>
-<li>
-<p><a href="reference012.htm#CACGEJDA">Dialogs</a></p>
-</li>
-<li>
-<p><a href="ref_persistence_perspective.htm#BABIFBDB">JPA Development perspective</a></p>
-</li>
-<li>
-<p><a href="reference014.htm#CACDHCIA">Icons and buttons</a></p>
-</li>
-<li>
-<p><a href="reference018.htm#CACBBDIB">Dali Developer Documentation</a></p>
-</li>
-</ul>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm
deleted file mode 100644
index 76eaa1a1a5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm
+++ /dev/null
@@ -1,42 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:22 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Wizards</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Wizards" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACJJJJH" name="CACJJJJH"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Wizards</h1>
-<p>This section includes information on the following wizards:</p>
-<ul>
-<li>
-<p><a href="ref_new_jpa_project_wizard.htm#CACBJGBG">Create New JPA Project wizard</a></p>
-</li>
-</ul>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm
deleted file mode 100644
index a050c21b74..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm
+++ /dev/null
@@ -1,51 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:22 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Property pages</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Property pages" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACDJIIG" name="CACDJIIG"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Property pages</h1>
-<p>This section includes information on the following property pages:</p>
-<ul>
-<li>
-<p><a href="ref_persistence_prop_view.htm#BABFAEBB">JPA Details view (for entities)</a></p>
-</li>
-<li>
-<p><a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a></p>
-</li>
-<li>
-<p><a href="ref_details_orm.htm#CACGDGHC">JPA Details view (for orm.xml)</a></p>
-</li>
-<li>
-<p><a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a></p>
-</li>
-</ul>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm
deleted file mode 100644
index 29c99c0f82..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm
+++ /dev/null
@@ -1,97 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:22 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>General information</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="General information" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACCAGGC" name="CACCAGGC"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>General information</h1>
-<p>This table lists the General information fields available in the <span class="gui-object-title">JPA Details</span> view for each entity type.</p>
-<div class="inftblinformal">
-<table class="Informal" title="This table describes the options on the Persistence Properties view, General tab." summary="This table describes the options on the Persistence Properties view, General tab." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t4">Property</th>
-<th align="left" valign="bottom" id="r1c2-t4">Description</th>
-<th align="left" valign="bottom" id="r1c3-t4">Default</th>
-<th align="left" valign="bottom" id="r1c4-t4">Available for Entity&nbsp;Type</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t4" headers="r1c1-t4">Map As</td>
-<td align="left" headers="r2c1-t4 r1c2-t4">Specify the type of entity: <span class="bold">Entity</span>, Mapped Superclass, Embeddable.</td>
-<td align="left" headers="r2c1-t4 r1c3-t4">Entity</td>
-<td align="left" headers="r2c1-t4 r1c4-t4"><a href="tasks004.htm#BABGBIEE">Entity</a>, <a href="tasks005.htm#BABFEICE">Embeddable</a>, and <a href="tasks006.htm#BABDAGCI">Mapped superclass</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t4" headers="r1c1-t4">Name</td>
-<td align="left" headers="r3c1-t4 r1c2-t4">The name of this entity. By default, the class name is used as the entity name.</td>
-<td align="left" headers="r3c1-t4 r1c3-t4"><br /></td>
-<td align="left" headers="r3c1-t4 r1c4-t4"><a href="tasks004.htm#BABGBIEE">Entity</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t4" headers="r1c1-t4">Table</td>
-<td align="left" headers="r4c1-t4 r1c2-t4">The default database table information for this entity. These fields can be overridden by the information in the <a href="reference004.htm#CACIJBGH">Attribute overrides</a> area.</td>
-<td align="left" headers="r4c1-t4 r1c3-t4"><br /></td>
-<td align="left" headers="r4c1-t4 r1c4-t4"><a href="tasks004.htm#BABGBIEE">Entity</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t4" headers="r1c1-t4">&nbsp;&nbsp;Name</td>
-<td align="left" headers="r5c1-t4 r1c2-t4">The name of the primary database table associated with the entity.</td>
-<td align="left" headers="r5c1-t4 r1c3-t4"><br /></td>
-<td align="left" headers="r5c1-t4 r1c4-t4"><a href="tasks004.htm#BABGBIEE">Entity</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r6c1-t4" headers="r1c1-t4">&nbsp;&nbsp;Catalog</td>
-<td align="left" headers="r6c1-t4 r1c2-t4">The database catalog that contains the <span class="bold">Table</span>.</td>
-<td align="left" headers="r6c1-t4 r1c3-t4">As defined in <code>orm.xml</code>.</td>
-<td align="left" headers="r6c1-t4 r1c4-t4"><a href="tasks004.htm#BABGBIEE">Entity</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r7c1-t4" headers="r1c1-t4">&nbsp;&nbsp;Schema</td>
-<td align="left" headers="r7c1-t4 r1c2-t4">The database schema that contains the <span class="bold">Table</span>.</td>
-<td align="left" headers="r7c1-t4 r1c3-t4">As defined in <code>orm.xml</code>.</td>
-<td align="left" headers="r7c1-t4 r1c4-t4"><a href="tasks004.htm#BABGBIEE">Entity</a><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblinformal" -->
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_prop_view.htm#BABFAEBB">JPA Details view (for entities)</a></div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm
deleted file mode 100644
index fb98972b97..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm
+++ /dev/null
@@ -1,75 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:22 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Attribute overrides</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Attribute overrides" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACIJBGH" name="CACIJBGH"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Attribute overrides</h1>
-<p><a id="sthref189" name="sthref189"></a><a id="sthref190" name="sthref190"></a><a id="sthref191" name="sthref191"></a>Use the <span class="gui-object-title">Attribute Overrides</span> area in the <span class="gui-object-title">Java Details</span> view to override the default settings specified in the <a href="reference003.htm#CACCAGGC">General information</a> area of an attribute.</p>
-<p>This table lists the Attribute override fields available in the <span class="gui-object-title">JPA Details</span> view for each entity type.</p>
-<div class="inftblinformal">
-<table class="Informal" title="This table describes the options on the Persistence Properties view, General tab." summary="This table describes the options on the Persistence Properties view, General tab." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t5">Property</th>
-<th align="left" valign="bottom" id="r1c2-t5">Description</th>
-<th align="left" valign="bottom" id="r1c3-t5">Default</th>
-<th align="left" valign="bottom" id="r1c4-t5">Available for Entity&nbsp;Type</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t5" headers="r1c1-t5">Attribute Overrides</td>
-<td align="left" headers="r2c1-t5 r1c2-t5">Specify a property or field to be overridden (from the default mappings). Select <span class="bold">Override Default</span>.</td>
-<td align="left" headers="r2c1-t5 r1c3-t5"><br /></td>
-<td align="left" headers="r2c1-t5 r1c4-t5"><a href="tasks004.htm#BABGBIEE">Entity</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t5" headers="r1c1-t5">Join Columns</td>
-<td align="left" headers="r3c1-t5 r1c2-t5"><br /></td>
-<td align="left" headers="r3c1-t5 r1c3-t5"><br /></td>
-<td align="left" headers="r3c1-t5 r1c4-t5"><a href="tasks004.htm#BABGBIEE">Entity</a><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblinformal" -->
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="reference003.htm#CACCAGGC">General information</a><br />
-<a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_prop_view.htm#BABFAEBB">JPA Details view (for entities)</a></div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm
deleted file mode 100644
index 172de14dd8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm
+++ /dev/null
@@ -1,47 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:22 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Secondary table information</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Secondary table information" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACBHIDA" name="CACBHIDA"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Secondary table information</h1>
-<p><a id="sthref192" name="sthref192"></a><a id="sthref193" name="sthref193"></a><a id="sthref194" name="sthref194"></a><a id="sthref195" name="sthref195"></a>Use the <span class="gui-object-title">Secondary Tables</span> area in the <span class="gui-object-title">Java Details</span> view to associate additional tables with an entity. Use this area if the data associated with an entity is spread across multiple tables.</p>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_additonal_tables.htm#CIHGBIEI">Specifying additional tables</a><br />
-<a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_prop_view.htm#BABFAEBB">JPA Details view (for entities)</a></div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm
deleted file mode 100644
index d75c4d72ad..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm
+++ /dev/null
@@ -1,101 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:23 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Inheritance information</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Inheritance information" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACFHGHE" name="CACFHGHE"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Inheritance information</h1>
-<p><a id="sthref196" name="sthref196"></a><a id="sthref197" name="sthref197"></a>This table lists the fields available on the <span class="gui-object-title">Inheritance</span> area in the <span class="gui-object-title">Java Details</span> view for each entity type.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table describes the options on the Persistence Properties view, Inheritance tab." summary="This table describes the options on the Persistence Properties view, Inheritance tab." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t6">Property</th>
-<th align="left" valign="bottom" id="r1c2-t6">Description</th>
-<th align="left" valign="bottom" id="r1c3-t6">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t6" headers="r1c1-t6">Strategy</td>
-<td align="left" headers="r2c1-t6 r1c2-t6">Specify the strategy to use when mapping a class or class hierarchy:
-<ul>
-<li>
-<p>Single table &ndash; All classes in the hierarchy are mapped to a single table.</p>
-</li>
-<li>
-<p>Joined &ndash; The root of the hierarchy is mapped to a single table; each child maps to its own table.</p>
-</li>
-<li>
-<p>Table per class &ndash; Each class is mapped to a separate table.</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r2c1-t6 r1c3-t6">Single table</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t6" headers="r1c1-t6">Discriminator Column</td>
-<td align="left" headers="r3c1-t6 r1c2-t6">Use to specify the name of the discriminator column when using a <span class="bold">Single</span> or <span class="bold">Joined</span> inheritance strategy.</td>
-<td align="left" headers="r3c1-t6 r1c3-t6"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t6" headers="r1c1-t6">Discriminator Type</td>
-<td align="left" headers="r4c1-t6 r1c2-t6">Set this field to set the discriminator type to <code>Char</code> or <code>Integer</code> (instead of its default: <code>String</code>). The <span class="bold">Discriminator Value</span> must conform to this type.</td>
-<td align="left" headers="r4c1-t6 r1c3-t6">String</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t6" headers="r1c1-t6">Discriminator Value</td>
-<td align="left" headers="r5c1-t6 r1c2-t6">Specify the discriminator value used to differentiate an entity in this inheritance hierarchy. The value must conform to the specified <span class="bold">Discriminator Type</span>.</td>
-<td align="left" headers="r5c1-t6 r1c3-t6"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r6c1-t6" headers="r1c1-t6">Primary Key Join Columns</td>
-<td align="left" headers="r6c1-t6 r1c2-t6">Use to override the default primary key join columns. Select <span class="bold">Override Default</span>, then click <span class="bold">Add</span> to select new Join Column.
-<p>This field corresponds with @PrimaryKeyJoinColumn annotation.</p>
-</td>
-<td align="left" headers="r6c1-t6 r1c3-t6"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" -->
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_inheritance.htm#CIHCCCJD">Specifying entity inheritance</a><br />
-<a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_prop_view.htm#BABFAEBB">JPA Details view (for entities)</a></div>
-<!-- class="sect3" -->
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm
deleted file mode 100644
index 5c3844baee..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm
+++ /dev/null
@@ -1,78 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:23 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Join Table Information</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Join Table Information" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACBAEBC" name="CACBAEBC"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Join Table Information</h1>
-<p>Use area to specify a mapped column for joining an entity association. By default, the mapping is assumed to have a single join.</p>
-<p>This table lists the fields available on the <span class="gui-object-title">Join Table</span> area in <span class="gui-object-title">the JPA Details</span> view for <a href="tasks013.htm#BABHGEBD">One-to-many mapping</a> and <a href="tasks011.htm#BABEIEGD">Many-to-many mapping</a> mapping types.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table describes the options on the Join Table tab." summary="This table describes the options on the Join Table tab." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t8">Property</th>
-<th align="left" valign="bottom" id="r1c2-t8">Description</th>
-<th align="left" valign="bottom" id="r1c3-t8">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t8" headers="r1c1-t8">Name</td>
-<td align="left" headers="r2c1-t8 r1c2-t8">Name of the join table that contains the foreign key column.</td>
-<td align="left" headers="r2c1-t8 r1c3-t8">By default, the name is assumed to be the primary tables associated with the entities concatenated with an underscore.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t8" headers="r1c1-t8"><a id="CACBBDFG" name="CACBBDFG"></a>Join Columns</td>
-<td align="left" headers="r3c1-t8 r1c2-t8"><a id="sthref216" name="sthref216"></a><a id="sthref217" name="sthref217"></a>Specify a mapped column for joining an entity association. This field corresponds to the <code>@JoinColum</code> attribute.
-<p>Select <span class="bold">Override Default</span>, then Add, Edit, or Remove the join columns.</p>
-</td>
-<td align="left" headers="r3c1-t8 r1c3-t8">By default, the mapping is assumed to have a single join.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t8" headers="r1c1-t8">Inverse Join Columns</td>
-<td align="left" headers="r4c1-t8 r1c2-t8">Select <span class="bold">Override Default</span>, then Add, Edit, or Remove the join columns.</td>
-<td align="left" headers="r4c1-t8 r1c3-t8"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" -->
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="reference013.htm#CACCGEHC">Edit Join Columns Dialog</a></div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm
deleted file mode 100644
index 58f244204d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm
+++ /dev/null
@@ -1,67 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:23 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Join Columns Information</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Join Columns Information" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACFCEJC" name="CACFCEJC"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Join Columns Information</h1>
-<p>This table lists the fields available in the <span class="gui-object-title">Join Table</span> area in <span class="gui-object-title">JPA Details</span> view for <a href="tasks012.htm#BABHFAFJ">Many-to-one mapping</a> and <a href="tasks014.htm#BABFHBCJ">One-to-one mapping</a> mapping types.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table describes the options on the Join Columns tab." summary="This table describes the options on the Join Columns tab." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t9">Property</th>
-<th align="left" valign="bottom" id="r1c2-t9">Description</th>
-<th align="left" valign="bottom" id="r1c3-t9">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t9" headers="r1c1-t9">Join Column</td>
-<td align="left" headers="r2c1-t9 r1c2-t9"><a id="sthref218" name="sthref218"></a><a id="sthref219" name="sthref219"></a>Specify a mapped column for joining an entity association. This field corresponds to the <code>@JoinColum</code> attribute.
-<p>Select <span class="bold">Override Default</span>, then Add, Edit, or Remove the join columns.</p>
-</td>
-<td align="left" headers="r2c1-t9 r1c3-t9">By default, the mapping is assumed to have a single join.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" -->
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="reference013.htm#CACCGEHC">Edit Join Columns Dialog</a></div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm
deleted file mode 100644
index 15924fcd39..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm
+++ /dev/null
@@ -1,94 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:23 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>General information</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="General information" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACCACGH" name="CACCACGH"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>General information</h1>
-<p>This table lists the General information fields available in the <span class="gui-object-title">JPA Details</span> view for each entity type.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table describes the options on the Persistence Properties view, General tab." summary="This table describes the options on the Persistence Properties view, General tab." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t11">Property</th>
-<th align="left" valign="bottom" id="r1c2-t11">Description</th>
-<th align="left" valign="bottom" id="r1c3-t11">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t11" headers="r1c1-t11">Package</td>
-<td align="left" headers="r2c1-t11 r1c2-t11">The Java package that contains the persistent entities. Click <span class="bold">Browse</span> and select the package</td>
-<td align="left" headers="r2c1-t11 r1c3-t11"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t11" headers="r1c1-t11">Schema</td>
-<td align="left" headers="r3c1-t11 r1c2-t11">The database schema that contains the <span class="bold">Table</span>.
-<p>This field corresponds to the <code>&lt;schema&gt;</code> element in the <code>orm.xml</code> file.</p>
-</td>
-<td align="left" headers="r3c1-t11 r1c3-t11"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t11" headers="r1c1-t11">Catalog</td>
-<td align="left" headers="r4c1-t11 r1c2-t11">The database catalog that contains the <span class="bold">Table</span>.
-<p>This field corresponds to the <code>&lt;catalog&gt;</code> element in the <code>orm.xml</code> file.</p>
-</td>
-<td align="left" headers="r4c1-t11 r1c3-t11"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t11" headers="r1c1-t11">Access</td>
-<td align="left" headers="r5c1-t11 r1c2-t11">Specify the default access method for the variables in the project:
-<ul>
-<li>
-<p>Property</p>
-</li>
-<li>
-<p>Field</p>
-</li>
-</ul>
-<p>This field corresponds to the <code>&lt;access&gt;</code> element in the <code>orm.xml</code> file.</p>
-</td>
-<td align="left" headers="r5c1-t11 r1c3-t11"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" -->
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_prop_view.htm#BABFAEBB">JPA Details view (for entities)</a></div>
-<!-- class="sect3" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm
deleted file mode 100644
index b7412b2c7f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm
+++ /dev/null
@@ -1,103 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:24 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Persistence Unit information</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Persistence Unit information" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACEAGBG" name="CACEAGBG"></a></p>
-<div class="sect3"><!-- infolevel="all" infotype="General" -->
-<h1>Persistence Unit information</h1>
-<p>This table lists the Persistence Unit information fields available in the <span class="gui-object-title">JPA Details</span> view for each entity type. These fields are contained in the <code>&lt;persistence-unit-metadata&gt;</code> element in the <code>orm.xml</code> file.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table describes the options on the Persistence Properties view, General tab." summary="This table describes the options on the Persistence Properties view, General tab." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t12">Property</th>
-<th align="left" valign="bottom" id="r1c2-t12">Description</th>
-<th align="left" valign="bottom" id="r1c3-t12">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t12" headers="r1c1-t12">XML Mapping Data Complete</td>
-<td align="left" headers="r2c1-t12 r1c2-t12">Specifies that the Java classes in this persistence unit are fully specified by their metadata. Any annotations will be ignored.
-<p>This field corresponds to the <code>&lt;xml-mapping-metadata-complete&gt;</code> element in the <code>orm.xml</code> file.</p>
-</td>
-<td align="left" headers="r2c1-t12 r1c3-t12"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t12" headers="r1c1-t12">Schema</td>
-<td align="left" headers="r3c1-t12 r1c2-t12">The database schema that contains the <span class="bold">Table</span>.
-<p>This field corresponds to the <code>&lt;schema&gt;</code> element in the <code>orm.xml</code> file.</p>
-</td>
-<td align="left" headers="r3c1-t12 r1c3-t12"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t12" headers="r1c1-t12">Catalog</td>
-<td align="left" headers="r4c1-t12 r1c2-t12">The database catalog that contains the <span class="bold">Table</span>.
-<p>This field corresponds to the <code>&lt;catalog&gt;</code> element in the <code>orm.xml</code> file.</p>
-</td>
-<td align="left" headers="r4c1-t12 r1c3-t12"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t12" headers="r1c1-t12">Access Type</td>
-<td align="left" headers="r5c1-t12 r1c2-t12">Specify how the entity its access instance variables.
-<ul>
-<li>
-<p>Property &ndash; Persistent state accessed through the property accessor methods. The property accessor methods must be <span class="bold">public</span> or <span class="bold">private</span>.</p>
-</li>
-<li>
-<p>Field &ndash; Instance variables are accessed directly. All non-transient instance variables are persistent.</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r5c1-t12 r1c3-t12">Property</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r6c1-t12" headers="r1c1-t12">Cascade Persist</td>
-<td align="left" headers="r6c1-t12 r1c2-t12">Adds cascade-persist to the set of cascade options in entity relationships of the persistence unit.
-<p>This field corresponds to the <code>&lt;cascade-persist&gt;</code> element in the <code>orm.xml</code> file.</p>
-</td>
-<td align="left" headers="r6c1-t12 r1c3-t12"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" -->
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_prop_view.htm#BABFAEBB">JPA Details view (for entities)</a></div>
-<!-- class="sect3" -->
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference011.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference011.htm
deleted file mode 100644
index 72829139c5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference011.htm
+++ /dev/null
@@ -1,42 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:24 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Preferences</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Preferences" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACDEIEE" name="CACDEIEE"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Preferences</h1>
-<p>This section includes information on the following preference pages:</p>
-<ul>
-<li>
-<p><a href="ref_project_properties.htm#BABJHBCI">Project Properties page &ndash; JPA Options</a></p>
-</li>
-</ul>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm
deleted file mode 100644
index 7f13b162d4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm
+++ /dev/null
@@ -1,45 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:24 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Dialogs</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Dialogs" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACGEJDA" name="CACGEJDA"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Dialogs</h1>
-<p>This section includes information on the following preference pages:</p>
-<ul>
-<li>
-<p><a href="task_generate_entities.htm#CACDAFJD">Generate Entities from Tables dialog</a></p>
-</li>
-<li>
-<p><a href="reference013.htm#CACCGEHC">Edit Join Columns Dialog</a></p>
-</li>
-</ul>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm
deleted file mode 100644
index 74a81b6a05..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm
+++ /dev/null
@@ -1,65 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:24 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Edit Join Columns Dialog</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Edit Join Columns Dialog" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACCGEHC" name="CACCGEHC"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Edit Join Columns Dialog</h1>
-<p>Use the <span class="gui-object-title">Join Columns</span> dialog to create or modify the join tables and columns in relationship mappings.</p>
-<p>This table lists the properties available in the <span class="gui-object-title">Join Columns</span> dialog.</p>
-<div class="inftblinformal">
-<table class="Informal" title="This table describes the options on the Join Columns dialog." summary="This table describes the options on the Join Columns dialog." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t15">Property</th>
-<th align="left" valign="bottom" id="r1c2-t15">Description</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t15" headers="r1c1-t15">Name</td>
-<td align="left" headers="r2c1-t15 r1c2-t15">Name of the joint table column that contains the foreign key column.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t15" headers="r1c1-t15">Referenced Column Name</td>
-<td align="left" headers="r3c1-t15 r1c2-t15">Name of the database column that contains the foreign key reference for the entity relationship.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblinformal" -->
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="reference007.htm#CACBAEBC">Join Table Information</a><br />
-<a href="reference008.htm#CACFCEJC">Join Columns Information</a></div>
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm
deleted file mode 100644
index b6ce42a4e7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm
+++ /dev/null
@@ -1,45 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:25 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Icons and buttons</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Icons and buttons" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACDHCIA" name="CACDHCIA"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Icons and buttons</h1>
-<p>This section includes information on each of the icons and buttons used in the Dali OR Mapping Tool.</p>
-<ul>
-<li>
-<p><a href="reference015.htm#CACGEACG">Icons</a></p>
-</li>
-<li>
-<p><a href="reference016.htm#CACDJCEI">Buttons</a></p>
-</li>
-</ul>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm
deleted file mode 100644
index 0216d82d18..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm
+++ /dev/null
@@ -1,110 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:25 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Icons</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Icons" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACGEACG" name="CACGEACG"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Icons</h1>
-<p>The following icons are used throughout the Dali OR Mapping Tool.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table describes the icons used in the Dali plug-in." summary="This table describes the icons used in the Dali plug-in." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t16">Icon</th>
-<th align="left" valign="bottom" id="r1c2-t16">Description</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t16" headers="r1c1-t16"><img src="img/icon_nonpersistent.png" alt="Nonpersistent class icon" title="Nonpersistent class icon" /><br /></td>
-<td align="left" headers="r2c1-t16 r1c2-t16">Nonpersistent class</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t16" headers="r1c1-t16"><img src="img/icon_persistent.png" alt="Persistent entity icon" title="Persistent entity icon" /><br /></td>
-<td align="left" headers="r3c1-t16 r1c2-t16"><a href="tasks004.htm#BABGBIEE">Entity</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t16" headers="r1c1-t16"><img src="img/icon_embeddable.png" alt="Embeddable entity icon" title="Embeddable entity icon" /><br /></td>
-<td align="left" headers="r4c1-t16 r1c2-t16"><a href="tasks005.htm#BABFEICE">Embeddable</a> entity</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t16" headers="r1c1-t16"><img src="img/icon_superclass.png" alt="Mapped superclass icon" title="Mapped superclass icon" /><br /></td>
-<td align="left" headers="r5c1-t16 r1c2-t16"><a href="tasks006.htm#BABDAGCI">Mapped superclass</a></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r6c1-t16" headers="r1c1-t16"><img src="img/icon_basicmapping.png" alt="Basic mapping icon" title="Basic mapping icon" /><br /></td>
-<td align="left" headers="r6c1-t16 r1c2-t16"><a href="tasks007.htm#BABBABCE">Basic mapping</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r7c1-t16" headers="r1c1-t16"><img src="img/icon_embeddedmapping.png" alt="Embedded mapping icon" title="Embedded mapping icon" /><br /></td>
-<td align="left" headers="r7c1-t16 r1c2-t16"><a href="tasks008.htm#BABCBHDF">Embedded mapping</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r8c1-t16" headers="r1c1-t16"><img src="img/icon_embeddedidmapping.png" alt="Embedded ID mapping icon" title="Embedded ID mapping icon" /><br /></td>
-<td align="left" headers="r8c1-t16 r1c2-t16"><a href="tasks009.htm#CIHDIAEE">Embedded ID mapping</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r9c1-t16" headers="r1c1-t16"><img src="img/icon_idmapping.png" alt="ID mapping icon" title="ID mapping icon" /><br /></td>
-<td align="left" headers="r9c1-t16 r1c2-t16"><a href="tasks010.htm#BABGCBHG">ID mapping</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r10c1-t16" headers="r1c1-t16"><img src="img/icon_mmmapping.png" alt="Many-to-many mapping icon" title="Many-to-many mapping icon" /><br /></td>
-<td align="left" headers="r10c1-t16 r1c2-t16"><a href="tasks011.htm#BABEIEGD">Many-to-many mapping</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r11c1-t16" headers="r1c1-t16"><img src="img/icon_m1mapping.png" alt="Many-to-one mapping icon" title="Many-to-one mapping icon" /><br /></td>
-<td align="left" headers="r11c1-t16 r1c2-t16"><a href="tasks012.htm#BABHFAFJ">Many-to-one mapping</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r12c1-t16" headers="r1c1-t16"><img src="img/icon_1mmapping.png" alt="One-to-many mapping icon" title="One-to-many mapping icon" /><br /></td>
-<td align="left" headers="r12c1-t16 r1c2-t16"><a href="tasks013.htm#BABHGEBD">One-to-many mapping</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r13c1-t16" headers="r1c1-t16"><img src="img/icon_11mapping.png" alt="One-to-one mapping icon" title="One-to-one mapping icon" /><br /></td>
-<td align="left" headers="r13c1-t16 r1c2-t16"><a href="tasks014.htm#BABFHBCJ">One-to-one mapping</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r14c1-t16" headers="r1c1-t16"><img src="img/icon_transientmapping.png" alt="Transient mapping icon" title="Transient mapping icon" /><br /></td>
-<td align="left" headers="r14c1-t16 r1c2-t16"><a href="tasks015.htm#BABHFHEI">Transient mapping</a><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r15c1-t16" headers="r1c1-t16"><img src="img/icon_versionmapping.png" alt="Version mapping icon" title="Version mapping icon" /><br /></td>
-<td align="left" headers="r15c1-t16 r1c2-t16"><a href="tasks016.htm#BABHIBII">Version mapping</a><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" -->
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<p><a href="reference014.htm#CACDHCIA">Icons and buttons</a></p>
-</div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm
deleted file mode 100644
index 20fecdb8c9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm
+++ /dev/null
@@ -1,59 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:26 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Buttons</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Buttons" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACDJCEI" name="CACDJCEI"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Buttons</h1>
-<p>The following buttons are used throughout the Dali OR Mapping Tool.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table describes the buttons used in the Dali plug-in." summary="This table describes the buttons used in the Dali plug-in." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t17">Icon</th>
-<th align="left" valign="bottom" id="r1c2-t17">Description</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t17" headers="r1c1-t17"><img src="img/button_jpa_perspective.png" alt="Persistence Perspective button" title="Persistence Perspective button" /><br /></td>
-<td align="left" headers="r2c1-t17 r1c2-t17">JPA Development perspective</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" -->
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<p><a href="reference014.htm#CACDHCIA">Icons and buttons</a></p>
-</div>
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm
deleted file mode 100644
index 974b79defc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm
+++ /dev/null
@@ -1,38 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:26 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Buttons</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Buttons" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<div class="sect1"><!-- infolevel="all" infotype="General" --><a id="sthref242" name="sthref242"></a>
-<h1>Javadoc</h1>
-<p>There is no public API for M5 - Release 2.0.0. Please refer to the <a href="reference018.htm#CACBBDIB">Dali Developer Documentation</a> for additional information.</p>
-</div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference018.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference018.htm
deleted file mode 100644
index 08720097d2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/reference018.htm
+++ /dev/null
@@ -1,52 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:26 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Dali Developer Documentation</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Dali Developer Documentation" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACBBDIB" name="CACBBDIB"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Dali Developer Documentation</h1>
-<p><a id="sthref243" name="sthref243"></a><a id="sthref244" name="sthref244"></a><a id="sthref245" name="sthref245"></a>Additional Dali documentation is available online at:</p>
-<p><code><a href="http://wiki.eclipse.org/index.php/Dali_Developer_Documentation">http://wiki.eclipse.org/index.php/Dali_Developer_Documentation</a></code></p>
-<p>This developer documentation includes information about:</p>
-<ul>
-<li>
-<p>Dali architecture</p>
-</li>
-<li>
-<p>Plugins that comprise the Dali JPA Eclipse feature</p>
-</li>
-<li>
-<p>Extension points</p>
-</li>
-</ul>
-</div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_add_persistence.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_add_persistence.htm
deleted file mode 100644
index 9ca7488621..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/task_add_persistence.htm
+++ /dev/null
@@ -1,59 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:17 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Adding persistence to a class</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Adding persistence to a class" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABHICAI" name="BABHICAI"></a></p>
-<div class="sect1">
-<h1>Adding persistence to a class</h1>
-<p><a id="sthref73" name="sthref73"></a><a id="sthref74" name="sthref74"></a><a id="sthref75" name="sthref75"></a>You can make a Java class into one of the following persistent types:</p>
-<ul>
-<li>
-<p><a href="tasks004.htm#BABGBIEE">Entity</a></p>
-</li>
-<li>
-<p><a href="tasks005.htm#BABFEICE">Embeddable</a></p>
-</li>
-<li>
-<p><a href="tasks006.htm#BABDAGCI">Mapped superclass</a></p>
-</li>
-</ul>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related tasks" title="Related tasks" /><br />
-<br />
-<a href="task_additonal_tables.htm#CIHGBIEI">Specifying additional tables</a><br />
-<a href="task_inheritance.htm#CIHCCCJD">Specifying entity inheritance</a><br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_persistence.htm#BABCAHIC">Understanding Java persistence</a><br />
-<a href="concepts003.htm#CHDBIJAC">The orm.xml file</a><br />
-<a href="concepts002.htm#CHDHAGIH">The persistence.xml file</a> <!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_additonal_tables.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_additonal_tables.htm
deleted file mode 100644
index fffd42b208..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/task_additonal_tables.htm
+++ /dev/null
@@ -1,70 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:17 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Specifying additional tables</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Specifying additional tables" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CIHGBIEI" name="CIHGBIEI"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Specifying additional tables</h1>
-<p><a id="sthref97" name="sthref97"></a><a id="sthref98" name="sthref98"></a>An entity may inherit properties from other entities. You can specify a specific strategy to use for inheritance.</p>
-<p>Use this procedure to specify inheritance (<code>@Inheritance)</code> for an existing entity (<code>@Entity</code>):</p>
-<ol start="1">
-<li>
-<p>Select the entity in the <span class="gui-object-title">Package Explorer</span>.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">JPA Details</span> view, select the <span class="gui-object-action">Secondary Tables</span> information.</p>
-<div class="figure"><a id="sthref99" name="sthref99"></a>
-<p class="titleinfigure">Specifying Secondary Tables</p>
-<img src="img/secondary_tables.png" alt="Secondary Tables area on the JPA Details view." title="Secondary Tables area on the JPA Details view." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>Click <span class="bold">Add</span> to associate an additional table with the entity. The Edit Secondary Table dialog appears</p>
-</li>
-<li>
-<p>Select the <span class="bold">Name</span>, <span class="bold">Catalog</span>, and <span class="bold">Schema</span> of the additional table to associate with the entity.</p>
-</li>
-</ol>
-<p>Eclipse adds the following annotations the entity:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@SecondaryTable(name="NAME", catalog = "CATALOG", schema = "SCHEMA"
-
-</pre>
-<br />
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_persistence.htm#BABCAHIC">Understanding Java persistence</a><br /></div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_create_new_project.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_create_new_project.htm
deleted file mode 100644
index e1dab94b80..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/task_create_new_project.htm
+++ /dev/null
@@ -1,97 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:16 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Creating a new JPA project</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Creating a new JPA project" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CIHHEJCJ" name="CIHHEJCJ"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Creating a new JPA project</h1>
-<p><a id="sthref49" name="sthref49"></a><a id="sthref50" name="sthref50"></a>Use this procedure to create a new JPA project.</p>
-<ol start="1">
-<li>
-<p>Select <span class="bold">File &gt; New &gt; Other</span>. The New Project dialog appears.</p>
-</li>
-<li>
-<p><a id="sthref51" name="sthref51"></a><a id="sthref52" name="sthref52"></a>On the New Project dialog, select <span class="bold">JPA &gt; JPA Project</span> and click <span class="bold">Next</span>. The New JPA Project wizard appears.</p>
-<div class="figure"><a id="sthref53" name="sthref53"></a>
-<p class="titleinfigure"><a id="sthref54" name="sthref54"></a>New JPA Project</p>
-<img src="img/new_jpa_project_dialog.png" alt="The New JPA Project dialog." title="The New JPA Project dialog." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>Complete the fields on the <a href="ref_new_jpa_project.htm#CACBJAGC">New JPA Project page</a> to specify the project name and location, target runtime, and pre-defined configuration.</p>
-</li>
-<li>
-<p>Click <span class="bold">Next</span>. The Project Facets page appears.</p>
-</li>
-<li>
-<p>Select the project facets to use to create the project and click <span class="bold">Next</span>. The JPA Facet page appears.</p>
-<div class="figure"><a id="sthref55" name="sthref55"></a>
-<p class="titleinfigure"><a id="sthref56" name="sthref56"></a>New JPA Project</p>
-<img src="img/jpa_facet_dialog.png" alt="The JPA Facet dialog" title="The JPA Facet dialog" /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>Complete the fields on the <a href="ref_jpa_facet.htm#CACIFDIF">JPA Facet page</a> to specify your vender-specific platform, database connection, and JPA implementation library.</p>
-<div align="center">
-<div class="inftblnote"><br />
-<table class="Note oac_no_warn" summary="" cellpadding="3" cellspacing="0">
-<tbody>
-<tr>
-<td align="left">
-<p class="notep1">Note:</p>
-If the server runtime does not provide a JPA implementation, you must explicitly select a JPA implementation library.
-<p>To insure the portability of your application, you must explicitly list the managed persistence classes that are included in the persistence unit. If the server supports EJB 3.0, the persistent classes will be discovered automatically.</p>
-</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblnote" --></div>
-</li>
-<li>
-<p>Click <span class="bold">Finish</span>. You should now open the <a href="ref_persistence_perspective.htm#BABIFBDB">JPA Development perspective</a>.</p>
-</li>
-</ol>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_new_jpa_project_wizard.htm#CACBJGBG">Create New JPA Project wizard</a><br />
-<a href="ref_persistence_perspective.htm#BABIFBDB">JPA Development perspective</a>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related tasks" title="Related tasks" /><br />
-<br />
-<a href="task_manage_persistence.htm#CIHDAJID">Managing the persistence.xml file</a><br />
-<a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_persistence.htm#BABCAHIC">Understanding Java persistence</a><br />
-<a href="concepts002.htm#CHDHAGIH">The persistence.xml file</a><br /></div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_generate_entities.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_generate_entities.htm
deleted file mode 100644
index 2a15e376ab..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/task_generate_entities.htm
+++ /dev/null
@@ -1,72 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:24 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Generate Entities from Tables dialog</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Generate Entities from Tables dialog" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CACDAFJD" name="CACDAFJD"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Generate Entities from Tables dialog</h1>
-<p><a id="sthref236" name="sthref236"></a><a id="sthref237" name="sthref237"></a><a id="sthref238" name="sthref238"></a>Use the <span class="gui-object-title">Generate Entities</span> dialog to create Java persistent entities from your database tables and columns.</p>
-<p>This table lists the properties available in the <span class="gui-object-title">Generate Entities dialog</span>.</p>
-<div class="inftblinformal">
-<table class="Informal" title="This table describes the options on the Generate Entities dialog." summary="This table describes the options on the Generate Entities dialog." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t14">Property</th>
-<th align="left" valign="bottom" id="r1c2-t14">Description</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t14" headers="r1c1-t14">Source Folder</td>
-<td align="left" headers="r2c1-t14 r1c2-t14">Enter a project folder name in which to generate the Java persistent entities, or click <span class="bold">Browse</span> to select an existing folder.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t14" headers="r1c1-t14">Package</td>
-<td align="left" headers="r3c1-t14 r1c2-t14">Enter a package name in which to generate the Java persistent entities, or click <span class="bold">Browse</span> to select an existing package.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t14" headers="r1c1-t14">Synchronize Classes in persistence.xml</td>
-<td align="left" headers="r4c1-t14 r1c2-t14">Specify if Dali should update the persistence.xml file to include the generated classes.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t14" headers="r1c1-t14">Tables</td>
-<td align="left" headers="r5c1-t14 r1c2-t14">Select the tables from which to create Java persistent entities. The tables shown are determined by the database connection that you defined in the <a href="ref_project_properties.htm#BABJHBCI">Project Properties page &ndash; JPA Options</a>.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblinformal" -->
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<p><a href="tasks017.htm#BABBAGFI">Generating entities from tables</a></p>
-<p>&nbsp;</p>
-</div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm
deleted file mode 100644
index b69c13e561..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm
+++ /dev/null
@@ -1,134 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:18 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Specifying entity inheritance</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Specifying entity inheritance" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CIHCCCJD" name="CIHCCCJD"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Specifying entity inheritance</h1>
-<p><a id="sthref100" name="sthref100"></a><a id="sthref101" name="sthref101"></a>An entity may inherit properties from other entities. You can specify a specific strategy to use for inheritance.</p>
-<p>Use this procedure to specify inheritance (<code>@Inheritance)</code> for an existing entity (<code>@Entity</code>):</p>
-<ol start="1">
-<li>
-<p>Select the entity in the <span class="gui-object-title">Package Explorer</span>.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">JPA Details</span> view, select the <span class="gui-object-action">Inheritance</span> information.</p>
-<div class="figure"><a id="sthref102" name="sthref102"></a>
-<p class="titleinfigure">Specifying Inheritance</p>
-<img src="img/inheritance_tab.png" alt="Selecting the Inheritance area on the JPA Details view." title="Selecting the Inheritance area on the JPA Details view." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>In the <span class="bold">Strategy</span> list, select one of the following the inheritance strategies:</p>
-<ul>
-<li>
-<p>A single table (default)</p>
-</li>
-<li>
-<p>Joined table</p>
-</li>
-<li>
-<p>One table per class</p>
-</li>
-</ul>
-</li>
-<li>
-<p>Use the following table to complete the remaining fields on the tab. See <a href="reference006.htm#CACFHGHE">"Inheritance information"</a> for additional details.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table describes the options on the Persistence Properties view, Inheritance tab." summary="This table describes the options on the Persistence Properties view, Inheritance tab." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t3">Property</th>
-<th align="left" valign="bottom" id="r1c2-t3">Description</th>
-<th align="left" valign="bottom" id="r1c3-t3">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t3" headers="r1c1-t3"><a id="sthref103" name="sthref103"></a><a id="sthref104" name="sthref104"></a>Discriminator Column</td>
-<td align="left" headers="r2c1-t3 r1c2-t3">Name of the discriminator column when using a <span class="bold">Single</span> or <span class="bold">Joined</span> inheritance strategy.
-<p>This field corresponds to the <code>@DiscriminatorColumn</code> annotation.</p>
-</td>
-<td align="left" headers="r2c1-t3 r1c3-t3"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t3" headers="r1c1-t3">Discriminator Type</td>
-<td align="left" headers="r3c1-t3 r1c2-t3">Set the discriminator type to <code>Char</code> or <code>Integer</code> (instead of its default: <code>String</code>). The <span class="bold">Discriminator Value</span> must conform to this type.</td>
-<td align="left" headers="r3c1-t3 r1c3-t3">String</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t3" headers="r1c1-t3"><a id="sthref105" name="sthref105"></a><a id="sthref106" name="sthref106"></a>Discriminator Value</td>
-<td align="left" headers="r4c1-t3 r1c2-t3">Specify the discriminator value used to differentiate an entity in this inheritance hierarchy. The value must conform to the specified <span class="bold">Discriminator Type</span>.
-<p>This field corresponds to the <code>@DiscriminatorValue</code> annotation.</p>
-</td>
-<td align="left" headers="r4c1-t3 r1c3-t3"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t3" headers="r1c1-t3">Override Default</td>
-<td align="left" headers="r5c1-t3 r1c2-t3">Use this field to specify custom primary key join columns.
-<p>This field corresponds to the <code>@PrimaryKeyJoinClumn</code> annotation.</p>
-</td>
-<td align="left" headers="r5c1-t3 r1c3-t3"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-</ol>
-<p>Eclipse adds the following annotations the entity field:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@Inheritance(strategy=InheritanceType.<span class="italic">&lt;INHERITANCE_STRATEGY&gt;</span>)
-@DiscriminatorColumn(name="<span class="italic">&lt;DISCRIMINATOR_COLUMN&gt;</span>",
- discriminatorType=<span class="italic">&lt;DISCRIMINATOR_TYPE&gt;</span>)
-@DiscriminatorValue(value-"<span class="italic">&lt;DISCRIMINATOR_VALUE&gt;</span>")
-@PrimaryKeyJoinColumn(name="<span class="italic">&lt;JOIN_COLUMN_NAME&gt;</span>",
- referencedColumnName = "<span class="italic">&lt;REFERENCED_COLUMN_NAME&gt;</span>")
-
-</pre>
-<p><a id="sthref107" name="sthref107"></a><a id="sthref108" name="sthref108"></a><a id="sthref109" name="sthref109"></a>The following figures illustrates the different inheritance strategies.</p>
-<div class="figure"><a id="sthref110" name="sthref110"></a>
-<p class="titleinfigure">Single Table Inheritance</p>
-<img src="img/inheritance_single.png" alt="This figure illustrates entity inheritance in a single table." title="This figure illustrates entity inheritance in a single table." /><br /></div>
-<!-- class="figure" -->
-<div class="figure"><a id="sthref111" name="sthref111"></a>
-<p class="titleinfigure"><a id="sthref112" name="sthref112"></a><a id="sthref113" name="sthref113"></a>Joined Table Inheritance</p>
-<img src="img/inheritance_join.png" alt="This figure illustrates a joined subclass inheritance strategy." title="This figure illustrates a joined subclass inheritance strategy." /><br /></div>
-<!-- class="figure" -->
-<br />
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_persistence.htm#BABCAHIC">Understanding Java persistence</a><br /></div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_orm.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_orm.htm
deleted file mode 100644
index f893e894f9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_orm.htm
+++ /dev/null
@@ -1,62 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:17 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Managing the orm.xml file</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Managing the orm.xml file" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CIHDGDCD" name="CIHDGDCD"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1><a id="sthref68" name="sthref68"></a>Managing the orm.xml file</h1>
-<p>When creating a JPA project, (see <a href="task_create_new_project.htm#CIHHEJCJ">"Creating a new JPA project"</a>) you can also create the <code>orm.xml</code> file that defines the mapping metadata and defaults.</p>
-<p><a id="sthref69" name="sthref69"></a>Eclipse creates the <code>META-INF\orm.xml</code> file in your project's directory:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-&lt;?xml version="1.0" encoding="UTF-8"?&gt;
-&lt;persistence version="<span class="italic">&lt;PERSISTENCE_VERSION&gt;</span>"
- xmlns="http://java.sun.com/xml/ns/persistence"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
- http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt;
- &lt;persistence-unit name="<span class="italic">&lt;PERSISTENCE_UNIT_NAME&gt;</span>"&gt;
- &lt;provider="<span class="italic">&lt;PERSISTENCE_PROVIDER&gt;</span>" /&gt;
- &lt;/persistence-unit&gt;
-&lt;/persistence&gt;
-</pre>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_new_jpa_project_wizard.htm#CACBJGBG">Create New JPA Project wizard</a>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="tasks003.htm#CIHBCDCE">Working with orm.xml file</a><br />
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concepts003.htm#CHDBIJAC">The orm.xml file</a><br />
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_persistence.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_persistence.htm
deleted file mode 100644
index 0a443efd03..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_persistence.htm
+++ /dev/null
@@ -1,62 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:16 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Managing the persistence.xml file</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Managing the persistence.xml file" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CIHDAJID" name="CIHDAJID"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1><a id="sthref57" name="sthref57"></a>Managing the persistence.xml file</h1>
-<p>When creating a JPA project, (see <a href="task_create_new_project.htm#CIHHEJCJ">"Creating a new JPA project"</a>) you can also create the <code>persistence.xml</code> file.</p>
-<p><a id="sthref58" name="sthref58"></a>Eclipse creates the <code>META-INF\persistence.xml</code> file in your project's directory:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-&lt;?xml version="1.0" encoding="UTF-8"?&gt;
-&lt;persistence version="<span class="italic">&lt;PERSISTENCE_VERSION&gt;</span>"
- xmlns="http://java.sun.com/xml/ns/persistence"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
- http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt;
- &lt;persistence-unit name="<span class="italic">&lt;PERSISTENCE_UNIT_NAME&gt;</span>"&gt;
- &lt;provider="<span class="italic">&lt;PERSISTENCE_PROVIDER&gt;</span>" /&gt;
- &lt;/persistence-unit&gt;
-&lt;/persistence&gt;
-</pre>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_new_jpa_project_wizard.htm#CACBJGBG">Create New JPA Project wizard</a>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="tasks001.htm#CIHEJAIE">Working with persistence.xml file</a><br />
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concepts002.htm#CHDHAGIH">The persistence.xml file</a><br />
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_mapping.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_mapping.htm
deleted file mode 100644
index cca2ca0754..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/task_mapping.htm
+++ /dev/null
@@ -1,72 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:18 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Mapping an entity</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Mapping an entity" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABDGBIJ" name="BABDGBIJ"></a></p>
-<div class="sect1">
-<h1>Mapping an entity</h1>
-<p>Dali supports the following mapping types for Java persistent entities:</p>
-<ul>
-<li>
-<p><a href="tasks007.htm#BABBABCE">Basic mapping</a></p>
-</li>
-<li>
-<p><a href="tasks008.htm#BABCBHDF">Embedded mapping</a></p>
-</li>
-<li>
-<p><a href="tasks009.htm#CIHDIAEE">Embedded ID mapping</a></p>
-</li>
-<li>
-<p><a href="tasks010.htm#BABGCBHG">ID mapping</a></p>
-</li>
-<li>
-<p><a href="tasks011.htm#BABEIEGD">Many-to-many mapping</a></p>
-</li>
-<li>
-<p><a href="tasks012.htm#BABHFAFJ">Many-to-one mapping</a></p>
-</li>
-<li>
-<p><a href="tasks013.htm#BABHGEBD">One-to-many mapping</a></p>
-</li>
-<li>
-<p><a href="tasks014.htm#BABFHBCJ">One-to-one mapping</a></p>
-</li>
-<li>
-<p><a href="tasks015.htm#BABHFHEI">Transient mapping</a></p>
-</li>
-<li>
-<p><a href="tasks016.htm#BABHIBII">Version mapping</a></p>
-</li>
-</ul>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_mapping.htm#BABBDJFI">Understanding OR mappings</a> <!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm
deleted file mode 100644
index e5839b48eb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm
+++ /dev/null
@@ -1,68 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:16 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Tasks</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content=" Tasks" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="sthref48" name="sthref48"></a></p>
-<h1>Tasks</h1>
-<p>This section includes detailed step-by-step procedures for accessing the Dali OR mapping tool functionality.</p>
-<ul>
-<li>
-<p><a href="task_create_new_project.htm#CIHHEJCJ">Creating a new JPA project</a></p>
-</li>
-<li>
-<p><a href="task_manage_persistence.htm#CIHDAJID">Managing the persistence.xml file</a></p>
-</li>
-<li>
-<p><a href="task_manage_orm.htm#CIHDGDCD">Managing the orm.xml file</a></p>
-</li>
-<li>
-<p><a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a></p>
-</li>
-<li>
-<p><a href="task_additonal_tables.htm#CIHGBIEI">Specifying additional tables</a></p>
-</li>
-<li>
-<p><a href="task_inheritance.htm#CIHCCCJD">Specifying entity inheritance</a></p>
-</li>
-<li>
-<p><a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a></p>
-</li>
-<li>
-<p><a href="tasks017.htm#BABBAGFI">Generating entities from tables</a></p>
-</li>
-<li>
-<p><a href="tasks019.htm#BABFAIBA">Validating mappings and reporting problems</a></p>
-</li>
-<li>
-<p><a href="tasks022.htm#BABDBCBI">Modifying persistent project properties</a></p>
-</li>
-</ul>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm
deleted file mode 100644
index fd32537468..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm
+++ /dev/null
@@ -1,61 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:16 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Working with persistence.xml file</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Working with persistence.xml file" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CIHEJAIE" name="CIHEJAIE"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Working with persistence.xml file</h1>
-<p><a id="sthref59" name="sthref59"></a><a id="sthref60" name="sthref60"></a>You can work with the <code>persistence.xml</code> by using the XML Editor.</p>
-<p>Use this procedure to work with the <code>persistence.xml</code> file:</p>
-<ol start="1">
-<li>
-<p>Right-click the <code>persistence.xml</code> file in the <span class="gui-object-title">Package Explorer</span> and select <span class="gui-object-action">Open With &gt; XML Editor</span>.</p>
-<div class="figure"><a id="sthref61" name="sthref61"></a>
-<p class="titleinfigure">Opening the XML Editor</p>
-<img src="img/open_persistence_editor.png" alt="This figure shows the Open &gt; XML Editor option for the persistence.xml file." title="This figure shows the Open &gt; XML Editor option for the persistence.xml file." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p><a id="sthref62" name="sthref62"></a><a id="sthref63" name="sthref63"></a>Use the <span class="gui-object-title">XML Editor</span> to edit the <code>persistence.xml</code> file.</p>
-<div class="figure"><a id="sthref64" name="sthref64"></a>
-<p class="titleinfigure">XML Editor</p>
-<img src="img/persistence_xml_editor.png" alt="This figure shows the XML Editor." title="This figure shows the XML Editor." /><br /></div>
-<!-- class="figure" --></li>
-</ol>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="#CIHEJAIE">Working with persistence.xml file</a><br />
-<a href="../org.eclipse.wst.xmleditor.doc.user/topics/cworkXML.html">Working with XML Files</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concepts002.htm#CHDHAGIH">The persistence.xml file</a><br /></div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks002.htm
deleted file mode 100644
index 6057d9704a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks002.htm
+++ /dev/null
@@ -1,61 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:16 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Synchronizing classes</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Synchronizing classes" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CIHFEBAI" name="CIHFEBAI"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Synchronizing classes</h1>
-<p>As you work with the classes in your Java project, you will need to update the <code>persistence.xml</code> file to reflect the changes. <a id="sthref65" name="sthref65"></a><a id="sthref66" name="sthref66"></a></p>
-<p>Use this procedure to synchronize the <code>persistence.xml</code> file:</p>
-<ol start="1">
-<li>
-<p>Right-click the <code>persistence.xml</code> file in the <span class="gui-object-title">Package Explorer</span> and select <span class="gui-object-action">JPA Tools &gt; Synchronize Classes</span>.</p>
-<div class="figure"><a id="sthref67" name="sthref67"></a>
-<p class="titleinfigure">Synchronizing the persistence.xml File</p>
-<img src="img/synchornize_classes.png" alt="This figure shows the JPA Tools &gt; Synchronize Classes option." title="This figure shows the JPA Tools &gt; Synchronize Classes option." /><br /></div>
-<!-- class="figure" -->
-<p>Dali adds the necessary <code>&lt;class&gt;</code> elements to the <code>persistence.xml</code> file.</p>
-</li>
-<li>
-<p>Use the <span class="gui-object-title">Persistence XML Editor</span> to continue editing the <code>persistence.xml</code> file.</p>
-</li>
-</ol>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="tasks001.htm#CIHEJAIE">Working with persistence.xml file</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concepts002.htm#CHDHAGIH">The persistence.xml file</a><br />
-<br /></div>
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm
deleted file mode 100644
index c45e9d91e1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm
+++ /dev/null
@@ -1,62 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:17 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Working with orm.xml file</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Working with orm.xml file" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CIHBCDCE" name="CIHBCDCE"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Working with orm.xml file</h1>
-<p><a id="sthref70" name="sthref70"></a><a id="sthref71" name="sthref71"></a>You can work with the <code>orm.xml</code> by using the JPA Details view.</p>
-<p>Use this procedure to work with the <code>orm.xml</code> file:</p>
-<ol start="1">
-<li>
-<p>Right-click the <code>orm.xml</code> file in the <span class="gui-object-title">Package Explorer</span> and select <span class="gui-object-action">Open</span>.</p>
-</li>
-<li>
-<p>In the JPA Structure view, select <span class="bold">EntityMappings</span>.</p>
-</li>
-<li>
-<p>Use the JPA Details view to configure the entity mapping and persistence unit defaults.</p>
-<div class="figure"><a id="sthref72" name="sthref72"></a>
-<p class="titleinfigure">JPA Details view for EntityMappings (orm.xml)</p>
-<img src="img/details_entitymappings.png" alt="JPA Details view for orm.xml file." title="JPA Details view for orm.xml file." /><br /></div>
-<!-- class="figure" --></li>
-</ol>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="#CIHBCDCE">Working with orm.xml file</a><br />
-<a href="../org.eclipse.wst.xmleditor.doc.user/topics/cworkXML.html">Working with XML Files</a><br />
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concepts003.htm#CHDBIJAC">The orm.xml file</a><br /></div>
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks004.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks004.htm
deleted file mode 100644
index c59206b0e7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks004.htm
+++ /dev/null
@@ -1,75 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:17 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Entity</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Entity" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABGBIEE" name="BABGBIEE"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Entity</h1>
-<p><a id="sthref76" name="sthref76"></a><a id="sthref77" name="sthref77"></a><a id="sthref78" name="sthref78"></a><a id="sthref79" name="sthref79"></a>An <span class="bold">Entity</span> is a persistent domain object.</p>
-<p>An entity <span class="italic">can be</span>:</p>
-<ul>
-<li>
-<p>Abstract or concrete classes. Entities may also extend non-entity classes as well as entity classes, and non-entity classes may extend entity classes.</p>
-</li>
-</ul>
-<p>An entity <span class="italic">must have</span>:</p>
-<ul>
-<li>
-<p>A no-arg constructor (public or protected); the entity class may have other constructors as well.</p>
-</li>
-</ul>
-<p><a id="sthref80" name="sthref80"></a><a id="sthref81" name="sthref81"></a><a id="sthref82" name="sthref82"></a>Each persistent entity must be mapped to a database table and contain a primary key. Persistent entities are identified by the <code>@Entity</code> annotation.</p>
-<p>Use this procedure to add persistence to an existing entity:</p>
-<ol start="1">
-<li>
-<p>Open the Java class in the <span class="gui-object-title">Package Explorer.</span></p>
-</li>
-<li>
-<p>Select the class in the JPA Structure view.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">JPA Details</span> view, use the <span class="gui-object-action">Map As</span> field to select <span class="gui-object-action">Entity</span>.</p>
-<div class="figure"><a id="sthref83" name="sthref83"></a>
-<p class="titleinfigure">Selecting Entity Persistence</p>
-<img src="img/persistence_view_entity.png" alt="Selecting entity persistence on the JPA Details view." title="Selecting entity persistence on the JPA Details view." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>Complete the remaining <a href="ref_persistence_prop_view.htm#BABFAEBB">JPA Details view (for entities)</a>.</p>
-</li>
-</ol>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related tasks" title="Related tasks" /><br />
-<br />
-<a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a><br />
-<a href="task_additonal_tables.htm#CIHGBIEI">Specifying additional tables</a><br />
-<a href="task_inheritance.htm#CIHCCCJD">Specifying entity inheritance</a><br /></div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm
deleted file mode 100644
index 61af807d44..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm
+++ /dev/null
@@ -1,66 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:17 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Embeddable</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Embeddable" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABFEICE" name="BABFEICE"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Embeddable</h1>
-<p><a id="sthref84" name="sthref84"></a><a id="sthref85" name="sthref85"></a>An <span class="bold">Embedded</span> class is a class whose instances are stored as part of an owning entity; it shares the identity of the owning entity. Each field of the embedded class is mapped to the database table associated with the owning entity.</p>
-<p>To override the mapping information for a specific subclass, use the <code>@AttributeOverride</code> annotation for that specific class.</p>
-<p><a id="sthref86" name="sthref86"></a><a id="sthref87" name="sthref87"></a><a id="sthref88" name="sthref88"></a>An embeddable entity is identified by the <code>@Embeddable</code> annotation.</p>
-<p>Use this procedure to add embeddable persistence to an existing entity:</p>
-<ol start="1">
-<li>
-<p>Open the Java class in the <span class="gui-object-title">Package Explorer</span>.</p>
-</li>
-<li>
-<p>Select the class in the JPA Structure view.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">JPA Details</span> view, use the <span class="gui-object-action">Map As</span> drop-list to select <span class="gui-object-action">Embeddable</span>.</p>
-<div class="figure"><a id="sthref89" name="sthref89"></a>
-<p class="titleinfigure">Selecting Embeddable Persistence</p>
-<img src="img/persistence_view_embedded.png" alt="Selecting embedded persistence on the JPA Details view." title="Selecting embedded persistence on the JPA Details view." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>Complete the remaining <a href="ref_persistence_prop_view.htm#BABFAEBB">JPA Details view (for entities)</a>.</p>
-</li>
-</ol>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related tasks" title="Related tasks" /><br />
-<dl>
-<dd><a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a></dd>
-<dd><a href="task_additonal_tables.htm#CIHGBIEI">Specifying additional tables</a></dd>
-<dd><a href="task_inheritance.htm#CIHCCCJD">Specifying entity inheritance</a></dd>
-</dl>
-</div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm
deleted file mode 100644
index 8e4ef2b773..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm
+++ /dev/null
@@ -1,80 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:17 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Mapped superclass</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Mapped superclass" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABDAGCI" name="BABDAGCI"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Mapped superclass</h1>
-<p><a id="sthref90" name="sthref90"></a><a id="sthref91" name="sthref91"></a>An entities that extend a <span class="bold">Mapped Superclass</span> class inherit the persistent state and mapping information from a superclass. You should use a mapped superclass to define mapping information that is common to multiple entity classes.</p>
-<p>A mapped superclass <span class="italic">can be</span>:</p>
-<ul>
-<li>
-<p>Abstract or concrete classes</p>
-</li>
-</ul>
-<p>A mapped superclass <span class="italic">cannot be</span>:</p>
-<ul>
-<li>
-<p>Be queried or passed as an argument to Entity-Manager or Query operations</p>
-</li>
-<li>
-<p>Be the target of a persistent relationship</p>
-</li>
-</ul>
-<p>A mapped superclass does not have a defined database table. Instead, its mapping information is derived from its superclass. To override the mapping information for a specific subclass, use the <code>@AttributeOverride</code> annotation for that specific class.</p>
-<p><a id="sthref92" name="sthref92"></a><a id="sthref93" name="sthref93"></a><a id="sthref94" name="sthref94"></a><a id="sthref95" name="sthref95"></a>A mapped superclass is identified by the <code>@MappedSuperclass</code> annotation.</p>
-<p>Use this procedure to add Mapped Superclass persistence to an existing entity:</p>
-<ol start="1">
-<li>
-<p>Open the Java class in the <span class="gui-object-title">Package Explorer</span>.</p>
-</li>
-<li>
-<p>Select the class in the JPA Structure view.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">JPA Details</span> view, use the <span class="gui-object-action">Map As</span> drop-list to select <span class="gui-object-action">Mapped Superclass</span>.</p>
-<div class="figure"><a id="sthref96" name="sthref96"></a>
-<p class="titleinfigure">Selecting Mapped Superclass Persistence</p>
-<img src="img/persistence_view_mappedsprc.png" alt="Selecting embedded persistence on the JPA Details view." title="Selecting embedded persistence on the JPA Details view." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>Complete the remaining <a href="ref_persistence_prop_view.htm#BABFAEBB">JPA Details view (for entities)</a>.</p>
-</li>
-</ol>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related tasks" title="Related tasks" /><br />
-<br />
-<a href="task_add_persistence.htm#BABHICAI">Adding persistence to a class</a><br />
-<a href="task_additonal_tables.htm#CIHGBIEI">Specifying additional tables</a><br />
-<a href="task_inheritance.htm#CIHCCCJD">Specifying entity inheritance</a><br /></div>
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm
deleted file mode 100644
index c722bf8306..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm
+++ /dev/null
@@ -1,184 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:18 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Basic mapping</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Basic mapping" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABBABCE" name="BABBABCE"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Basic mapping</h1>
-<p><a id="sthref114" name="sthref114"></a><a id="sthref115" name="sthref115"></a><a id="sthref116" name="sthref116"></a><a id="sthref117" name="sthref117"></a>Use a <span class="bold">Basic Mapping</span> to map an attribute directly to a database column. Basic mappings may be used only with the following attribute types:</p>
-<ul>
-<li>
-<p>Java primitive types and wrappers of the primitive types</p>
-</li>
-<li>
-<p><code>java.lang.String, java.math.BigInteger</code></p>
-</li>
-<li>
-<p><code>java.math.BigDecimal</code></p>
-</li>
-<li>
-<p><code>java.util.Date</code></p>
-</li>
-<li>
-<p><code>java.util.Calendar, java.sql.Date</code></p>
-</li>
-<li>
-<p><code>java.sql.Time</code></p>
-</li>
-<li>
-<p><code>java.sql.Timestamp</code></p>
-</li>
-<li>
-<p><code>byte[]</code></p>
-</li>
-<li>
-<p><code>Byte[]</code></p>
-</li>
-<li>
-<p><code>char[]</code></p>
-</li>
-<li>
-<p><code>Character[]</code></p>
-</li>
-<li>
-<p>enums</p>
-</li>
-<li>
-<p>any other type that implements <code>Serializable</code></p>
-</li>
-</ul>
-<p>To create a basic mapping:</p>
-<ol start="1">
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the field to map. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the selected field.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">Basic</span>.</p>
-</li>
-<li>
-<p>Use this table to complete the remaining fields on the <span class="gui-object-title">JPA Details</span> view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Persistence Properties view for this mapping." summary="This table lists the fields in the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t4">Property</th>
-<th align="left" valign="bottom" id="r1c2-t4">Description</th>
-<th align="left" valign="bottom" id="r1c3-t4">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t4" headers="r1c1-t4">Map As</td>
-<td align="left" headers="r2c1-t4 r1c2-t4">Defines this mapping as a <span class="bold">Basic Mapping</span>.
-<p>This field corresponds to the <code>@Basic</code> annotation.</p>
-</td>
-<td align="left" headers="r2c1-t4 r1c3-t4">Basic</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t4" headers="r1c1-t4">Column</td>
-<td align="left" headers="r3c1-t4 r1c2-t4">The database column mapped to the entity attribute. See <a href="ref_mapping_general.htm#CACGCBHB">"Column"</a> for details.</td>
-<td align="left" headers="r3c1-t4 r1c3-t4">By default, the Column is assumed to be named identically to the attribute and always included in the <code>INSERT</code> and <code>UPDATE</code> statements.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t4" headers="r1c1-t4">Table</td>
-<td align="left" headers="r4c1-t4 r1c2-t4">Name of the database table.</td>
-<td align="left" headers="r4c1-t4 r1c3-t4"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t4" headers="r1c1-t4">Fetch</td>
-<td align="left" headers="r5c1-t4 r1c2-t4">Defines how data is loaded from the database. See <a href="ref_mapping_general.htm#CACGGGHB">"Fetch Type"</a> for details.
-<ul>
-<li>
-<p>Eager</p>
-</li>
-<li>
-<p>Lazy</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r5c1-t4 r1c3-t4">Eager</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r6c1-t4" headers="r1c1-t4">Optional</td>
-<td align="left" headers="r6c1-t4 r1c2-t4">Specifies if this field is can be null.</td>
-<td align="left" headers="r6c1-t4 r1c3-t4">Yes</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r7c1-t4" headers="r1c1-t4">Lob</td>
-<td align="left" headers="r7c1-t4 r1c2-t4">Specifies if this is a large objects (BLOB or CLOB). See <a href="ref_mapping_general.htm#CACBBIBI">"Lob"</a> for details.</td>
-<td align="left" headers="r7c1-t4 r1c3-t4"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r8c1-t4" headers="r1c1-t4">Temporal</td>
-<td align="left" headers="r8c1-t4 r1c2-t4">Specifies the type of data. See <a href="ref_mapping_general.htm#CACEAJGD">"Temporal"</a> for details.
-<ul>
-<li>
-<p>Date</p>
-</li>
-<li>
-<p>Time</p>
-</li>
-<li>
-<p>Timestamp</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r8c1-t4 r1c3-t4"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-</ol>
-<p>Eclipse adds the following annotations to the field:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@Column(name="<span class="italic">&lt;COLUMN_NAME&gt;</span>", table="<span class="italic">&lt;COLUMN_TABLE&gt;</span>",
- insertable=<span class="italic">&lt;INSERTABLE&gt;</span>, updatable=<span class="italic">&lt;UPDATABLE&gt;</span>)
-@Basic(fetch=FetchType.<span class="italic">&lt;FETCH_TYPE&gt;</span>, optional = <span class="italic">&lt;OPTIONAL&gt;</span>)
-@Temporal(TemporalType.<span class="italic">&lt;TEMPORAL&gt;</span>)
-
-</pre>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a><br />
-<a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_mapping.htm#BABBDJFI">Understanding OR mappings</a><br />
-<a href="concepts001.htm#BABBGFJG">Understanding EJB 3.0 Java Persistence API</a></div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm
deleted file mode 100644
index 69fce65365..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm
+++ /dev/null
@@ -1,107 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:18 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Embedded mapping</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Embedded mapping" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABCBHDF" name="BABCBHDF"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Embedded mapping</h1>
-<p><a id="sthref118" name="sthref118"></a><a id="sthref119" name="sthref119"></a><a id="sthref120" name="sthref120"></a><a id="sthref121" name="sthref121"></a>Use an <span class="bold">Embedded Mapping</span> to specify a persistent field or property of an entity whose value is an instance of an embeddable class.</p>
-<ol start="1">
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the field to map. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the selected field.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">Embedded</span>.</p>
-</li>
-<li>
-<p>Use this table to complete the remaining fields on the <span class="gui-object-title">JPA Details</span> view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Persistence Properties view for this mapping." summary="This table lists the fields in the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t5">Property</th>
-<th align="left" valign="bottom" id="r1c2-t5">Description</th>
-<th align="left" valign="bottom" id="r1c3-t5">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t5" headers="r1c1-t5">Map As</td>
-<td align="left" headers="r2c1-t5 r1c2-t5">Defines this mapping as a <span class="bold">Embedded</span>.
-<p>This field corresponds to the <code>@Embedded</code> annotation.</p>
-</td>
-<td align="left" headers="r2c1-t5 r1c3-t5">Embedded</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t5" headers="r1c1-t5">Attribute Overrides</td>
-<td align="left" headers="r3c1-t5 r1c2-t5">Specify to override the default mapping of an entity's attribute. Select <span class="bold">Override Default</span>.</td>
-<td align="left" headers="r3c1-t5 r1c3-t5"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t5" headers="r1c1-t5">Columns</td>
-<td align="left" headers="r4c1-t5 r1c2-t5">The database column (and its table) mapped to the entity attribute. See <a href="ref_mapping_general.htm#CACGCBHB">"Column"</a> for details.
-<ul>
-<li>
-<p>Name &ndash; Name of the database column.</p>
-</li>
-<li>
-<p>Table &ndash; Name of the database table.</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r4c1-t5 r1c3-t5"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-</ol>
-<p>Eclipse adds the following annotations to the field:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@Embedded
-@AttributeOverride(column=@Column(table="<span class="italic">&lt;COLUMN_TABLE&gt;</span>", name = "<span class="italic">&lt;COLUMN_NAME&gt;</span>"))
-</pre>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a><br />
-<a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_mapping.htm#BABBDJFI">Understanding OR mappings</a><br />
-<a href="concepts001.htm#BABBGFJG">Understanding EJB 3.0 Java Persistence API</a></div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm
deleted file mode 100644
index cce17cab80..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm
+++ /dev/null
@@ -1,87 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:18 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Embedded ID mapping</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Embedded ID mapping" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CIHDIAEE" name="CIHDIAEE"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Embedded ID mapping</h1>
-<p><a id="sthref122" name="sthref122"></a><a id="sthref123" name="sthref123"></a><a id="sthref124" name="sthref124"></a><a id="sthref125" name="sthref125"></a>Use an <span class="bold">Embedded ID Mapping</span> to specify the primary key of an embedded ID. These mappings may be used with a <a href="tasks005.htm#BABFEICE">Embeddable</a> entities.</p>
-<ol start="1">
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the field to map. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the selected field.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">Embedded Id</span>.</p>
-</li>
-<li>
-<p>Use this table to complete the remaining fields on the <span class="gui-object-title">JPA Details</span> view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Persistence Properties view for this mapping." summary="This table lists the fields in the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t6">Property</th>
-<th align="left" valign="bottom" id="r1c2-t6">Description</th>
-<th align="left" valign="bottom" id="r1c3-t6">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t6" headers="r1c1-t6">Map As</td>
-<td align="left" headers="r2c1-t6 r1c2-t6">Defines this mapping as a <span class="bold">Embedded Id</span>.
-<p>This field corresponds to the <code>@EmbeddedId</code> annotation.</p>
-</td>
-<td align="left" headers="r2c1-t6 r1c3-t6">Embedded Id</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-</ol>
-<p>Eclipse adds the following annotations to the field:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@EmbeddedId
-</pre>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a><br />
-<a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_mapping.htm#BABBDJFI">Understanding OR mappings</a><br />
-<a href="concepts001.htm#BABBGFJG">Understanding EJB 3.0 Java Persistence API</a></div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm
deleted file mode 100644
index 8edd2e8392..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm
+++ /dev/null
@@ -1,169 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:19 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>ID mapping</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="ID mapping" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABGCBHG" name="BABGCBHG"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>ID mapping</h1>
-<p><a id="sthref126" name="sthref126"></a><a id="sthref127" name="sthref127"></a><a id="sthref128" name="sthref128"></a><a id="sthref129" name="sthref129"></a>Use an <span class="bold">ID Mapping</span> to specify the primary key of an entity. ID mappings may be used with a <a href="tasks004.htm#BABGBIEE">Entity</a> or <a href="tasks006.htm#BABDAGCI">Mapped superclass</a>. Each <a href="tasks004.htm#BABGBIEE">Entity</a> must have an ID mapping.</p>
-<ol start="1">
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the field to map. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the selected.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">ID</span>.</p>
-</li>
-<li>
-<p>Use this table to complete the <a href="ref_mapping_general.htm#CACBHFIJ">General information</a> fields in the <span class="gui-object-title">JPA Details</span> view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Persistence Properties view for this mapping." summary="This table lists the fields in the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t7">Property</th>
-<th align="left" valign="bottom" id="r1c2-t7">Description</th>
-<th align="left" valign="bottom" id="r1c3-t7">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t7" headers="r1c1-t7">Map As</td>
-<td align="left" headers="r2c1-t7 r1c2-t7">Defines this mapping as an <span class="bold">ID Mapping</span>.
-<p>This field corresponds to the <code>@Id</code> annotation.</p>
-</td>
-<td align="left" headers="r2c1-t7 r1c3-t7">ID</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t7" headers="r1c1-t7">Column</td>
-<td align="left" headers="r3c1-t7 r1c2-t7">The database column mapped to the entity attribute. See <a href="ref_mapping_general.htm#CACGCBHB">"Column"</a> for details.</td>
-<td align="left" headers="r3c1-t7 r1c3-t7">By default, the Column is assumed to be named identically to the attribute.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t7" headers="r1c1-t7">Table</td>
-<td align="left" headers="r4c1-t7 r1c2-t7">The database table mapped to the entity attribute.</td>
-<td align="left" headers="r4c1-t7 r1c3-t7">By default, the Table is assumed to be identical to the table associated with the entity.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t7" headers="r1c1-t7">Temporal</td>
-<td align="left" headers="r5c1-t7 r1c2-t7">Specifies the type of data. See <a href="ref_mapping_general.htm#CACEAJGD">"Temporal"</a> for details.
-<ul>
-<li>
-<p>Date</p>
-</li>
-<li>
-<p>Time</p>
-</li>
-<li>
-<p>Timestamp</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r5c1-t7 r1c3-t7"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-<li>
-<p>Use this table to complete the fields in <a href="ref_primary_key.htm#CACFCCAB">Primary Key Generation information</a> area in the <span class="gui-object-title">JPA Details</span> view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the PK Generation tab." summary="This table lists the fields in the PK Generation tab." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t8">Property</th>
-<th align="left" valign="bottom" id="r1c2-t8">Description</th>
-<th align="left" valign="bottom" id="r1c3-t8">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t8" headers="r1c1-t8">Primary Key Generation</td>
-<td align="left" headers="r2c1-t8 r1c2-t8">These fields define how the primary key is generated.</td>
-<td align="left" headers="r2c1-t8 r1c3-t8"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t8" headers="r1c1-t8">&nbsp;&nbsp;Strategy</td>
-<td align="left" headers="r3c1-t8 r1c2-t8">See <a href="ref_primary_key.htm#CACBAJBC">"Primary Key Generation"</a> for details.
-<ul>
-<li>
-<p>Auto</p>
-</li>
-<li>
-<p>Sequence</p>
-</li>
-<li>
-<p>Identity</p>
-</li>
-<li>
-<p>Table</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r3c1-t8 r1c3-t8">Auto</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t8" headers="r1c1-t8">&nbsp;&nbsp;Generator&nbsp;Name</td>
-<td align="left" headers="r4c1-t8 r1c2-t8">Name of the primary key generator specified in the <span class="bold">Strategy</span></td>
-<td align="left" headers="r4c1-t8 r1c3-t8"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-</ol>
-<p>Additional fields will appear in the <a href="ref_primary_key.htm#CACFCCAB">Primary Key Generation information</a> area, depending on the selected Strategy. See <a href="ref_persistence_map_view.htm#BABIFBAF">"JPA Details view (for attributes)"</a> for additional information.</p>
-<p>Eclipse adds the following annotations to the field:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@Id
-@Column(name="<span class="italic">&lt;COLUMN_NAME&gt;</span>", table="<span class="italic">&lt;TABLE_NAME&gt;</span>", insertable=<span class="italic">&lt;INSERTABLE&gt;</span>,
- updatable=<span class="italic">&lt;UPDATABLE&gt;</span>)
-@Temporal(<span class="italic">&lt;TEMPORAL&gt;</span>)
-@GeneratedValue(strategy=GeneratorType.<span class="italic">&lt;STRATEGY&gt;</span>, generator="<span class="italic">&lt;GENERATOR_NAME&gt;</span>")@TableGenerator(name="<span class="italic">&lt;TABLE_GENERATOR_NAME&gt;</span>", table = "<span class="italic">&lt;TABLE_GENERATOR_TABLE&gt;</span>",
- pkColumnName = "<span class="italic">&lt;TABLE_GENERATOR_PK&gt;</span>",
- valueColumnName = "<span class="italic">&lt;TABLE_GENERATOR_VALUE_COLUMN&gt;</span>",
- pkColumnValue = "<span class="italic">&lt;TABLE_GENERATOR_PK_COLUMN_VALUE&gt;</span>")@SequenceGenerator(name="<span class="italic">&lt;SEQUENCE_GENERATOR_NAME&gt;</span>",
- sequenceName="<span class="italic">&lt;SEQUENCE_GENERATOR_SEQUENCE&gt;</span>")
-</pre>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a><br />
-<a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_mapping.htm#BABBDJFI">Understanding OR mappings</a><br />
-<a href="concepts001.htm#BABBGFJG">Understanding EJB 3.0 Java Persistence API</a></div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm
deleted file mode 100644
index 8d7932a37f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm
+++ /dev/null
@@ -1,172 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:19 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Many-to-many mapping</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Many-to-many mapping" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABEIEGD" name="BABEIEGD"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Many-to-many mapping</h1>
-<p><a id="sthref130" name="sthref130"></a><a id="sthref131" name="sthref131"></a><a id="sthref132" name="sthref132"></a><a id="sthref133" name="sthref133"></a>Use a <span class="bold">Many-to-Many Mapping</span> to define a many-valued association with many-to-many multiplicity. A many-to-many mapping has two sides: the <span class="italic">owning side</span> and <span class="italic">non-owning side</span>. You must specify the join table on the owning side. For bidirectional mappings, either side may be the owning side.</p>
-<ol start="1">
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the field to map. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the selected.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">Many-to-Many</span>.</p>
-</li>
-<li>
-<p>Use this table to complete the <a href="ref_mapping_general.htm#CACBHFIJ">General information</a> fields of the <span class="gui-object-title">JPA Details</span> view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Persistence Properties view for this mapping." summary="This table lists the fields in the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t9">Property</th>
-<th align="left" valign="bottom" id="r1c2-t9">Description</th>
-<th align="left" valign="bottom" id="r1c3-t9">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t9" headers="r1c1-t9">Map As</td>
-<td align="left" headers="r2c1-t9 r1c2-t9">Defines this mapping as a <span class="bold">Many to Many Mapping</span>.
-<p>This field corresponds to the <code>@ManyToMany</code> annotation.</p>
-</td>
-<td align="left" headers="r2c1-t9 r1c3-t9">Many to Many</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t9" headers="r1c1-t9">Target Entity</td>
-<td align="left" headers="r3c1-t9 r1c2-t9">The entity to which this attribute is mapped.</td>
-<td align="left" headers="r3c1-t9 r1c3-t9">null
-<p>You do not need to explicitly specify the target entity, since it can be inferred from the type of object being referenced.</p>
-</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t9" headers="r1c1-t9">Fetch</td>
-<td align="left" headers="r4c1-t9 r1c2-t9">Defines how data is loaded from the database. See <a href="ref_mapping_general.htm#CACGGGHB">"Fetch Type"</a> for details.
-<ul>
-<li>
-<p>Eager</p>
-</li>
-<li>
-<p>Lazy</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r4c1-t9 r1c3-t9">Lazy</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t9" headers="r1c1-t9">Mapped By</td>
-<td align="left" headers="r5c1-t9 r1c2-t9">The database field that owns the relationship.</td>
-<td align="left" headers="r5c1-t9 r1c3-t9"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r6c1-t9" headers="r1c1-t9">Order By</td>
-<td align="left" headers="r6c1-t9 r1c2-t9">Specify the default order for objects returned from a query. See <a href="ref_mapping_general.htm#CACDADIH">"Order By"</a> for details.
-<ul>
-<li>
-<p>No ordering</p>
-</li>
-<li>
-<p>Primary key</p>
-</li>
-<li>
-<p>Custom</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r6c1-t9 r1c3-t9">No ordering</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-<li>
-<p>Use this table to complete the fields in the <a href="reference007.htm#CACBAEBC">Join Table Information</a> area in the <span class="gui-object-title">JPA Details</span> view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Join Table tab of the Persistence Properties view for this mapping." summary="This table lists the fields in the Join Table tab of the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t10">Property</th>
-<th align="left" valign="bottom" id="r1c2-t10">Description</th>
-<th align="left" valign="bottom" id="r1c3-t10">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t10" headers="r1c1-t10">Name</td>
-<td align="left" headers="r2c1-t10 r1c2-t10">Name of the join table that contains the foreign key column.</td>
-<td align="left" headers="r2c1-t10 r1c3-t10">You must specify the join table on the owning side.
-<p>By default, the name is assumed to be the primary tables associated with the entities concatenated with an underscore.</p>
-</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t10" headers="r1c1-t10">Join Columns</td>
-<td align="left" headers="r3c1-t10 r1c2-t10">Select <span class="bold">Override Default</span>, then Add, Edit, or Remove the join columns.</td>
-<td align="left" headers="r3c1-t10 r1c3-t10">By default, the name is assumed to be the primary tables associated with the entities concatenated with an underscore.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t10" headers="r1c1-t10">Inverse Join Columns</td>
-<td align="left" headers="r4c1-t10 r1c2-t10">Select <span class="bold">Override Default</span>, then Add, Edit, or Remove the join columns.</td>
-<td align="left" headers="r4c1-t10 r1c3-t10">By default, the mapping is assumed to have a single join.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-<li>
-<p>To add a new Join or Inverse Join Column, click <span class="gui-object-action">Add</span>.</p>
-<p>To edit an existing Join or Inverse Join Column, select the field to and click <span class="gui-object-action">Edit</span>.</p>
-</li>
-</ol>
-<p>Eclipse adds the following annotations to the field:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@JoinTable(joinColumns=@JoinColumn(name="<span class="italic">&lt;JOIN_COLUMN&gt;</span>"),
- name = "<span class="italic">&lt;JOIN_TABLE_NAME&gt;</span>")
-@ManyToMany(cascade=CascadeType.<span class="italic">&lt;CASCADE_TYPE&gt;</span>, fetch=FetchType.<span class="italic">&lt;FETCH_TYPE&gt;</span>,
- targetEntity=<span class="italic">&lt;TARGET_ENTITY&gt;</span>, mappedBy = "<span class="italic">&lt;MAPPED_BY&gt;</span>")
-@OrderBy("<span class="italic">&lt;ORDER_BY&gt;</span>")
-
-</pre>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a><br />
-<a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_mapping.htm#BABBDJFI">Understanding OR mappings</a><br />
-<a href="concepts001.htm#BABBGFJG">Understanding EJB 3.0 Java Persistence API</a></div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm
deleted file mode 100644
index cdc7e6ff31..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm
+++ /dev/null
@@ -1,127 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:19 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Many-to-one mapping</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Many-to-one mapping" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABHFAFJ" name="BABHFAFJ"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Many-to-one mapping</h1>
-<p><a id="sthref134" name="sthref134"></a><a id="sthref135" name="sthref135"></a><a id="sthref136" name="sthref136"></a><a id="sthref137" name="sthref137"></a>Use a <span class="bold">Many-to-One</span> mapping to defines a single-valued association to another entity class that has many-to-one multiplicity.</p>
-<ol start="1">
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the field to map. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the selected.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">Many-to-One</span>.</p>
-</li>
-<li>
-<p>Use this table to complete the <a href="ref_mapping_general.htm#CACBHFIJ">General information</a> fields JPA Details view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields ion the General tab for this mapping." summary="This table lists the fields ion the General tab for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t11">Property</th>
-<th align="left" valign="bottom" id="r1c2-t11">Description</th>
-<th align="left" valign="bottom" id="r1c3-t11">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t11" headers="r1c1-t11">Target Entity</td>
-<td align="left" headers="r2c1-t11 r1c2-t11">The entity to which this attribute is mapped.</td>
-<td align="left" headers="r2c1-t11 r1c3-t11">null
-<p>You do not need to explicitly specify the target entity, since it can be inferred from the type of object being referenced.</p>
-</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t11" headers="r1c1-t11">Fetch Type</td>
-<td align="left" headers="r3c1-t11 r1c2-t11">Defines how data is loaded from the database. See <a href="ref_mapping_general.htm#CACGGGHB">"Fetch Type"</a> for details.
-<ul>
-<li>
-<p>Eager</p>
-</li>
-<li>
-<p>Lazy</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r3c1-t11 r1c3-t11">Eager</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-<li>
-<p>Use this table to complete the fields on the <a href="reference008.htm#CACFCEJC">Join Columns Information</a> tab in the <span class="gui-object-title">JPA Details</span> view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Persistence Properties view for this mapping." summary="This table lists the fields in the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t12">Property</th>
-<th align="left" valign="bottom" id="r1c2-t12">Description</th>
-<th align="left" valign="bottom" id="r1c3-t12">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t12" headers="r1c1-t12">Join Column</td>
-<td align="left" headers="r2c1-t12 r1c2-t12"><a id="sthref138" name="sthref138"></a><a id="sthref139" name="sthref139"></a>Specify a mapped column for joining an entity association. This field corresponds to the <code>@JoinColum</code> attribute.
-<p>Select <span class="bold">Override Default</span>, then Add, Edit, or Remove the join columns.</p>
-</td>
-<td align="left" headers="r2c1-t12 r1c3-t12">By default, the mapping is assumed to have a single join.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-</ol>
-<p>Eclipse adds the following annotations to the field:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@JoinTable(joinColumns=@JoinColumn(name="<span class="italic">&lt;JOIN_COLUMN&gt;</span>"),
- name = "<span class="italic">&lt;JOIN_TABLE_NAME&gt;</span>")
-@ManyToOne(targetEntity=<span class="italic">&lt;TARGET_ENTITY&gt;</span>, fetch=<span class="italic">&lt;FETCH_TYPE&gt;</span>,
- cascade=<span class="italic">&lt;CASCADE_TYPE&gt;</span>)
-</pre>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a><br />
-<a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_mapping.htm#BABBDJFI">Understanding OR mappings</a><br />
-<a href="concepts001.htm#BABBGFJG">Understanding EJB 3.0 Java Persistence API</a></div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm
deleted file mode 100644
index 8218ffd209..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm
+++ /dev/null
@@ -1,162 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:19 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>One-to-many mapping</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="One-to-many mapping" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABHGEBD" name="BABHGEBD"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>One-to-many mapping</h1>
-<p><a id="sthref140" name="sthref140"></a><a id="sthref141" name="sthref141"></a><a id="sthref142" name="sthref142"></a><a id="sthref143" name="sthref143"></a>Use a <span class="bold">One-to-Many Mapping</span> to define a relationship with one-to-many multiplicity.</p>
-<ol start="1">
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the field to map. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the selected.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">One-to-many</span>.</p>
-</li>
-<li>
-<p>Use this table to complete the <a href="ref_mapping_general.htm#CACBHFIJ">General information</a> fields JPA Details view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the General tab of the Persistence Properties view for this mapping." summary="This table lists the fields in the General tab of the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t13">Property</th>
-<th align="left" valign="bottom" id="r1c2-t13">Description</th>
-<th align="left" valign="bottom" id="r1c3-t13">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t13" headers="r1c1-t13">Target Entity</td>
-<td align="left" headers="r2c1-t13 r1c2-t13">The entity to which this attribute is mapped.</td>
-<td align="left" headers="r2c1-t13 r1c3-t13"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t13" headers="r1c1-t13">Fetch Type</td>
-<td align="left" headers="r3c1-t13 r1c2-t13">Defines how data is loaded from the database. See <a href="ref_mapping_general.htm#CACGGGHB">"Fetch Type"</a> for details.
-<ul>
-<li>
-<p>Eager</p>
-</li>
-<li>
-<p>Lazy</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r3c1-t13 r1c3-t13">Eager</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t13" headers="r1c1-t13">Mapped By</td>
-<td align="left" headers="r4c1-t13 r1c2-t13">The database field that owns the relationship.</td>
-<td align="left" headers="r4c1-t13 r1c3-t13"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r5c1-t13" headers="r1c1-t13">Order By</td>
-<td align="left" headers="r5c1-t13 r1c2-t13">Specify the default order for objects returned from a query. See <a href="ref_mapping_general.htm#CACDADIH">"Order By"</a> for details.
-<ul>
-<li>
-<p>No ordering</p>
-</li>
-<li>
-<p>Primary key</p>
-</li>
-<li>
-<p>Custom</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r5c1-t13 r1c3-t13">No ordering</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-<li>
-<p>Use this table to complete the <a href="reference007.htm#CACBAEBC">Join Table Information</a> fields in the JPA Details view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Join Table tab of the Persistence Properties view for this mapping." summary="This table lists the fields in the Join Table tab of the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t14">Property</th>
-<th align="left" valign="bottom" id="r1c2-t14">Description</th>
-<th align="left" valign="bottom" id="r1c3-t14">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t14" headers="r1c1-t14">Name</td>
-<td align="left" headers="r2c1-t14 r1c2-t14">Name of the join table</td>
-<td align="left" headers="r2c1-t14 r1c3-t14">By default, the name is assumed to be the primary tables associated with the entities concatenated with an underscore.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t14" headers="r1c1-t14">Join Columns</td>
-<td align="left" headers="r3c1-t14 r1c2-t14">Specify two or more join columns (that is, a primary key).</td>
-<td align="left" headers="r3c1-t14 r1c3-t14"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t14" headers="r1c1-t14">Inverse Join Columns</td>
-<td align="left" headers="r4c1-t14 r1c2-t14">The join column on the owned (or inverse) side of the association: the owned entity's primary key column.</td>
-<td align="left" headers="r4c1-t14 r1c3-t14"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-</ol>
-<p>Eclipse adds the following annotations to the field:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@OneToMany(targetEntity=<span class="italic">&lt;TARGET_ENTITY&gt;</span>)
-@Column(name="<span class="italic">&lt;COLUMN&gt;</span>")
-
-
-@OneToMany(targetEntity=<span class="italic">&lt;TARGET_ENTITY&gt;</span>.class, cascade=CascadeType.<span class="italic">&lt;CASCADE_TYPE&gt;</span>,
- fetch = FetchType.<span class="italic">&lt;FETCH_TYPE&gt;</span>, mappedBy = "<span class="italic">&lt;MAPPED_BY&gt;</span>")@OrderBy("<span class="italic">&lt;ORDER_BY&gt;</span>")
-@JoinTable(name="<span class="italic">&lt;JOIN_TABLE_NAME&gt;</span>", joinColumns=@JoinColumn(name=
- "<span class="italic">&lt;JOIN_COLUMN_NAME&gt;</span>", referencedColumnName="<span class="italic">&lt;JOIN_COLUMN_REFERENCED_COLUMN&gt;</span>"),
- inverseJoinColumns=@JoinColumn(name="<span class="italic">&lt;INVERSE_JOIN_COLUMN_NAME&gt;</span>",
- referencedColumnName="<span class="italic">&lt;INVERSE_JOIN_COLUMN_REFERENCED_COLUMN&gt;</span>"))
-
-</pre>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a><br />
-<a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_mapping.htm#BABBDJFI">Understanding OR mappings</a><br />
-<a href="concepts001.htm#BABBGFJG">Understanding EJB 3.0 Java Persistence API</a></div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm
deleted file mode 100644
index b23f849efa..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm
+++ /dev/null
@@ -1,134 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:20 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>One-to-one mapping</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="One-to-one mapping" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABFHBCJ" name="BABFHBCJ"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>One-to-one mapping</h1>
-<p><a id="sthref144" name="sthref144"></a><a id="sthref145" name="sthref145"></a><a id="sthref146" name="sthref146"></a><a id="sthref147" name="sthref147"></a>Use a <span class="bold">One-to-One Mapping</span> to define a relationship with one-to-many multiplicity.</p>
-<ol start="1">
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the field to map. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the selected.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">One-to-one</span>.</p>
-</li>
-<li>
-<p>Use this table to complete the <a href="ref_mapping_general.htm#CACBHFIJ">General information</a> fields in the JPA Details view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Persistence Properties view for this mapping." summary="This table lists the fields in the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t15">Property</th>
-<th align="left" valign="bottom" id="r1c2-t15">Description</th>
-<th align="left" valign="bottom" id="r1c3-t15">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t15" headers="r1c1-t15">Target Entity</td>
-<td align="left" headers="r2c1-t15 r1c2-t15">The entity to which this attribute is mapped.</td>
-<td align="left" headers="r2c1-t15 r1c3-t15">null
-<p>You do not need to explicitly specify the target entity, since it can be inferred from the type of object being referenced.</p>
-</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t15" headers="r1c1-t15">Fetch Type</td>
-<td align="left" headers="r3c1-t15 r1c2-t15">Defines how data is loaded from the database. See <a href="ref_mapping_general.htm#CACGGGHB">"Fetch Type"</a> for details.
-<ul>
-<li>
-<p>Eager</p>
-</li>
-<li>
-<p>Lazy</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r3c1-t15 r1c3-t15">Eager</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t15" headers="r1c1-t15">Mapped By</td>
-<td align="left" headers="r4c1-t15 r1c2-t15">The database field that owns the relationship.</td>
-<td align="left" headers="r4c1-t15 r1c3-t15"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-<li>
-<p>Use this table to complete the <a href="reference008.htm#CACFCEJC">Join Columns Information</a> fields in the <span class="gui-object-title">JPA Details</span> view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Persistence Properties view for this mapping." summary="This table lists the fields in the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t16">Property</th>
-<th align="left" valign="bottom" id="r1c2-t16">Description</th>
-<th align="left" valign="bottom" id="r1c3-t16">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t16" headers="r1c1-t16">Join Column</td>
-<td align="left" headers="r2c1-t16 r1c2-t16"><a id="sthref148" name="sthref148"></a><a id="sthref149" name="sthref149"></a>Specify a mapped column for joining an entity association. This field corresponds to the <code>@JoinColum</code> attribute.
-<p>Select <span class="bold">Override Default</span>, then Add, Edit, or Remove the join columns.</p>
-</td>
-<td align="left" headers="r2c1-t16 r1c3-t16">By default, the mapping is assumed to have a single join.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-</ol>
-<p>Eclipse adds the following annotations to the field:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@OneToOne(targetEntity=<span class="italic">&lt;TARGET_ENTITY&gt;</span>, cascade=CascadeType.<span class="italic">&lt;CASCADE_TYPE&gt;</span>,
- fetch = FetchType.<span class="italic">&lt;FETCH_TYPE&gt;</span>, mappedBy = "<span class="italic">&lt;MAPPED_BY&gt;</span>")
-@JoinColumn(name="<span class="italic">&lt;JOIN_COLUMN_NAME&gt;</span>", referencedColumnName=
- "<span class="italic">&lt;JOIN_COLUMN_REFERENCED_COLUMN&gt;</span>", insertable = <span class="italic">&lt;INSERTABLE&gt;</span>,
- updatable = <span class="italic">&lt;UPDATABLE&gt;</span>)
-
-</pre>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a><br />
-<a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_mapping.htm#BABBDJFI">Understanding OR mappings</a><br />
-<a href="concepts001.htm#BABBGFJG">Understanding EJB 3.0 Java Persistence API</a></div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm
deleted file mode 100644
index edec5f8640..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm
+++ /dev/null
@@ -1,65 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:20 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Transient mapping</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Transient mapping" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABHFHEI" name="BABHFHEI"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Transient mapping</h1>
-<p><a id="sthref150" name="sthref150"></a><a id="sthref151" name="sthref151"></a><a id="sthref152" name="sthref152"></a><a id="sthref153" name="sthref153"></a>Use the Transient Mapping to specify a field of the entity class that <span class="italic">is not</span> persistent.</p>
-<p>To create a transient mapping:</p>
-<ol start="1">
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the field to map. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the selected.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">Transient</span>.</p>
-</li>
-</ol>
-<p>Eclipse adds the following annotation to the field:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@Transient
-</pre>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a><br />
-<a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_mapping.htm#BABBDJFI">Understanding OR mappings</a><br />
-<a href="concepts001.htm#BABBGFJG">Understanding EJB 3.0 Java Persistence API</a></div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm
deleted file mode 100644
index 453b5115cd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm
+++ /dev/null
@@ -1,128 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:20 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Version mapping</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Version mapping" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABHIBII" name="BABHIBII"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Version mapping</h1>
-<p><a id="sthref154" name="sthref154"></a><a id="sthref155" name="sthref155"></a><a id="sthref156" name="sthref156"></a><a id="sthref157" name="sthref157"></a>Use a <span class="bold">Version Mapping</span> to specify the field used for optimistic locking. If the entity is associated with multiple tables, you should use a version mapping only with the primary table. You should have only a single version mapping per persistent entity. Version mappings may be used only with the following attribute types:</p>
-<ul>
-<li>
-<p><code>int</code></p>
-</li>
-<li>
-<p><code>Integer</code></p>
-</li>
-<li>
-<p><code>short, Short</code></p>
-</li>
-<li>
-<p><code>long, Long</code></p>
-</li>
-<li>
-<p><code>Timestamp</code></p>
-</li>
-</ul>
-<p>To create a version mapping:</p>
-<ol start="1">
-<li>
-<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the field to map. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the selected.</p>
-</li>
-<li>
-<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">Version</span>.</p>
-</li>
-<li>
-<p>Use this table to complete the remaining fields in the JPA Details view.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Persistence Properties view for this mapping." summary="This table lists the fields in the Persistence Properties view for this mapping." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t17">Property</th>
-<th align="left" valign="bottom" id="r1c2-t17">Description</th>
-<th align="left" valign="bottom" id="r1c3-t17">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t17" headers="r1c1-t17">Column</td>
-<td align="left" headers="r2c1-t17 r1c2-t17">The database column mapped to the entity attribute. See <a href="ref_mapping_general.htm#CACGCBHB">"Column"</a> for details.</td>
-<td align="left" headers="r2c1-t17 r1c3-t17">By default, the Column is assumed to be named identically to the attribute and always included in the <code>INSERT</code> and <code>UPDATE</code> statements.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t17" headers="r1c1-t17">Table</td>
-<td align="left" headers="r3c1-t17 r1c2-t17">Name of the database table. This must be the primary table associated with the attribute's entity.</td>
-<td align="left" headers="r3c1-t17 r1c3-t17"><br /></td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r4c1-t17" headers="r1c1-t17">Temporal</td>
-<td align="left" headers="r4c1-t17 r1c2-t17">Specifies the type of data. See <a href="ref_mapping_general.htm#CACEAJGD">"Temporal"</a> for details.
-<ul>
-<li>
-<p>Date</p>
-</li>
-<li>
-<p>Time</p>
-</li>
-<li>
-<p>Timestamp</p>
-</li>
-</ul>
-</td>
-<td align="left" headers="r4c1-t17 r1c3-t17"><br /></td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-</ol>
-<p>Eclipse adds the following annotations to the field:</p>
-<pre xml:space="preserve" class="oac_no_warn">
-@Version
-@Column(table="<span class="italic">&lt;COLUMN_TABLE&gt;</span>", name="&lt;<span class="italic">COLUMN_NAME</span>&gt;")
-
-</pre>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_mapping.htm#BABDGBIJ">Mapping an entity</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a><br />
-<a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_mapping.htm#BABBDJFI">Understanding OR mappings</a><br />
-<a href="concepts001.htm#BABBGFJG">Understanding EJB 3.0 Java Persistence API</a></div>
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm
deleted file mode 100644
index 2fd09c1339..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm
+++ /dev/null
@@ -1,66 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:21 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Generating entities from tables</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Generating entities from tables" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABBAGFI" name="BABBAGFI"></a></p>
-<div class="sect1">
-<h1>Generating entities from tables</h1>
-<p><a id="sthref158" name="sthref158"></a><a id="sthref159" name="sthref159"></a>Use this procedure to generate Java persistent entities from database tables. You must create a JPA project and establish a database connection <span class="italic">before</span> generating persistent entities. See <a href="task_create_new_project.htm#CIHHEJCJ">"Creating a new JPA project"</a> for more information.</p>
-<ol start="1">
-<li>
-<p>Right-click the JPA project in the <span class="gui-object-title">Package Explorer</span> and select <span class="gui-object-action">JPA Tools &gt; Generate Entities</span>.</p>
-<div class="figure"><a id="sthref160" name="sthref160"></a>
-<p class="titleinfigure">Generating Entities</p>
-<img src="img/generate_entities.png" alt="Using the JPA Tools &gt; Generate Entities menu option." title="Using the JPA Tools &gt; Generate Entities menu option." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>If you are not currently connected to the database, the Database Connection page appears. Select your database connection and schema, and click <span class="bold">Reconnect</span>.</p>
-<p>To create a new database connection, click <span class="bold">Add connection</span>.</p>
-<p>After connecting to the database, click <span class="bold">Next</span>.</p>
-</li>
-<li>
-<p><a id="sthref161" name="sthref161"></a><a id="sthref162" name="sthref162"></a>On the <a href="task_generate_entities.htm#CACDAFJD">Generate Entities from Tables dialog</a> dialog, select the tables from which to generate Java persistent entities and click <span class="bold">Finish</span>.</p>
-</li>
-</ol>
-<p>Eclipse creates a Java persistent entity for each database table. Each entity contains fields based on the table's columns. Eclipse will also generate entity relationships (such as one-to-one) based on the table constraints. <a href="#CIHJIJJC">Figure: Generating Entities from Tables</a> illustrates how Eclipse generates entities from tables.</p>
-<div class="figure"><a id="CIHJIJJC" name="CIHJIJJC"></a>
-<p class="titleinfigure">Generating Entities from Tables</p>
-<img src="img/table_entity.png" alt="This figure shows the EMPLOYEE and ADDRESS entities generated from database tables." title="This figure shows the EMPLOYEE and ADDRESS entities generated from database tables." /><br /></div>
-<!-- class="figure" -->
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<p><a href="task_create_new_project.htm#CIHHEJCJ">Creating a new JPA project</a></p>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_project_properties.htm#BABJHBCI">Project Properties page &ndash; JPA Options</a></div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm
deleted file mode 100644
index 8f98e88f8a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:21 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Generating DDL from Entities</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Generating DDL from Entities" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CIHJIGBE" name="CIHJIGBE"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Generating DDL from Entities</h1>
-<p>When using a vendor-specific platform, you can create a DDL script from your persistent entities.</p>
-<p><span class="italic">InformationPending</span></p>
-</div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm
deleted file mode 100644
index 07c6bdace0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm
+++ /dev/null
@@ -1,53 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:21 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Validating mappings and reporting problems</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Validating mappings and reporting problems" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABFAIBA" name="BABFAIBA"></a></p>
-<div class="sect1">
-<h1>Validating mappings and reporting problems</h1>
-<p><a id="sthref163" name="sthref163"></a><a id="sthref164" name="sthref164"></a><a id="sthref165" name="sthref165"></a><a id="sthref166" name="sthref166"></a>Errors and warnings on persistent entities and mappings are indicated with a red error or yellow warning next to the resource with the error, as well as the parent containers up to the project.</p>
-<div class="figure"><a id="sthref167" name="sthref167"></a>
-<p class="titleinfigure">Sample Errors and Warnings</p>
-<img src="img/error_sample.png" alt="This figure shows sample error and warning icons in the Explorer view." title="This figure shows sample error and warning icons in the Explorer view." /><br /></div>
-<!-- class="figure" -->
-<p>This section contains information on the following:</p>
-<ul>
-<li>
-<p><a href="tasks020.htm#CIHFEDEI">Error messages</a></p>
-</li>
-<li>
-<p><a href="tasks021.htm#CIHGEAIJ">Warning messages</a></p>
-</li>
-</ul>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<p><a href="../org.eclipse.platform.doc.user/concepts/cprbview.htm">Problems view</a></p>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" --></div>
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm
deleted file mode 100644
index 264be579e5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm
+++ /dev/null
@@ -1,91 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:21 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Error messages</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Error messages" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CIHFEDEI" name="CIHFEDEI"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Error messages<a id="sthref168" name="sthref168"></a></h1>
-<p>This section contains information on error messages (including how to resolve the issue) you may encounter while working with Dali.</p>
-<a id="sthref169" name="sthref169"></a>
-<p class="subhead2">Attribute "<span class="italic">&lt;ATTRIBUTE__NAME&gt;</span>" has invalid mapping type in this context</p>
-<p>The mapped attribute is invalid. Either change the mapping type or change the entity type.</p>
-<p>See <a href="task_mapping.htm#BABDGBIJ">"Mapping an entity"</a> for more information.</p>
-<a id="sthref170" name="sthref170"></a>
-<p class="subhead2">Attribute "<span class="italic">&lt;ATTRIBUTE_NAME&gt;</span>" cannot be resolved.</p>
-<p>Dali cannot map the attribute to a database table and column. Verify that you database connection information is correct.</p>
-<p>See <a href="task_create_new_project.htm#CIHHEJCJ">"Creating a new JPA project"</a> for more information.</p>
-<a id="sthref171" name="sthref171"></a>
-<p class="subhead2">Class "<span class="italic">&lt;CLASS_NAME&gt;</span>" is not annotated as a persistent class.</p>
-<p>The class has not been identified as a persistent class. Configure the class as an Entity, Mapped Superclass, or Embeddable persistent entity.</p>
-<p>See <a href="task_add_persistence.htm#BABHICAI">"Adding persistence to a class"</a>.</p>
-<a id="sthref172" name="sthref172"></a>
-<p class="subhead2">Column "<span class="italic">&lt;COLUMN_NAME&gt;</span>" cannot be resolved.</p>
-<p>You mapped an entity's field to an incorrect or invalid column in the database table. By default, Dali will attempt to map each field in the entity with an identically named row in the database table. If the field's name differs from the row's name, you must explicitly create the mapping.</p>
-<p>Map the field to a valid row in the database table as shown in <a href="task_mapping.htm#BABDGBIJ">"Mapping an entity"</a>.</p>
-<a id="sthref173" name="sthref173"></a>
-<p class="subhead2">Duplicate class "<span class="italic">&lt;CLASS_NAME&gt;</span>".</p>
-<p>You created to persistence classes with the same name. Each Java class must have a unique name. See <a href="task_add_persistence.htm#BABHICAI">"Adding persistence to a class"</a> for more information.</p>
-<a id="sthref174" name="sthref174"></a>
-<p class="subhead2">Entity does not have an Id or Embedded Id.</p>
-<p>You created a persistent entity without identifying its primary key. A persistent entity must have a primary key field designated with an <code>@Id</code> or <code>@EmbeddedId</code> annotation.</p>
-<p>Add an ID mapping to the entity as shown in <a href="tasks010.htm#BABGCBHG">"ID mapping"</a> or <a href="tasks009.htm#CIHDIAEE">"Embedded ID mapping"</a>.</p>
-<a id="sthref175" name="sthref175"></a>
-<p class="subhead2">Multiple persistence.xml files in project.</p>
-<p>You created a JPA project with more than one <code>persistence.xml</code> file. Each JPA project must contain a <span class="italic">single</span> <code>persistence.xml</code> file.</p>
-<p>See <a href="task_manage_persistence.htm#CIHDAJID">"Managing the persistence.xml file"</a> for more information.</p>
-<a id="sthref176" name="sthref176"></a>
-<p class="subhead2">No generator named "<span class="italic">&lt;GENERATOR_NAME&gt;</span>" is defined in persistence unit.</p>
-<p>You created a persistence entity that uses sequencing, but did not define a sequence generator in the persistence unit. Either define the generator by using an annotation or including it in the XML mapping file.</p>
-<a id="sthref177" name="sthref177"></a>
-<p class="subhead2">No persistence unit defined.</p>
-<p>There is no persistence unit defined in the <code>persistence.xml</code> file. Use the &lt;persistence-unit name="<span class="italic">&lt;PERSISTENCE_UNIT_NAME&gt;</span>" tag to define the persistent unit.</p>
-<p>See <a href="task_manage_orm.htm#CIHDGDCD">"Managing the orm.xml file"</a> for more information.</p>
-<a id="sthref178" name="sthref178"></a>
-<p class="subhead2">No persistence.xml file in project.</p>
-<p>You created a JPA project without a <code>persistence.xml</code> file. Each JPA project must contain a <span class="italic">single</span> <code>persistence.xml</code> file.</p>
-<p>See <a href="task_manage_persistence.htm#CIHDAJID">"Managing the persistence.xml file"</a> for more information.</p>
-<a id="sthref179" name="sthref179"></a>
-<p class="subhead2">Referenced column "<span class="italic">&lt;COLUMN_NAME&gt;</span>" in join column "<span class="italic">&lt;COLUMN_NAME&gt;</span>" cannot be resolved.</p>
-<p>The column that you selected to join a relationship mapping does not exist on the database table. Either select a different column on the <a href="reference007.htm#CACBAEBC">Join Table Information</a> or create the necessary column on the database table.</p>
-<p>See <a href="ref_persistence_map_view.htm#BABIFBAF">"JPA Details view (for attributes)"</a> for more information.</p>
-<a id="sthref180" name="sthref180"></a>
-<p class="subhead2">Schema "&lt;<span class="italic">SCHEMA_NAME</span>&gt;" cannot be resolved for table/join table "&lt;<span class="italic">TABLE_NAME</span>&gt;".</p>
-<p>Define the default database schema information in the persistence unit.</p>
-<p>See <a href="task_manage_orm.htm#CIHDGDCD">"Managing the orm.xml file"</a> for more information.</p>
-<a id="sthref181" name="sthref181"></a>
-<p class="subhead2">Table "<span class="italic">&lt;TABLE_NAME&gt;</span>" cannot be resolved.</p>
-<p>You associated a persistent entity to an incorrect or invalid database table. By default, Dali will attempt to associate each persistent entity with an identically named database table. If the entity's name differs from the table's name, you must explicitly create the association.</p>
-<p>Associate the entity with a valid database table as shown in <a href="task_add_persistence.htm#BABHICAI">"Adding persistence to a class"</a>.</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<p><a href="../org.eclipse.platform.doc.user/concepts/cprbview.htm">Problems view</a></p>
-</div>
-<!-- class="sect2" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm
deleted file mode 100644
index eef04d4577..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm
+++ /dev/null
@@ -1,49 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:22 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Warning messages</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Warning messages" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CIHGEAIJ" name="CIHGEAIJ"></a></p>
-<div class="sect2"><!-- infolevel="all" infotype="General" -->
-<h1>Warning messages</h1>
-<p>This section contains information on warning messages (including how to resolve the issue) you may encounter while working with Dali.</p>
-<a id="sthref182" name="sthref182"></a>
-<p class="subhead2">Connection "<span class="italic">&lt;CONNECTION_NAME&gt;</span>" is not active. No validation will be done against the data source.</p>
-<p>The database connection you specified to use with the JPA project is not active. The JPA project requires an active connection.</p>
-<a id="sthref183" name="sthref183"></a>
-<p class="subhead2">No connection specified for the project. No data-specific validation will be performed.</p>
-<p>You created a JPA project without specifying a database connection. The JPA project requires an active connection.</p>
-<p>See <a href="task_create_new_project.htm#CIHHEJCJ">"Creating a new JPA project"</a> or <a href="tasks022.htm#BABDBCBI">"Modifying persistent project properties"</a> for information on specifying a database connection.</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<p><a href="../org.eclipse.platform.doc.user/concepts/cprbview.htm">Problems view</a></p>
-</div>
-<!-- class="sect2" -->
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks022.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks022.htm
deleted file mode 100644
index 6108817038..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks022.htm
+++ /dev/null
@@ -1,83 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:22 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Modifying persistent project properties</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Modifying persistent project properties" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="BABDBCBI" name="BABDBCBI"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Modifying persistent project properties</h1>
-<p>Each persistent project must be associated with a database connection. To create a new database connection, click <span class="gui-object-action">Database Connection</span> use the New Connection wizard.</p>
-<p>Use this procedure to modify the vender-specific platform and database connection associated with your JPA project.</p>
-<ol start="1">
-<li>
-<p>Right-click the project in the <span class="gui-object-title">Explorer</span> view and select <span class="gui-object-action">Properties</span>. The Properties page appears.</p>
-<div class="figure"><a id="sthref184" name="sthref184"></a>
-<p class="titleinfigure">Properties &ndash; Persistence Page</p>
-<img src="img/properties_persistence.png" alt="This figure shows the JPA options on the Properties dialog." title="This figure shows the JPA options on the Properties dialog." /><br /></div>
-<!-- class="figure" --></li>
-<li>
-<p>Use this table to complete the remaining fields on the Properties &ndash; JPA page and click <span class="bold">OK</span>.</p>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the fields in the Properties - Java Persistence dialog." summary="This table lists the fields in the Properties - Java Persistence dialog." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t18">Property</th>
-<th align="left" valign="bottom" id="r1c2-t18">Description</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t18" headers="r1c1-t18">Platform</td>
-<td align="left" headers="r2c1-t18 r1c2-t18">Select the vendor-specific platform for the JPA implementation.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t18" headers="r1c1-t18">Database Connection</td>
-<td align="left" headers="r3c1-t18 r1c2-t18">Database connection to use to store the persistent entities. To create a new connection, click <span class="bold">Add Connection</span>.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" --></li>
-</ol>
-<p>To create a new connection, click <span class="bold">Add connections</span>.</p>
-<p>&nbsp;</p>
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="task_create_new_project.htm#CIHHEJCJ">Creating a new JPA project</a>
-<p>&nbsp;</p>
-<img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br />
-<br />
-<a href="ref_project_properties.htm#BABJHBCI">Project Properties page &ndash; JPA Options</a>
-<p>&nbsp;</p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="concept_persistence.htm#BABCAHIC">Understanding Java persistence</a></div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tips_and_tricks.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tips_and_tricks.htm
deleted file mode 100644
index 594506c794..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/tips_and_tricks.htm
+++ /dev/null
@@ -1,65 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:26 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Tips and tricks</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content=" Tips and tricks" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CHDHGHBF" name="CHDHGHBF"></a></p>
-<h1>Tips and tricks</h1>
-<p>The following tips and tricks give some helpful ideas for increasing your productivity.</p>
-<ul>
-<li>
-<p><a href="#BABFIIHA"><span class="bold">Database Connections</span></a></p>
-</li>
-<li>
-<p><a href="#BABCHAHF"><span class="bold">Schema-based persistence.xml</span></a></p>
-</li>
-</ul>
-<div class="inftblruleinformal">
-<table class="RuleInformal" title="This table lists the tips and tricks in this category." summary="This table lists the tips and tricks in this category." dir="ltr" border="1" width="100%" frame="border" rules="all" cellpadding="3" cellspacing="0">
-<thead>
-<tr align="left" valign="top">
-<th align="left" valign="bottom" id="r1c1-t2">Tip</th>
-<th align="left" valign="bottom" id="r1c2-t2">Description</th>
-</tr>
-</thead>
-<tbody>
-<tr align="left" valign="top">
-<td align="left" id="r2c1-t2" headers="r1c1-t2"><a id="BABFIIHA" name="BABFIIHA"></a><span class="bold">Database Connections</span></td>
-<td align="left" headers="r2c1-t2 r1c2-t2">When starting a new workbench session, be sure to <a href="../org.eclipse.wst.datatools.connection.ui.doc.user/topics/tdbconn_recon.html">reconnect to your database</a> (if you are working online). This allows Dali to provide database-related mapping assistance and validation.</td>
-</tr>
-<tr align="left" valign="top">
-<td align="left" id="r3c1-t2" headers="r1c1-t2"><a id="BABCHAHF" name="BABCHAHF"></a><span class="bold">Schema-based persistence.xml</span></td>
-<td align="left" headers="r3c1-t2 r1c2-t2">If you are behind a firewall, you may need to configure your Eclipse workspace proxy in the <a href="../org.eclipse.platform.doc.user/reference/ref-72.htm">Preferences dialog</a> (<span class="gui-object-action">Preferences &gt; Internet &gt; Proxy Settings</span>) to properly validate a schema-based <code>persistence.xml</code> file.</td>
-</tr>
-</tbody>
-</table>
-<br /></div>
-<!-- class="inftblruleinformal" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/toc.xml b/jpa/plugins/org.eclipse.jpt.doc.user/toc.xml
deleted file mode 100644
index c3be9cc71b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/toc.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- User Guide -->
- <toc label="Dali Java Persistence Tools User Guide">
- <topic href="getting_started.htm" label="Getting started">
- <topic href="getting_started001.htm#BABEFHCD" label="Requirements and installation" />
- <topic href="getting_started002.htm#BABIGCJA" label="Dali quick start">
- <topic href="getting_started003.htm#BABDFHDA" label="Creating a new project" />
- <topic href="getting_started004.htm#BABFGDDG" label="Creating a Java persistent entity" />
- <topic href="getting_started005.htm#BABHACAF" label="Mapping an entity" />
- </topic>
- <topic href="getting_started006.htm#BABCDECJ" label="Dali basic tutorial">
- <topic href="getting_started007.htm#BABBBBID" label="Generate the tutorial database schema">
- <topic href="getting_started008.htm#BABDHFCD" label="Create a database connection" />
- </topic>
- <topic href="getting_started009.htm#BABBBAIG" label="Create a JPA project" />
- <topic href="getting_started010.htm#BABIJIGF" label="Create persistent Java entities">
- <topic href="getting_started011.htm#BABDCBDD" label="Add fields to the entities" />
- <topic href="getting_started012.htm#BABIHGGD" label="Associate the entity with a database table" />
- </topic>
- <topic href="getting_started013.htm#BABEBGBC" label="Create OR mappings">
- <topic href="getting_started014.htm#BABGEFDI" label="Create ID mappings" />
- <topic href="getting_started015.htm#BABEEFJA" label="Create basic mappings" />
- <topic href="getting_started016.htm#BABGBGHF" label="Create one-to-one mappings" />
- <topic href="getting_started017.htm#BABBEHEG" label="Create one-to-many mappings" />
- <topic href="getting_started018.htm#BABCHIHI" label="Create many-to-one mappings" />
- <topic href="getting_started019.htm#BABIDFFG" label="Create version mappings" />
- </topic>
- </topic>
- </topic>
- <topic href="concepts.htm" label=" Concepts">
- <topic href="concept_persistence.htm#BABCAHIC" label="Understanding Java persistence" />
- <topic href="concept_mapping.htm#BABBDJFI" label="Understanding OR mappings" />
- <topic href="concepts001.htm#BABBGFJG" label="Understanding EJB 3.0 Java Persistence API">
- <topic href="concepts002.htm#CHDHAGIH" label="The persistence.xml file" />
- <topic href="concepts003.htm#CHDBIJAC" label="The orm.xml file" />
- </topic>
- </topic>
- <topic href="tasks.htm" label=" Tasks">
- <topic href="task_create_new_project.htm#CIHHEJCJ" label="Creating a new JPA project" />
- <topic href="task_manage_persistence.htm#CIHDAJID" label="Managing the persistence.xml file">
- <topic href="tasks001.htm#CIHEJAIE" label="Working with persistence.xml file" />
- <topic href="tasks002.htm#CIHFEBAI" label="Synchronizing classes" />
- </topic>
- <topic href="task_manage_orm.htm#CIHDGDCD" label="Managing the orm.xml file">
- <topic href="tasks003.htm#CIHBCDCE" label="Working with orm.xml file" />
- </topic>
- <topic href="task_add_persistence.htm#BABHICAI" label="Adding persistence to a class">
- <topic href="tasks004.htm#BABGBIEE" label="Entity" />
- <topic href="tasks005.htm#BABFEICE" label="Embeddable" />
- <topic href="tasks006.htm#BABDAGCI" label="Mapped superclass" />
- </topic>
- <topic href="task_additonal_tables.htm#CIHGBIEI" label="Specifying additional tables" />
- <topic href="task_inheritance.htm#CIHCCCJD" label="Specifying entity inheritance" />
- <topic href="task_mapping.htm#BABDGBIJ" label="Mapping an entity">
- <topic href="tasks007.htm#BABBABCE" label="Basic mapping" />
- <topic href="tasks008.htm#BABCBHDF" label="Embedded mapping" />
- <topic href="tasks009.htm#CIHDIAEE" label="Embedded ID mapping" />
- <topic href="tasks010.htm#BABGCBHG" label="ID mapping" />
- <topic href="tasks011.htm#BABEIEGD" label="Many-to-many mapping" />
- <topic href="tasks012.htm#BABHFAFJ" label="Many-to-one mapping" />
- <topic href="tasks013.htm#BABHGEBD" label="One-to-many mapping" />
- <topic href="tasks014.htm#BABFHBCJ" label="One-to-one mapping" />
- <topic href="tasks015.htm#BABHFHEI" label="Transient mapping" />
- <topic href="tasks016.htm#BABHIBII" label="Version mapping" />
- </topic>
- <topic href="tasks017.htm#BABBAGFI" label="Generating entities from tables" />
- <topic href="tasks018.htm#CIHJIGBE" label="Generating DDL from Entities" />
- <topic href="tasks019.htm#BABFAIBA" label="Validating mappings and reporting problems">
- <topic href="tasks020.htm#CIHFEDEI" label="Error messages" />
- <topic href="tasks021.htm#CIHGEAIJ" label="Warning messages" />
- </topic>
- <topic href="tasks022.htm#BABDBCBI" label="Modifying persistent project properties" />
- </topic>
- <topic label=" Reference">
- <topic label="Wizards">
- <topic href="ref_new_jpa_project_wizard.htm#CACBJGBG" label="Create New JPA Project wizard">
- <topic href="ref_new_jpa_project.htm#CACBJAGC" label="New JPA Project page" />
- <topic href="ref_jpa_facet.htm#CACIFDIF" label="JPA Facet page" />
- </topic>
- </topic>
- <topic label="Property pages">
- <topic href="ref_persistence_prop_view.htm#BABFAEBB" label="JPA Details view (for entities)">
- <topic href="reference003.htm#CACCAGGC" label="General information" />
- <topic href="reference004.htm#CACIJBGH" label="Attribute overrides" />
- <topic href="reference005.htm#CACBHIDA" label="Secondary table information" />
- <topic href="reference006.htm#CACFHGHE" label="Inheritance information" />
- </topic>
- <topic href="ref_persistence_map_view.htm#BABIFBAF" label="JPA Details view (for attributes)">
- <topic href="ref_mapping_general.htm#CACBHFIJ" label="General information" />
- <topic href="reference007.htm#CACBAEBC" label="Join Table Information" />
- <topic href="reference008.htm#CACFCEJC" label="Join Columns Information" />
- <topic href="ref_primary_key.htm#CACFCCAB" label="Primary Key Generation information" />
- </topic>
- <topic href="ref_details_orm.htm#CACGDGHC" label="JPA Details view (for orm.xml)">
- <topic href="reference009.htm#CACCACGH" label="General information" />
- <topic href="reference010.htm#CACEAGBG" label="Persistence Unit information" />
- </topic>
- <topic href="ref_persistence_outline.htm#BABEGGFE" label="JPA Structure view" />
- </topic>
- <topic label="Preferences">
- <topic href="ref_project_properties.htm#BABJHBCI" label="Project Properties page - JPA Options" />
- </topic>
- <topic label="Dialogs">
- <topic href="task_generate_entities.htm#CACDAFJD" label="Generate Entities from Tables dialog" />
- <topic href="reference013.htm#CACCGEHC" label="Edit Join Columns Dialog" />
- </topic>
- <topic href="ref_persistence_perspective.htm#BABIFBDB" label="JPA Development perspective" />
- <topic label="Icons and buttons">
- <topic href="reference015.htm#CACGEACG" label="Icons" />
- <topic href="reference016.htm#CACDJCEI" label="Buttons" />
- </topic>
- <topic href="reference017.htm#sthref242" label="Javadoc" />
- <topic href="reference018.htm#CACBBDIB" label="Dali Developer Documentation" />
- </topic>
- <topic href="tips_and_tricks.htm" label="Tips and tricks" />
- <topic href="legal.htm" label=" Legal">
- <topic href="about.htm#sthref249" label="About this content" />
- </topic>
-</toc>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm
deleted file mode 100644
index 261e7db8ed..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:26 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>What's new</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content=" What's new" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="sthref246" name="sthref246"></a> What's new</p>
-<p>This section contains descriptions of the following new feature and significant changes made to the Dali OR Mapping Tool for M5 - Release 2.0.0:</p>
-<ul>
-<li>
-<p><a href="whats_new001.htm#CEGIDCCE">Generate DDL from Entities wizard</a></p>
-</li>
-</ul>
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm
deleted file mode 100644
index 6c39a8347f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm
+++ /dev/null
@@ -1,44 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = January 22, 2008 9:11:26 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Generate DDL from Entities wizard</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="noarchive" />
-<meta name="doctitle" content="Generate DDL from Entities wizard" />
-<meta name="relnum" content="M5 - Release 2.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CEGIDCCE" name="CEGIDCCE"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<h1>Generate DDL from Entities wizard</h1>
-<p>Use the <span class="gui-object-title">Generate DDL</span> wizard to quickly create DDL scripts from your persistent entities.</p>
-<p><span class="italic">InformationPending</span></p>
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
-<br />
-<a href="tasks018.htm#CIHJIGBE">Generating DDL from Entities</a></div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm
deleted file mode 100644
index 455826bdea..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = May 21, 2007 6:35:58 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create and Manage the persistence.xml file</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter - Version 4.5.3 Build 02" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="all" scheme="http://www.robotstxt.org/" />
-<meta name="doctitle" content="Create and Manage the persistence.xml file" />
-<meta name="relnum" content="Release 1.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CEGBCIBB" name="CEGBCIBB"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr valign="bottom">
-<td align="left" width="86%">
-<h1>Create and Manage the persistence.xml file</h1>
-</td>
-</tr>
-</table>
-<p>When creating a JPA project, Dali automatically creates the <code>perssistence.xml</code> file.</p>
-<div class="figure"><a id="sthref244" name="sthref244"></a>
-<p class="titleinfigure">JPA Project with persistence.xml File</p>
-<img src="img/new_project_2.png" alt="JPA project with persistence.xml file." title="JPA project with persistence.xml file." /><br /></div>
-<!-- class="figure" -->
-<p>Use the XML editor to edit the <code>persistence.xml</code> file.</p>
-<p>After adding your JPA entities, use the <span class="gui-object-action">Java Persistence &gt; Synchronize Classes</span> option to add the classes to the <code>persistence.xml</code> file.</p>
-<div class="figure"><a id="sthref245" name="sthref245"></a>
-<p class="titleinfigure">Synchronizing the persistence.xml File.</p>
-<img src="img/synchornize_classes.png" alt="The JPA Tools &gt; Synchronize Classes option." title="The JPA Tools &gt; Synchronize Classes option." /><br /></div>
-<!-- class="figure" -->
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="whats_new.htm#BGGEDBGF">What's new</a></div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2007,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm
deleted file mode 100644
index b75c0a95fb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm
+++ /dev/null
@@ -1,56 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<!-- Run date = May 21, 2007 6:35:58 -->
-<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
-<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-<title>Create and Manage the orm.xml file</title>
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta http-equiv="Content-Script-Type" content="text/javascript" />
-<meta name="generator" content="Oracle DARB XHTML Converter - Version 4.5.3 Build 02" />
-<meta name="date" content="2005-07-10T12:57:20+08:00" />
-<meta name="robots" content="all" scheme="http://www.robotstxt.org/" />
-<meta name="doctitle" content="Create and Manage the orm.xml file" />
-<meta name="relnum" content="Release 1.0.0" />
-<meta name="partnum" content="" />
-<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
-<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
-<link rel="start" href="../../index.htm" title="Home" type="text/html" />
-<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
-</head>
-<body>
-<p><a id="CEGJJBEE" name="CEGJJBEE"></a></p>
-<div class="sect1"><!-- infolevel="all" infotype="General" -->
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr valign="bottom">
-<td align="left" width="86%">
-<h1>Create and Manage the orm.xml file</h1>
-</td>
-</tr>
-</table>
-<p>When creating a JPA project, you can also create the <code>orm.xml</code> file. Select the <span class="bold">Create orm.xml</span> option on the <a href="ref_jpa_facet.htm#CACIFDIF">JPA Facet page</a> page of the <a href="ref_new_jpa_project_wizard.htm#CACBJGBG">Create New JPA Project wizard</a>.</p>
-<div class="figure"><a id="sthref246" name="sthref246"></a>
-<p class="titleinfigure">JPA Facet Dialog</p>
-<img src="img/jpa_facet_dialog.png" alt="JPA Facet dialog." title="JPA Facet dialog." /><br /></div>
-<!-- class="figure" -->
-<p>Use the <code>orm.xml</code> file to define the project and persistence unit defaults.</p>
-<div class="figure"><a id="sthref247" name="sthref247"></a>
-<p class="titleinfigure">JPA Details view for orm.xml file.</p>
-<img src="img/details_entitymappings.png" alt="JPA Details view for orm.xml file." title="JPA Details view for orm.xml file." /><br /></div>
-<!-- class="figure" -->
-<img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br />
-<br />
-<a href="whats_new.htm#BGGEDBGF">What's new</a></div>
-<!-- class="sect1" -->
-<!-- Start Footer -->
-<div class="footer">
-<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
-<tr>
-<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2007,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
-</tr>
-</table>
-</div>
-<!-- class="footer" -->
-</body>
-</html>
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/.classpath b/jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/.classpath
deleted file mode 100644
index 51cae5c536..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JPA">
- <attributes>
- <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="R:/jlib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/.cvsignore b/jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/.cvsignore
deleted file mode 100644
index c5e82d7458..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/.project b/jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/.project
deleted file mode 100644
index 5fabc7f997..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.eclipselink.core.ddlgen</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/src/org/eclipse/jpt/eclipselink/core/ddlgen/Main.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/src/org/eclipse/jpt/eclipselink/core/ddlgen/Main.java
deleted file mode 100644
index c20f38a33b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core.ddlgen/src/org/eclipse/jpt/eclipselink/core/ddlgen/Main.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.ddlgen;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-
-import org.eclipse.persistence.jpa.config.PersistenceUnitProperties;
-
-/**
- * This class creates a EclipseLink <code>EntityManagerFactory</code>,
- * and executes the DDL generator with the command set in the properties:
- * <code>eclipselink.ddl-generation.output-mode</code>
- * <code>eclipselink.application-location</code>
- *
- * Current command-line arguments:
- * [-pu puName] - persistence unit name
- * [-p propertiesFilePath] - properties for EclipseLink EntityManager
- *
- * Example of a properties file:
- * eclipselink.jdbc.bind-parameters=false
- * eclipselink.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
- * eclipselink.jdbc.url=jdbc\:derby\:c\:/derbydb/testdb;create\=true
- * eclipselink.jdbc.user=tran
- * eclipselink.jdbc.password=
- * eclipselink.logging.level=FINEST
- * eclipselink.logging.timestamp=false
- * eclipselink.logging.thread=false
- * eclipselink.logging.session=false
- * eclipselink.logging.exceptions=true
- * eclipselink.orm.throw.exceptions=true
- * eclipselink.ddl-generation.output-mode=database
- * eclipselink.ddl-generation=drop-and-create-tables
- * eclipselink.application-location=c\:/_Projects_/ExampleDDL
- */
-public class Main
-{
- protected EntityManagerFactory emf;
- private Map<String, String> eclipseLinkProperties;
- private String createDDLFileName;
- private String dropDDLFileName;
- private String appLocation;
- private String eclipseLinkPropertiesPath;
- private boolean isDebugMode;
-
- // ********** constructors **********
-
- public static void main(String[] args) {
- new Main().execute(args);
- }
-
- private Main() {
- super();
- }
-
- // ********** behavior **********
-
- protected void execute(String[] args) {
- this.initializeWith(args);
-
- this.emf = Persistence.createEntityManagerFactory(this.getPUName(args), this.eclipseLinkProperties);
- this.perform();
- this.closeEntityManagerFactory();
-
- this.dispose();
- return;
- }
-
- protected void perform() {
- // create an EM to generate schema.
- this.emf.createEntityManager().close();
- }
-
- protected void closeEntityManagerFactory() {
- this.emf.close();
- }
-
- private void initializeWith(String[] args) {
-
- this.eclipseLinkPropertiesPath = this.getEclipseLinkPropertiesPath(args);
- this.eclipseLinkProperties = this.getProperties(this.eclipseLinkPropertiesPath);
-
- this.createDDLFileName = this.getConfigPropertyAsString(
- PersistenceUnitProperties.CREATE_JDBC_DDL_FILE,
- this.eclipseLinkProperties,
- PersistenceUnitProperties.DEFAULT_CREATE_JDBC_FILE_NAME);
-
- this.dropDDLFileName = this.getConfigPropertyAsString(
- PersistenceUnitProperties.DROP_JDBC_DDL_FILE,
- this.eclipseLinkProperties,
- PersistenceUnitProperties.DEFAULT_DROP_JDBC_FILE_NAME);
-
- this.appLocation = this.eclipseLinkProperties.get(PersistenceUnitProperties.APP_LOCATION);
- this.isDebugMode = this.getDebugMode(args);
- }
-
- private void dispose() {
-
- if( ! this.isDebugMode) {
- new File(this.appLocation + "/" + this.createDDLFileName).delete();
- new File(this.appLocation + "/" + this.dropDDLFileName).delete();
- new File(this.eclipseLinkPropertiesPath).delete();
- }
- }
-
- private Map<String, String> getProperties(String eclipseLinkPropertiesPath) {
-
- Set<Entry<Object, Object>> propertiesSet = null;
- try {
- propertiesSet = this.loadEclipseLinkProperties(eclipseLinkPropertiesPath);
- }
- catch (IOException e) {
- throw new RuntimeException("Missing: " + eclipseLinkPropertiesPath, e);
- }
-
- Map<String, String> properties = new HashMap<String, String>();
- for(Entry<Object, Object> property : propertiesSet) {
- properties.put((String)property.getKey(), (String)property.getValue());
- }
- return properties;
- }
-
- private Set<Entry<Object, Object>> loadEclipseLinkProperties(String eclipseLinkPropertiesPath) throws IOException {
-
- FileInputStream stream = new FileInputStream(eclipseLinkPropertiesPath);
-
- Properties properties = new Properties();
- properties.load(stream);
-
- return properties.entrySet();
- }
-
- // ********** argument queries **********
-
- private String getPUName(String[] args) {
-
- return this.getArgumentValue("-pu", args);
- }
-
- private String getEclipseLinkPropertiesPath(String[] args) {
-
- return this.getArgumentValue("-p", args);
- }
-
- private boolean getDebugMode(String[] args) {
-
- return this.argumentExists("-debug", args);
- }
-
- private String getArgumentValue(String argument, String[] args) {
- for (int i = 0; i < args.length; i++) {
- String arg = args[i];
- if (arg.toLowerCase().equals(argument)) {
- int j = i + 1;
- if (j < args.length) {
- return args[j];
- }
- }
- }
- return null;
- }
-
- private boolean argumentExists(String argument, String[] args) {
- for (int i = 0; i < args.length; i++) {
- String arg = args[i];
- if (arg.toLowerCase().equals(argument)) {
- return true;
- }
- }
- return false;
- }
-
- // ****** utility methods *******
-
- /**
- * Check the provided map for an object with the given key. If that object is not available, check the
- * System properties. If it is not available from either location, return the default value.
- * @param propertyKey
- * @param map
- * @param defaultValue
- * @return
- */
- protected String getConfigPropertyAsString(String propertyKey, Map<String, String> overrides, String defaultValue){
- String value = this.getConfigPropertyAsString(propertyKey, overrides);
- if (value == null){
- value = defaultValue;
- }
- return value;
- }
-
- protected String getConfigPropertyAsString(String propertyKey, Map<String, String> overrides){
- String value = null;
- if (overrides != null){
- value = (String)overrides.get(propertyKey);
- }
- if (value == null){
- value = System.getProperty(propertyKey);
- }
- return value;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/Main.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/Main.java
deleted file mode 100644
index 83571ef672..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/Main.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.internal.ddlgen;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration;
-
-/**
- * This class creates a EclipseLink <code>EntityManagerFactory</code>,
- * and executes the DDL generator with the command set in the properties:
- * <code>eclipselink.ddl-generation.output-mode</code>
- * <code>eclipselink.application-location</code>
- *
- * Current command-line arguments:
- * [-pu puName] - persistence unit name
- * [-p propertiesFilePath] - properties for EclipseLink EntityManager
- *
- * Example of a properties file:
- * eclipselink.jdbc.bind-parameters=false
- * eclipselink.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
- * eclipselink.jdbc.url=jdbc\:derby\:c\:/derbydb/testdb;create\=true
- * eclipselink.jdbc.user=tran
- * eclipselink.jdbc.password=
- * eclipselink.logging.level=FINEST
- * eclipselink.logging.timestamp=false
- * eclipselink.logging.thread=false
- * eclipselink.logging.session=false
- * eclipselink.logging.exceptions=true
- * eclipselink.orm.throw.exceptions=true
- * eclipselink.ddl-generation.output-mode=database
- * eclipselink.ddl-generation=drop-and-create-tables
- * eclipselink.application-location=c\:/_Projects_/ExampleDDL
- */
-public class Main
-{
- protected EntityManagerFactory emf;
- private Map<String, String> eclipseLinkProperties;
- private String createDDLFileName;
- private String dropDDLFileName;
- private String appLocation;
- private String eclipseLinkPropertiesPath;
- private boolean isDebugMode;
-
- // ********** constructors **********
-
- public static void main(String[] args) {
- new Main().execute(args);
- }
-
- private Main() {
- super();
- }
-
- // ********** behavior **********
-
- protected void execute(String[] args) {
- this.initializeWith(args);
-
- this.emf = Persistence.createEntityManagerFactory(this.getPUName(args), this.eclipseLinkProperties);
- this.perform();
- this.closeEntityManagerFactory();
-
- this.dispose();
- return;
- }
-
- protected void perform() {
- // create an EM to generate schema.
- this.emf.createEntityManager().close();
- }
-
- protected void closeEntityManagerFactory() {
- this.emf.close();
- }
-
- private void initializeWith(String[] args) {
-
- this.eclipseLinkPropertiesPath = this.getEclipseLinkPropertiesPath(args);
- this.eclipseLinkProperties = this.getProperties(this.eclipseLinkPropertiesPath);
-
- this.createDDLFileName = this.getConfigPropertyAsString(
- SchemaGeneration.ECLIPSELINK_CREATE_FILE_NAME,
- this.eclipseLinkProperties,
- SchemaGeneration.DEFAULT_SCHEMA_GENERATION_CREATE_FILE_NAME);
-
- this.dropDDLFileName = this.getConfigPropertyAsString(
- SchemaGeneration.ECLIPSELINK_DROP_FILE_NAME,
- this.eclipseLinkProperties,
- SchemaGeneration.DEFAULT_SCHEMA_GENERATION_DROP_FILE_NAME);
-
- this.appLocation = this.eclipseLinkProperties.get(SchemaGeneration.ECLIPSELINK_APPLICATION_LOCATION);
- this.isDebugMode = this.getDebugMode(args);
- }
-
- private void dispose() {
-
- if( ! this.isDebugMode) {
- new File(this.appLocation + "/" + this.createDDLFileName).delete();
- new File(this.appLocation + "/" + this.dropDDLFileName).delete();
- new File(this.eclipseLinkPropertiesPath).delete();
- }
- }
-
- private Map<String, String> getProperties(String eclipseLinkPropertiesPath) {
-
- Set<Entry<Object, Object>> propertiesSet = null;
- try {
- propertiesSet = this.loadEclipseLinkProperties(eclipseLinkPropertiesPath);
- }
- catch (IOException e) {
- throw new RuntimeException("Missing: " + eclipseLinkPropertiesPath, e);
- }
-
- Map<String, String> properties = new HashMap<String, String>();
- for(Entry<Object, Object> property : propertiesSet) {
- properties.put((String)property.getKey(), (String)property.getValue());
- }
- return properties;
- }
-
- private Set<Entry<Object, Object>> loadEclipseLinkProperties(String eclipseLinkPropertiesPath) throws IOException {
-
- FileInputStream stream = new FileInputStream(eclipseLinkPropertiesPath);
-
- Properties properties = new Properties();
- properties.load(stream);
-
- return properties.entrySet();
- }
-
- // ********** argument queries **********
-
- private String getPUName(String[] args) {
-
- return this.getArgumentValue("-pu", args);
- }
-
- private String getEclipseLinkPropertiesPath(String[] args) {
-
- return this.getArgumentValue("-p", args);
- }
-
- private boolean getDebugMode(String[] args) {
-
- return this.argumentExists("-debug", args);
- }
-
- private String getArgumentValue(String argument, String[] args) {
- for (int i = 0; i < args.length; i++) {
- String arg = args[i];
- if (arg.toLowerCase().equals(argument)) {
- int j = i + 1;
- if (j < args.length) {
- return args[j];
- }
- }
- }
- return null;
- }
-
- private boolean argumentExists(String argument, String[] args) {
- for (int i = 0; i < args.length; i++) {
- String arg = args[i];
- if (arg.toLowerCase().equals(argument)) {
- return true;
- }
- }
- return false;
- }
-
- // ****** utility methods *******
-
- /**
- * Check the provided map for an object with the given key. If that object is not available, check the
- * System properties. If it is not available from either location, return the default value.
- * @param propertyKey
- * @param map
- * @param defaultValue
- * @return
- */
- protected String getConfigPropertyAsString(String propertyKey, Map<String, String> overrides, String defaultValue){
- String value = this.getConfigPropertyAsString(propertyKey, overrides);
- if (value == null){
- value = defaultValue;
- }
- return value;
- }
-
- protected String getConfigPropertyAsString(String propertyKey, Map<String, String> overrides){
- String value = null;
- if (overrides != null){
- value = (String)overrides.get(propertyKey);
- }
- if (value == null){
- value = System.getProperty(propertyKey);
- }
- return value;
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.classpath b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.classpath
deleted file mode 100644
index ca0a231785..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.classpath
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="property_files"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/utility/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/core/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/ui/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.cvsignore b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.cvsignore
deleted file mode 100644
index 76e64421ad..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-bin
-@dot
-temp.folder
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.project b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.project
deleted file mode 100644
index e572be1b93..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.eclipselink.ui</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.settings/org.eclipse.core.resources.prefs b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 2fdb2b173d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Mon Apr 07 14:26:59 EDT 2008
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.settings/org.eclipse.jdt.core.prefs b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dd4c3641c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Sun Feb 24 21:27:01 EST 2008
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/META-INF/MANIFEST.MF
deleted file mode 100644
index f6c286022a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,30 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jpt.eclipselink.ui;singleton:=true
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.jpt.eclipselink.ui.internal.JptEclipseLinkUiPlugin
-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.emf.edit.ui;bundle-version="[2.4.0,3.0.0)",
- org.eclipse.jpt.utility;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.jpt.db;bundle-version="[1.1.1,2.0.0)",
- org.eclipse.jpt.core;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jpt.ui;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.ui.navigator;bundle-version="[3.3.100,4.0.0)",
- org.eclipse.ui.views.properties.tabbed;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jpt.eclipselink.core;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.jdt.ui;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)"
-Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.jpt.eclipselink.ui.internal,
- org.eclipse.jpt.eclipselink.ui.internal.caching,
- org.eclipse.jpt.eclipselink.ui.internal.customization,
- org.eclipse.jpt.eclipselink.ui.internal.logging,
- org.eclipse.jpt.eclipselink.ui.internal.options,
- org.eclipse.jpt.eclipselink.ui.internal.persistencexml.details,
- org.eclipse.jpt.eclipselink.ui.internal.platform,
- org.eclipse.jpt.eclipselink.ui.internal.schema.generation
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Bundle-Vendor: %providerName
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/about.html b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/about.html
deleted file mode 100644
index 9e73bdabb6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>June 06, 2007</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/build.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/build.properties
deleted file mode 100644
index 23f6550873..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/build.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-################################################################################
-# Copyright (c) 2006, 2007 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-javacSource = 1.5
-javacTarget = 1.5
-source.. = src/,\
- property_files/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- about.html,\
- plugin.xml,\
- plugin.properties
-jars.compile.order = .
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.properties
deleted file mode 100644
index 3d576e695f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2008 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-pluginName= Java Persistence API EclipseLink Extension - UI
-providerName=Eclipse.org
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.xml
deleted file mode 100644
index de2d94cccd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.2"?>
-<plugin>
-
- <extension
- point="org.eclipse.jpt.ui.jpaPlatform">
- <jpaPlatform
- class="org.eclipse.jpt.eclipselink.ui.internal.platform.EclipseLinkPlatformUI"
- id="org.eclipse.eclipselink.platform">
- </jpaPlatform>
- </extension>
-
-</plugin>
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties
deleted file mode 100644
index 0b9362df53..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties
+++ /dev/null
@@ -1,233 +0,0 @@
-###############################################################################
-# Copyright (c) 2007, 2008 Oracle. - initial API and implementation
-###############################################################################
-
-Boolean_True = True
-Boolean_False = False
-
-DefaultWithoutValue=Default ()
-DefaultWithValue=Default ({0})
-
-PersistenceXmlTabFolder_defaultEmpty = Default ()
-PersistenceXmlTabFolder_defaultWithOneParam = Default ({0})
-
-PersistenceXmlGeneralTab_name = Name:
-PersistenceXmlGeneralTab_provider = Provider:
-PersistenceXmlGeneralTab_browse = Browse...
-PersistenceXmlGeneralTab_description = Description:
-
-# Connection
-PersistenceXmlConnectionTab_title = Connection
-PersistenceXmlConnectionTab_sectionTitle = Persistence Unit Connection
-PersistenceXmlConnectionTab_sectionDescription = Configure the Data Source or JDBC Connection properties.
-PersistenceXmlConnectionTab_defaultWithOneParam = Default ({0})
-PersistenceXmlConnectionTab_defaultEmpty = Default ()
-
-PersistenceXmlConnectionTab_transactionTypeLabel = Transaction Type:
-
-TransactionTypeComposite_jta = JTA
-TransactionTypeComposite_resource_local = Resource Local
-
-PersistenceXmlConnectionTab_nativeSqlLabel = Native SQL
-PersistenceXmlConnectionTab_nativeSqlLabelDefault = Native SQL ({0})
-
-PersistenceXmlConnectionTab_batchWritingLabel = Batch Writing:
-
-BatchWritingComposite_none = None
-BatchWritingComposite_jdbc = JDBC
-BatchWritingComposite_buffered = Buffered
-BatchWritingComposite_oracle_jdbc = Oracle JDBC
-
-PersistenceXmlConnectionTab_cacheStatementsLabel = Statement Caching:
-
-PersistenceXmlConnectionTab_jtaDataSourceLabel = JTA Data Source:
-PersistenceXmlConnectionTab_nonJtaDataSourceLabel = Non-JTA Data Source:
-
-PersistenceXmlConnectionTab_driverLabel = Driver:
-PersistenceXmlConnectionTab_urlLabel = URL:
-PersistenceXmlConnectionTab_userLabel = User:
-PersistenceXmlConnectionTab_passwordLabel = Password:
-PersistenceXmlConnectionTab_bindParametersLabel = Bind Parameters
-PersistenceXmlConnectionTab_bindParametersLabelDefault = Bind Parameters ({0})
-
-PersistenceXmlConnectionTab_readConnectionsSharedLabel = Shared
-PersistenceXmlConnectionTab_readConnectionsSharedLabelDefault = Shared ({0})
-PersistenceXmlConnectionTab_readConnectionsSectionTitle = Read Connection
-PersistenceXmlConnectionTab_readConnectionsMinLabel = Minimum:
-PersistenceXmlConnectionTab_readConnectionsMaxLabel = Maximum:
-PersistenceXmlConnectionTab_writeConnectionsSectionTitle = Write Connection
-PersistenceXmlConnectionTab_writeConnectionsMinLabel = Minimum:
-PersistenceXmlConnectionTab_writeConnectionsMaxLabel = Maximum:
-
-ConnectionPropertiesComposite_Database_GroupBox=Database
-
-JdbcPropertiesComposite_EclipseLinkConnectionPool_GroupBox=EclipseLink Connection Pool
-
-JdbcConnectionPropertiesComposite_ConnectionDialog_Message=&Enter connection name or pattern (*, ?, or camel case):
-JdbcConnectionPropertiesComposite_ConnectionDialog_Title=Connection Selection
-
-# SchemaGeneration
-PersistenceXmlSchemaGenerationTab_title = Schema Generation
-PersistenceXmlSchemaGenerationTab_sectionTitle = Persistence Unit Schema Generation
-PersistenceXmlSchemaGenerationTab_sectionDescription = Configure the EclipseLink Schema Generation properties.
-PersistenceXmlSchemaGenerationTab_defaultWithOneParam = Default ({0})
-PersistenceXmlSchemaGenerationTab_defaultEmpty = Default ()
-
-PersistenceXmlSchemaGenerationTab_ddlGenerationTypeLabel = DDL Generation Type:
-PersistenceXmlSchemaGenerationTab_outputModeLabel = Output Mode:
-PersistenceXmlSchemaGenerationTab_createDdlFileNameLabel = Create DDL File Name:
-PersistenceXmlSchemaGenerationTab_dropDdlFileNameLabel = Drop DDL File Name:
-
-OutputModeComposite_both = Both
-OutputModeComposite_sql_script = Sql-script
-OutputModeComposite_database = Database
-
-DdlGenerationTypeComposite_none = None
-DdlGenerationTypeComposite_create_tables = Create Tables
-DdlGenerationTypeComposite_drop_and_create_tables = Drop and Create Tables
-
-PersistenceXmlSchemaGenerationTab_ddlGenerationLocationLabel = DDL Generation Location:
-
-DdlGenerationLocationComposite_dialogTitle = Generation Location
-
-# Caching
-PersistenceXmlCachingTab_title = Caching
-PersistenceXmlCachingTab_sectionTitle = Persistence Unit Caching
-PersistenceXmlCachingTab_sectionDescription = Configure the session or entity specific EclipseLink caching properties.
-
-PersistenceXmlCachingTab_defaultCacheTypeLabel = Default Cache Type:
-PersistenceXmlCachingTab_cacheTypeLabel = Cache Type:
-
-PersistenceXmlCachingTab_defaultSharedCacheLabel = Shared Cache ({0})
-PersistenceXmlCachingTab_sharedCacheLabel = Shared Cache
-
-PersistenceXmlCachingTab_defaultSharedCacheDefaultLabel = Default Shared Cache ({0})
-PersistenceXmlCachingTab_sharedCacheDefaultLabel = Default Shared Cache
-
-CacheSizeComposite_cacheSize=Cache Size:
-
-CacheTypeComposite_full = Full
-CacheTypeComposite_hard_weak = Weak With Hard Subcache
-CacheTypeComposite_none = None
-CacheTypeComposite_soft = Soft
-CacheTypeComposite_soft_weak = Weak with Soft Subcache
-CacheTypeComposite_weak = Weak
-
-DefaultCacheSizeComposite_defaultCacheSize=Default Cache Size:
-
-DefaultCacheTypeComposite_full = Full
-DefaultCacheTypeComposite_hard_weak = Weak With Hard Subcache
-DefaultCacheTypeComposite_none = None
-DefaultCacheTypeComposite_soft = Soft
-DefaultCacheTypeComposite_soft_weak = Weak with Soft Subcache
-DefaultCacheTypeComposite_weak = Weak
-
-EntityDialog_selectEntity = Select an Entity
-EntityDialog_name = Name:
-
-CachingEntityListComposite_groupTitle = Entity Caching
-CachingEntityListComposite_editButton = Edit...
-
-# Customization
-PersistenceXmlCustomizationTab_title = Customization
-PersistenceXmlCustomizationTab_sectionTitle = Persistence Unit Customization
-PersistenceXmlCustomizationTab_sectionDescription = Set default or entity specific EclipseLink customization and validation properties.
-
-PersistenceXmlCustomizationTab_throwExceptionsLabelDefault = Throw Exceptions ({0})
-PersistenceXmlCustomizationTab_throwExceptionsLabel = Throw Exceptions
-
-PersistenceXmlCustomizationTab_weavingLabel = Weaving:
-
-PersistenceXmlCustomizationTab_weavingLazyLabelDefault = Weaving Lazy ({0})
-PersistenceXmlCustomizationTab_weavingLazyLabel = Weaving Lazy
-
-PersistenceXmlCustomizationTab_weavingChangeTrackingLabelDefault = Weaving Change Tracking ({0})
-PersistenceXmlCustomizationTab_weavingChangeTrackingLabel = Weaving Change Tracking
-
-PersistenceXmlCustomizationTab_weavingFetchGroupsLabelDefault = Weaving Fetch Groups ({0})
-PersistenceXmlCustomizationTab_weavingFetchGroupsLabel = Weaving Fetch Groups
-
-WeavingComposite_true_ = Weave Dynamically
-WeavingComposite_false_ = No Weaving
-WeavingComposite_static_ = Weave Statically
-
-CustomizationEntityListComposite_groupTitle = Descriptor Customizer
-CustomizationEntityListComposite_editButton = Edit...
-PersistenceXmlCustomizationTab_customizerLabel = Customizer:
-PersistenceXmlCustomizationTab_sessionCustomizerLabel = Session Customizer:
-
-# Logging
-PersistenceXmlLoggingTab_title = Logging
-PersistenceXmlLoggingTab_sectionTitle = Persistence Unit Logging
-PersistenceXmlLoggingTab_sectionDescription = Configure the EclipseLink Logging properties.
-PersistenceXmlLoggingTab_defaultWithOneParam = Default ({0})
-PersistenceXmlLoggingTab_defaultEmpty = Default ()
-
-PersistenceXmlLoggingTab_loggingLevelLabel = Logging Level:
-
-LoggingLevelComposite_off = Off
-LoggingLevelComposite_severe = Severe
-LoggingLevelComposite_warning = Warning
-LoggingLevelComposite_info = Info
-LoggingLevelComposite_config = Config
-LoggingLevelComposite_fine = Fine
-LoggingLevelComposite_finer = Finer
-LoggingLevelComposite_finest = Finest
-
-PersistenceXmlLoggingTab_loggerLabel = Logger:
-
-LoggerComposite_default_logger = Default Logger
-LoggerComposite_java_logger = Java Logger
-LoggerComposite_server_logger = Server Logger
-
-PersistenceXmlLoggingTab_timestampLabel = Timestamp
-PersistenceXmlLoggingTab_timestampLabelDefault = Timestamp ({0})
-PersistenceXmlLoggingTab_threadLabel = Thread
-PersistenceXmlLoggingTab_threadLabelDefault = Thread ({0})
-PersistenceXmlLoggingTab_sessionLabel = Session
-PersistenceXmlLoggingTab_sessionLabelDefault = Session ({0})
-PersistenceXmlLoggingTab_exceptionsLabel = Exceptions
-PersistenceXmlLoggingTab_exceptionsLabelDefault = Exceptions ({0})
-PersistenceXmlLoggingTab_logFileLabel = Log File
-PersistenceXmlLoggingTab_logFileLabelDefault = Log File ({0})
-PersistenceXmlLoggingTab_loggersLabel = Loggers:
-
-# Options
-PersistenceXmlOptionsTab_title = Options
-PersistenceXmlOptionsTab_sectionTitle = EclipseLink Session Options
-PersistenceXmlOptionsTab_sectionDescription = Configure the EclipseLink Session Options.
-PersistenceXmlOptionsTab_defaultWithOneParam = Default ({0})
-PersistenceXmlOptionsTab_defaultEmpty = Default ()
-
-PersistenceXmlOptionsTab_sessionName = Session Name:
-PersistenceXmlOptionsTab_sessionsXml = Sessions Xml:
-
-PersistenceXmlOptionsTab_includeDescriptorQueriesLabel = Include Descriptor Queries
-PersistenceXmlOptionsTab_includeDescriptorQueriesLabelDefault = Include Descriptor Queries ({0})
-
-PersistenceXmlOptionsTab_eventListenerLabel = Event Listener:
-PersistenceXmlOptionsTab_targetDatabaseLabel = Target Database:
-
-TargetDatabaseComposite_attunity = Attunity
-TargetDatabaseComposite_auto = Auto
-TargetDatabaseComposite_cloudscape = Cloudscape
-TargetDatabaseComposite_database = Database
-TargetDatabaseComposite_db2 = DB2
-TargetDatabaseComposite_db2mainframe = DB2Mainframe
-TargetDatabaseComposite_dbase = DBase
-TargetDatabaseComposite_derby = Derby
-TargetDatabaseComposite_hsql = HSQL
-TargetDatabaseComposite_informix = Informix
-TargetDatabaseComposite_javadb = JavaDB
-TargetDatabaseComposite_mysql4 = MySQL4
-TargetDatabaseComposite_oracle = Oracle
-TargetDatabaseComposite_pointbase = PointBase
-TargetDatabaseComposite_postgresql = PostgreSQL
-TargetDatabaseComposite_sqlanywhere = SQLAnyWhere
-TargetDatabaseComposite_sqlserver = SQLServer
-TargetDatabaseComposite_sybase = Sybase
-TargetDatabaseComposite_timesten = TimesTen
-
-# DDLGeneration
-EclipseLinkDDLGeneratorUi_generatingDDLWarningTitle = Generating DDL
-EclipseLinkDDLGeneratorUi_generatingDDLWarningMessage = Warning: Generating DDL will DROP existing tables and{0}CREATE new tables based on the Entities in your project.{1}Are you sure you want to continue?
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java
deleted file mode 100644
index c950fbb2ff..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007, 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal;
-
-/**
- * EclipseLinkUiMessages
- */
-import org.eclipse.osgi.util.NLS;
-
-public class EclipseLinkUiMessages extends NLS
-{
- private static final String BUNDLE_NAME = "eclipselink_ui"; //$NON-NLS-1$
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, EclipseLinkUiMessages.class);
- }
-
- public static String Boolean_True;
- public static String Boolean_False;
-
- public static String DefaultWithoutValue;
- public static String DefaultWithValue;
-
- public static String PersistenceXmlTabFolder_defaultEmpty;
- public static String PersistenceXmlTabFolder_defaultWithOneParam;
-
- public static String PersistenceXmlGeneralTab_name;
- public static String PersistenceXmlGeneralTab_provider;
- public static String PersistenceXmlGeneralTab_browse;
- public static String PersistenceXmlGeneralTab_description;
-
- // Connection
- public static String PersistenceXmlConnectionTab_title;
- public static String PersistenceXmlConnectionTab_sectionTitle;
- public static String PersistenceXmlConnectionTab_sectionDescription;
- public static String PersistenceXmlConnectionTab_defaultWithOneParam;
- public static String PersistenceXmlConnectionTab_defaultEmpty;
-
- public static String PersistenceXmlConnectionTab_transactionTypeLabel;
-
- public static String ConnectionPropertiesComposite_Database_GroupBox;
-
- public static String JdbcPropertiesComposite_EclipseLinkConnectionPool_GroupBox;
-
- public static String JdbcConnectionPropertiesComposite_ConnectionDialog_Message;
- public static String JdbcConnectionPropertiesComposite_ConnectionDialog_Title;
-
- public static String TransactionTypeComposite_jta;
- public static String TransactionTypeComposite_resource_local;
-
- public static String PersistenceXmlConnectionTab_nativeSqlLabel;
- public static String PersistenceXmlConnectionTab_nativeSqlLabelDefault;
-
- public static String PersistenceXmlConnectionTab_batchWritingLabel;
-
- public static String BatchWritingComposite_none;
- public static String BatchWritingComposite_jdbc;
- public static String BatchWritingComposite_buffered;
- public static String BatchWritingComposite_oracle_jdbc;
-
- public static String PersistenceXmlConnectionTab_cacheStatementsLabel;
-
- public static String PersistenceXmlConnectionTab_jtaDataSourceLabel;
- public static String PersistenceXmlConnectionTab_nonJtaDataSourceLabel;
-
- public static String PersistenceXmlConnectionTab_driverLabel;
- public static String PersistenceXmlConnectionTab_urlLabel;
- public static String PersistenceXmlConnectionTab_userLabel;
- public static String PersistenceXmlConnectionTab_passwordLabel;
- public static String PersistenceXmlConnectionTab_bindParametersLabel;
- public static String PersistenceXmlConnectionTab_bindParametersLabelDefault;
-
- public static String PersistenceXmlConnectionTab_readConnectionsSharedLabel;
- public static String PersistenceXmlConnectionTab_readConnectionsSharedLabelDefault;
- public static String PersistenceXmlConnectionTab_readConnectionsSectionTitle;
- public static String PersistenceXmlConnectionTab_readConnectionsMinLabel;
- public static String PersistenceXmlConnectionTab_readConnectionsMaxLabel;
- public static String PersistenceXmlConnectionTab_writeConnectionsSectionTitle;
- public static String PersistenceXmlConnectionTab_writeConnectionsMinLabel;
- public static String PersistenceXmlConnectionTab_writeConnectionsMaxLabel;
-
- // SchemaGeneration
- public static String PersistenceXmlSchemaGenerationTab_title;
- public static String PersistenceXmlSchemaGenerationTab_sectionTitle;
- public static String PersistenceXmlSchemaGenerationTab_sectionDescription;
- public static String PersistenceXmlSchemaGenerationTab_defaultWithOneParam;
- public static String PersistenceXmlSchemaGenerationTab_defaultEmpty;
-
- public static String PersistenceXmlSchemaGenerationTab_ddlGenerationTypeLabel;
- public static String PersistenceXmlSchemaGenerationTab_outputModeLabel;
-
- public static String PersistenceXmlSchemaGenerationTab_createDdlFileNameLabel;
- public static String PersistenceXmlSchemaGenerationTab_dropDdlFileNameLabel;
-
- public static String OutputModeComposite_both;
- public static String OutputModeComposite_sql_script;
- public static String OutputModeComposite_database;
-
- public static String DdlGenerationTypeComposite_none;
- public static String DdlGenerationTypeComposite_create_tables;
- public static String DdlGenerationTypeComposite_drop_and_create_tables;
-
- public static String PersistenceXmlSchemaGenerationTab_ddlGenerationLocationLabel;
-
- public static String DdlGenerationLocationComposite_dialogTitle;
-
- // Caching
- public static String PersistenceXmlCachingTab_title;
- public static String PersistenceXmlCachingTab_sectionTitle;
- public static String PersistenceXmlCachingTab_sectionDescription;
-
- public static String PersistenceXmlCachingTab_defaultCacheTypeLabel;
- public static String PersistenceXmlCachingTab_cacheTypeLabel;
-
- public static String PersistenceXmlCachingTab_defaultSharedCacheLabel;
- public static String PersistenceXmlCachingTab_sharedCacheLabel;
-
- public static String PersistenceXmlCachingTab_defaultSharedCacheDefaultLabel;
- public static String PersistenceXmlCachingTab_sharedCacheDefaultLabel;
-
- public static String CacheSizeComposite_cacheSize;
-
- public static String CacheTypeComposite_full;
- public static String CacheTypeComposite_hard_weak;
- public static String CacheTypeComposite_none;
- public static String CacheTypeComposite_soft;
- public static String CacheTypeComposite_soft_weak;
- public static String CacheTypeComposite_weak;
-
- public static String DefaultCacheSizeComposite_defaultCacheSize;
-
- public static String DefaultCacheTypeComposite_full;
- public static String DefaultCacheTypeComposite_hard_weak;
- public static String DefaultCacheTypeComposite_none;
- public static String DefaultCacheTypeComposite_soft;
- public static String DefaultCacheTypeComposite_soft_weak;
- public static String DefaultCacheTypeComposite_weak;
-
- public static String EntityDialog_selectEntity;
- public static String EntityDialog_name;
-
- public static String CachingEntityListComposite_groupTitle;
- public static String CachingEntityListComposite_editButton;
-
- // Customization
- public static String PersistenceXmlCustomizationTab_title;
- public static String PersistenceXmlCustomizationTab_sectionTitle;
- public static String PersistenceXmlCustomizationTab_sectionDescription;
-
- public static String PersistenceXmlCustomizationTab_throwExceptionsLabelDefault;
- public static String PersistenceXmlCustomizationTab_throwExceptionsLabel;
-
- public static String PersistenceXmlCustomizationTab_weavingLabel;
-
- public static String PersistenceXmlCustomizationTab_weavingLazyLabelDefault;
- public static String PersistenceXmlCustomizationTab_weavingLazyLabel;
-
- public static String PersistenceXmlCustomizationTab_weavingChangeTrackingLabelDefault;
- public static String PersistenceXmlCustomizationTab_weavingChangeTrackingLabel;
-
- public static String PersistenceXmlCustomizationTab_weavingFetchGroupsLabelDefault;
- public static String PersistenceXmlCustomizationTab_weavingFetchGroupsLabel;
-
- public static String WeavingComposite_true_;
- public static String WeavingComposite_false_;
- public static String WeavingComposite_static_;
-
- public static String CustomizationEntityListComposite_groupTitle;
- public static String CustomizationEntityListComposite_editButton;
- public static String PersistenceXmlCustomizationTab_customizerLabel;
- public static String PersistenceXmlCustomizationTab_sessionCustomizerLabel;
-
- // Logging
- public static String PersistenceXmlLoggingTab_title;
- public static String PersistenceXmlLoggingTab_sectionTitle;
- public static String PersistenceXmlLoggingTab_sectionDescription;
- public static String PersistenceXmlLoggingTab_defaultWithOneParam;
- public static String PersistenceXmlLoggingTab_defaultEmpty;
-
- public static String PersistenceXmlLoggingTab_loggingLevelLabel;
-
- public static String LoggingLevelComposite_off;
- public static String LoggingLevelComposite_severe;
- public static String LoggingLevelComposite_warning;
- public static String LoggingLevelComposite_info;
- public static String LoggingLevelComposite_config;
- public static String LoggingLevelComposite_fine;
- public static String LoggingLevelComposite_finer;
- public static String LoggingLevelComposite_finest;
-
- public static String PersistenceXmlLoggingTab_loggerLabel;
-
- public static String LoggerComposite_default_logger;
- public static String LoggerComposite_java_logger;
- public static String LoggerComposite_server_logger;
-
- public static String PersistenceXmlLoggingTab_timestampLabel;
- public static String PersistenceXmlLoggingTab_timestampLabelDefault;
- public static String PersistenceXmlLoggingTab_threadLabel;
- public static String PersistenceXmlLoggingTab_threadLabelDefault;
- public static String PersistenceXmlLoggingTab_sessionLabel;
- public static String PersistenceXmlLoggingTab_sessionLabelDefault;
- public static String PersistenceXmlLoggingTab_exceptionsLabel;
- public static String PersistenceXmlLoggingTab_exceptionsLabelDefault;
- public static String PersistenceXmlLoggingTab_logFileLabel;
- public static String PersistenceXmlLoggingTab_logFileLabelDefault;
- public static String PersistenceXmlLoggingTab_loggersLabel;
-
- // Session Options
- public static String PersistenceXmlOptionsTab_title;
- public static String PersistenceXmlOptionsTab_sectionTitle;
- public static String PersistenceXmlOptionsTab_sectionDescription;
- public static String PersistenceXmlOptionsTab_defaultWithOneParam;
- public static String PersistenceXmlOptionsTab_defaultEmpty;
-
- public static String PersistenceXmlOptionsTab_sessionName;
- public static String PersistenceXmlOptionsTab_sessionsXml;
-
- public static String PersistenceXmlOptionsTab_includeDescriptorQueriesLabel;
- public static String PersistenceXmlOptionsTab_includeDescriptorQueriesLabelDefault;
-
- public static String PersistenceXmlOptionsTab_eventListenerLabel;
- public static String PersistenceXmlOptionsTab_targetDatabaseLabel;
-
- public static String TargetDatabaseComposite_attunity;
- public static String TargetDatabaseComposite_auto;
- public static String TargetDatabaseComposite_cloudscape;
- public static String TargetDatabaseComposite_database;
- public static String TargetDatabaseComposite_db2;
- public static String TargetDatabaseComposite_db2mainframe;
- public static String TargetDatabaseComposite_dbase;
- public static String TargetDatabaseComposite_derby;
- public static String TargetDatabaseComposite_hsql;
- public static String TargetDatabaseComposite_informix;
- public static String TargetDatabaseComposite_javadb;
- public static String TargetDatabaseComposite_mysql4;
- public static String TargetDatabaseComposite_oracle;
- public static String TargetDatabaseComposite_pointbase;
- public static String TargetDatabaseComposite_postgresql;
- public static String TargetDatabaseComposite_sqlanywhere;
- public static String TargetDatabaseComposite_sqlserver;
- public static String TargetDatabaseComposite_sybase;
- public static String TargetDatabaseComposite_timesten;
-
- // DDLGeneration
- public static String EclipseLinkDDLGeneratorUi_generatingDDLWarningTitle;
- public static String EclipseLinkDDLGeneratorUi_generatingDDLWarningMessage;
-
- private EclipseLinkUiMessages() {
- throw new UnsupportedOperationException();
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EntityDialog.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EntityDialog.java
deleted file mode 100644
index 3b0a649ed4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EntityDialog.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * EntityDialog
- */
-public class EntityDialog extends Dialog
-{
- private Entity entity;
-
- private JpaProject jpaProject;
-
- protected Combo nameCombo;
-
- private String selectedName;
-
- public EntityDialog(Shell parent, JpaProject jpaProject) {
- super(parent);
- this.jpaProject = jpaProject;
- }
-
- public EntityDialog(Shell parent, Entity entity, JpaProject jpaProject) {
- super(parent);
- this.entity = entity;
- this.jpaProject = jpaProject;
- }
-
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(getTitle());
- }
-
- protected String getTitle() {
- return EclipseLinkUiMessages.EntityDialog_selectEntity;
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- GridLayout gridLayout = (GridLayout) composite.getLayout();
- gridLayout.numColumns = 2;
-
- Label nameLabel = new Label(composite, SWT.LEFT);
- nameLabel.setText(EclipseLinkUiMessages.EntityDialog_name);
- GridData gridData = new GridData();
- nameLabel.setLayoutData(gridData);
-
- this.nameCombo = new Combo(composite, SWT.LEFT);
- gridData = new GridData();
- gridData.grabExcessHorizontalSpace = true;
- gridData.horizontalAlignment = SWT.FILL;
- this.nameCombo.setLayoutData(gridData);
-
- populateNameCombo();
- return composite;
- }
-
- protected void populateNameCombo() {
- if (selectedName != null) {
- this.nameCombo.setText(selectedName);
- }
- }
-
- protected Combo getNameCombo() {
- return this.nameCombo;
- }
-
- protected Entity getEntity() {
- return this.entity;
- }
-
- public String getSelectedName() {
- return this.selectedName;
- }
-
- public void setSelectedName(String selectedName) {
- this.selectedName = selectedName;
- }
-
- @Override
- public boolean close() {
- this.selectedName = this.nameCombo.getText();
- return super.close();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/JptEclipseLinkUiPlugin.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/JptEclipseLinkUiPlugin.java
deleted file mode 100644
index 638046d4de..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/JptEclipseLinkUiPlugin.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class JptEclipseLinkUiPlugin extends AbstractUIPlugin
-{
- private static JptEclipseLinkUiPlugin INSTANCE;
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.jpt.eclipselink.ui";
-
- // The shared instance
- private static JptEclipseLinkUiPlugin plugin;
-
- // ********** constructors **********
- public JptEclipseLinkUiPlugin() {
- super();
- INSTANCE = this;
- }
-
- /**
- * Returns the singleton Plugin
- */
- public static JptEclipseLinkUiPlugin getPlugin() {
- return INSTANCE;
- }
-
- public static void log(IStatus status) {
- INSTANCE.getLog().log(status);
- }
-
- public static void log(String msg) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, null));
- }
-
- public static void log(Throwable throwable) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, throwable.getLocalizedMessage(), throwable));
- }
-
- // ********** Image API **********
- /**
- * This gets a .gif from the icons folder.
- */
- public static ImageDescriptor getImageDescriptor(String key) {
- if (! key.startsWith("icons/")) {
- key = "icons/" + key;
- }
- if (! key.endsWith(".gif")) {
- key = key + ".gif";
- }
- return imageDescriptorFromPlugin(PLUGIN_ID, key);
- }
-
- /**
- * This returns an image for a .gif from the icons folder
- */
- public static Image getImage(String key) {
- ImageDescriptor desc = getImageDescriptor(key);
- return (desc == null) ? null : desc.createImage();
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static JptEclipseLinkUiPlugin getDefault() {
- return plugin;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheSizeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheSizeComposite.java
deleted file mode 100644
index f33a87a30a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheSizeComposite.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.caching;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
-
-/**
- * CacheSizeComposite
- */
-@SuppressWarnings("nls")
-public class CacheSizeComposite extends AbstractPane<EntityCacheProperties>
-{
- /**
- * Creates a new <code>CacheTypeComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public CacheSizeComposite(AbstractPane<EntityCacheProperties> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Integer> buildCacheSizeHolder() {
- return new PropertyAspectAdapter<EntityCacheProperties, Integer>(getSubjectHolder(), EntityCacheProperties.CACHE_SIZE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getCacheSize();
- if (value == null) {
- value = -1;
- }
- return value;
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setCacheSize(value);
- }
- };
- }
-
- private PropertyValueModel<Caching> buildCachingHolder() {
- return new TransformationPropertyValueModel<EntityCacheProperties, Caching>(getSubjectHolder()) {
- @Override
- protected Caching transform_(EntityCacheProperties value) {
- return value.getCaching();
- }
- };
- }
-
- private PropertyValueModel<Integer> buildDefaultCacheSizeHolder() {
- return new PropertyAspectAdapter<Caching, Integer>(buildCachingHolder(), Caching.CACHE_SIZE_DEFAULT_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getCacheSizeDefault();
- if (value == null) {
- value = subject.getDefaultCacheSizeDefault();
- }
- return value;
- }
- };
- }
-
- private Control buildDefaultCacheSizeLabel(Composite container) {
-
- Label label = buildLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultCacheSizeLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultCacheSizeLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultCacheSizeHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- Spinner spinner = this.buildLabeledSpinner(
- container,
- EclipseLinkUiMessages.CacheSizeComposite_cacheSize,
- this.buildCacheSizeHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- this.buildDefaultCacheSizeLabel(container)
- );
-
- updateGridData(container, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java
deleted file mode 100644
index 0fe159e179..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.caching;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.CacheType;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * CacheTypeComposite
- */
-public class CacheTypeComposite extends AbstractPane<EntityCacheProperties>
-{
- /**
- * Creates a new <code>CacheTypeComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public CacheTypeComposite(AbstractPane<EntityCacheProperties> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private EnumFormComboViewer<EntityCacheProperties, CacheType> buildCacheTypeCombo(Composite container) {
- return new EnumFormComboViewer<EntityCacheProperties, CacheType>(this, container) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(EntityCacheProperties.CACHE_TYPE_PROPERTY);
- }
-
- @Override
- protected CacheType[] choices() {
- return CacheType.values();
- }
-
- @Override
- protected boolean sortChoices() {
- return false;
- }
-
- @Override
- protected CacheType defaultValue() {
- return this.subject().getDefaultCacheType();
- }
-
- @Override
- protected String displayString(CacheType value) {
- return buildDisplayString(EclipseLinkUiMessages.class, CacheTypeComposite.this, value);
- }
-
- @Override
- protected CacheType getValue() {
- return this.subject().getCacheType();
- }
-
- @Override
- protected void setValue(CacheType value) {
- this.subject().setCacheType(value);
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildLabeledComposite(
- container,
- EclipseLinkUiMessages.PersistenceXmlCachingTab_cacheTypeLabel,
- this.buildCacheTypeCombo(container),
- null // TODO IJpaHelpContextIds.
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/DefaultCacheSizeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/DefaultCacheSizeComposite.java
deleted file mode 100644
index 50387934ff..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/DefaultCacheSizeComposite.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.caching;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
-
-/**
- * CacheSizeComposite
- */
-@SuppressWarnings("nls")
-public class DefaultCacheSizeComposite extends AbstractPane<Caching>
-{
- /**
- * Creates a new <code>CacheTypeComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public DefaultCacheSizeComposite(AbstractPane<Caching> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Integer> buildCacheSizeHolder() {
- return new PropertyAspectAdapter<Caching, Integer>(getSubjectHolder(), Caching.CACHE_SIZE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getCacheSizeDefault();
-
- if (value == null) {
- value = -1;
- }
- return value;
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setCacheSizeDefault(value);
- }
- };
- }
-
- private PropertyValueModel<Integer> buildDefaultCacheSizeHolder() {
- return new PropertyAspectAdapter<Caching, Integer>(getSubjectHolder(), "") {
- @Override
- protected Integer buildValue_() {
- return subject.getDefaultCacheSizeDefault();
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- private Control buildDefaultCacheSizeLabel(Composite container) {
-
- Label label = buildLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultCacheSizeLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultCacheSizeLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultCacheSizeHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- Spinner spinner = this.buildLabeledSpinner(
- container,
- EclipseLinkUiMessages.DefaultCacheSizeComposite_defaultCacheSize,
- this.buildCacheSizeHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- this.buildDefaultCacheSizeLabel(container)
- );
-
- updateGridData(container, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/DefaultCacheTypeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/DefaultCacheTypeComposite.java
deleted file mode 100644
index ffba8d4f94..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/DefaultCacheTypeComposite.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.caching;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.CacheType;
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * DefaultCacheTypeComposite
- */
-public class DefaultCacheTypeComposite extends AbstractFormPane<Caching>
-{
- /**
- * Creates a new <code>DefaultCacheTypeComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public DefaultCacheTypeComposite(
- AbstractFormPane<? extends Caching> parentComposite,
- Composite parent) {
-
- super( parentComposite, parent);
- }
-
- private EnumFormComboViewer<Caching, CacheType> buildDefaultCacheTypeCombo(Composite container) {
- return new EnumFormComboViewer<Caching, CacheType>(this, container) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(Caching.CACHE_TYPE_DEFAULT_PROPERTY);
- }
-
- @Override
- protected CacheType[] choices() {
- return CacheType.values();
- }
-
- @Override
- protected boolean sortChoices() {
- return false;
- }
-
- @Override
- protected CacheType defaultValue() {
- return subject().getDefaultCacheTypeDefault();
- }
-
- @Override
- protected String displayString(CacheType value) {
- return buildDisplayString(EclipseLinkUiMessages.class, DefaultCacheTypeComposite.this, value);
- }
-
- @Override
- protected CacheType getValue() {
- return subject().getCacheTypeDefault();
- }
-
- @Override
- protected void setValue(CacheType value) {
- subject().setCacheTypeDefault(value);
- }
- };
- }
-
- @Override
- protected void initializeLayout( Composite container) {
-
- this.buildLabeledComposite(
- container,
- EclipseLinkUiMessages.PersistenceXmlCachingTab_defaultCacheTypeLabel,
- this.buildDefaultCacheTypeCombo( container),
- null // TODO IJpaHelpContextIds.
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/DefaultSharedCacheComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/DefaultSharedCacheComposite.java
deleted file mode 100644
index 0dbe7500bc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/DefaultSharedCacheComposite.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.caching;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * DefaultShareCacheComposite
- */
-public class DefaultSharedCacheComposite extends AbstractFormPane<Caching>
-{
- /**
- * Creates a new <code>DefaultShareCacheComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public DefaultSharedCacheComposite(
- AbstractFormPane<? extends Caching> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildDefaultSharedCacheHolder() {
- return new PropertyAspectAdapter<Caching, Boolean>(getSubjectHolder(), Caching.SHARED_CACHE_DEFAULT_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getSharedCacheDefault();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setSharedCacheDefault(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildDefaultSharedCacheStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildDefaultSharedCacheHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultSharedCacheDefault();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlCachingTab_defaultSharedCacheDefaultLabel, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlCachingTab_sharedCacheDefaultLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlCachingTab_sharedCacheDefaultLabel,
- this.buildDefaultSharedCacheHolder(),
- this.buildDefaultSharedCacheStringHolder(),
- null
-// EclipseLinkHelpContextIds.CACHING_SHARED_CACHE_DEFAULT
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EclipseLinkCachingComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EclipseLinkCachingComposite.java
deleted file mode 100644
index f726f88072..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EclipseLinkCachingComposite.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.caching;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * EclipseLinkCachingComposite
- */
-public class EclipseLinkCachingComposite extends AbstractFormPane<Caching>
-{
- public EclipseLinkCachingComposite(AbstractFormPane<Caching> subjectHolder,
- Composite container) {
-
- super(subjectHolder, container);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- container = buildSection(
- container,
- EclipseLinkUiMessages.PersistenceXmlCachingTab_sectionTitle,
- EclipseLinkUiMessages.PersistenceXmlCachingTab_sectionDescription
- );
-
- // Default pane
- int groupBoxMargin = groupBoxMargin();
-
- Composite defaultPane = buildSubPane(
- container,
- 0, groupBoxMargin, 0, groupBoxMargin
- );
-
- // Default Cache Type
- new DefaultCacheTypeComposite(this, defaultPane);
-
- // Default Cache Size
- new DefaultCacheSizeComposite(this, defaultPane);
-
- // Default Shared Cache
- new DefaultSharedCacheComposite(this, defaultPane);
-
- // EntitiesList
- new EntityListComposite(this, container);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCacheProperties.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCacheProperties.java
deleted file mode 100644
index b4a33092f5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCacheProperties.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.caching;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.CacheType;
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-
-/**
- * EntityCacheProperties
- */
-@SuppressWarnings("nls")
-public class EntityCacheProperties extends AbstractModel {
-
- private Caching caching;
- private String entityName;
-
- private static final long serialVersionUID = 1L;
-
- public static final String CACHE_SIZE_PROPERTY = Caching.CACHE_SIZE_PROPERTY;
- public static final String CACHE_TYPE_PROPERTY = Caching.CACHE_TYPE_PROPERTY;
- public static final String SHARED_CACHE_PROPERTY = Caching.SHARED_CACHE_DEFAULT_PROPERTY;
-
- // ********** constructors **********
- public EntityCacheProperties(Caching caching, String entityName) {
- super();
- this.caching = caching;
- this.entityName = entityName;
- }
-
- public boolean entityNameIsValid() {
- return !StringTools.stringIsEmpty(this.entityName);
- }
-
- public Integer getCacheSize() {
- return this.caching.getCacheSize(this.entityName);
- }
-
- public CacheType getCacheType() {
- return this.caching.getCacheType(this.entityName);
- }
-
- public Caching getCaching() {
- return caching;
- }
-
- public Integer getDefaultCacheSize() {
- return this.caching.getDefaultCacheSize();
- }
-
- public CacheType getDefaultCacheType() {
- return this.caching.getDefaultCacheType();
- }
-
- public String getEntityName() {
- return this.entityName;
- }
-
- public Boolean getSharedCache() {
- return this.caching.getSharedCache(this.entityName);
- }
-
- public Boolean getDefaultSharedCache() {
- return this.caching.getDefaultSharedCache();
- }
-
- public void setCacheSize(Integer cacheSize) {
- Integer oldCacheSize = this.getCacheSize();
- this.caching.setCacheSize(cacheSize, this.entityName);
- this.firePropertyChanged(CACHE_SIZE_PROPERTY, oldCacheSize, cacheSize);
- }
-
- public void setCacheType(CacheType cacheType) {
- CacheType oldCacheType = this.getCacheType();
- this.caching.setCacheType(cacheType, this.entityName);
- this.firePropertyChanged(CACHE_TYPE_PROPERTY, oldCacheType, cacheType);
- }
-
- public void setSharedCache(Boolean sharedCache) {
- Boolean oldSharedCache = this.getSharedCache();
- this.caching.setSharedCache(sharedCache, this.entityName);
- this.firePropertyChanged(SHARED_CACHE_PROPERTY, oldSharedCache, sharedCache);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- StringTools.buildSimpleToStringOn(this, sb);
- sb.append(" (");
- this.toString(sb);
- sb.append(')');
- return sb.toString();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append("name: ");
- sb.append(this.entityName);
- sb.append(", type: ");
- sb.append(this.getCacheType());
- sb.append(", size: ");
- sb.append(this.getCacheSize());
- sb.append(", isShared: ");
- sb.append(this.getSharedCache());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCachingPropertyComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCachingPropertyComposite.java
deleted file mode 100644
index 5be8a632ce..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCachingPropertyComposite.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.caching;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @version 2.0
- * @since 2.0
- */
-public class EntityCachingPropertyComposite extends AbstractPane<EntityCacheProperties> {
-
- /**
- * Creates a new <code>EntityCachingPropertyComposite</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- */
- public EntityCachingPropertyComposite(AbstractPane<Caching> parentComposite,
- PropertyValueModel<EntityCacheProperties> subjectHolder,
- Composite parent) {
-
- super(parentComposite, subjectHolder, parent);
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeLayout(Composite container) {
-
- // Cache Type
- new CacheTypeComposite(this, container);
-
- // Cache Size
- new CacheSizeComposite(this, container);
-
- // Share Cache
- new SharedCacheComposite(this, container);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java
deleted file mode 100644
index 07520792d3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.caching;
-
-import java.util.ListIterator;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.eclipselink.ui.internal.EntityDialog;
-import org.eclipse.jpt.ui.internal.util.PaneEnabler;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.TransformationListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * EntityListComposite
- */
-public class EntityListComposite extends AbstractPane<Caching>
-{
- public EntityListComposite(AbstractPane<Caching> parentComposite, Composite parent) {
-
- super(parentComposite, parent);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- container = this.buildTitledPane(
- container,
- EclipseLinkUiMessages.CachingEntityListComposite_groupTitle
- );
-
- WritablePropertyValueModel<EntityCacheProperties> entityHolder = this.buildEntityHolder();
-
- // Entities add/remove list pane
- new AddRemoveListPane<Caching>(
- this,
- container,
- this.buildEntitiesAdapter(),
- this.buildEntityCachingListHolder(),
- entityHolder,
- this.buildEntityLabelProvider(),
- null // EclipseLinkHelpContextIds.CACHING_ENTITIES
- );
-
- // Entity Caching property pane
- EntityCachingPropertyComposite pane = new EntityCachingPropertyComposite(
- this,
- entityHolder,
- container
- );
-
- this.installPaneEnabler(entityHolder, pane);
- }
-
- private void installPaneEnabler(WritablePropertyValueModel<EntityCacheProperties> entityHolder,
- EntityCachingPropertyComposite pane) {
-
- new PaneEnabler(
- this.buildPaneEnablerHolder(entityHolder),
- pane
- );
- }
-
- private PropertyValueModel<Boolean> buildPaneEnablerHolder(WritablePropertyValueModel<EntityCacheProperties> entityHolder) {
- return new TransformationPropertyValueModel<EntityCacheProperties, Boolean>(entityHolder) {
- @Override
- protected Boolean transform_(EntityCacheProperties value) {
- return value.entityNameIsValid();
- }
- };
- }
-
- private AddRemoveListPane.Adapter buildEntitiesAdapter() {
- return new AddRemoveListPane.AbstractAdapter() {
-
- public void addNewItem(ObjectListSelectionModel listSelectionModel) {
- addEntityFromDialog(listSelectionModel);
- }
-
- public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
- Caching caching = subject();
- for (Object item : listSelectionModel.selectedValues()) {
- EntityCacheProperties entityCaching = (EntityCacheProperties) item;
- caching.removeEntity(entityCaching.getEntityName());
- }
- }
- };
- }
-
- private void addEntityFromDialog(ObjectListSelectionModel listSelectionModel) {
-
- EntityDialog dialog = new EntityDialog(getControl().getShell(), jpaProject());
-
- if (dialog.open() == Window.OK) {
- String name = dialog.getSelectedName();
- String entity = this.subject().addEntity(name);
-
- listSelectionModel.setSelectedValue(entity);
- }
- }
-
- private ILabelProvider buildEntityLabelProvider() {
- return new LabelProvider() {
- @Override
- public String getText(Object element) {
- EntityCacheProperties entityCaching = (EntityCacheProperties) element;
- return entityCaching.getEntityName();
- }
- };
- }
-
- private WritablePropertyValueModel<EntityCacheProperties> buildEntityHolder() {
- return new SimplePropertyValueModel<EntityCacheProperties>();
- }
-
- private JpaProject jpaProject() {
- // TODO
- return null;
- }
-
- private ListValueModel<EntityCacheProperties> buildEntityCachingListHolder() {
- return new TransformationListValueModelAdapter<String, EntityCacheProperties>(buildEntitiesListHolder()) {
- @Override
- protected EntityCacheProperties transformItem(String item) {
- return new EntityCacheProperties(subject(), item);
- }
- };
- }
-
- private ListValueModel<String> buildEntitiesListHolder() {
- return new ListAspectAdapter<Caching, String>(
- this.getSubjectHolder(), Caching.ENTITIES_LIST_PROPERTY) {
- @Override
- protected ListIterator<String> listIterator_() {
- return this.subject.entities();
- }
- @Override
- protected int size_() {
- return this.subject.entitiesSize();
- }
- };
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/PersistenceXmlCachingTab.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/PersistenceXmlCachingTab.java
deleted file mode 100644
index c7cdba6d75..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/PersistenceXmlCachingTab.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007, 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.caching;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.WidgetFactory;
-import org.eclipse.jpt.ui.details.JpaPageComposite;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * PersistenceXmlCachingTab
- */
-public class PersistenceXmlCachingTab
- extends AbstractFormPane<Caching>
- implements JpaPageComposite<PersistenceUnit>
-{
- public PersistenceXmlCachingTab(
- PropertyValueModel<Caching> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- new EclipseLinkCachingComposite(this, container);
- }
-
- // ********** JpaPageComposite implementation **********
-
- public String getHelpID() {
- return null;
- }
-
- public Image getPageImage() {
- return null;
- }
- public String getPageText() {
- return EclipseLinkUiMessages.PersistenceXmlCachingTab_title;
- }
-
- // ********** Layout **********
-
- @Override
- protected Composite buildContainer(Composite parent) {
- GridLayout layout = new GridLayout(1, true);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.marginTop = 0;
- layout.marginLeft = 0;
- layout.marginBottom = 0;
- layout.marginRight = 0;
- layout.verticalSpacing = 15;
-
- Composite container = buildPane(parent, layout);
- updateGridData(container);
-
- return container;
- }
-
- private void updateGridData(Composite container) {
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = SWT.FILL;
- gridData.verticalAlignment = SWT.FILL;
- container.setLayoutData(gridData);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/SharedCacheComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/SharedCacheComposite.java
deleted file mode 100644
index 9e6febdc88..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/SharedCacheComposite.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.caching;
-
-import java.util.ArrayList;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.ui.internal.widgets.TriStateCheckBox;
-import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.ListPropertyValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * SharedCacheComposite
- */
-public class SharedCacheComposite extends AbstractPane<EntityCacheProperties>
-{
- private TriStateCheckBox sharedCacheCheckBox;
-
- /**
- * Creates a new <code>ShareCacheComposite</code>.
- *
- * @param parentController The parent container of this one
- * @param parent The parent container
- */
- public SharedCacheComposite(AbstractPane<EntityCacheProperties> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private PropertyValueModel<Caching> buildCachingHolder() {
- return new TransformationPropertyValueModel<EntityCacheProperties, Caching>(getSubjectHolder()) {
- @Override
- protected Caching transform_(EntityCacheProperties value) {
- return value.getCaching();
- }
- };
- }
-
- private PropertyValueModel<Boolean> buildDefaultAndNonDefaultSharedCacheHolder() {
- return new ListPropertyValueModelAdapter<Boolean>(
- buildDefaultAndNonDefaultSharedCacheListHolder()
- ) {
- @Override
- protected Boolean buildValue() {
- // If the number of ListValueModel equals 1, that means the shared
- // Cache properties is not set (partially selected), which means we
- // want to see the default value appended to the text
- if (listHolder.size() == 1) {
- return (Boolean) listHolder.listIterator().next();
- }
- return null;
- }
- };
- };
-
- private ListValueModel<Boolean> buildDefaultAndNonDefaultSharedCacheListHolder() {
- ArrayList<ListValueModel<Boolean>> holders = new ArrayList<ListValueModel<Boolean>>(2);
- holders.add(buildSharedCacheListHolder());
- holders.add(buildDefaultSharedCacheListHolder());
-
- return new CompositeListValueModel<ListValueModel<Boolean>, Boolean>(
- holders
- );
- }
-
- private PropertyValueModel<Boolean> buildDefaultSharedCacheHolder() {
- return new PropertyAspectAdapter<Caching, Boolean>(buildCachingHolder(), Caching.SHARED_CACHE_DEFAULT_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- Boolean value = subject.getSharedCacheDefault();
- if (value == null) {
- value = subject.getDefaultSharedCacheDefault();
- }
- return value;
- }
- };
- }
-
- private ListValueModel<Boolean> buildDefaultSharedCacheListHolder() {
- return new PropertyListValueModelAdapter<Boolean>(
- buildDefaultSharedCacheHolder()
- );
- }
-
- private WritablePropertyValueModel<Boolean> buildSharedCacheHolder() {
- return new PropertyAspectAdapter<EntityCacheProperties, Boolean>(
- getSubjectHolder(), EntityCacheProperties.SHARED_CACHE_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getSharedCache();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setSharedCache(value);
- }
- };
- }
-
- private ListValueModel<Boolean> buildSharedCacheListHolder() {
- return new PropertyListValueModelAdapter<Boolean>(
- buildSharedCacheHolder()
- );
- }
-
- private PropertyValueModel<String> buildSharedCacheStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildDefaultAndNonDefaultSharedCacheHolder()) {
- @Override
- protected String transform(Boolean value) {
- if (value != null) {
- String defaultStringValue = value ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlCachingTab_defaultSharedCacheLabel, defaultStringValue);
- }
- return EclipseLinkUiMessages.PersistenceXmlCachingTab_sharedCacheLabel;
- }
- };
- }
-
- @Override
- public void enableWidgets(boolean enabled) {
- super.enableWidgets(enabled);
- this.sharedCacheCheckBox.setEnabled(enabled);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.sharedCacheCheckBox = this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlCachingTab_sharedCacheLabel,
- this.buildSharedCacheHolder(),
- this.buildSharedCacheStringHolder(),
- null
-// EclipseLinkHelpContextIds.CACHING_SHARED_CACHE
- );
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/BatchWritingComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/BatchWritingComposite.java
deleted file mode 100644
index 6b0152186e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/BatchWritingComposite.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.BatchWriting;
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * BatchWritingComposite
- */
-public class BatchWritingComposite extends AbstractFormPane<Connection>
-{
- /**
- * Creates a new <code>BatchWritingComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public BatchWritingComposite(
- AbstractFormPane<? extends Connection> parentComposite,
- Composite parent) {
-
- super( parentComposite, parent);
- }
-
- private EnumFormComboViewer<Connection, BatchWriting> buildBatchWritingCombo(Composite container) {
- return new EnumFormComboViewer<Connection, BatchWriting>(this, container) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(Connection.BATCH_WRITING_PROPERTY);
- }
-
- @Override
- protected BatchWriting[] choices() {
- return BatchWriting.values();
- }
-
- @Override
- protected BatchWriting defaultValue() {
- return subject().getDefaultBatchWriting();
- }
-
- @Override
- protected String displayString(BatchWriting value) {
- return buildDisplayString(EclipseLinkUiMessages.class, BatchWritingComposite.this, value);
- }
-
- @Override
- protected BatchWriting getValue() {
- return subject().getBatchWriting();
- }
-
- @Override
- protected void setValue(BatchWriting value) {
- subject().setBatchWriting(value);
- }
- };
- }
-
- @Override
- protected void initializeLayout( Composite container) {
-
- this.buildLabeledComposite(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_batchWritingLabel,
- this.buildBatchWritingCombo( container),
- null // TODO IJpaHelpContextIds.
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsPropertiesComposite.java
deleted file mode 100644
index 5f702580c1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsPropertiesComposite.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.ControlEnabler;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.ui.internal.widgets.TriStateCheckBox;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
-
-/**
- * CacheStatementsPropertiesComposite
- */
-@SuppressWarnings("nls")
-public class CacheStatementsPropertiesComposite extends AbstractPane<Connection>
-{
- public CacheStatementsPropertiesComposite(AbstractPane<Connection> parentComposite, Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildCacheStatementsHolder() {
- return new PropertyAspectAdapter<Connection, Boolean>(getSubjectHolder(), Connection.CACHE_STATEMENTS_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getCacheStatements();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setCacheStatements(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private WritablePropertyValueModel<Integer> buildCacheStatementsSizeHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.CACHE_STATEMENTS_SIZE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getCacheStatementsSize();
-
- if (value == null) {
- value = -1;
- }
- return value;
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setCacheStatementsSize(value);
- }
- };
- }
-
- private PropertyValueModel<Integer> buildDefaultCacheStatementsSizeHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
- @Override
- protected Integer buildValue_() {
- return subject.getDefaultCacheStatementsSize();
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- private Label buildDefaultCacheStatementsSizeLabel(Composite container) {
-
- Label label = buildLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultCacheStatementsSizeLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultCacheStatementsSizeLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultCacheStatementsSizeHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- WritablePropertyValueModel<Boolean> cacheStatementsHolder = buildCacheStatementsHolder();
-
- TriStateCheckBox checkBox = this.buildTriStateCheckBox(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_cacheStatementsLabel,
- cacheStatementsHolder,
- null
- );
-
- Spinner spinner = this.buildSpinner(
- container,
- this.buildCacheStatementsSizeHolder(),
- -1,
- -1,
- Integer.MAX_VALUE
- );
-
- Label label = this.buildDefaultCacheStatementsSizeLabel(container);
-
- this.buildLabeledComposite(
- container,
- checkBox.getCheckBox(),
- (spinner.getParent() == container) ? spinner : spinner.getParent(),
- label,
- null
-// EclipseLinkHelpContextIds.
- );
-
- this.installControlEnabler(cacheStatementsHolder, label, spinner);
- this.updateGridData(container, spinner);
- }
-
- private void installControlEnabler(WritablePropertyValueModel<Boolean> cacheStatementsHolder,
- Label label,
- Spinner spinner) {
-
- new ControlEnabler(cacheStatementsHolder, label, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/ConnectionPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/ConnectionPropertiesComposite.java
deleted file mode 100644
index bdda408506..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/ConnectionPropertiesComposite.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * ConnectionPropertiesComposite
- */
-public class ConnectionPropertiesComposite extends AbstractPane<Connection>
-{
- public ConnectionPropertiesComposite(AbstractPane<Connection> parentComposite, Composite parent) {
-
- super(parentComposite, parent);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- container = buildTitledPane(
- container,
- EclipseLinkUiMessages.ConnectionPropertiesComposite_Database_GroupBox
- );
-
- new DataSourcePropertiesComposite(this, container);
- new JdbcPropertiesComposite(this, container);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/DataSourcePropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/DataSourcePropertiesComposite.java
deleted file mode 100644
index 11a2533d19..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/DataSourcePropertiesComposite.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnitTransactionType;
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.ControlEnabler;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * @version 2.0
- * @since 2.0
- */
-public class DataSourcePropertiesComposite extends AbstractPane<Connection> {
-
- /**
- * Creates a new <code>DataSourcePropertiesComposite</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- */
- public DataSourcePropertiesComposite(AbstractPane<Connection> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<String> buildJtaDataSourceHolder() {
- return new PropertyAspectAdapter<Connection, String>(getSubjectHolder(), Connection.JTA_DATA_SOURCE_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.getJtaDataSource();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- subject.setJtaDataSource(value);
- }
- };
- }
-
- private PropertyValueModel<Boolean> buildJTADataSourceHolder() {
- return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) {
- @Override
- protected Boolean transform(PersistenceUnitTransactionType value) {
- return value == null || value == PersistenceUnitTransactionType.JTA;
- }
- };
- }
-
- private WritablePropertyValueModel<String> buildNonJtaDataSourceHolder() {
- return new PropertyAspectAdapter<Connection, String>(getSubjectHolder(), Connection.NON_JTA_DATA_SOURCE_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.getNonJtaDataSource();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- subject.setNonJtaDataSource(value);
- }
- };
- }
-
- private PropertyValueModel<Boolean> buildNonJTADataSourceHolder() {
- return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) {
- @Override
- protected Boolean transform(PersistenceUnitTransactionType value) {
- return value == PersistenceUnitTransactionType.RESOURCE_LOCAL;
- }
- };
- }
-
- private PropertyValueModel<PersistenceUnitTransactionType> buildTransactionTypeHolder() {
- return new PropertyAspectAdapter<Connection, PersistenceUnitTransactionType>(getSubjectHolder(), Connection.TRANSACTION_TYPE_PROPERTY) {
- @Override
- protected PersistenceUnitTransactionType buildValue_() {
- return subject.getTransactionType();
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- int groupBoxMargin = groupBoxMargin();
-
- container = buildSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin);
-
- // JTA Data Source
- Text text = this.buildLabeledText(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_jtaDataSourceLabel,
- buildJtaDataSourceHolder()
- );
-
- this.installJTADataSourceControlEnabler(text);
-
- // Non-JTA Data Source
- text = this.buildLabeledText(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_nonJtaDataSourceLabel,
- buildNonJtaDataSourceHolder()
- );
-
- this.installNonJTADataSourceControlEnabler(text);
- }
-
- private void installJTADataSourceControlEnabler(Text text) {
- new ControlEnabler(buildJTADataSourceHolder(), text);
- }
-
- private void installNonJTADataSourceControlEnabler(Text text) {
- new ControlEnabler(buildNonJTADataSourceHolder(), text);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/EclipseLinkConnectionComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/EclipseLinkConnectionComposite.java
deleted file mode 100644
index b267a226cd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/EclipseLinkConnectionComposite.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * EclipseLinkConnectionComposite
- */
-public class EclipseLinkConnectionComposite
- extends AbstractFormPane<Connection>
-{
- public EclipseLinkConnectionComposite(
- AbstractFormPane<Connection> subjectHolder,
- Composite container) {
- super(subjectHolder, container, false);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- int groupBoxMargin = groupBoxMargin() * 2;
-
- container = buildSection(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_sectionTitle,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_sectionDescription
- );
-
- Composite subPane = buildSubPane(
- container,
- 0, groupBoxMargin, 10, groupBoxMargin
- );
-
- new TransactionTypeComposite(this, subPane);
-
- new BatchWritingComposite(this, subPane);
-
- new CacheStatementsPropertiesComposite(this, subPane);
-
- new NativeSqlComposite(this, subPane);
-
- new ConnectionPropertiesComposite(this, container);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcBindParametersComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcBindParametersComposite.java
deleted file mode 100644
index a1f80707c7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcBindParametersComposite.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * JdbcBindParametersComposite
- */
-public class JdbcBindParametersComposite extends AbstractPane<Connection>
-{
- /**
- * Creates a new <code>JdbcBindParametersComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public JdbcBindParametersComposite(
- AbstractPane<? extends Connection> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildBindParametersHolder() {
- return new PropertyAspectAdapter<Connection, Boolean>(getSubjectHolder(), Connection.BIND_PARAMETERS_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getBindParameters();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setBindParameters(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildBindParametersStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildBindParametersHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultBindParameters();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlConnectionTab_bindParametersLabelDefault, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlConnectionTab_bindParametersLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_bindParametersLabel,
- this.buildBindParametersHolder(),
- this.buildBindParametersStringHolder(),
- null
-// EclipseLinkHelpContextIds.
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcConnectionPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcConnectionPropertiesComposite.java
deleted file mode 100644
index 2bbe6c9c0a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcConnectionPropertiesComposite.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import java.util.Comparator;
-import java.util.Iterator;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jpt.db.ConnectionProfile;
-import org.eclipse.jpt.db.JptDbPlugin;
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.JptUiPlugin;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
-
-/**
- * JdbcConnectionPropertiesComposite
- */
-@SuppressWarnings("nls")
-public class JdbcConnectionPropertiesComposite extends AbstractPane<Connection>
-{
- /**
- * The constant ID used to retrieve the dialog settings.
- */
- private static final String DIALOG_SETTINGS = "org.eclipse.jpt.eclipselink.ui.dialogs.ConnectionDialog";
-
- public JdbcConnectionPropertiesComposite(AbstractPane<Connection> parentComposite, Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<String> buildPasswordHolder() {
- return new PropertyAspectAdapter<Connection, String>(getSubjectHolder(), Connection.PASSWORD_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.getPassword();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- subject.setPassword(value);
- }
- };
- }
-
- private Runnable buildPopulateFromConnectionAction() {
- return new Runnable() {
- public void run() {
- promptConnection();
- }
- };
- }
-
- private WritablePropertyValueModel<String> buildUrlHolder() {
- return new PropertyAspectAdapter<Connection, String>(getSubjectHolder(), Connection.URL_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.getUrl();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- subject.setUrl(value);
- }
- };
- }
-
- private WritablePropertyValueModel<String> buildUserHolder() {
- return new PropertyAspectAdapter<Connection, String>(getSubjectHolder(), Connection.USER_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.getUser();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- subject.setUser(value);
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- // Populate from Connection hyperlink
- this.buildHyperLink(
- container,
- "Populate from Connection...",
- buildPopulateFromConnectionAction()
- );
-
- // Driver
- new JdbcDriverComposite(this, container);
-
- // Url
- this.buildLabeledText(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_urlLabel,
- buildUrlHolder()
- );
-
- // User
- this.buildLabeledText(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_userLabel,
- buildUserHolder()
- );
-
- // Password
- this.buildLabeledPasswordText(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_passwordLabel,
- buildPasswordHolder()
- );
-
- // Bind Parameters
- new JdbcBindParametersComposite(this, container);
- }
-
- private void promptConnection() {
-
- ConnecionSelectionDialog dialog = new ConnecionSelectionDialog();
-
- if (dialog.open() == IDialogConstants.OK_ID) {
-
- String name = (String) dialog.getResult()[0];
- ConnectionProfile profile = JptDbPlugin.instance().getConnectionProfileRepository().connectionProfileNamed(name);
-
- Connection connection = subject();
- connection.setUrl(profile.getUrl());
- connection.setUser(profile.getUserName());
- connection.setPassword(profile.getUserPassword());
- connection.setDriver(profile.getDriverClassName());
- }
- }
-
- /**
- * This dialog shows the list of possible connection names and lets the user
- * the option to filter them using a search field.
- */
- protected class ConnecionSelectionDialog extends FilteredItemsSelectionDialog {
-
- /**
- * Creates a new <code>MappingSelectionDialog</code>.
- */
- private ConnecionSelectionDialog() {
- super(JdbcConnectionPropertiesComposite.this.shell(), false);
- setMessage(EclipseLinkUiMessages.JdbcConnectionPropertiesComposite_ConnectionDialog_Message);
- setTitle(EclipseLinkUiMessages.JdbcConnectionPropertiesComposite_ConnectionDialog_Title);
- setListLabelProvider(buildLabelProvider());
- setDetailsLabelProvider(buildLabelProvider());
- }
-
- private ILabelProvider buildLabelProvider() {
- return new LabelProvider() {
- @Override
- public Image getImage(Object element) {
- return null;
- }
-
- @Override
- public String getText(Object element) {
- return (element == null) ? "" : element.toString();
- }
- };
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected Control createExtendedContentArea(Composite parent) {
- return null;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected ItemsFilter createFilter() {
- return new ConnectionItemsFilter();
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void fillContentProvider(AbstractContentProvider provider,
- ItemsFilter itemsFilter,
- IProgressMonitor monitor) throws CoreException {
-
- monitor.beginTask(null, -1);
-
- try {
- // Add the connection names to the dialog
- for (Iterator<String> names = JptDbPlugin.instance().getConnectionProfileRepository().connectionProfileNames(); names.hasNext(); ) {
- provider.add(names.next(), itemsFilter);
- }
- }
- finally {
- monitor.done();
- }
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected IDialogSettings getDialogSettings() {
-
- IDialogSettings dialogSettings = JptUiPlugin.getPlugin().getDialogSettings();
- IDialogSettings settings = dialogSettings.getSection(DIALOG_SETTINGS);
-
- if (settings == null) {
- settings = dialogSettings.addNewSection(DIALOG_SETTINGS);
- }
-
- return settings;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public String getElementName(Object object) {
- return object.toString();
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected Comparator<String> getItemsComparator() {
- return new Comparator<String>() {
- public int compare(String item1, String item2) {
- return item1.compareTo(item2);
- }
- };
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected IStatus validateItem(Object item) {
-
- if (item == null) {
- return new Status(IStatus.ERROR, JptUiPlugin.PLUGIN_ID, IStatus.ERROR, "", null);
- }
-
- return Status.OK_STATUS;
- }
-
- /**
- * Create the filter responsible to remove any connection name based on
- * the pattern entered in the text field.
- */
- private class ConnectionItemsFilter extends ItemsFilter {
-
- /**
- * Creates a new <code>ConnectionItemsFilter</code>.
- */
- ConnectionItemsFilter() {
-
- super();
-
- // Make sure that if the pattern is empty, we specify * in order
- // to show all the mapping types
- if (StringTools.stringIsEmpty(getPattern())) {
- patternMatcher.setPattern("*");
- }
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public boolean isConsistentItem(Object item) {
- return true;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public boolean matchItem(Object item) {
- return matches(item.toString());
- }
- }
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcDriverComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcDriverComposite.java
deleted file mode 100644
index cc897af3a7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcDriverComposite.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * JdbcDriverComposite
- */
-public class JdbcDriverComposite extends AbstractPane<Connection>
-{
- /**
- * Creates a new <code>EventListenerComposite</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- */
- public JdbcDriverComposite(AbstractPane<? extends Connection> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- private ClassChooserPane<Connection> initializeClassChooser(Composite container) {
-
- return new ClassChooserPane<Connection>(this, container) {
-
- @Override
- protected WritablePropertyValueModel<String> buildTextHolder() {
- return new PropertyAspectAdapter<Connection, String>(getSubjectHolder(), Connection.DRIVER_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.getDriver();
- }
-
- @Override
- protected void setValue_(String value) {
-
- if (value.length() == 0) {
- value = null;
- }
-
- subject.setDriver(value);
- }
- };
- }
-
- @Override
- protected String className() {
- return subject().getDriver();
- }
-
- @Override
- protected String labelText() {
- return EclipseLinkUiMessages.PersistenceXmlConnectionTab_driverLabel;
- }
-
- @Override
- protected IPackageFragmentRoot packageFragmentRoot() {
- //TODO
-// IProject project = subject().getJpaProject().getProject();
-// IJavaProject root = JavaCore.create(project);
-//
-// try {
-// return root.getAllPackageFragmentRoots()[0];
-// }
-// catch (JavaModelException e) {
-// JptEclipseLinkUiPlugin.log(e);
-// }
- return null;
- }
-
- @Override
- protected void promptType() {
- IType type = chooseType();
-
- if (type != null) {
- String className = type.getFullyQualifiedName('.');
- subject().setDriver(className);
- }
- }
- };
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeLayout(Composite container) {
- this.initializeClassChooser(container);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcPropertiesComposite.java
deleted file mode 100644
index 065a074319..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcPropertiesComposite.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnitTransactionType;
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.PaneEnabler;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * JdbcPropertiesComposite
- */
-public class JdbcPropertiesComposite extends AbstractPane<Connection>
-{
- public JdbcPropertiesComposite(AbstractPane<Connection> parentComposite, Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private PropertyValueModel<Boolean> buildPaneEnablerHolder() {
- return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) {
- @Override
- protected Boolean transform(PersistenceUnitTransactionType value) {
- return value == PersistenceUnitTransactionType.RESOURCE_LOCAL;
- }
- };
- }
-
- private PropertyValueModel<PersistenceUnitTransactionType> buildTransactionTypeHolder() {
- return new PropertyAspectAdapter<Connection, PersistenceUnitTransactionType>(getSubjectHolder(), Connection.TRANSACTION_TYPE_PROPERTY) {
- @Override
- protected PersistenceUnitTransactionType buildValue_() {
- return subject.getTransactionType();
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- container = buildTitledPane(
- buildSubPane(container, 10),
- EclipseLinkUiMessages.JdbcPropertiesComposite_EclipseLinkConnectionPool_GroupBox
- );
-
- new JdbcConnectionPropertiesComposite(this, container);
-
- container = buildPane(container, new GridLayout(2, true));
-
- new JdbcReadConnectionPropertiesComposite(this, container);
- new JdbcWriteConnectionPropertiesComposite(this, container);
-
- this.installPaneEnabler();
- }
-
- private void installPaneEnabler() {
- new PaneEnabler(buildPaneEnablerHolder(), this);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionPropertiesComposite.java
deleted file mode 100644
index 94fe416459..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionPropertiesComposite.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * JdbcReadConnectionPropertiesComposite
- */
-public class JdbcReadConnectionPropertiesComposite extends AbstractPane<Connection>
-{
- public JdbcReadConnectionPropertiesComposite(AbstractPane<Connection> parentComposite, Composite parent) {
-
- super(parentComposite, parent, false);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- container = this.buildSection(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsSectionTitle
- );
-
- GridData data = (GridData) container.getLayoutData();
- data.verticalAlignment = SWT.TOP;
-
- data = (GridData) getControl().getLayoutData();
- data.verticalAlignment = SWT.TOP;
-
- // Read Connections Shared
- new JdbcReadConnectionsSharedComposite(this, container);
-
- // Read Connections Minimum
- new JdbcReadConnectionsMinComposite(this, container);
-
- // Read Connections Maximum
- new JdbcReadConnectionsMaxComposite(this, container);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMaxComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMaxComposite.java
deleted file mode 100644
index e27a93fc75..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMaxComposite.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
-
-/**
- * JdbcReadConnectionsMaxComposite
- */
-@SuppressWarnings("nls")
-public class JdbcReadConnectionsMaxComposite extends AbstractPane<Connection>
-{
- /**
- * Creates a new <code>JdbcReadConnectionsMaxComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public JdbcReadConnectionsMaxComposite(AbstractPane<Connection> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Integer> buildReadConnectionsMaxHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.READ_CONNECTIONS_MAX_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getReadConnectionsMax();
-
- if (value == null) {
- value = -1;
- }
- return value;
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setReadConnectionsMax(value);
- }
- };
- }
-
- private PropertyValueModel<Integer> buildDefaultReadConnectionsMaxHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
- @Override
- protected Integer buildValue_() {
- return subject.getDefaultReadConnectionsMax();
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- private Control buildDefaultReadConnectionsMaxLabel(Composite container) {
-
- Label label = buildLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultReadConnectionsMaxLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultReadConnectionsMaxLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultReadConnectionsMaxHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- Spinner spinner = this.buildLabeledSpinner(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsMaxLabel,
- this.buildReadConnectionsMaxHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- this.buildDefaultReadConnectionsMaxLabel(container)
- );
-
- updateGridData(container, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMinComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMinComposite.java
deleted file mode 100644
index 07c5f88113..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMinComposite.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
-
-/**
- * JdbcReadConnectionsMinComposite
- */
-@SuppressWarnings("nls")
-public class JdbcReadConnectionsMinComposite extends AbstractPane<Connection>
-{
- /**
- * Creates a new <code>JdbcReadConnectionsMinComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public JdbcReadConnectionsMinComposite(AbstractPane<Connection> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Integer> buildReadConnectionsMinHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.READ_CONNECTIONS_MIN_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getReadConnectionsMin();
-
- if (value == null) {
- value = -1;
- }
- return value;
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setReadConnectionsMin(value);
- }
- };
- }
-
- private PropertyValueModel<Integer> buildDefaultReadConnectionsMinHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
- @Override
- protected Integer buildValue_() {
- return subject.getDefaultReadConnectionsMin();
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- private Control buildDefaultReadConnectionsMinLabel(Composite container) {
-
- Label label = buildLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultReadConnectionsMinLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultReadConnectionsMinLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultReadConnectionsMinHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- Spinner spinner = this.buildLabeledSpinner(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsMinLabel,
- this.buildReadConnectionsMinHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- this.buildDefaultReadConnectionsMinLabel(container)
- );
-
- updateGridData(container, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsSharedComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsSharedComposite.java
deleted file mode 100644
index 547b654c24..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsSharedComposite.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * ReadConnectionsSharedComposite
- */
-public class JdbcReadConnectionsSharedComposite extends AbstractPane<Connection>
-{
- /**
- * Creates a new <code>ReadConnectionsSharedComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public JdbcReadConnectionsSharedComposite(
- AbstractPane<? extends Connection> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildReadConnectionsSharedHolder() {
- return new PropertyAspectAdapter<Connection, Boolean>(getSubjectHolder(), Connection.READ_CONNECTIONS_SHARED_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getReadConnectionsShared();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setReadConnectionsShared(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildReadConnectionsSharedStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildReadConnectionsSharedHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultReadConnectionsShared();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsSharedLabelDefault, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsSharedLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsSharedLabel,
- this.buildReadConnectionsSharedHolder(),
- this.buildReadConnectionsSharedStringHolder(),
- null
-// EclipseLinkHelpContextIds.
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionPropertiesComposite.java
deleted file mode 100644
index c62c741194..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionPropertiesComposite.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * JdbcWriteConnectionPropertiesComposite
- */
-@SuppressWarnings("nls")
-public class JdbcWriteConnectionPropertiesComposite extends AbstractPane<Connection>
-{
- public JdbcWriteConnectionPropertiesComposite(AbstractPane<Connection> parentComposite, Composite parent) {
-
- super(parentComposite, parent, false);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- container = this.buildSection(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_writeConnectionsSectionTitle
- );
-
- GridData data = (GridData) container.getLayoutData();
- data.verticalAlignment = SWT.TOP;
-
- data = (GridData) getControl().getLayoutData();
- data.verticalAlignment = SWT.TOP;
-
- // This will add space to have the same layout than read connection pool
- Button space = this.getWidgetFactory().createCheckBox(container, "m");
- Point size = space.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- container = this.buildSubPane(container, size.y + 5);
- space.dispose();
-
- // Write Connections Minimum
- new JdbcWriteConnectionsMinComposite(this, container);
-
- // Write Connections Maximum
- new JdbcWriteConnectionsMaxComposite(this, container);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMaxComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMaxComposite.java
deleted file mode 100644
index d5336af9f0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMaxComposite.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
-
-/**
- * JdbcWriteConnectionsMaxComposite
- */
-@SuppressWarnings("nls")
-public class JdbcWriteConnectionsMaxComposite extends AbstractPane<Connection>
-{
- /**
- * Creates a new <code>JdbcWriteConnectionsMaxComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public JdbcWriteConnectionsMaxComposite(AbstractPane<Connection> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Integer> buildWriteConnectionsMaxHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.WRITE_CONNECTIONS_MAX_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getWriteConnectionsMax();
-
- if (value == null) {
- value = -1;
- }
- return value;
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setWriteConnectionsMax(value);
- }
- };
- }
-
- private PropertyValueModel<Integer> buildDefaultWriteConnectionsMaxHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
- @Override
- protected Integer buildValue_() {
- return subject.getDefaultWriteConnectionsMax();
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- private Control buildDefaultWriteConnectionsMaxLabel(Composite container) {
-
- Label label = buildLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultWriteConnectionsMaxLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultWriteConnectionsMaxLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultWriteConnectionsMaxHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- Spinner spinner = this.buildLabeledSpinner(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_writeConnectionsMaxLabel,
- this.buildWriteConnectionsMaxHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- this.buildDefaultWriteConnectionsMaxLabel(container)
- );
-
- updateGridData(container, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMinComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMinComposite.java
deleted file mode 100644
index bc39035de9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMinComposite.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
-
-/**
- * JdbcWriteConnectionsMinComposite
- */
-@SuppressWarnings("nls")
-public class JdbcWriteConnectionsMinComposite extends AbstractPane<Connection>
-{
- /**
- * Creates a new <code>JdbcWriteConnectionsMinComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public JdbcWriteConnectionsMinComposite(AbstractPane<Connection> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Integer> buildWriteConnectionsMinHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.WRITE_CONNECTIONS_MIN_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getWriteConnectionsMin();
-
- if (value == null) {
- value = -1;
- }
- return value;
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setWriteConnectionsMin(value);
- }
- };
- }
-
- private PropertyValueModel<Integer> buildDefaultWriteConnectionsMinHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
- @Override
- protected Integer buildValue_() {
- return subject.getDefaultWriteConnectionsMin();
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- private Control buildDefaultWriteConnectionsMinLabel(Composite container) {
-
- Label label = buildLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultWriteConnectionsMinLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultWriteConnectionsMinLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultWriteConnectionsMinHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- Spinner spinner = this.buildLabeledSpinner(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_writeConnectionsMinLabel,
- this.buildWriteConnectionsMinHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- this.buildDefaultWriteConnectionsMinLabel(container)
- );
-
- updateGridData(container, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/NativeSqlComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/NativeSqlComposite.java
deleted file mode 100644
index ea891c7860..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/NativeSqlComposite.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * NativeSqlComposite
- */
-public class NativeSqlComposite extends AbstractPane<Connection>
-{
- /**
- * Creates a new <code>NativeSqlComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public NativeSqlComposite(
- AbstractPane<? extends Connection> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildNativeSqlHolder() {
- return new PropertyAspectAdapter<Connection, Boolean>(getSubjectHolder(), Connection.NATIVE_SQL_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getNativeSql();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setNativeSql(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildNativeSqlStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildNativeSqlHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultNativeSql();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlConnectionTab_nativeSqlLabelDefault, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlConnectionTab_nativeSqlLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_nativeSqlLabel,
- this.buildNativeSqlHolder(),
- this.buildNativeSqlStringHolder(),
- null
-// EclipseLinkHelpContextIds.
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/PersistenceXmlConnectionTab.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/PersistenceXmlConnectionTab.java
deleted file mode 100644
index cce0f7586f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/PersistenceXmlConnectionTab.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.WidgetFactory;
-import org.eclipse.jpt.ui.details.JpaPageComposite;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * PersistenceXmlConnectionTab
- */
-public class PersistenceXmlConnectionTab
- extends AbstractFormPane<Connection>
- implements JpaPageComposite<PersistenceUnit>
-{
- // ********** constructors/initialization **********
- public PersistenceXmlConnectionTab(
- PropertyValueModel<Connection> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- new EclipseLinkConnectionComposite(this, container);
- }
-
- // ********** JpaPageComposite implementation **********
- public String getHelpID() {
- return null;
- }
-
- public Image getPageImage() {
- return null;
- }
-
- public String getPageText() {
- return EclipseLinkUiMessages.PersistenceXmlConnectionTab_title;
- }
-
- // ********** Layout **********
- @Override
- protected Composite buildContainer(Composite parent) {
- GridLayout layout = new GridLayout(1, true);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.marginTop = 0;
- layout.marginLeft = 0;
- layout.marginBottom = 0;
- layout.marginRight = 0;
- layout.verticalSpacing = 15;
- Composite container = this.buildPane(parent, layout);
- this.updateGridData(container);
- return container;
- }
-
- private void updateGridData(Composite container) {
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = SWT.FILL;
- gridData.verticalAlignment = SWT.FILL;
- container.setLayoutData(gridData);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/TransactionTypeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/TransactionTypeComposite.java
deleted file mode 100644
index f8432780e6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/TransactionTypeComposite.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.connection;
-
-import java.util.Collection;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnitTransactionType;
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * TransactionTypeComposite
- */
-public class TransactionTypeComposite extends AbstractFormPane<Connection>
-{
- /**
- * Creates a new <code>TransactionTypeComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public TransactionTypeComposite(
- AbstractFormPane<? extends Connection> parentComposite,
- Composite parent) {
-
- super( parentComposite, parent);
- }
-
- private EnumFormComboViewer<Connection, PersistenceUnitTransactionType> buildTransactionTypeCombo(Composite container) {
- return new EnumFormComboViewer<Connection, PersistenceUnitTransactionType>(this, container) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(Connection.TRANSACTION_TYPE_PROPERTY);
- }
-
- @Override
- protected PersistenceUnitTransactionType[] choices() {
- return PersistenceUnitTransactionType.values();
- }
-
- @Override
- protected PersistenceUnitTransactionType defaultValue() {
- return subject().getDefaultTransactionType();
- }
-
- @Override
- protected String displayString(PersistenceUnitTransactionType value) {
- return buildDisplayString(EclipseLinkUiMessages.class, TransactionTypeComposite.this, value);
- }
-
- @Override
- protected PersistenceUnitTransactionType getValue() {
- return subject().getTransactionType();
- }
-
- @Override
- protected void setValue(PersistenceUnitTransactionType value) {
- subject().setTransactionType(value);
-
- if (value == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
- clearJTAProperties();
- }
- else {
- clearResourceLocalProperties();
- }
- }
- };
- }
-
- private void clearJTAProperties() {
- subject().setJtaDataSource(null);
- }
-
- private void clearResourceLocalProperties() {
- Connection connection = subject();
- connection.setNonJtaDataSource(null);
- connection.setDriver(null);
- connection.setUrl(null);
- connection.setUser(null);
- connection.setPassword(null);
- connection.setBindParameters(null);
- connection.setWriteConnectionsMax(null);
- connection.setWriteConnectionsMin(null);
- connection.setReadConnectionsMax(null);
- connection.setReadConnectionsMin(null);
- connection.setReadConnectionsShared(null);
- }
-
- @Override
- protected void initializeLayout( Composite container) {
-
- this.buildLabeledComposite(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_transactionTypeLabel,
- this.buildTransactionTypeCombo( container),
- null // TODO IJpaHelpContextIds.
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/CustomizerComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/CustomizerComposite.java
deleted file mode 100644
index ee1d838414..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/CustomizerComposite.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.customization;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.eclipselink.ui.internal.JptEclipseLinkUiPlugin;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * CustomizerComposite
- */
-public class CustomizerComposite extends AbstractPane<EntityCustomizerProperties>
-{
- /**
- * Creates a new <code>CustomizerComposite</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- */
- public CustomizerComposite(AbstractPane<? extends EntityCustomizerProperties> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- private ClassChooserPane<EntityCustomizerProperties> initializeClassChooser(Composite container) {
-
- return new ClassChooserPane<EntityCustomizerProperties>(this, container) {
-
- @Override
- protected WritablePropertyValueModel<String> buildTextHolder() {
- return new PropertyAspectAdapter<EntityCustomizerProperties, String>(
- getSubjectHolder(), Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.getDescriptorCustomizer();
- }
-
- @Override
- protected void setValue_(String value) {
-
- if (value.length() == 0) {
- value = null;
- }
-
- subject.setDescriptorCustomizer(value);
- }
- };
- }
-
- @Override
- protected String className() {
- return subject().getDescriptorCustomizer();
- }
-
- @Override
- protected String labelText() {
- return EclipseLinkUiMessages.PersistenceXmlCustomizationTab_customizerLabel;
- }
-
- @Override
- protected IPackageFragmentRoot packageFragmentRoot() {
- IProject project = subject().getJpaProject().getProject();
- IJavaProject root = JavaCore.create(project);
-
- try {
- return root.getAllPackageFragmentRoots()[0];
- }
- catch (JavaModelException e) {
- JptEclipseLinkUiPlugin.log(e);
- }
- return null;
- }
-
- @Override
- protected void promptType() {
- IType type = chooseType();
-
- if (type != null) {
- String className = type.getFullyQualifiedName('.');
- subject().setDescriptorCustomizer(className);
- }
- }
- };
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeLayout(Composite container) {
- this.initializeClassChooser(container);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EclipseLinkCustomizationComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EclipseLinkCustomizationComposite.java
deleted file mode 100644
index 648b7fc1ae..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EclipseLinkCustomizationComposite.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.customization;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * PersistenceUnitCustomizationComposite
- */
-public class EclipseLinkCustomizationComposite extends AbstractFormPane<Customization>
-{
- public EclipseLinkCustomizationComposite(AbstractFormPane<Customization> subjectHolder,
- Composite container) {
-
- super(subjectHolder, container);
- }
-
- @Override
- protected void initializeLayout(Composite parent) {
- Section section = getWidgetFactory().createSection(parent, SWT.FLAT | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
- section.setText(EclipseLinkUiMessages.PersistenceXmlCustomizationTab_sectionTitle);
- section.setDescription(EclipseLinkUiMessages.PersistenceXmlCustomizationTab_sectionDescription);
- section.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Composite composite = this.buildSubPane(section);
- section.setClient(composite);
-
- // Default pane
- int groupBoxMargin = this.groupBoxMargin();
-
- Composite defaultPane = this.buildSubPane(
- composite,
- 0, groupBoxMargin, 0, groupBoxMargin
- );
-
- // Weaving
- new WeavingComposite(this, defaultPane);
-
- // Weaving Lazy
- new WeavingLazyComposite(this, defaultPane);
-
- // Weaving Fetch Groups
- new WeavingFetchGroupsComposite(this, defaultPane);
-
- // Weaving Change Tracking
- new WeavingChangeTrackingComposite(this, defaultPane);
-
- // Throw Exceptions
- new ThrowExceptionsComposite(this, defaultPane);
-
- // Session Customizer
- new SessionCustomizerComposite(this, defaultPane);
-
- // EntitiesList
- new EntityListComposite(this, composite);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityCustomizationPropertyComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityCustomizationPropertyComposite.java
deleted file mode 100644
index bdbfcb5d75..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityCustomizationPropertyComposite.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.customization;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * EntityCustomizationPropertyComposite
- */
-public class EntityCustomizationPropertyComposite extends AbstractPane<EntityCustomizerProperties> {
-
- /**
- * Creates a new <code>EntityCustomizationPropertyComposite</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- */
- public EntityCustomizationPropertyComposite(AbstractPane<Customization> parentComposite,
- PropertyValueModel<EntityCustomizerProperties> subjectHolder,
- Composite parent) {
-
- super(parentComposite, subjectHolder, parent);
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeLayout(Composite container) {
-
- // Customizer
- new CustomizerComposite(this, container);
-
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityCustomizerProperties.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityCustomizerProperties.java
deleted file mode 100644
index 19af38f3a4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityCustomizerProperties.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.customization;
-
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-
-/**
- * EntityCustomizerProperties
- */
-public class EntityCustomizerProperties extends AbstractModel {
-
- private Customization customization;
-
- private String entityName;
-
- private static final long serialVersionUID = 1L;
-
- // ********** constructors **********
- public EntityCustomizerProperties(Customization customization, String entityName) {
- super();
- this.customization = customization;
- this.entityName = entityName;
- }
-
- // ********** behavior **********
- public boolean entityNameIsValid() {
- return !StringTools.stringIsEmpty(this.entityName);
- }
-
- public String getEntityName() {
- return this.entityName;
- }
-
- public String getDescriptorCustomizer() {
- return this.customization.getDescriptorCustomizer(this.entityName);
- }
-
- public String getDefaultDescriptorCustomizer() {
- return this.customization.getDefaultDescriptorCustomizer();
- }
-
- public void setDescriptorCustomizer(String descriptorCustomizer) {
- this.customization.setDescriptorCustomizer(descriptorCustomizer, this.entityName);
- }
-
- public JpaProject getJpaProject() {
- return this.customization.getJpaProject();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityListComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityListComposite.java
deleted file mode 100644
index 3ac60dbbce..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityListComposite.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.customization;
-
-import java.util.ListIterator;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.eclipselink.ui.internal.EntityDialog;
-import org.eclipse.jpt.ui.internal.util.PaneEnabler;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.TransformationListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * EntityListComposite
- */
-public class EntityListComposite extends AbstractPane<Customization>
-{
- private WritablePropertyValueModel<EntityCustomizerProperties> entityHolder;
-
- public EntityListComposite(AbstractPane<Customization> parentComposite, Composite parent) {
-
- super(parentComposite, parent);
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- entityHolder = this.buildEntityHolder();
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- container = this.buildTitledPane(
- container,
- EclipseLinkUiMessages.CustomizationEntityListComposite_groupTitle
- );
-
- // Entities add/remove list pane
- new AddRemoveListPane<Customization>(
- this,
- container,
- this.buildEntitiesAdapter(),
- this.buildEntityCustomizationListHolder(),
- entityHolder,
- this.buildEntityLabelProvider(),
- null // EclipseLinkHelpContextIds.CUSTOMIZATION_ENTITIES
- );
-
- // Entity Customization property pane
- EntityCustomizationPropertyComposite pane = new EntityCustomizationPropertyComposite(
- this,
- entityHolder,
- container
- );
-
- this.installPaneEnabler(entityHolder, pane);
- }
-
- private void installPaneEnabler(WritablePropertyValueModel<EntityCustomizerProperties> entityHolder,
- EntityCustomizationPropertyComposite pane) {
-
- new PaneEnabler(
- this.buildPaneEnablerHolder(entityHolder),
- pane
- );
- }
-
- private PropertyValueModel<Boolean> buildPaneEnablerHolder(WritablePropertyValueModel<EntityCustomizerProperties> entityHolder) {
- return new TransformationPropertyValueModel<EntityCustomizerProperties, Boolean>(entityHolder) {
- @Override
- protected Boolean transform_(EntityCustomizerProperties value) {
- return value.entityNameIsValid();
- }
- };
- }
-
- private AddRemoveListPane.Adapter buildEntitiesAdapter() {
- return new AddRemoveListPane.AbstractAdapter() {
-
- public void addNewItem(ObjectListSelectionModel listSelectionModel) {
- addEntityFromDialog(listSelectionModel);
- }
-
- public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
- Customization customization = subject();
-
- for (Object item : listSelectionModel.selectedValues()) {
- EntityCustomizerProperties entityCustomization = (EntityCustomizerProperties) item;
- customization.removeEntity(entityCustomization.getEntityName());
- }
- }
- };
- }
-
- private void addEntityFromDialog(ObjectListSelectionModel listSelectionModel) {
-
- EntityDialog dialog = new EntityDialog(getControl().getShell(), getJpaProject());
-
- if (dialog.open() == Window.OK) {
- String name = dialog.getSelectedName();
- this.subject().addEntity(name);
-
- int index = CollectionTools.indexOf(this.subject().entities(), name);
- EntityCustomizerProperties item = (EntityCustomizerProperties) listSelectionModel.getListModel().getElementAt(index);
- entityHolder.setValue(item);
- }
- }
-
- private ILabelProvider buildEntityLabelProvider() {
- return new LabelProvider() {
- @Override
- public String getText(Object element) {
- EntityCustomizerProperties entityCustomization = (EntityCustomizerProperties) element;
- return entityCustomization.getEntityName();
- }
- };
- }
-
- private WritablePropertyValueModel<EntityCustomizerProperties> buildEntityHolder() {
- return new SimplePropertyValueModel<EntityCustomizerProperties>();
- }
-
- private JpaProject getJpaProject() {
- return this.subject().getJpaProject();
- }
-
- private ListValueModel<EntityCustomizerProperties> buildEntityCustomizationListHolder() {
- return new TransformationListValueModelAdapter<String, EntityCustomizerProperties>(buildEntitiesListHolder()) {
- @Override
- protected EntityCustomizerProperties transformItem(String item) {
- return new EntityCustomizerProperties(subject(), item);
- }
- };
- }
-
- private ListValueModel<String> buildEntitiesListHolder() {
- return new ListAspectAdapter<Customization, String>(
- this.getSubjectHolder(), Customization.ENTITIES_LIST_PROPERTY) {
- @Override
- protected ListIterator<String> listIterator_() {
- return this.subject.entities();
- }
- @Override
- protected int size_() {
- return this.subject.entitiesSize();
- }
- };
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/PersistenceXmlCustomizationTab.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/PersistenceXmlCustomizationTab.java
deleted file mode 100644
index 4b72f1f5e0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/PersistenceXmlCustomizationTab.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.customization;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.WidgetFactory;
-import org.eclipse.jpt.ui.details.JpaPageComposite;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * PersistenceXmlCustomizationTabItem
- */
-public class PersistenceXmlCustomizationTab
- extends AbstractFormPane<Customization>
- implements JpaPageComposite<PersistenceUnit>
-{
- public PersistenceXmlCustomizationTab(
- PropertyValueModel<Customization> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- new EclipseLinkCustomizationComposite(this, container);
- }
-
- // ********** JpaPageComposite implementation **********
-
- public String getHelpID() {
- return null;
- }
-
- public Image getPageImage() {
- return null;
- }
- public String getPageText() {
- return EclipseLinkUiMessages.PersistenceXmlCustomizationTab_title;
- }
-
- // ********** Layout **********
-
- @Override
- protected Composite buildContainer(Composite parent) {
- GridLayout layout = new GridLayout(1, true);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.marginTop = 0;
- layout.marginLeft = 0;
- layout.marginBottom = 0;
- layout.marginRight = 0;
- layout.verticalSpacing = 15;
-
- Composite container = buildPane(parent, layout);
- updateGridData(container);
-
- return container;
- }
-
- private void updateGridData(Composite container) {
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = SWT.FILL;
- gridData.verticalAlignment = SWT.FILL;
- container.setLayoutData(gridData);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/SessionCustomizerComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/SessionCustomizerComposite.java
deleted file mode 100644
index 03537a4d3d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/SessionCustomizerComposite.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.customization;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.eclipselink.ui.internal.JptEclipseLinkUiPlugin;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * SessionCustomizerComposite
- */
-public class SessionCustomizerComposite extends AbstractPane<Customization>
-{
- /**
- * Creates a new <code>SessionCustomizerComposite</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- */
- public SessionCustomizerComposite(AbstractPane<? extends Customization> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- private ClassChooserPane<Customization> initializeClassChooser(Composite container) {
-
- return new ClassChooserPane<Customization>(this, container) {
-
- @Override
- protected WritablePropertyValueModel<String> buildTextHolder() {
- return new PropertyAspectAdapter<Customization, String>(getSubjectHolder(), Customization.SESSION_CUSTOMIZER_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.getSessionCustomizer();
- }
-
- @Override
- protected void setValue_(String value) {
-
- if (value.length() == 0) {
- value = null;
- }
-
- subject.setSessionCustomizer(value);
- }
- };
- }
-
- @Override
- protected String className() {
- return subject().getSessionCustomizer();
- }
-
- @Override
- protected String labelText() {
- return EclipseLinkUiMessages.PersistenceXmlCustomizationTab_sessionCustomizerLabel;
- }
-
- @Override
- protected IPackageFragmentRoot packageFragmentRoot() {
- IProject project = subject().getJpaProject().getProject();
- IJavaProject root = JavaCore.create(project);
-
- try {
- return root.getAllPackageFragmentRoots()[0];
- }
- catch (JavaModelException e) {
- JptEclipseLinkUiPlugin.log(e);
- }
- return null;
- }
-
- @Override
- protected void promptType() {
- IType type = chooseType();
-
- if (type != null) {
- String className = type.getFullyQualifiedName('.');
- subject().setSessionCustomizer(className);
- }
- }
- };
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeLayout(Composite container) {
- this.initializeClassChooser(container);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/ThrowExceptionsComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/ThrowExceptionsComposite.java
deleted file mode 100644
index 9257a1ca24..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/ThrowExceptionsComposite.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.customization;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * ThrowExceptionsComposite
- */
-public class ThrowExceptionsComposite extends AbstractFormPane<Customization>
-{
- /**
- * Creates a new <code>ThrowExceptionsComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public ThrowExceptionsComposite(
- AbstractFormPane<? extends Customization> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildThrowExceptionsHolder() {
- return new PropertyAspectAdapter<Customization, Boolean>(getSubjectHolder(), Customization.THROW_EXCEPTIONS_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getThrowExceptions();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setThrowExceptions(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildThrowExceptionsStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildThrowExceptionsHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultThrowExceptions();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlCustomizationTab_throwExceptionsLabelDefault, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlCustomizationTab_throwExceptionsLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlCustomizationTab_throwExceptionsLabel,
- this.buildThrowExceptionsHolder(),
- this.buildThrowExceptionsStringHolder(),
- null
-// EclipseLinkHelpContextIds.CUSTOMIZATION_THROW_EXCEPTIONS
- );
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingChangeTrackingComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingChangeTrackingComposite.java
deleted file mode 100644
index ff2b0d7d75..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingChangeTrackingComposite.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.customization;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * WeavingChangeTrackingComposite
- */
-public class WeavingChangeTrackingComposite extends AbstractFormPane<Customization>
-{
- /**
- * Creates a new <code>WeavingChangeTrackingComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public WeavingChangeTrackingComposite(
- AbstractFormPane<? extends Customization> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildWeavingChangeTrackingHolder() {
- return new PropertyAspectAdapter<Customization, Boolean>(getSubjectHolder(), Customization.WEAVING_CHANGE_TRACKING_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getWeavingChangeTracking();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setWeavingChangeTracking(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildWeavingChangeTrackingStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildWeavingChangeTrackingHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultWeavingChangeTracking();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlCustomizationTab_weavingChangeTrackingLabelDefault, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlCustomizationTab_weavingChangeTrackingLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlCustomizationTab_weavingChangeTrackingLabel,
- this.buildWeavingChangeTrackingHolder(),
- this.buildWeavingChangeTrackingStringHolder(),
- null
-// EclipseLinkHelpContextIds.CUSTOMIZATION_WEAVING_CHANGE_TRACKING
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingComposite.java
deleted file mode 100644
index d1b078a77d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingComposite.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.customization;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Weaving;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * WeavingComposite
- */
-public class WeavingComposite extends AbstractFormPane<Customization>
-{
- /**
- * Creates a new <code>WeavingComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public WeavingComposite(
- AbstractFormPane<? extends Customization> parentComposite,
- Composite parent) {
-
- super( parentComposite, parent);
- }
-
- private EnumFormComboViewer<Customization, Weaving> buildWeavingCombo(Composite container) {
- return new EnumFormComboViewer<Customization, Weaving>(this, container) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(Customization.WEAVING_PROPERTY);
- }
-
- @Override
- protected Weaving[] choices() {
- return Weaving.values();
- }
-
- @Override
- protected Weaving defaultValue() {
- return subject().getDefaultWeaving();
- }
-
- @Override
- protected String displayString(Weaving value) {
- return buildDisplayString(EclipseLinkUiMessages.class, WeavingComposite.this, value);
- }
-
- @Override
- protected Weaving getValue() {
- return subject().getWeaving();
- }
-
- @Override
- protected void setValue(Weaving value) {
- subject().setWeaving(value);
- }
- };
- }
-
- @Override
- protected void initializeLayout( Composite container) {
-
- this.buildLabeledComposite(
- container,
- EclipseLinkUiMessages.PersistenceXmlCustomizationTab_weavingLabel,
- this.buildWeavingCombo( container),
- null // TODO IJpaHelpContextIds.
- );
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingFetchGroupsComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingFetchGroupsComposite.java
deleted file mode 100644
index 7e1f1829d8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingFetchGroupsComposite.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.customization;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * WeavingFetchGroupsComposite
- */
-public class WeavingFetchGroupsComposite extends AbstractFormPane<Customization>
-{
- /**
- * Creates a new <code>WeavingFetchGroupsComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public WeavingFetchGroupsComposite(
- AbstractFormPane<? extends Customization> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildWeavingLazyHolder() {
- return new PropertyAspectAdapter<Customization, Boolean>(getSubjectHolder(), Customization.WEAVING_FETCH_GROUPS_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getWeavingFetchGroups();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setWeavingFetchGroups(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildWeavingLazyStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildWeavingLazyHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultWeavingLazy();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlCustomizationTab_weavingFetchGroupsLabelDefault, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlCustomizationTab_weavingFetchGroupsLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlCustomizationTab_weavingFetchGroupsLabel,
- this.buildWeavingLazyHolder(),
- this.buildWeavingLazyStringHolder(),
- null
-// EclipseLinkHelpContextIds.CUSTOMIZATION_WEAVING_FETCH_GROUPS
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingLazyComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingLazyComposite.java
deleted file mode 100644
index 67d4adf1c5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/WeavingLazyComposite.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.customization;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * WeavingLazyComposite
- */
-public class WeavingLazyComposite extends AbstractFormPane<Customization>
-{
- /**
- * Creates a new <code>WeavingLazyComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public WeavingLazyComposite(
- AbstractFormPane<? extends Customization> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildWeavingLazyHolder() {
- return new PropertyAspectAdapter<Customization, Boolean>(getSubjectHolder(), Customization.WEAVING_LAZY_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getWeavingLazy();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setWeavingLazy(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildWeavingLazyStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildWeavingLazyHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultWeavingLazy();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlCustomizationTab_weavingLazyLabelDefault, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlCustomizationTab_weavingLazyLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlCustomizationTab_weavingLazyLabel,
- this.buildWeavingLazyHolder(),
- this.buildWeavingLazyStringHolder(),
- null
-// EclipseLinkHelpContextIds.CUSTOMIZATION_WEAVING_LAZY
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java
deleted file mode 100644
index 1ddf744d0f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007, 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.ddlgen;
-
-import java.text.MessageFormat;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jpt.core.JpaPlatform;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.context.persistence.Persistence;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.eclipselink.core.internal.ddlgen.EclipseLinkDDLGenerator;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.eclipselink.ui.internal.ddlgen.wizards.GenerateDDLWizard;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * EclipseLinkDLLGeneratorUi is used by the EclipseLinkPlatformUi to initiate
- * the execution of EclipseLink DDL generator.
- */
-public class EclipseLinkDDLGeneratorUi
-{
- private JpaProject project;
- private String projectLocation;
- private IStructuredSelection selection;
-
- // ********** constructors **********
-
- public static void generate(JpaProject project, String projectLocation, IStructuredSelection selection) {
- if (project == null) {
- throw new NullPointerException();
- }
- new EclipseLinkDDLGeneratorUi(project, projectLocation, selection).generate();
- }
-
- private EclipseLinkDDLGeneratorUi() {
- super();
- }
-
- private EclipseLinkDDLGeneratorUi(JpaProject project, String projectLocation, IStructuredSelection selection) {
- super();
- this.project = project;
- this.selection = selection;
- this.projectLocation = projectLocation;
- }
-
- // ********** behavior **********
-
- protected void generate() {
-
- PersistenceUnit persistenceUnit = this.getPersistenceUnits().next(); // Take the first persistenceUnit
- String puName = persistenceUnit.getName();
- if( ! this.displayGeneratingDDLWarning()) {
- return;
- }
-
- GenerateDDLWizard wizard = new GenerateDDLWizard(this.project, this.selection);
- WizardDialog dialog = new WizardDialog(this.getCurrentShell(), wizard);
- dialog.create();
- if(wizard.getPageCount() > 0) {
- int returnCode = dialog.open();
- if (returnCode == Window.CANCEL) {
- return;
- }
- }
- IWorkspaceRunnable runnable = new GenerateDDLRunnable(puName, this.project, projectLocation);
- try {
- ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
- }
- catch (CoreException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private Shell getCurrentShell() {
- return Display.getCurrent().getActiveShell();
- }
-
- private boolean displayGeneratingDDLWarning() {
- String message = org.eclipse.osgi.util.NLS.bind(
- EclipseLinkUiMessages.EclipseLinkDDLGeneratorUi_generatingDDLWarningMessage,
- System.getProperty("line.separator"),
- System.getProperty("line.separator") + System.getProperty( "line.separator"));
-
- return MessageDialog.openQuestion(
- this.getCurrentShell(),
- EclipseLinkUiMessages.EclipseLinkDDLGeneratorUi_generatingDDLWarningTitle,
- message);
- }
-
- // ********** Persistence Unit **********
-
- protected JpaPlatform getPlatform() {
- return this.project.getJpaPlatform();
- }
-
- protected Iterator<PersistenceUnit> getPersistenceUnits() {
- return this.getPersistence().persistenceUnits();
- }
-
- protected Persistence getPersistence() {
- return this.project.getRootContext().getPersistenceXml().getPersistence();
- }
-
- // ********** runnable **********
-
- static class GenerateDDLRunnable implements IWorkspaceRunnable {
- private final String puName;
- private final JpaProject project;
- private String projectLocation;
-
- GenerateDDLRunnable(String puName, JpaProject project, String projectLocation) {
- super();
- this.puName = puName;
- this.project = project;
- this.projectLocation = projectLocation;
- }
-
- public void run(IProgressMonitor monitor) throws CoreException {
- try {
- EclipseLinkDDLGenerator.generate(this.puName, this.project, this.projectLocation, monitor);
- }
- catch (OperationCanceledException e) {
- return;
- // fall through and tell monitor we are done
- }
- catch (RuntimeException re) {
- String msg = re.getMessage();
- String message = (msg == null) ? re.toString() : msg;
-
- this.logError(message);
- throw new RuntimeException(re);
- }
- }
-
- protected void logError(String message) {
- this.displayError(message);
- }
-
- private void displayError(String message) {
-
- String msg = MessageFormat.format(message, new String [] {message});
- MessageDialog.openError(getShell(), "Error", msg);
- }
-
- private Shell getShell() {
- Display display = Display.getCurrent();
- Shell shell = (display == null) ? null : display.getActiveShell();
- if (shell == null && display != null) {
- Shell[] shells = display.getShells();
- if (shells.length > 0)
- shell = shells[0];
- }
- return shell;
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/wizards/GenerateDDLWizard.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/wizards/GenerateDDLWizard.java
deleted file mode 100644
index 84963eaf48..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/wizards/GenerateDDLWizard.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007, 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.ddlgen.wizards;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.db.ConnectionProfile;
-import org.eclipse.jpt.db.JptDbPlugin;
-import org.eclipse.jpt.ui.internal.wizards.DatabaseReconnectWizardPage;
-
-/**
- * GenerateDDLWizard
- */
-public class GenerateDDLWizard extends Wizard {
-
- private JpaProject jpaProject;
-
- private IStructuredSelection selection;
-
- private DatabaseReconnectWizardPage dbSettingsPage;
-
- public GenerateDDLWizard(JpaProject jpaProject, IStructuredSelection selection) {
- super();
- this.jpaProject = jpaProject;
- this.selection = selection;
- this.setWindowTitle("DDL Generation");
- }
-
- public void addPages() {
- super.addPages();
- if ( ! this.jpaProjectHasConnection()) {
- this.dbSettingsPage = new DatabaseReconnectWizardPage(this.jpaProject);
- this.addPage(this.dbSettingsPage);
- }
- }
-
- @SuppressWarnings("restriction")
- public boolean performFinish() {
- String name = getProjectConnectionProfile().getName();
- if ( ! this.jpaProjectHasConnection()) {
-
- String connectionProfileName = this.dbSettingsPage.getSelectedConnectionProfileName();
- ConnectionProfile profile = JptDbPlugin.instance().getConnectionProfileRepository().connectionProfileNamed( connectionProfileName);
- if( profile.isNull()) {
- this.dbSettingsPage.clearConnectionProfileName();
- return false;
- }
- this.setProjectConnectionProfileName(connectionProfileName);
- }
- return true;
- }
-
- public boolean canFinish() {
- boolean canFinish = true;
- if ( ! this.dbSettingsPage.isPageComplete()) {
- canFinish = false;
- }
- return canFinish;
- }
-
- private boolean jpaProjectHasConnection() {
- return ! this.getProjectConnectionProfile().isNull();
- }
-
- private ConnectionProfile getProjectConnectionProfile() {
- return this.jpaProject.getConnectionProfile();
- }
-
- private void setProjectConnectionProfileName(String connectionProfileName) {
- this.jpaProject.getDataSource().setConnectionProfileName(connectionProfileName);
- JptCorePlugin.setConnectionProfileName(this.jpaProject.getProject(), connectionProfileName);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/EclipseLinkLoggingComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/EclipseLinkLoggingComposite.java
deleted file mode 100644
index ddabf0a8fd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/EclipseLinkLoggingComposite.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.logging;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logging;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * EclipseLinkLoggingComposite
- */
-public class EclipseLinkLoggingComposite
- extends AbstractFormPane<Logging>
-{
- public EclipseLinkLoggingComposite(
- AbstractFormPane<Logging> subjectHolder,
- Composite container) {
- super(subjectHolder, container, false);
- }
-
- @Override
- protected void initializeLayout(Composite parent) {
- Section section = getWidgetFactory().createSection(parent, SWT.FLAT | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
- section.setText(EclipseLinkUiMessages.PersistenceXmlLoggingTab_sectionTitle);
- section.setDescription(EclipseLinkUiMessages.PersistenceXmlLoggingTab_sectionDescription);
- Composite composite = getWidgetFactory().createComposite(section);
- composite.setLayout(new GridLayout(1, false));
- section.setClient(composite);
- this.updateGridData(composite);
- this.updateGridData(composite.getParent());
-
- // LoggingLevel:
- new LoggingLevelComposite(this, composite);
-
- // Timestamp:
- new TimestampComposite(this, composite);
-
- // Thread:
- new ThreadComposite(this, composite);
-
- // Session:
- new SessionComposite(this, composite);
-
- // Exceptions:
- new ExceptionsComposite(this, composite);
-
- // Logger:
- new LoggerComposite(this, composite);
-
- return;
- }
-
- private void updateGridData(Composite container) {
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = SWT.FILL;
- gridData.verticalAlignment = SWT.FILL;
- container.setLayoutData(gridData);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/ExceptionsComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/ExceptionsComposite.java
deleted file mode 100644
index 80e6dbc130..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/ExceptionsComposite.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.logging;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logging;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * ExceptionsComposite
- */
-public class ExceptionsComposite extends AbstractFormPane<Logging>
-{
- /**
- * Creates a new <code>ExceptionsComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public ExceptionsComposite(
- AbstractFormPane<? extends Logging> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildExceptionsHolder() {
- return new PropertyAspectAdapter<Logging, Boolean>(getSubjectHolder(), Logging.EXCEPTIONS_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getExceptions();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setExceptions(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildExceptionsStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildExceptionsHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultExceptions();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlLoggingTab_exceptionsLabelDefault, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlLoggingTab_exceptionsLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlLoggingTab_exceptionsLabel,
- this.buildExceptionsHolder(),
- this.buildExceptionsStringHolder(),
- null
-// EclipseLinkHelpContextIds.LOGGING_
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/LoggerComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/LoggerComposite.java
deleted file mode 100644
index c7d60bf24d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/LoggerComposite.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.logging;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Iterator;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logger;
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logging;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringConverter;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * LoggerComposite
- */
-public class LoggerComposite extends AbstractPane<Logging>
-{
- /**
- * Creates a new <code>LoggerComposite</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- */
- public LoggerComposite(
- AbstractPane<? extends Logging> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- private PropertyValueModel<String> buildDefaultLoggerHolder() {
- return new PropertyAspectAdapter<Logging, String>(this.getSubjectHolder(), Logging.DEFAULT_LOGGER) {
- @Override
- protected String buildValue_() {
- return LoggerComposite.this.defaultValue(subject);
- }
- };
- }
-
- private ListValueModel<String> buildDefaultLoggerListHolder() {
- return new PropertyListValueModelAdapter<String>(
- this.buildDefaultLoggerHolder()
- );
- }
-
- private String buildDisplayString(String loggerName) {
-
- switch (Logger.valueOf(loggerName)) {
- case default_logger: {
- return EclipseLinkUiMessages.LoggerComposite_default_logger;
- }
- case java_logger: {
- return EclipseLinkUiMessages.LoggerComposite_java_logger;
- }
- case server_logger: {
- return EclipseLinkUiMessages.LoggerComposite_server_logger;
- }
- default: {
- return null;
- }
- }
- }
-
- private Comparator<String> buildLoggerComparator() {
- return new Comparator<String>() {
- public int compare(String logger1, String logger2) {
- logger1 = buildDisplayString(logger1);
- logger2 = buildDisplayString(logger2);
- return Collator.getInstance().compare(logger1, logger2);
- }
- };
- }
-
- private StringConverter<String> buildLoggerConverter() {
- return new StringConverter<String>() {
- public String convertToString(String value) {
- try {
- Logger.valueOf(value);
- value = buildDisplayString(value);
- }
- catch (Exception e) {
- // Ignore since the value is not a Logger
- }
- return value;
- }
- };
- }
-
- private WritablePropertyValueModel<String> buildLoggerHolder() {
- return new PropertyAspectAdapter<Logging, String>(this.getSubjectHolder(), Logging.LOGGER_PROPERTY) {
- @Override
- protected String buildValue_() {
-
- String name = subject.getLogger();
- if (name == null) {
- name = LoggerComposite.this.defaultValue(subject);
- }
- return name;
- }
-
- @Override
- protected void setValue_(String value) {
-
- if (defaultValue(subject).equals(value)) {
- value = null;
- }
- subject.setLogger(value);
- }
- };
- }
-
- private ListValueModel<String> buildLoggerListHolder() {
- ArrayList<ListValueModel<String>> holders = new ArrayList<ListValueModel<String>>(2);
- holders.add(buildDefaultLoggerListHolder());
- holders.add(buildLoggersListHolder());
- return new CompositeListValueModel<ListValueModel<String>, String>(holders);
- }
-
- private Iterator<String> buildLoggers() {
- return new TransformationIterator<Logger, String>(CollectionTools.iterator(Logger.values())) {
- @Override
- protected String transform(Logger next) {
- return next.name();
- }
- };
- }
-
- private CollectionValueModel<String> buildLoggersCollectionHolder() {
- return new SimpleCollectionValueModel<String>(
- CollectionTools.collection(buildLoggers())
- );
- }
-
- private ListValueModel<String> buildLoggersListHolder() {
- return new SortedListValueModelAdapter<String>(
- buildLoggersCollectionHolder(),
- buildLoggerComparator()
- );
- }
-
- private String defaultValue(Logging subject) {
- String defaultValue = subject.getDefaultLogger();
-
- if (defaultValue != null) {
- return NLS.bind(
- EclipseLinkUiMessages.PersistenceXmlLoggingTab_defaultWithOneParam,
- defaultValue
- );
- }
- else {
- return EclipseLinkUiMessages.PersistenceXmlLoggingTab_defaultEmpty;
- }
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeLayout(Composite container) {
-
- CCombo combo = buildLabeledEditableCCombo(
- container,
- EclipseLinkUiMessages.PersistenceXmlLoggingTab_loggerLabel,
- this.buildLoggerListHolder(),
- this.buildLoggerHolder(),
- this.buildLoggerConverter(),
- null // EclipseLinkHelpContextIds.LOGGER_NAME
- );
-
- SWTUtil.attachDefaultValueHandler(combo);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/LoggingLevelComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/LoggingLevelComposite.java
deleted file mode 100644
index 6b862f69d6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/LoggingLevelComposite.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.logging;
-
-import java.util.Collection;
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logging;
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.LoggingLevel;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * LoggingLevelComposite
- */
-public class LoggingLevelComposite extends AbstractFormPane<Logging>
-{
- /**
- * Creates a new <code>LoggingLevelComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public LoggingLevelComposite(
- AbstractFormPane<? extends Logging> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private EnumFormComboViewer<Logging, LoggingLevel> buildLoggingLevelCombo(Composite container) {
- return new EnumFormComboViewer<Logging, LoggingLevel>(this, container) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(Logging.LEVEL_PROPERTY);
- }
-
- @Override
- protected LoggingLevel[] choices() {
- return LoggingLevel.values();
- }
-
- @Override
- protected boolean sortChoices() {
- return false;
- }
-
- @Override
- protected LoggingLevel defaultValue() {
- return this.subject().getDefaultLevel();
- }
-
- @Override
- protected String displayString(LoggingLevel value) {
- return this.buildDisplayString(EclipseLinkUiMessages.class, LoggingLevelComposite.this, value);
- }
-
- @Override
- protected LoggingLevel getValue() {
- return this.subject().getLevel();
- }
-
- @Override
- protected void setValue(LoggingLevel value) {
- this.subject().setLevel(value);
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- this.buildLabeledComposite(
- container,
- EclipseLinkUiMessages.PersistenceXmlLoggingTab_loggingLevelLabel,
- this.buildLoggingLevelCombo(container),
- null // TODO IJpaHelpContextIds.
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/PersistenceXmlLoggingTab.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/PersistenceXmlLoggingTab.java
deleted file mode 100644
index 5d3147363a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/PersistenceXmlLoggingTab.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.logging;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logging;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.WidgetFactory;
-import org.eclipse.jpt.ui.details.JpaPageComposite;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * PersistenceXmlLoggingTab
- */
-public class PersistenceXmlLoggingTab
- extends AbstractFormPane<Logging>
- implements JpaPageComposite<PersistenceUnit>
-{
- // ********** constructors/initialization **********
- public PersistenceXmlLoggingTab(
- PropertyValueModel<Logging> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- new EclipseLinkLoggingComposite(this, container);
- }
-
- // ********** JpaPageComposite implementation **********
- public String getHelpID() {
- return null;
- }
-
- public Image getPageImage() {
- return null;
- }
-
- public String getPageText() {
- return EclipseLinkUiMessages.PersistenceXmlLoggingTab_title;
- }
-
- // ********** Layout **********
- @Override
- protected Composite buildContainer(Composite parent) {
- GridLayout layout = new GridLayout(1, true);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.marginTop = 0;
- layout.marginLeft = 0;
- layout.marginBottom = 0;
- layout.marginRight = 0;
- layout.verticalSpacing = 15;
- Composite container = this.buildPane(parent, layout);
- this.updateGridData(container);
- return container;
- }
-
- private void updateGridData(Composite container) {
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = SWT.FILL;
- gridData.verticalAlignment = SWT.FILL;
- container.setLayoutData(gridData);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/SessionComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/SessionComposite.java
deleted file mode 100644
index 81c223f41f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/SessionComposite.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.logging;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logging;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * SessionComposite
- */
-public class SessionComposite extends AbstractFormPane<Logging>
-{
- /**
- * Creates a new <code>SessionComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public SessionComposite(
- AbstractFormPane<? extends Logging> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildSessionHolder() {
- return new PropertyAspectAdapter<Logging, Boolean>(getSubjectHolder(), Logging.SESSION_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getSession();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setSession(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildSessionStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildSessionHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultSession();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlLoggingTab_sessionLabelDefault, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlLoggingTab_sessionLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlLoggingTab_sessionLabel,
- this.buildSessionHolder(),
- this.buildSessionStringHolder(),
- null
-// EclipseLinkHelpContextIds.LOGGING_
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/ThreadComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/ThreadComposite.java
deleted file mode 100644
index 987c5332c1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/ThreadComposite.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.logging;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logging;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * ThreadComposite
- */
-public class ThreadComposite extends AbstractFormPane<Logging>
-{
- /**
- * Creates a new <code>ThreadComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public ThreadComposite(
- AbstractFormPane<? extends Logging> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildThreadHolder() {
- return new PropertyAspectAdapter<Logging, Boolean>(getSubjectHolder(), Logging.THREAD_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getThread();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setThread(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildThreadStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildThreadHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultThread();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlLoggingTab_threadLabelDefault, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlLoggingTab_threadLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlLoggingTab_threadLabel,
- this.buildThreadHolder(),
- this.buildThreadStringHolder(),
- null
-// EclipseLinkHelpContextIds.LOGGING_
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/TimestampComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/TimestampComposite.java
deleted file mode 100644
index c04f8735b7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/logging/TimestampComposite.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.logging;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logging;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * TimestampComposite
- */
-public class TimestampComposite extends AbstractFormPane<Logging>
-{
- /**
- * Creates a new <code>TimestampComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public TimestampComposite(
- AbstractFormPane<? extends Logging> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildTimestampHolder() {
- return new PropertyAspectAdapter<Logging, Boolean>(getSubjectHolder(), Logging.TIMESTAMP_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getTimestamp();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setTimestamp(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildTimestampStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildTimestampHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultTimestamp();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlLoggingTab_timestampLabelDefault, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlLoggingTab_timestampLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlLoggingTab_timestampLabel,
- this.buildTimestampHolder(),
- this.buildTimestampStringHolder(),
- null
-// EclipseLinkHelpContextIds.LOGGING_
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/EclipseLinkOptionsComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/EclipseLinkOptionsComposite.java
deleted file mode 100644
index 43fd246bff..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/EclipseLinkOptionsComposite.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.options;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.options.Options;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * EclipseLinkOptionsComposite
- */
-public class EclipseLinkOptionsComposite
- extends AbstractFormPane<Options>
-{
- public EclipseLinkOptionsComposite(
- AbstractFormPane<Options> subjectHolder,
- Composite container) {
- super(subjectHolder, container, false);
- }
-
- @Override
- protected void initializeLayout(Composite parent) {
- Section section = getWidgetFactory().createSection(parent, SWT.FLAT | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
- section.setText(EclipseLinkUiMessages.PersistenceXmlOptionsTab_sectionTitle);
- section.setDescription(EclipseLinkUiMessages.PersistenceXmlOptionsTab_sectionDescription);
- Composite composite = getWidgetFactory().createComposite(section);
- composite.setLayout(new GridLayout(1, false));
- section.setClient(composite);
- this.updateGridData(composite);
- this.updateGridData(composite.getParent());
-
- new SessionNameComposite(this, composite);
-
- new SessionsXmlComposite(this, composite);
-
- new TargetDatabaseComposite(this, composite);
-
- new EventListenerComposite(this, composite);
-
- new IncludeDescriptorQueriesComposite(this, composite);
-
- return;
- }
-
- private void updateGridData(Composite container) {
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = SWT.FILL;
- gridData.verticalAlignment = SWT.FILL;
- container.setLayoutData(gridData);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/EventListenerComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/EventListenerComposite.java
deleted file mode 100644
index a5f1ef205e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/EventListenerComposite.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.options;
-
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.eclipselink.core.internal.context.options.Options;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * EventListenerComposite
- */
-public class EventListenerComposite extends AbstractPane<Options>
-{
- /**
- * Creates a new <code>EventListenerComposite</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- */
- public EventListenerComposite(AbstractPane<? extends Options> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- private ClassChooserPane<Options> initializeClassChooser(Composite container) {
-
- return new ClassChooserPane<Options>(this, container) {
-
- @Override
- protected WritablePropertyValueModel<String> buildTextHolder() {
- return new PropertyAspectAdapter<Options, String>(getSubjectHolder(), Options.SESSION_EVENT_LISTENER_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.getEventListener();
- }
-
- @Override
- protected void setValue_(String value) {
-
- if (value.length() == 0) {
- value = null;
- }
-
- subject.setEventListener(value);
- }
- };
- }
-
- @Override
- protected String className() {
- return subject().getEventListener();
- }
-
- @Override
- protected String labelText() {
- return EclipseLinkUiMessages.PersistenceXmlOptionsTab_eventListenerLabel;
- }
-
- @Override
- protected IPackageFragmentRoot packageFragmentRoot() {
- //TODO
-// IProject project = subject().getJpaProject().getProject();
-// IJavaProject root = JavaCore.create(project);
-//
-// try {
-// return root.getAllPackageFragmentRoots()[0];
-// }
-// catch (JavaModelException e) {
-// JptEclipseLinkUiPlugin.log(e);
-// }
- return null;
- }
-
- @Override
- protected void promptType() {
- IType type = chooseType();
-
- if (type != null) {
- String className = type.getFullyQualifiedName('.');
- subject().setEventListener(className);
- }
- }
- };
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeLayout(Composite container) {
- this.initializeClassChooser(container);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/IncludeDescriptorQueriesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/IncludeDescriptorQueriesComposite.java
deleted file mode 100644
index dc37254192..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/IncludeDescriptorQueriesComposite.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.options;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.options.Options;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * IncludeDescriptorQueriesComposite
- */
-public class IncludeDescriptorQueriesComposite extends AbstractFormPane<Options>
-{
- /**
- * Creates a new <code>IncludeDescriptorQueriesComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public IncludeDescriptorQueriesComposite(
- AbstractFormPane<? extends Options> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private WritablePropertyValueModel<Boolean> buildIncludeDescriptorQueriesHolder() {
- return new PropertyAspectAdapter<Options, Boolean>(getSubjectHolder(), Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return subject.getIncludeDescriptorQueries();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- subject.setIncludeDescriptorQueries(value);
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildIncludeDescriptorQueriesStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildIncludeDescriptorQueriesHolder()) {
- @Override
- protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultIncludeDescriptorQueries();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlOptionsTab_includeDescriptorQueriesLabelDefault, defaultStringValue);
- }
- }
- return EclipseLinkUiMessages.PersistenceXmlOptionsTab_includeDescriptorQueriesLabel;
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlOptionsTab_includeDescriptorQueriesLabel,
- this.buildIncludeDescriptorQueriesHolder(),
- this.buildIncludeDescriptorQueriesStringHolder(),
- null
-// EclipseLinkHelpContextIds.
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/PersistenceXmlOptionsTab.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/PersistenceXmlOptionsTab.java
deleted file mode 100644
index 1be92b621a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/PersistenceXmlOptionsTab.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.options;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.eclipselink.core.internal.context.options.Options;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.WidgetFactory;
-import org.eclipse.jpt.ui.details.JpaPageComposite;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * PersistenceXmlOptionsTab
- */
-public class PersistenceXmlOptionsTab
- extends AbstractFormPane<Options>
- implements JpaPageComposite<PersistenceUnit>
-{
- // ********** constructors/initialization **********
- public PersistenceXmlOptionsTab(
- PropertyValueModel<Options> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- new EclipseLinkOptionsComposite(this, container);
- }
-
- // ********** JpaPageComposite implementation **********
- public String getHelpID() {
- return null;
- }
-
- public Image getPageImage() {
- return null;
- }
-
- public String getPageText() {
- return EclipseLinkUiMessages.PersistenceXmlOptionsTab_title;
- }
-
- // ********** Layout **********
- @Override
- protected Composite buildContainer(Composite parent) {
- GridLayout layout = new GridLayout(1, true);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.marginTop = 0;
- layout.marginLeft = 0;
- layout.marginBottom = 0;
- layout.marginRight = 0;
- layout.verticalSpacing = 15;
- Composite container = this.buildPane(parent, layout);
- this.updateGridData(container);
- return container;
- }
-
- private void updateGridData(Composite container) {
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = SWT.FILL;
- gridData.verticalAlignment = SWT.FILL;
- container.setLayoutData(gridData);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/SessionNameComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/SessionNameComposite.java
deleted file mode 100644
index 81148be0ce..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/SessionNameComposite.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.options;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.options.Options;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * SessionNameComposite
- */
-public class SessionNameComposite extends AbstractPane<Options>
-{
- /**
- * Creates a new <code>SessionNameComposite</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- */
- public SessionNameComposite(
- AbstractPane<? extends Options> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- private PropertyValueModel<String> buildDefaultSessionNameHolder() {
- return new PropertyAspectAdapter<Options, String>(this.getSubjectHolder(), Options.DEFAULT_SESSION_NAME) {
- @Override
- protected String buildValue_() {
- return SessionNameComposite.this.defaultValue(subject);
- }
- };
- }
-
- private ListValueModel<String> buildDefaultSessionNameListHolder() {
- return new PropertyListValueModelAdapter<String>(
- this.buildDefaultSessionNameHolder()
- );
- }
-
- private WritablePropertyValueModel<String> buildSessionNameHolder() {
- return new PropertyAspectAdapter<Options, String>(this.getSubjectHolder(), Options.SESSION_NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
-
- String name = subject.getSessionName();
- if (name == null) {
- name = SessionNameComposite.this.defaultValue(subject);
- }
- return name;
- }
-
- @Override
- protected void setValue_(String value) {
-
- if (defaultValue(subject).equals(value)) {
- value = null;
- }
- subject.setSessionName(value);
- }
- };
- }
-
- private String defaultValue(Options subject) {
- String defaultValue = subject.getDefaultSessionName();
-
- if (defaultValue != null) {
- return NLS.bind(
- EclipseLinkUiMessages.PersistenceXmlOptionsTab_defaultWithOneParam,
- defaultValue
- );
- }
- else {
- return EclipseLinkUiMessages.PersistenceXmlOptionsTab_defaultEmpty;
- }
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeLayout(Composite container) {
-
- CCombo combo = buildLabeledEditableCCombo(
- container,
- EclipseLinkUiMessages.PersistenceXmlOptionsTab_sessionName,
- this.buildDefaultSessionNameListHolder(),
- this.buildSessionNameHolder(),
- null // EclipseLinkHelpContextIds.
- );
- SWTUtil.attachDefaultValueHandler(combo);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/SessionsXmlComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/SessionsXmlComposite.java
deleted file mode 100644
index e6596c6e6b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/SessionsXmlComposite.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.options;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.options.Options;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * SessionsXmlComposite
- */
-public class SessionsXmlComposite extends AbstractPane<Options>
-{
- /**
- * Creates a new <code>SessionsXmlComposite</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- */
- public SessionsXmlComposite(
- AbstractPane<? extends Options> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- private PropertyValueModel<String> buildDefaultSessionsXmlFileNameHolder() {
- return new PropertyAspectAdapter<Options, String>(this.getSubjectHolder(), Options.DEFAULT_SESSIONS_XML) {
- @Override
- protected String buildValue_() {
- return SessionsXmlComposite.this.defaultValue(subject);
- }
- };
- }
-
- private ListValueModel<String> buildDefaultSessionsXmlFileNameListHolder() {
- return new PropertyListValueModelAdapter<String>(
- this.buildDefaultSessionsXmlFileNameHolder()
- );
- }
-
- private WritablePropertyValueModel<String> buildSessionsXmlFileNameHolder() {
- return new PropertyAspectAdapter<Options, String>(this.getSubjectHolder(), Options.SESSIONS_XML_PROPERTY) {
- @Override
- protected String buildValue_() {
-
- String name = subject.getSessionsXml();
- if (name == null) {
- name = SessionsXmlComposite.this.defaultValue(subject);
- }
- return name;
- }
-
- @Override
- protected void setValue_(String value) {
-
- if (defaultValue(subject).equals(value)) {
- value = null;
- }
- subject.setSessionsXml(value);
- }
- };
- }
-
- private String defaultValue(Options subject) {
- String defaultValue = subject.getDefaultSessionsXml();
-
- if (defaultValue != null) {
- return NLS.bind(
- EclipseLinkUiMessages.PersistenceXmlOptionsTab_defaultWithOneParam,
- defaultValue
- );
- }
- else {
- return EclipseLinkUiMessages.PersistenceXmlOptionsTab_defaultEmpty;
- }
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeLayout(Composite container) {
-
- CCombo combo = buildLabeledEditableCCombo(
- container,
- EclipseLinkUiMessages.PersistenceXmlOptionsTab_sessionsXml,
- this.buildDefaultSessionsXmlFileNameListHolder(),
- this.buildSessionsXmlFileNameHolder(),
- null // EclipseLinkHelpContextIds.
- );
- SWTUtil.attachDefaultValueHandler(combo);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/TargetDatabaseComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/TargetDatabaseComposite.java
deleted file mode 100644
index 2c346c9a4f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/TargetDatabaseComposite.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.options;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.options.Options;
-import org.eclipse.jpt.eclipselink.core.internal.context.options.TargetDatabase;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * TargetDatabaseComposite
- */
-public class TargetDatabaseComposite extends AbstractFormPane<Options>
-{
- /**
- * Creates a new <code>TargetDatabaseComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public TargetDatabaseComposite(
- AbstractFormPane<? extends Options> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private EnumFormComboViewer<Options, TargetDatabase> buildTargetDatabaseCombo(Composite container) {
- return new EnumFormComboViewer<Options, TargetDatabase>(this, container) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(Options.TARGET_DATABASE_PROPERTY);
- }
-
- @Override
- protected TargetDatabase[] choices() {
- return TargetDatabase.values();
- }
-
- @Override
- protected TargetDatabase defaultValue() {
- return this.subject().getDefaultTargetDatabase();
- }
-
- @Override
- protected String displayString(TargetDatabase value) {
- return this.buildDisplayString(EclipseLinkUiMessages.class, TargetDatabaseComposite.this, value);
- }
-
- @Override
- protected TargetDatabase getValue() {
- return this.subject().getTargetDatabase();
- }
-
- @Override
- protected void setValue(TargetDatabase value) {
- this.subject().setTargetDatabase(value);
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- this.buildLabeledComposite(
- container,
- EclipseLinkUiMessages.PersistenceXmlOptionsTab_targetDatabaseLabel,
- this.buildTargetDatabaseCombo(container),
- null // TODO IJpaHelpContextIds.
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/EclipseLinkNavigatorItemContentProviderFactory.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/EclipseLinkNavigatorItemContentProviderFactory.java
deleted file mode 100644
index dc9e883485..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/EclipseLinkNavigatorItemContentProviderFactory.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.persistencexml.details;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceXml;
-import org.eclipse.jpt.ui.internal.jface.DelegatingTreeContentAndLabelProvider;
-import org.eclipse.jpt.ui.internal.platform.generic.PersistenceXmlItemContentProvider;
-import org.eclipse.jpt.ui.jface.DelegatingContentAndLabelProvider;
-import org.eclipse.jpt.ui.jface.TreeItemContentProvider;
-import org.eclipse.jpt.ui.jface.TreeItemContentProviderFactory;
-
-/**
- * EclipseLinkNavigatorItemContentProviderFactory
- */
-public class EclipseLinkNavigatorItemContentProviderFactory
- implements TreeItemContentProviderFactory
-{
- public TreeItemContentProvider buildItemContentProvider(
- Object item,
- DelegatingContentAndLabelProvider contentAndLabelProvider) {
-
- DelegatingTreeContentAndLabelProvider treeContentAndLabelProvider =
- (DelegatingTreeContentAndLabelProvider) contentAndLabelProvider;
-
- if (item instanceof PersistenceXml) {
- return new PersistenceXmlItemContentProvider((PersistenceXml) item, treeContentAndLabelProvider);
- }
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/EclipseLinkNavigatorItemLabelProviderFactory.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/EclipseLinkNavigatorItemLabelProviderFactory.java
deleted file mode 100644
index 1e7467fbd0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/EclipseLinkNavigatorItemLabelProviderFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.persistencexml.details;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceXml;
-import org.eclipse.jpt.ui.internal.platform.generic.PersistenceXmlItemLabelProvider;
-import org.eclipse.jpt.ui.jface.DelegatingContentAndLabelProvider;
-import org.eclipse.jpt.ui.jface.ItemLabelProvider;
-import org.eclipse.jpt.ui.jface.ItemLabelProviderFactory;
-
-/**
- * EclipseLinkNavigatorItemLabelProviderFactory
- */
-public class EclipseLinkNavigatorItemLabelProviderFactory
- implements ItemLabelProviderFactory
-{
- public ItemLabelProvider buildItemLabelProvider(
- Object item,
- DelegatingContentAndLabelProvider contentAndLabelProvider) {
-
- if (item instanceof PersistenceXml) {
- return new PersistenceXmlItemLabelProvider((PersistenceXml) item, contentAndLabelProvider);
- }
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/PersistenceDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/PersistenceDetailsProvider.java
deleted file mode 100644
index 78c0b862ba..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/PersistenceDetailsProvider.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Oracle. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.persistencexml.details;
-
-import org.eclipse.jpt.core.JpaStructureNode;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.persistence.PersistenceStructureNodes;
-import org.eclipse.jpt.ui.WidgetFactory;
-import org.eclipse.jpt.ui.details.JpaDetailsPage;
-import org.eclipse.jpt.ui.details.JpaDetailsProvider;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * PersistenceDetailsProvider
- */
-public class PersistenceDetailsProvider implements JpaDetailsProvider
-{
- public PersistenceDetailsProvider() {
- super();
- }
-
- public JpaDetailsPage<? extends JpaStructureNode> buildDetailsPage(
- Composite parent,
- Object contentNodeId,
- WidgetFactory widgetFactory) {
-
- if (contentNodeId == PersistenceStructureNodes.PERSISTENCE_ID) {
- return new PersistenceXmlDetailsPage(parent, widgetFactory);
- }
- else if (contentNodeId == PersistenceStructureNodes.PERSISTENCE_UNIT_ID) {
- return new PersistenceXmlDetailsPage(parent, widgetFactory);
- }
- return null;
- }
-
- public String fileContentType() {
- return JptCorePlugin.PERSISTENCE_XML_CONTENT_TYPE;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/PersistenceXmlDetailsPage.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/PersistenceXmlDetailsPage.java
deleted file mode 100644
index cc4c6eb673..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistencexml/details/PersistenceXmlDetailsPage.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Oracle. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.persistencexml.details;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.ui.WidgetFactory;
-import org.eclipse.jpt.ui.internal.details.AbstractJpaDetailsPage;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * PersistenceXmlDetailsPage
- */
-public class PersistenceXmlDetailsPage extends AbstractJpaDetailsPage<PersistenceUnit>
-{
-
- public PersistenceXmlDetailsPage(Composite parent, WidgetFactory widgetFactory) {
- super(parent, widgetFactory);
- }
-
- protected void initialize() {
- super.initialize();
- }
-
- @Override
- protected void initializeLayout(Composite composite) {
- composite.setLayout(new FillLayout());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkNavigatorProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkNavigatorProvider.java
deleted file mode 100644
index f8e5c4b3d3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkNavigatorProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.platform;
-
-import org.eclipse.jpt.eclipselink.ui.internal.persistencexml.details.EclipseLinkNavigatorItemContentProviderFactory;
-import org.eclipse.jpt.eclipselink.ui.internal.persistencexml.details.EclipseLinkNavigatorItemLabelProviderFactory;
-import org.eclipse.jpt.ui.jface.ItemLabelProviderFactory;
-import org.eclipse.jpt.ui.jface.TreeItemContentProviderFactory;
-import org.eclipse.jpt.ui.navigator.JpaNavigatorProvider;
-
-/**
- * EclipseLinkNavigatorProvider
- */
-public class EclipseLinkNavigatorProvider implements JpaNavigatorProvider
-{
- public ItemLabelProviderFactory getItemLabelProviderFactory() {
- return new EclipseLinkNavigatorItemLabelProviderFactory();
- }
-
- public TreeItemContentProviderFactory getTreeItemContentProviderFactory() {
- return new EclipseLinkNavigatorItemContentProviderFactory();
- }
-
- public void dispose() {
-
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkPlatformUI.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkPlatformUI.java
deleted file mode 100644
index 7c7f7518d1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkPlatformUI.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.platform;
-
-import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.eclipselink.ui.internal.ddlgen.EclipseLinkDDLGeneratorUi;
-import org.eclipse.jpt.eclipselink.ui.internal.persistencexml.details.PersistenceDetailsProvider;
-import org.eclipse.jpt.ui.JpaUiFactory;
-import org.eclipse.jpt.ui.details.AttributeMappingUiProvider;
-import org.eclipse.jpt.ui.details.JpaDetailsProvider;
-import org.eclipse.jpt.ui.details.TypeMappingUiProvider;
-import org.eclipse.jpt.ui.internal.platform.base.BaseJpaPlatformUi;
-import org.eclipse.jpt.ui.navigator.JpaNavigatorProvider;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * EclipseLinkPlatformUI
- */
-public class EclipseLinkPlatformUI extends BaseJpaPlatformUi
-{
- public EclipseLinkPlatformUI() {
- super();
- }
-
- // ********* navigator content *********
- public JpaNavigatorProvider buildNavigatorProvider() {
- return new EclipseLinkNavigatorProvider();
- }
-
- @Override
- protected JpaUiFactory createJpaUiFactory() {
- return new EclipseLinkUiFactory();
- }
-
- public void generateDDL(JpaProject project, IStructuredSelection selection) {
-
- String projectLocation = project.getProject().getLocation().toString();
-
- EclipseLinkDDLGeneratorUi.generate(project, projectLocation, selection);
- }
-
- protected void displayNotSupportedMessage(String title, String message) {
- String formattedMessage = MessageFormat.format(message, message);
- Shell currentShell = Display.getCurrent().getActiveShell();
- MessageDialog.openInformation(currentShell, title, formattedMessage);
- }
-
- @Override
- protected void addDetailsProvidersTo(Collection<JpaDetailsProvider> providers) {
- super.addDetailsProvidersTo(providers);
- providers.add(new PersistenceDetailsProvider());
- }
-
- @Override
- protected void addJavaAttributeMappingUiProvidersTo(
- List<AttributeMappingUiProvider<? extends AttributeMapping>> providers) {
- super.addJavaAttributeMappingUiProvidersTo(providers);
- }
-
- @Override
- protected void addJavaTypeMappingUiProvidersTo(
- List<TypeMappingUiProvider<? extends TypeMapping>> providers) {
- super.addJavaTypeMappingUiProvidersTo(providers);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkUiFactory.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkUiFactory.java
deleted file mode 100644
index 4732fb0c2f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkUiFactory.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.platform;
-
-import java.util.ArrayList;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logging;
-import org.eclipse.jpt.eclipselink.core.internal.context.options.Options;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.eclipselink.ui.internal.caching.PersistenceXmlCachingTab;
-import org.eclipse.jpt.eclipselink.ui.internal.connection.PersistenceXmlConnectionTab;
-import org.eclipse.jpt.eclipselink.ui.internal.customization.PersistenceXmlCustomizationTab;
-import org.eclipse.jpt.eclipselink.ui.internal.logging.PersistenceXmlLoggingTab;
-import org.eclipse.jpt.eclipselink.ui.internal.options.PersistenceXmlOptionsTab;
-import org.eclipse.jpt.eclipselink.ui.internal.schema.generation.PersistenceXmlSchemaGenerationTab;
-import org.eclipse.jpt.ui.WidgetFactory;
-import org.eclipse.jpt.ui.details.JpaPageComposite;
-import org.eclipse.jpt.ui.internal.BaseJpaUiFactory;
-import org.eclipse.jpt.ui.internal.persistence.details.PersistenceUnitGeneralComposite;
-import org.eclipse.jpt.ui.internal.persistence.details.PersistenceUnitPropertiesComposite;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * EclipseLinkUiFactory
- */
-public class EclipseLinkUiFactory extends BaseJpaUiFactory
-{
- public EclipseLinkUiFactory() {
- super();
- }
-
- @Override
- public ListIterator<JpaPageComposite<PersistenceUnit>> createPersistenceUnitComposites(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- PropertyValueModel<EclipseLinkPersistenceUnit> eclipseLinkPersistenceUnitHolder =
- this.buildEclipseLinkPersistenceUnitHolder(subjectHolder);
- ArrayList<JpaPageComposite<PersistenceUnit>> pages =
- new ArrayList<JpaPageComposite<PersistenceUnit>>(8);
-
- pages.add(new PersistenceUnitGeneralComposite(subjectHolder, parent, widgetFactory));
-
- PropertyValueModel<Connection> connectionHolder =
- this.buildConnectionHolder(eclipseLinkPersistenceUnitHolder);
- pages.add(new PersistenceXmlConnectionTab(connectionHolder, parent, widgetFactory));
-
- PropertyValueModel<Customization> customizationHolder =
- this.buildCustomizationHolder(eclipseLinkPersistenceUnitHolder);
- pages.add(new PersistenceXmlCustomizationTab(customizationHolder, parent, widgetFactory));
-
- PropertyValueModel<Caching> cachingHolder =
- this.buildCachingHolder(eclipseLinkPersistenceUnitHolder);
- pages.add(new PersistenceXmlCachingTab(cachingHolder, parent, widgetFactory));
-
- PropertyValueModel<Logging> loggingHolder =
- this.buildLoggingHolder(eclipseLinkPersistenceUnitHolder);
- pages.add(new PersistenceXmlLoggingTab(loggingHolder, parent, widgetFactory));
-
- PropertyValueModel<Options> optionsHolder =
- this.buildOptionsHolder(eclipseLinkPersistenceUnitHolder);
- pages.add(new PersistenceXmlOptionsTab(optionsHolder, parent, widgetFactory));
-
- PropertyValueModel<SchemaGeneration> schemaGenHolder =
- this.buildSchemaGenerationHolder(eclipseLinkPersistenceUnitHolder);
- pages.add(new PersistenceXmlSchemaGenerationTab(schemaGenHolder, parent, widgetFactory));
-
- pages.add(new PersistenceUnitPropertiesComposite(subjectHolder, parent, widgetFactory));
-
- return pages.listIterator();
- }
-
- private PropertyValueModel<Connection> buildConnectionHolder(
- PropertyValueModel<EclipseLinkPersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<EclipseLinkPersistenceUnit, Connection>(subjectHolder) {
- @Override
- protected Connection transform_(EclipseLinkPersistenceUnit value) {
- return value.getConnection();
- }
- };
- }
-
- private PropertyValueModel<Options> buildOptionsHolder(
- PropertyValueModel<EclipseLinkPersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<EclipseLinkPersistenceUnit, Options>(subjectHolder) {
- @Override
- protected Options transform_(EclipseLinkPersistenceUnit value) {
- return value.getOptions();
- }
- };
- }
-
- private PropertyValueModel<Logging> buildLoggingHolder(
- PropertyValueModel<EclipseLinkPersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<EclipseLinkPersistenceUnit, Logging>(subjectHolder) {
- @Override
- protected Logging transform_(EclipseLinkPersistenceUnit value) {
- return value.getLogging();
- }
- };
- }
-
- private PropertyValueModel<Customization> buildCustomizationHolder(
- PropertyValueModel<EclipseLinkPersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<EclipseLinkPersistenceUnit, Customization>(subjectHolder) {
- @Override
- protected Customization transform_(EclipseLinkPersistenceUnit value) {
- return value.getCustomization();
- }
- };
- }
-
- private PropertyValueModel<Caching> buildCachingHolder(
- PropertyValueModel<EclipseLinkPersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<EclipseLinkPersistenceUnit, Caching>(subjectHolder) {
- @Override
- protected Caching transform_(EclipseLinkPersistenceUnit value) {
- return value.getCaching();
- }
- };
- }
-
- private PropertyValueModel<SchemaGeneration> buildSchemaGenerationHolder(
- PropertyValueModel<EclipseLinkPersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<EclipseLinkPersistenceUnit, SchemaGeneration>(subjectHolder) {
- @Override
- protected SchemaGeneration transform_(EclipseLinkPersistenceUnit value) {
- return value.getSchemaGeneration();
- }
- };
- }
-
- private PropertyValueModel<EclipseLinkPersistenceUnit> buildEclipseLinkPersistenceUnitHolder(
- PropertyValueModel<PersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<PersistenceUnit, EclipseLinkPersistenceUnit>(subjectHolder) {
- @Override
- protected EclipseLinkPersistenceUnit transform_(PersistenceUnit value) {
- return (EclipseLinkPersistenceUnit) value;
- }
- };
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/CreateDdlFileNameComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/CreateDdlFileNameComposite.java
deleted file mode 100644
index 52f159c2e7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/CreateDdlFileNameComposite.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.schema.generation;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * CreateDdlFileNameComposite
- */
-public class CreateDdlFileNameComposite extends AbstractPane<SchemaGeneration>
-{
- /**
- * Creates a new <code>CreateDdlFileNameComposite</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- */
- public CreateDdlFileNameComposite(
- AbstractPane<? extends SchemaGeneration> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- private PropertyValueModel<String> buildDefaultCreateDdlFileNameHolder() {
- return new PropertyAspectAdapter<SchemaGeneration, String>(this.getSubjectHolder(), SchemaGeneration.DEFAULT_SCHEMA_GENERATION_CREATE_FILE_NAME) {
- @Override
- protected String buildValue_() {
- return CreateDdlFileNameComposite.this.defaultValue(subject);
- }
- };
- }
-
- private ListValueModel<String> buildDefaultCreateDdlFileNameListHolder() {
- return new PropertyListValueModelAdapter<String>(
- this.buildDefaultCreateDdlFileNameHolder()
- );
- }
-
- private WritablePropertyValueModel<String> buildCreateDdlFileNameHolder() {
- return new PropertyAspectAdapter<SchemaGeneration, String>(this.getSubjectHolder(), SchemaGeneration.CREATE_FILE_NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
-
- String name = subject.getCreateFileName();
- if (name == null) {
- name = CreateDdlFileNameComposite.this.defaultValue(subject);
- }
- return name;
- }
-
- @Override
- protected void setValue_(String value) {
-
- if (defaultValue(subject).equals(value)) {
- value = null;
- }
- subject.setCreateFileName(value);
- }
- };
- }
-
- private String defaultValue(SchemaGeneration subject) {
- String defaultValue = subject.getDefaultCreateFileName();
-
- if (defaultValue != null) {
- return NLS.bind(
- EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_defaultWithOneParam,
- defaultValue
- );
- }
- else {
- return EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_defaultEmpty;
- }
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeLayout(Composite container) {
-
- CCombo combo = buildLabeledEditableCCombo(
- container,
- EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_createDdlFileNameLabel,
- this.buildDefaultCreateDdlFileNameListHolder(),
- this.buildCreateDdlFileNameHolder(),
- null // EclipseLinkHelpContextIds.CREATE_DDL_FILE_NAME
- );
- SWTUtil.attachDefaultValueHandler(combo);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/DdlGenerationLocationComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/DdlGenerationLocationComposite.java
deleted file mode 100644
index 8913542b47..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/DdlGenerationLocationComposite.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.schema.generation;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.ui.internal.widgets.FileChooserPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * DdlGenerationLocationComposite
- */
-public class DdlGenerationLocationComposite extends AbstractPane<SchemaGeneration>
-{
- public DdlGenerationLocationComposite(AbstractPane<? extends SchemaGeneration> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- new FileChooserPane<SchemaGeneration>(this, container) {
-
- @Override
- protected WritablePropertyValueModel<String> buildTextHolder() {
- return new PropertyAspectAdapter<SchemaGeneration, String>(getSubjectHolder(), SchemaGeneration.APPLICATION_LOCATION_PROPERTY) {
- @Override
- protected String buildValue_() {
-
- String name = subject.getApplicationLocation();
- if (name == null) {
- name = defaultValue(subject);
- }
- return name;
- }
-
- @Override
- protected void setValue_(String value) {
-
- if (defaultValue(subject).equals(value)) {
- value = null;
- }
- subject.setApplicationLocation(value);
- }
- };
- }
-
- private String defaultValue(SchemaGeneration subject) {
- String defaultValue = subject.getDefaultApplicationLocation();
-
- if (defaultValue != null) {
- return NLS.bind(
- EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_defaultWithOneParam,
- defaultValue
- );
- }
- else {
- return EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_defaultEmpty;
- }
- }
-
- @Override
- protected String dialogMessage() {
- //TODO
- return "TODO";
- }
-
- @Override
- protected String dialogTitle() {
- return EclipseLinkUiMessages.DdlGenerationLocationComposite_dialogTitle;
- }
-
- @Override
- protected IResource getDialogInput() {
- return null;
- }
-
- @Override
- protected String labelText() {
- return EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_ddlGenerationLocationLabel;
- }
- };
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/DdlGenerationTypeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/DdlGenerationTypeComposite.java
deleted file mode 100644
index cba5e59fb8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/DdlGenerationTypeComposite.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.schema.generation;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.DdlGenerationType;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * DdlGenerationTypeComposite
- */
-public class DdlGenerationTypeComposite
- extends AbstractFormPane<SchemaGeneration>
-{
- /**
- * Creates a new <code>DdlGenerationTypeComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public DdlGenerationTypeComposite(
- AbstractFormPane<? extends SchemaGeneration> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private EnumFormComboViewer<SchemaGeneration, DdlGenerationType> buildDdlGenerationTypeCombo(Composite container) {
- return new EnumFormComboViewer<SchemaGeneration, DdlGenerationType>(this, container) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY);
- }
-
- @Override
- protected DdlGenerationType[] choices() {
- return DdlGenerationType.values();
- }
-
- @Override
- protected DdlGenerationType defaultValue() {
- return this.subject().getDefaultDdlGenerationType();
- }
-
- @Override
- protected String displayString(DdlGenerationType value) {
- return this.buildDisplayString(EclipseLinkUiMessages.class, DdlGenerationTypeComposite.this, value);
- }
-
- @Override
- protected DdlGenerationType getValue() {
- return this.subject().getDdlGenerationType();
- }
-
- @Override
- protected void setValue(DdlGenerationType value) {
- this.subject().setDdlGenerationType(value);
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.buildLabeledComposite(
- container,
- EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_ddlGenerationTypeLabel,
- buildDdlGenerationTypeCombo( container),
- null // TODO IJpaHelpContextIds.
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/DropDdlFileNameComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/DropDdlFileNameComposite.java
deleted file mode 100644
index 986ce3762c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/DropDdlFileNameComposite.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.schema.generation;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * DropDdlFileNameComposite
- */
-public class DropDdlFileNameComposite extends AbstractPane<SchemaGeneration>
-{
- /**
- * Creates a new <code>DropDdlFileNameComposite</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- */
- public DropDdlFileNameComposite(
- AbstractPane<? extends SchemaGeneration> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- private PropertyValueModel<String> buildDefaultDropDdlFileNameHolder() {
- return new PropertyAspectAdapter<SchemaGeneration, String>(this.getSubjectHolder(), SchemaGeneration.DEFAULT_SCHEMA_GENERATION_DROP_FILE_NAME) {
- @Override
- protected String buildValue_() {
- return DropDdlFileNameComposite.this.defaultValue(subject);
- }
- };
- }
-
- private ListValueModel<String> buildDefaultDropDdlFileNameListHolder() {
- return new PropertyListValueModelAdapter<String>(
- this.buildDefaultDropDdlFileNameHolder()
- );
- }
-
- private WritablePropertyValueModel<String> buildDropDdlFileNameHolder() {
- return new PropertyAspectAdapter<SchemaGeneration, String>(this.getSubjectHolder(), SchemaGeneration.DROP_FILE_NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
-
- String name = subject.getDropFileName();
- if (name == null) {
- name = DropDdlFileNameComposite.this.defaultValue(subject);
- }
- return name;
- }
-
- @Override
- protected void setValue_(String value) {
-
- if (DropDdlFileNameComposite.this.defaultValue(subject).equals(value)) {
- value = null;
- }
- subject.setDropFileName(value);
- }
- };
- }
-
- private String defaultValue(SchemaGeneration subject) {
- String defaultValue = subject.getDefaultDropFileName();
-
- if (defaultValue != null) {
- return NLS.bind(
- EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_defaultWithOneParam,
- defaultValue
- );
- }
- else {
- return EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_defaultEmpty;
- }
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeLayout(Composite container) {
-
- CCombo combo = buildLabeledEditableCCombo(
- container,
- EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_dropDdlFileNameLabel,
- this.buildDefaultDropDdlFileNameListHolder(),
- this.buildDropDdlFileNameHolder(),
- null // EclipseLinkHelpContextIds.DROP_DDL_FILE_NAME
- );
- SWTUtil.attachDefaultValueHandler(combo);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/EclipseLinkSchemaGenerationComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/EclipseLinkSchemaGenerationComposite.java
deleted file mode 100644
index 993483bc59..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/EclipseLinkSchemaGenerationComposite.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.schema.generation;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * EclipseLinkSchemaGenerationComposite
- */
-public class EclipseLinkSchemaGenerationComposite
- extends AbstractFormPane<SchemaGeneration>
-{
- public EclipseLinkSchemaGenerationComposite(
- AbstractFormPane<SchemaGeneration> subjectHolder,
- Composite container) {
- super(subjectHolder, container, false);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- container = buildSection(
- container,
- EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_sectionTitle,
- EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_sectionDescription
- );
-
- // DDL Generation Type:
- new DdlGenerationTypeComposite(this, container);
- // Output Mode:
- new OutputModeComposite(this, container);
- // DDL Generation Location
- new DdlGenerationLocationComposite(this, container);
- // Create DDL File Name:
- new CreateDdlFileNameComposite(this, container);
- // Drop DDL File Name:
- new DropDdlFileNameComposite(this, container);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/OutputModeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/OutputModeComposite.java
deleted file mode 100644
index 6bfac27ba1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/OutputModeComposite.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.schema.generation;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.OutputMode;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * OutputModeComposite
- */
-public class OutputModeComposite extends AbstractFormPane<SchemaGeneration>
-{
- /**
- * Creates a new <code>OutputModeComposite</code>.
- *
- * @param parentController
- * The parent container of this one
- * @param parent
- * The parent container
- */
- public OutputModeComposite(
- AbstractFormPane<? extends SchemaGeneration> parentComposite,
- Composite parent) {
-
- super(parentComposite, parent);
- }
-
- private EnumFormComboViewer<SchemaGeneration, OutputMode> buildOutputModeCombo(Composite container) {
- return new EnumFormComboViewer<SchemaGeneration, OutputMode>(this, container) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(SchemaGeneration.OUTPUT_MODE_PROPERTY);
- }
-
- @Override
- protected OutputMode[] choices() {
- return OutputMode.values();
- }
-
- @Override
- protected OutputMode defaultValue() {
- return this.subject().getDefaultOutputMode();
- }
-
- @Override
- protected String displayString(OutputMode value) {
- return this.buildDisplayString(EclipseLinkUiMessages.class, OutputModeComposite.this, value);
- }
-
- @Override
- protected OutputMode getValue() {
- return this.subject().getOutputMode();
- }
-
- @Override
- protected void setValue(OutputMode value) {
- this.subject().setOutputMode(value);
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- this.buildLabeledComposite(
- container,
- EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_outputModeLabel,
- this.buildOutputModeCombo(container),
- null // TODO IJpaHelpContextIds.
- );
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/PersistenceXmlSchemaGenerationTab.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/PersistenceXmlSchemaGenerationTab.java
deleted file mode 100644
index 9469040a9a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/schema/generation/PersistenceXmlSchemaGenerationTab.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.ui.internal.schema.generation;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.WidgetFactory;
-import org.eclipse.jpt.ui.details.JpaPageComposite;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * PersistenceXmlSchemaGenerationTab
- */
-public class PersistenceXmlSchemaGenerationTab
- extends AbstractFormPane<SchemaGeneration>
- implements JpaPageComposite<PersistenceUnit>
-{
- // ********** constructors/initialization **********
- public PersistenceXmlSchemaGenerationTab(
- PropertyValueModel<SchemaGeneration> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- new EclipseLinkSchemaGenerationComposite(this, container);
- }
-
- // ********** JpaPageComposite implementation **********
- public String getHelpID() {
- return null;
- }
-
- public Image getPageImage() {
- return null;
- }
-
- public String getPageText() {
- return EclipseLinkUiMessages.PersistenceXmlSchemaGenerationTab_title;
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.gen/.classpath b/jpa/plugins/org.eclipse.jpt.gen/.classpath
deleted file mode 100644
index 304e86186a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/plugins/org.eclipse.jpt.gen/.cvsignore b/jpa/plugins/org.eclipse.jpt.gen/.cvsignore
deleted file mode 100644
index a196dd7686..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/.cvsignore
+++ /dev/null
@@ -1,6 +0,0 @@
-bin
-@dot
-temp.folder
-build.xml
-javaCompiler...args
-javaCompiler...args.* \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.gen/.project b/jpa/plugins/org.eclipse.jpt.gen/.project
deleted file mode 100644
index ef2d5088ee..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.gen</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.core.resources.prefs b/jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 1f15ff2b4b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tue Jan 15 11:12:07 EST 2008
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.jdt.core.prefs b/jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 3e1d50ad46..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Sun May 27 14:28:54 EDT 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/jpa/plugins/org.eclipse.jpt.gen/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.gen/META-INF/MANIFEST.MF
deleted file mode 100644
index 3f44799ab8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,15 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.gen
-Bundle-Version: 1.1.0.qualifier
-Bundle-ClassPath: .
-Bundle-Localization: plugin
-Export-Package: org.eclipse.jpt.gen.internal; x-friends:="org.eclipse.jpt.ui"
-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jpt.utility;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.jpt.db;bundle-version="[1.1.1,2.0.0)",
- org.eclipse.jpt.core;bundle-version="[2.0.0,3.0.0)"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/jpa/plugins/org.eclipse.jpt.gen/about.html b/jpa/plugins/org.eclipse.jpt.gen/about.html
deleted file mode 100644
index 9e73bdabb6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>June 06, 2007</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/jpa/plugins/org.eclipse.jpt.gen/build.properties b/jpa/plugins/org.eclipse.jpt.gen/build.properties
deleted file mode 100644
index 41837ebdd1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/build.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-################################################################################
-# Copyright (c) 2006, 2007 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-source.. = src/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- about.html,\
- plugin.properties
-jars.compile.order = .
diff --git a/jpa/plugins/org.eclipse.jpt.gen/component.xml b/jpa/plugins/org.eclipse.jpt.gen/component.xml
deleted file mode 100644
index 7a4e04e21f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/component.xml
+++ /dev/null
@@ -1 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.jpt.gen"><description url=""></description><component-depends unrestricted="true"></component-depends><plugin id="org.eclipse.jpt.gen" fragment="false"/></component> \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.gen/plugin.properties b/jpa/plugins/org.eclipse.jpt.gen/plugin.properties
deleted file mode 100644
index 4875a8b174..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/plugin.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-###############################################################################
-# Copyright (c) 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName = Java Persistence API Tools - Entity Gen
-providerName = Eclipse.org
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/EntityGenerator.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/EntityGenerator.java
deleted file mode 100644
index e8724927a9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/EntityGenerator.java
+++ /dev/null
@@ -1,1520 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.gen.internal;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.io.StringWriter;
-import java.lang.reflect.Modifier;
-import java.text.Collator;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.db.Column;
-import org.eclipse.jpt.db.ForeignKey;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.JavaType;
-import org.eclipse.jpt.utility.internal.IndentingPrintWriter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-
-// TODO handle table names that are illegal class names
-// TODO handle table names that are illegal file names
-// TODO handle column names that are illegal field/method names
-// TODO format code per preferences
-// TODO organize imports per preferences
-// TODO prompt user to overwrite existing classes
-/**
- * This generator will generate an entity for a table.
- */
-public class EntityGenerator {
- final Config config;
- private final IPackageFragment packageFragment;
- private final GenTable genTable;
- private final String entityClassName;
- private final OverwriteConfirmer overwriteConfirmer;
- private final IProgressMonitor monitor;
- private final String pkClassName;
-
-
- // ********** public API **********
-
- static void generateEntity(Config config, IPackageFragment packageFragment, GenTable genTable, OverwriteConfirmer overwriteConfirmer, IProgressMonitor monitor) {
- if ((config == null) || (packageFragment == null) || (genTable == null)) {
- throw new NullPointerException();
- }
- new EntityGenerator(config, packageFragment, genTable, overwriteConfirmer, monitor).generateEntity();
- }
-
-
- // ********** constructor/initialization **********
-
- private EntityGenerator(Config config, IPackageFragment packageFragment, GenTable genTable, OverwriteConfirmer overwriteConfirmer, IProgressMonitor monitor) {
- super();
- this.config = config;
- this.packageFragment = packageFragment;
- this.genTable = genTable;
- this.entityClassName = this.fullyQualify(this.entityName());
- this.overwriteConfirmer = overwriteConfirmer;
- this.monitor = monitor;
- this.pkClassName = this.entityClassName + "PK"; // hack
- }
-
-
- // ********** code gen **********
-
- private void generateEntity() {
- int totalWork = pkClassIsGenerated() ? 40 : 20;
- try {
- this.monitor.beginTask("", totalWork);
- this.generateEntity_();
- } catch (JavaModelException ex) {
- throw new RuntimeException(ex);
- }
- finally {
- this.monitor.done();
- }
- }
-
- private void generateEntity_() throws JavaModelException {
- // build the body source first so we can gather up the import statements
- this.generateSourceFile(this.entityClassName, this.entityName() + ".java", this.buildSource(this.buildBodySource()));
- if (this.pkClassIsGenerated()) {
- this.generateSourceFile(this.pkClassName, this.pkName() + ".java", this.buildSource(this.buildPKBodySource()));
- }
-
- }
-
- private void generateSourceFile(String className, String fileName, String source) throws JavaModelException {
- try {
- this.packageFragment.createCompilationUnit(fileName, source, false, new SubProgressMonitor(this.monitor, 10));
- } catch (JavaModelException ex) {
- if (ex.getJavaModelStatus().getCode() == IJavaModelStatusConstants.NAME_COLLISION) {
- if (this.overwriteConfirmer.overwrite(className)) {
- this.packageFragment.createCompilationUnit(fileName, source, true, new SubProgressMonitor(this.monitor, 0));
- }
- } else {
- throw ex;
- }
- }
- }
-
- /**
- * build the "body" source first; then build the "package" and "imports" source
- * and concatenate the "body" source to it
- */
- private String buildSource(BodySource bodySource) {
- StringWriter sw = new StringWriter(bodySource.length() + 1000);
- PrintWriter pw = new PrintWriter(sw);
- this.printPackageAndImportsOn(pw, bodySource);
- pw.print(bodySource.source());
- this.monitor.worked(10);
- return sw.toString();
- }
-
- private BodySource buildBodySource() {
- EntitySourceWriter pw = new EntitySourceWriter(this.packageName(), this.entityClassName);
- this.printBodySourceOn(pw);
- return pw;
- }
-
- private BodySource buildPKBodySource() {
- EntitySourceWriter pw = new EntitySourceWriter(this.packageName(), this.pkClassName);
- this.printPrimaryKeyClassOn(pw);
- return pw;
- }
-
- private void printBodySourceOn(EntitySourceWriter pw) {
- this.printClassDeclarationOn(pw);
-
- pw.indent();
- this.printEntityPrimaryKeyFieldsOn(pw);
- this.printEntityNonPrimaryKeyBasicFieldsOn(pw);
- this.printEntityManyToOneFieldsOn(pw);
- this.printEntityOneToManyFieldsOn(pw);
- this.printEntityOwnedManyToManyFieldsOn(pw);
- this.printEntityNonOwnedManyToManyFieldsOn(pw);
- this.printSerialVersionUID(pw);
- pw.println();
-
- this.printZeroArgumentConstructorOn(this.entityName(), this.config.methodVisibility(), pw);
- if (this.config.propertyAccessType() || this.config.generateGettersAndSetters()) {
- this.printEntityPrimaryKeyGettersAndSettersOn(pw);
- this.printEntityNonPrimaryKeyBasicGettersAndSettersOn(pw);
- this.printEntityManyToOneGettersAndSettersOn(pw);
- this.printEntityOneToManyGettersAndSettersOn(pw);
- this.printEntityOwnedManyToManyGettersAndSettersOn(pw);
- this.printEntityNonOwnedManyToManyGettersAndSettersOn(pw);
- }
- pw.undent();
-
- pw.print('}');
- pw.println();
- }
-
- private void printClassDeclarationOn(EntitySourceWriter pw) {
- this.printEntityAnnotationOn(pw);
- this.printTableAnnotationOn(pw);
- this.printIdClassAnnotationOn(pw);
-
- pw.print("public class ");
- pw.printTypeDeclaration(this.entityClassName);
- if (config.serializable()) {
- pw.print(" implements ");
- pw.printTypeDeclaration(Serializable.class.getName());
- }
- pw.print(" {");
- pw.println();
- }
-
- private void printEntityAnnotationOn(EntitySourceWriter pw) {
- pw.printAnnotation(JPA.ENTITY);
- pw.println();
- }
-
- private void printTableAnnotationOn(EntitySourceWriter pw) {
- if ( ! this.table().matchesShortJavaClassName(this.entityName())) {
- pw.printAnnotation(JPA.TABLE);
- pw.print("(name=\"");
- pw.print(this.table().getName());
- pw.print("\")");
- pw.println();
- }
- }
-
- private void printIdClassAnnotationOn(EntitySourceWriter pw) {
- if (this.pkClassIsGenerated() && this.config.generateIdClassForCompoundPK()) {
- pw.printAnnotation(JPA.ID_CLASS);
- pw.print('(');
- pw.printTypeDeclaration(pkClassName);
- pw.print(".class)");
- pw.println();
- }
- }
-
- private void printEntityPrimaryKeyFieldsOn(EntitySourceWriter pw) {
- if (this.pkClassIsGenerated() && this.config.generateEmbeddedIdForCompoundPK()) {
- this.printEntityEmbeddedIdPrimaryKeyFieldOn(pw);
- } else {
- this.printEntityReadOnlyPrimaryKeyFieldsOn(pw);
- this.printEntityWritablePrimaryKeyFieldsOn(pw);
- }
- }
-
- private void printEntityEmbeddedIdPrimaryKeyFieldOn(EntitySourceWriter pw) {
- if (this.config.fieldAccessType()) {
- pw.printAnnotation(JPA.EMBEDDED_ID);
- pw.println();
- }
- pw.printVisibility(this.config.fieldVisibility());
- pw.printTypeDeclaration(this.pkClassName);
- pw.print(' ');
- pw.print(this.genTable.fieldNameForEmbeddedId());
- pw.print(';');
- pw.println();
- pw.println();
- }
-
- private void printEntityReadOnlyPrimaryKeyFieldsOn(EntitySourceWriter pw) {
- this.printReadOnlyPrimaryKeyFieldsOn(pw, true); // true=print ID annotation on fields
- }
-
- private void printReadOnlyPrimaryKeyFieldsOn(EntitySourceWriter pw, boolean printIdAnnotation) {
- for (Iterator<Column> stream = this.genTable.readOnlyPrimaryKeyColumns(); stream.hasNext(); ) {
- this.printReadOnlyPrimaryKeyFieldOn(stream.next(), pw, printIdAnnotation);
- }
- }
-
- // TODO if the field's type is java.util.Date, it needs @Temporal(DATE)
- // TODO if the primary key is auto-generated, the field must be an integral type
- private void printReadOnlyPrimaryKeyFieldOn(Column column, EntitySourceWriter pw, boolean printIdAnnotation) {
- String fieldName = this.genTable.fieldNameFor(column);
- if (this.config.fieldAccessType()) {
- if (printIdAnnotation) {
- pw.printAnnotation(JPA.ID);
- pw.println();
- }
- if (column.matchesJavaFieldName(fieldName)) {
- this.printReadOnlyColumnAnnotationOn(pw); // no Column name needed
- } else {
- this.printReadOnlyColumnAnnotationOn(column.getName(), pw);
- }
- }
- pw.printVisibility(this.config.fieldVisibility());
- pw.printTypeDeclaration(column.getPrimaryKeyJavaTypeDeclaration());
- pw.print(' ');
- pw.print(fieldName);
- pw.print(';');
- pw.println();
- pw.println();
- }
-
- private void printReadOnlyColumnAnnotationOn(String columnName, EntitySourceWriter pw) {
- pw.printAnnotation(JPA.COLUMN);
- pw.print("(name=\"");
- pw.print(columnName);
- pw.print("\", insertable=false, updatable=false)");
- pw.println();
- }
-
- private void printReadOnlyColumnAnnotationOn(EntitySourceWriter pw) {
- pw.printAnnotation(JPA.COLUMN);
- pw.print("(insertable=false, updatable=false)");
- pw.println();
- }
-
- private void printEntityWritablePrimaryKeyFieldsOn(EntitySourceWriter pw) {
- this.printWritablePrimaryKeyFieldsOn(pw, true); // true=print ID annotation on fields
- }
-
- private void printWritablePrimaryKeyFieldsOn(EntitySourceWriter pw, boolean printIdAnnotation) {
- for (Iterator<Column> stream = this.genTable.writablePrimaryKeyColumns(); stream.hasNext(); ) {
- this.printWritablePrimaryKeyFieldOn(stream.next(), pw, printIdAnnotation);
- }
- }
-
- // TODO if the field's type is java.util.Date, it needs @Temporal(DATE)
- // TODO if the primary key is auto-generated, the field must be an integral type
- private void printWritablePrimaryKeyFieldOn(Column column, EntitySourceWriter pw, boolean printIdAnnotation) {
- String fieldName = this.genTable.fieldNameFor(column);
- if (this.config.fieldAccessType()) {
- if (printIdAnnotation) {
- pw.printAnnotation(JPA.ID);
- pw.println();
- }
- if ( ! column.matchesJavaFieldName(fieldName)) {
- this.printColumnAnnotationOn(column.getName(), pw);
- }
- }
- pw.printVisibility(this.config.fieldVisibility());
- pw.printTypeDeclaration(column.getPrimaryKeyJavaTypeDeclaration());
- pw.print(' ');
- pw.print(fieldName);
- pw.print(';');
- pw.println();
- pw.println();
- }
-
- private void printEntityNonPrimaryKeyBasicFieldsOn(EntitySourceWriter pw) {
- for (Iterator<Column> stream = this.genTable.nonPrimaryKeyBasicColumns(); stream.hasNext(); ) {
- this.printEntityNonPrimaryKeyBasicFieldOn(stream.next(), pw);
- }
- }
-
- private void printEntityNonPrimaryKeyBasicFieldOn(Column column, EntitySourceWriter pw) {
- String fieldName = this.genTable.fieldNameFor(column);
- if (this.config.fieldAccessType()) {
- if ( ! column.matchesJavaFieldName(fieldName)) {
- this.printColumnAnnotationOn(column.getName(), pw);
- }
- }
- if (column.dataTypeIsLOB()) {
- pw.printAnnotation(JPA.LOB);
- pw.println();
- }
- pw.printVisibility(this.config.fieldVisibility());
- pw.printTypeDeclaration(column.getJavaTypeDeclaration());
- pw.print(' ');
- pw.print(fieldName);
- pw.print(';');
- pw.println();
- pw.println();
- }
-
- private void printColumnAnnotationOn(String columnName, EntitySourceWriter pw) {
- pw.printAnnotation(JPA.COLUMN);
- pw.print("(name=\"");
- pw.print(columnName);
- pw.print("\")");
- pw.println();
- }
-
- private void printEntityManyToOneFieldsOn(EntitySourceWriter pw) {
- for (Iterator<ManyToOneRelation> stream = this.genTable.manyToOneRelations(); stream.hasNext(); ) {
- this.printEntityManyToOneFieldOn(stream.next(), pw);
- }
- }
-
- private void printEntityManyToOneFieldOn(ManyToOneRelation relation, EntitySourceWriter pw) {
- String fieldName = this.genTable.fieldNameFor(relation);
- if (this.config.fieldAccessType()) {
- this.printManyToOneAnnotationOn(fieldName, relation, pw);
- }
- pw.printVisibility(this.config.fieldVisibility());
- pw.printTypeDeclaration(this.fullyQualify(relation.referencedEntityName()));
- pw.print(' ');
- pw.print(fieldName);
- pw.print(';');
- pw.println();
- pw.println();
- }
-
- private void printManyToOneAnnotationOn(String fieldName, ManyToOneRelation relation, EntitySourceWriter pw) {
- pw.printAnnotation(JPA.MANY_TO_ONE);
- pw.println();
- ForeignKey fk = relation.getForeignKey();
- if (fk.defaultMatchesJavaFieldName(fieldName)) {
- return; // no JoinColumn annotation needed
- }
- if (fk.referencesSingleColumnPrimaryKey()) {
- pw.printAnnotation(JPA.JOIN_COLUMN);
- pw.print("(name=\"");
- pw.print(fk.columnPair().baseColumn().getName());
- pw.print("\")");
- } else {
- if (fk.columnPairsSize() > 1) {
- pw.printAnnotation(JPA.JOIN_COLUMNS);
- pw.print("({");
- pw.println();
- pw.indent();
- }
- this.printJoinColumnAnnotationsOn(fk, pw);
- if (fk.columnPairsSize() > 1) {
- pw.undent();
- pw.println();
- pw.print("})");
- }
- }
- pw.println();
- }
-
- private void printJoinColumnAnnotationsOn(ForeignKey foreignKey, EntitySourceWriter pw) {
- for (Iterator<ForeignKey.ColumnPair> stream = foreignKey.columnPairs(); stream.hasNext(); ) {
- this.printJoinColumnAnnotationOn(stream.next(), pw);
- if (stream.hasNext()) {
- pw.println(',');
- }
- }
- }
-
- private void printJoinColumnAnnotationOn(ForeignKey.ColumnPair columnPair, EntitySourceWriter pw) {
- this.printJoinColumnAnnotationOn(columnPair.baseColumn().getName(), columnPair.referencedColumn().getName(), pw);
- }
-
- /**
- * assume that at least one of the two names is not null
- */
- private void printJoinColumnAnnotationOn(String baseColumnName, String referencedColumnName, EntitySourceWriter pw) {
- pw.printAnnotation(JPA.JOIN_COLUMN);
- pw.print('(');
- if (baseColumnName != null) {
- pw.print("name=\"");
- pw.print(baseColumnName);
- }
- if (referencedColumnName != null) {
- if (baseColumnName != null) {
- pw.print("\", ");
- }
- pw.print("referencedColumnName=\"");
- pw.print(referencedColumnName);
- }
- pw.print("\")");
- }
-
- private void printEntityOneToManyFieldsOn(EntitySourceWriter pw) {
- for (Iterator<OneToManyRelation> stream = this.genTable.oneToManyRelations(); stream.hasNext(); ) {
- this.printEntityOneToManyFieldOn(stream.next(), pw);
- }
- }
-
- private void printEntityOneToManyFieldOn(OneToManyRelation relation, EntitySourceWriter pw) {
- String fieldName = this.genTable.fieldNameFor(relation);
- if (this.config.fieldAccessType()) {
- this.printOneToManyAnnotationOn(fieldName, relation, pw);
- }
- pw.printVisibility(this.config.fieldVisibility());
- pw.printTypeDeclaration(this.config.getCollectionTypeName());
- pw.print('<');
- pw.printTypeDeclaration(this.fullyQualify(relation.referencedEntityName()));
- pw.print('>');
- pw.print(' ');
- pw.print(fieldName);
- pw.print(';');
- pw.println();
- pw.println();
- }
-
- private void printOneToManyAnnotationOn(String fieldName, OneToManyRelation relation, EntitySourceWriter pw) {
- pw.printAnnotation(JPA.ONE_TO_MANY);
- pw.print("(mappedBy=\"");
- pw.print(relation.mappedBy());
- pw.print("\")");
- pw.println();
- }
-
- private void printEntityOwnedManyToManyFieldsOn(EntitySourceWriter pw) {
- for (Iterator<ManyToManyRelation> stream = this.genTable.ownedManyToManyRelations(); stream.hasNext(); ) {
- this.printEntityOwnedManyToManyFieldOn(stream.next(), pw);
- }
- }
-
- private void printEntityOwnedManyToManyFieldOn(ManyToManyRelation relation, EntitySourceWriter pw) {
- String fieldName = this.genTable.fieldNameFor(relation);
- if (this.config.fieldAccessType()) {
- this.printOwnedManyToManyAnnotationOn(fieldName, relation, pw);
- }
- pw.printVisibility(this.config.fieldVisibility());
- pw.printTypeDeclaration(this.config.getCollectionTypeName());
- pw.print('<');
- pw.printTypeDeclaration(this.fullyQualify(relation.nonOwningEntityName()));
- pw.print('>');
- pw.print(' ');
- pw.print(fieldName);
- pw.print(';');
- pw.println();
- pw.println();
- }
-
- /**
- * I guess you could build a state machine for all this crap,
- * but that seems like overkill...
- */
- private void printOwnedManyToManyAnnotationOn(String fieldName, ManyToManyRelation relation, EntitySourceWriter pw) {
- pw.printAnnotation(JPA.MANY_TO_MANY);
- pw.println();
- boolean first = true;
- boolean comma = false;
- if ( ! relation.joinTableNameIsDefault()) {
- if (first) {
- first = false;
- pw.printAnnotation(JPA.JOIN_TABLE);
- pw.print('(');
- }
- pw.print("name=\"");
- pw.print(relation.getJoinTable().name());
- pw.print('\"');
- comma = true;
- }
- if ( ! relation.joinColumnsIsDefaultFor(fieldName)) {
- if (first) {
- first = false;
- pw.printAnnotation(JPA.JOIN_TABLE);
- pw.print('(');
- } else if (comma) {
- pw.print(',');
- }
- pw.println();
- pw.indent();
- this.printJoinTableJoinColumnsOn("joinColumns", fieldName, relation.getOwningForeignKey(), pw);
- pw.undent();
- comma = true;
- }
- String inverseFieldName = relation.getNonOwningTable().fieldNameFor(relation);
- if ( ! relation.inverseJoinColumnsIsDefaultFor(inverseFieldName)) {
- if (first) {
- first = false;
- pw.printAnnotation(JPA.JOIN_TABLE);
- pw.print('(');
- } else if (comma) {
- pw.print(',');
- }
- pw.println();
- pw.indent();
- this.printJoinTableJoinColumnsOn("inverseJoinColumns", inverseFieldName, relation.getNonOwningForeignKey(), pw);
- pw.undent();
- comma = true;
- }
- if ( ! first) {
- pw.print(')');
- }
- pw.println();
- }
-
- private void printJoinTableJoinColumnsOn(String elementName, String fieldName, ForeignKey foreignKey, EntitySourceWriter pw) {
- if (foreignKey.columnPairsSize() != 1) {
- this.printJoinTableJoinColumnsOn(elementName, foreignKey, pw);
- } else if (foreignKey.getReferencedTable().primaryKeyColumnsSize() != 1) {
- // if the referenced table has a composite primary key, neither of the columns can be a default
- // since both of the defaults require a single-column primary key
- this.printJoinTableJoinColumnsOn(elementName, foreignKey, pw);
- } else {
- ForeignKey.ColumnPair columnPair = foreignKey.columnPair();
- Column pkColumn = foreignKey.getReferencedTable().primaryKeyColumn();
- if (columnPair.baseColumn().matchesJavaFieldName(fieldName + "_" + pkColumn.getName())) {
- if (columnPair.referencedColumn() == pkColumn) {
- // we shouldn't get here...
- } else {
- pw.print(elementName);
- pw.print('=');
- this.printJoinColumnAnnotationOn(null, columnPair.referencedColumn().getName(), pw);
- }
- } else {
- if (columnPair.referencedColumn() == pkColumn) {
- pw.print(elementName);
- pw.print('=');
- this.printJoinColumnAnnotationOn(columnPair.baseColumn().getName(), null, pw);
- } else {
- this.printJoinTableJoinColumnsOn(elementName, foreignKey, pw);
- }
- }
- }
- }
-
- private void printJoinTableJoinColumnsOn(String elementName, ForeignKey foreignKey, EntitySourceWriter pw) {
- pw.print(elementName);
- pw.print('=');
- if (foreignKey.columnPairsSize() > 1) {
- pw.print('{');
- pw.println();
- pw.indent();
- }
- this.printJoinColumnAnnotationsOn(foreignKey, pw);
- if (foreignKey.columnPairsSize() > 1) {
- pw.undent();
- pw.println();
- pw.print('}');
- pw.println();
- }
- }
-
- private void printEntityNonOwnedManyToManyFieldsOn(EntitySourceWriter pw) {
- for (Iterator<ManyToManyRelation> stream = this.genTable.nonOwnedManyToManyRelations(); stream.hasNext(); ) {
- this.printEntityNonOwnedManyToManyFieldOn(stream.next(), pw);
- }
- }
-
- private void printEntityNonOwnedManyToManyFieldOn(ManyToManyRelation relation, EntitySourceWriter pw) {
- String fieldName = this.genTable.fieldNameFor(relation);
- if (this.config.fieldAccessType()) {
- this.printNonOwnedManyToManyAnnotationOn(fieldName, relation, pw);
- }
- pw.printVisibility(this.config.fieldVisibility());
- pw.printTypeDeclaration(this.config.getCollectionTypeName());
- pw.print('<');
- pw.printTypeDeclaration(this.fullyQualify(relation.owningEntityName()));
- pw.print('>');
- pw.print(' ');
- pw.print(fieldName);
- pw.print(';');
- pw.println();
- pw.println();
- }
-
- private void printNonOwnedManyToManyAnnotationOn(String fieldName, ManyToManyRelation relation, EntitySourceWriter pw) {
- pw.printAnnotation(JPA.MANY_TO_MANY);
- pw.print("(mappedBy=\"");
- pw.print(relation.getMappedBy());
- pw.print("\")");
- pw.println();
- }
-
- private String fullyQualify(String shortClassName) {
- String pkg = this.packageName();
- return (pkg.length() == 0) ? shortClassName : pkg + '.' + shortClassName;
- }
-
- private void printSerialVersionUID(EntitySourceWriter pw) {
- if (this.config.generateSerialVersionUID()) {
- pw.print("private static final long serialVersionUID = 1L;");
- pw.println();
- }
- }
-
- private void printZeroArgumentConstructorOn(String ctorName, String visibility, EntitySourceWriter pw) {
- if (this.config.generateDefaultConstructor()) {
- pw.printVisibility(visibility);
- pw.print(ctorName);
- pw.print("() {");
- pw.println();
- pw.indent();
- pw.println("super();");
- pw.undent();
- pw.print('}');
- pw.println();
- pw.println();
- }
- }
-
- private void printEntityPrimaryKeyGettersAndSettersOn(EntitySourceWriter pw) {
- if (this.pkClassIsGenerated() && this.config.generateEmbeddedIdForCompoundPK()) {
- this.printEntityEmbeddedIdPrimaryKeyGetterAndSetterOn(pw);
- } else {
- this.printEntityReadOnlyPrimaryKeyGettersAndSettersOn(pw);
- this.printEntityWritablePrimaryKeyGettersAndSettersOn(pw);
- }
- }
-
- private void printEntityEmbeddedIdPrimaryKeyGetterAndSetterOn(EntitySourceWriter pw) {
- if (this.config.propertyAccessType()) {
- pw.printAnnotation(JPA.EMBEDDED_ID);
- pw.println();
- }
- pw.printGetterAndSetter(this.genTable.fieldNameForEmbeddedId(), this.pkClassName, this.config.methodVisibility());
- }
-
- private void printEntityReadOnlyPrimaryKeyGettersAndSettersOn(EntitySourceWriter pw) {
- this.printReadOnlyPrimaryKeyGettersAndSettersOn(pw, true); // true=print ID annotation on fields
- }
-
- private void printReadOnlyPrimaryKeyGettersAndSettersOn(EntitySourceWriter pw, boolean printIdAnnotation) {
- for (Iterator<Column> stream = this.genTable.readOnlyPrimaryKeyColumns(); stream.hasNext(); ) {
- this.printReadOnlyPrimaryKeyGetterAndSetterOn(stream.next(), pw, printIdAnnotation);
- }
- }
-
- // TODO if the property's type is java.util.Date, it needs @Temporal(DATE)
- // TODO if the primary key is auto-generated, the property must be an integral type
- private void printReadOnlyPrimaryKeyGetterAndSetterOn(Column column, EntitySourceWriter pw, boolean printIdAnnotation) {
- String propertyName = this.genTable.fieldNameFor(column);
- if (this.config.propertyAccessType()) {
- if (printIdAnnotation) {
- pw.printAnnotation(JPA.ID);
- pw.println();
- }
- if (column.matchesJavaFieldName(propertyName)) {
- this.printReadOnlyColumnAnnotationOn(pw); // no Column name needed
- } else {
- this.printReadOnlyColumnAnnotationOn(column.getName(), pw);
- }
- }
-
- pw.printGetterAndSetter(propertyName, column.getPrimaryKeyJavaTypeDeclaration(), this.config.methodVisibility());
- }
-
- private void printEntityWritablePrimaryKeyGettersAndSettersOn(EntitySourceWriter pw) {
- this.printWritablePrimaryKeyGettersAndSettersOn(pw, true); // true=print ID annotation on fields
- }
-
- private void printWritablePrimaryKeyGettersAndSettersOn(EntitySourceWriter pw, boolean printIdAnnotation) {
- for (Iterator<Column> stream = this.genTable.writablePrimaryKeyColumns(); stream.hasNext(); ) {
- this.printWritablePrimaryKeyGetterAndSetterOn(stream.next(), pw, printIdAnnotation);
- }
- }
-
- // TODO if the property's type is java.util.Date, it needs @Temporal(DATE)
- // TODO if the primary key is auto-generated, the property must be an integral type
- private void printWritablePrimaryKeyGetterAndSetterOn(Column column, EntitySourceWriter pw, boolean printIdAnnotation) {
- String propertyName = this.genTable.fieldNameFor(column);
- if (this.config.propertyAccessType()) {
- if (printIdAnnotation) {
- pw.printAnnotation(JPA.ID);
- pw.println();
- }
- if ( ! column.matchesJavaFieldName(propertyName)) {
- this.printColumnAnnotationOn(column.getName(), pw);
- }
- }
-
- pw.printGetterAndSetter(propertyName, column.getPrimaryKeyJavaTypeDeclaration(), this.config.methodVisibility());
- }
-
- private void printEntityNonPrimaryKeyBasicGettersAndSettersOn(EntitySourceWriter pw) {
- for (Iterator<Column> stream = this.genTable.nonPrimaryKeyBasicColumns(); stream.hasNext(); ) {
- this.printEntityNonPrimaryKeyBasicGetterAndSetterOn(stream.next(), pw);
- }
- }
-
- private void printEntityNonPrimaryKeyBasicGetterAndSetterOn(Column column, EntitySourceWriter pw) {
- String propertyName = this.genTable.fieldNameFor(column);
- if (this.config.propertyAccessType()) {
- if ( ! column.matchesJavaFieldName(propertyName)) {
- this.printColumnAnnotationOn(column.getName(), pw);
- }
- }
-
- pw.printGetterAndSetter(propertyName, column.getJavaTypeDeclaration(), this.config.methodVisibility());
- }
-
- private void printEntityManyToOneGettersAndSettersOn(EntitySourceWriter pw) {
- for (Iterator<ManyToOneRelation> stream = this.genTable.manyToOneRelations(); stream.hasNext(); ) {
- this.printEntityManyToOneGetterAndSetterOn(stream.next(), pw);
- }
- }
-
- private void printEntityManyToOneGetterAndSetterOn(ManyToOneRelation relation, EntitySourceWriter pw) {
- String propertyName = this.genTable.fieldNameFor(relation);
- if (this.config.propertyAccessType()) {
- this.printManyToOneAnnotationOn(propertyName, relation, pw);
- }
-
- String typeDeclaration = this.fullyQualify(relation.referencedEntityName());
- pw.printGetterAndSetter(propertyName, typeDeclaration, this.config.methodVisibility());
- }
-
- private void printEntityOneToManyGettersAndSettersOn(EntitySourceWriter pw) {
- for (Iterator<OneToManyRelation> stream = this.genTable.oneToManyRelations(); stream.hasNext(); ) {
- this.printEntityOneToManyGetterAndSetterOn(stream.next(), pw);
- }
- }
-
- private void printEntityOneToManyGetterAndSetterOn(OneToManyRelation relation, EntitySourceWriter pw) {
- String propertyName = this.genTable.fieldNameFor(relation);
- if (this.config.propertyAccessType()) {
- this.printOneToManyAnnotationOn(propertyName, relation, pw);
- }
-
- String elementTypeDeclaration = this.fullyQualify(relation.referencedEntityName());
- pw.printCollectionGetterAndSetter(propertyName, this.config.getCollectionTypeName(), elementTypeDeclaration, this.config.methodVisibility());
- }
-
- private void printEntityOwnedManyToManyGettersAndSettersOn(EntitySourceWriter pw) {
- for (Iterator<ManyToManyRelation> stream = this.genTable.ownedManyToManyRelations(); stream.hasNext(); ) {
- this.printEntityOwnedManyToManyGetterAndSetterOn(stream.next(), pw);
- }
- }
-
- private void printEntityOwnedManyToManyGetterAndSetterOn(ManyToManyRelation relation, EntitySourceWriter pw) {
- String propertyName = this.genTable.fieldNameFor(relation);
- if (this.config.propertyAccessType()) {
- this.printOwnedManyToManyAnnotationOn(propertyName, relation, pw);
- }
-
- String elementTypeDeclaration = this.fullyQualify(relation.nonOwningEntityName());
- pw.printCollectionGetterAndSetter(propertyName, this.config.getCollectionTypeName(), elementTypeDeclaration, this.config.methodVisibility());
- }
-
- private void printEntityNonOwnedManyToManyGettersAndSettersOn(EntitySourceWriter pw) {
- for (Iterator<ManyToManyRelation> stream = this.genTable.nonOwnedManyToManyRelations(); stream.hasNext(); ) {
- this.printEntityNonOwnedManyToManyGetterAndSetterOn(stream.next(), pw);
- }
- }
-
- private void printEntityNonOwnedManyToManyGetterAndSetterOn(ManyToManyRelation relation, EntitySourceWriter pw) {
- String propertyName = this.genTable.fieldNameFor(relation);
- if (this.config.propertyAccessType()) {
- this.printNonOwnedManyToManyAnnotationOn(propertyName, relation, pw);
- }
-
- String elementTypeDeclaration = this.fullyQualify(relation.owningEntityName());
- pw.printCollectionGetterAndSetter(propertyName, this.config.getCollectionTypeName(), elementTypeDeclaration, this.config.methodVisibility());
- }
-
- private void printPrimaryKeyClassOn(EntitySourceWriter pw) {
- if (this.config.generateEmbeddedIdForCompoundPK()) {
- pw.printAnnotation(JPA.EMBEDDABLE);
- pw.println();
- }
- pw.print("public class ");
- pw.printTypeDeclaration(this.pkClassName);
- pw.print(" implements ");
- pw.printTypeDeclaration(Serializable.class.getName());
- pw.print(" {");
- pw.println();
-
- pw.indent();
- if (this.config.generateEmbeddedIdForCompoundPK()) {
- this.printEmbeddableReadOnlyPrimaryKeyFieldsOn(pw);
- this.printEmbeddableWritablePrimaryKeyFieldsOn(pw);
- } else {
- this.printIdFieldsOn(pw);
- }
- this.printSerialVersionUID(pw);
- pw.println();
- this.printZeroArgumentConstructorOn(this.pkName(), "public", pw);
-
- if (this.config.propertyAccessType() || this.config.generateGettersAndSetters()) {
- if (this.config.generateEmbeddedIdForCompoundPK()) {
- this.printEmbeddableReadOnlyPrimaryKeyGettersAndSettersOn(pw);
- this.printEmbeddableWritablePrimaryKeyGettersAndSettersOn(pw);
- } else {
- this.printIdGettersAndSettersOn(pw);
- }
- }
-
- this.printPrimaryKeyEqualsMethodOn(this.pkName(), this.table().primaryKeyColumns(), pw);
- this.printPrimaryKeyHashCodeMethodOn(this.table().primaryKeyColumns(), pw);
- pw.undent();
-
- pw.print('}');
- pw.println();
- }
-
- private void printEmbeddableReadOnlyPrimaryKeyFieldsOn(EntitySourceWriter pw) {
- this.printReadOnlyPrimaryKeyFieldsOn(pw, false); // false=do not print ID annotation on fields
- }
-
- private void printEmbeddableWritablePrimaryKeyFieldsOn(EntitySourceWriter pw) {
- this.printWritablePrimaryKeyFieldsOn(pw, false); // false=do not print ID annotation on fields
- }
-
- private void printIdFieldsOn(EntitySourceWriter pw) {
- for (Iterator<Column> stream = this.table().primaryKeyColumns(); stream.hasNext(); ) {
- this.printIdFieldOn(stream.next(), pw);
- }
- }
-
- private void printIdFieldOn(Column column, EntitySourceWriter pw) {
- String fieldName = this.genTable.fieldNameFor(column);
- pw.printVisibility(this.config.fieldVisibility());
- pw.printTypeDeclaration(column.getPrimaryKeyJavaTypeDeclaration());
- pw.print(' ');
- pw.print(fieldName);
- pw.print(';');
- pw.println();
- }
-
- private void printEmbeddableReadOnlyPrimaryKeyGettersAndSettersOn(EntitySourceWriter pw) {
- this.printReadOnlyPrimaryKeyGettersAndSettersOn(pw, false); // false=do not print ID annotation on fields
- }
-
- private void printEmbeddableWritablePrimaryKeyGettersAndSettersOn(EntitySourceWriter pw) {
- this.printWritablePrimaryKeyGettersAndSettersOn(pw, false); // false=do not print ID annotation on fields
- }
-
- private void printIdGettersAndSettersOn(EntitySourceWriter pw) {
- for (Iterator<Column> stream = this.table().primaryKeyColumns(); stream.hasNext(); ) {
- this.printIdGetterAndSetterOn(stream.next(), pw);
- }
- }
-
- private void printIdGetterAndSetterOn(Column column, EntitySourceWriter pw) {
- String propertyName = this.genTable.fieldNameFor(column);
- pw.printGetterAndSetter(propertyName, column.getPrimaryKeyJavaTypeDeclaration(), this.config.methodVisibility());
- }
-
- private void printPrimaryKeyEqualsMethodOn(String className, Iterator<Column> columns, EntitySourceWriter pw) {
- pw.printAnnotation("java.lang.Override");
- pw.println();
-
- pw.println("public boolean equals(Object o) {");
- pw.indent();
- pw.println("if (o == this) {");
- pw.indent();
- pw.println("return true;");
- pw.undent();
- pw.print('}');
- pw.println();
-
- pw.print("if ( ! (o instanceof ");
- pw.print(className);
- pw.print(")) {");
- pw.println();
- pw.indent();
- pw.println("return false;");
- pw.undent();
- pw.print('}');
- pw.println();
-
- pw.print(className);
- pw.print(" other = (");
- pw.print(className);
- pw.print(") o;");
- pw.println();
-
- pw.print("return ");
- pw.indent();
- while (columns.hasNext()) {
- this.printPrimaryKeyEqualsClauseOn(columns.next(), pw);
- if (columns.hasNext()) {
- pw.println();
- pw.print("&& ");
- }
- }
- pw.print(';');
- pw.println();
- pw.undent();
- pw.undent();
- pw.print('}');
- pw.println();
- pw.println();
- }
-
- private void printPrimaryKeyEqualsClauseOn(Column column, EntitySourceWriter pw) {
- String fieldName = this.genTable.fieldNameFor(column);
- JavaType javaType = column.getPrimaryKeyJavaType();
- if (javaType.isPrimitive()) {
- this.printPrimitiveEqualsClauseOn(fieldName, pw);
- } else {
- this.printReferenceEqualsClauseOn(fieldName, pw);
- }
- }
-
- private void printPrimitiveEqualsClauseOn(String fieldName, EntitySourceWriter pw) {
- pw.print("(this.");
- pw.print(fieldName);
- pw.print(" == other.");
- pw.print(fieldName);
- pw.print(')');
- }
-
- private void printReferenceEqualsClauseOn(String fieldName, EntitySourceWriter pw) {
- pw.print("this.");
- pw.print(fieldName);
- pw.print(".equals(other.");
- pw.print(fieldName);
- pw.print(')');
- }
-
- private void printPrimaryKeyHashCodeMethodOn(Iterator<Column> columns, EntitySourceWriter pw) {
- pw.printAnnotation("java.lang.Override");
- pw.println();
-
- pw.println("public int hashCode() {");
- pw.indent();
- pw.println("final int prime = 31;");
- pw.println("int hash = 17;");
- while (columns.hasNext()) {
- pw.print("hash = hash * prime + ");
- this.printPrimaryKeyHashCodeClauseOn(columns.next(), pw);
- pw.print(';');
- pw.println();
- }
- pw.println("return hash;");
- pw.undent();
- pw.print('}');
- pw.println();
- pw.println();
- }
-
- private void printPrimaryKeyHashCodeClauseOn(Column column, EntitySourceWriter pw) {
- String fieldName = this.genTable.fieldNameFor(column);
- JavaType javaType = column.getPrimaryKeyJavaType();
- if (javaType.isPrimitive()) {
- this.printPrimitiveHashCodeClauseOn(javaType.getElementTypeName(), fieldName, pw);
- } else {
- this.printReferenceHashCodeClauseOn(fieldName, pw);
- }
- }
-
- private void printPrimitiveHashCodeClauseOn(String primitiveName, String fieldName, EntitySourceWriter pw) {
- if (primitiveName.equals("int")) {
- // this.value
- pw.print("this.");
- pw.print(fieldName);
- } else if (primitiveName.equals("short") || primitiveName.equals("byte") || primitiveName.equals("char")) { // explicit cast
- // ((int) this.value)
- pw.print("((int) this.");
- pw.print(fieldName);
- pw.print(')');
- } else if (primitiveName.equals("long")) { // cribbed from Long#hashCode()
- // ((int) (this.value ^ (this.value >>> 32)))
- pw.print("((int) (this.");
- pw.print(fieldName);
- pw.print(" ^ (this.");
- pw.print(fieldName);
- pw.print(" >>> 32)))");
- } else if (primitiveName.equals("float")) { // cribbed from Float#hashCode()
- // java.lang.Float.floatToIntBits(this.value)
- pw.printTypeDeclaration("java.lang.Float");
- pw.print(".floatToIntBits(this.");
- pw.print(fieldName);
- pw.print(')');
- } else if (primitiveName.equals("double")) { // cribbed from Double#hashCode()
- // ((int) (java.lang.Double.doubleToLongBits(this.value) ^ (java.lang.Double.doubleToLongBits(this.value) >>> 32)))
- pw.print("((int) (");
- pw.printTypeDeclaration("java.lang.Double");
- pw.print(".doubleToLongBits(this.");
- pw.print(fieldName);
- pw.print(") ^ (");
- pw.printTypeDeclaration("java.lang.Double");
- pw.print(".doubleToLongBits(this.");
- pw.print(fieldName);
- pw.print(") >>> 32)))");
- } else if (primitiveName.equals("boolean")) {
- // (this.value ? 1 : 0)
- pw.print("(this.");
- pw.print(fieldName);
- pw.print(" ? 1 : 0)");
- } else {
- throw new IllegalArgumentException(primitiveName);
- }
- }
-
- private void printReferenceHashCodeClauseOn(String fieldName, EntitySourceWriter pw) {
- pw.print("this.");
- pw.print(fieldName);
- pw.print(".hashCode()");
- }
-
- private void printPackageAndImportsOn(PrintWriter pw, BodySource bodySource) {
- if (this.packageName().length() != 0) {
- pw.print("package ");
- pw.print(this.packageName());
- pw.print(';');
- pw.println();
- pw.println();
- }
-
- for (Iterator<Map.Entry<String, String>> stream = bodySource.importEntries(); stream.hasNext(); ) {
- Map.Entry<String, String> entry = stream.next();
- pw.print("import ");
- pw.print(entry.getValue()); // package
- pw.print('.');
- pw.print(entry.getKey()); // short class name
- pw.print(';');
- pw.println();
- }
- pw.println();
- }
-
-
- // ********** convenience methods **********
-
- private String packageName() {
- return this.packageFragment.getElementName();
- }
-
- private Table table() {
- return this.genTable.getTable();
- }
-
- private String entityName() {
- return this.genTable.getEntityName();
- }
-
- private String pkName() {
- return this.entityName() + "PK"; // hack
- }
-
- private boolean pkClassIsGenerated() {
- return this.table().primaryKeyColumnsSize() > 1;
- }
-
-
- // ********** writer **********
-
- private interface BodySource {
-
- /**
- * return a sorted set of map entries; the key is the short class name,
- * the value is the package name
- */
- Iterator<Map.Entry<String, String>> importEntries();
-
- /**
- * return the body source code
- */
- String source();
-
- /**
- * return the length of the body source code
- */
- int length();
-
- }
-
- /**
- * Extend IndentingPrintWriter with some methods that facilitate building
- * class source code.
- */
- private static class EntitySourceWriter extends IndentingPrintWriter implements BodySource {
- final String packageName;
- final String className;
- // key = short class name; value = package name
- private final Map<String, String> imports = new HashMap<String, String>();
-
- EntitySourceWriter(String packageName, String className) {
- super(new StringWriter(20000));
- this.packageName = packageName;
- this.className = className;
- }
-
- void printVisibility(String visibilityModifier) {
- if (visibilityModifier.length() != 0) {
- this.print(visibilityModifier);
- this.print(' ');
- }
- }
-
- void printAnnotation(String annotationName) {
- this.print('@');
- this.printTypeDeclaration(annotationName);
- }
-
- void printTypeDeclaration(String typeDeclaration) {
- this.print(this.importedTypeDeclaration(typeDeclaration));
- }
-
- /**
- * Return the specified class's "imported" name.
- * The class declaration must be of the form:
- * "int"
- * "int[]" (not "[I")
- * "java.lang.Object"
- * "java.lang.Object[]" (not "[Ljava.lang.Object;")
- * "java.util.Map.Entry" (not "java.util.Map$Entry")
- * "java.util.Map.Entry[][]" (not "[[Ljava.util.Map$Entry;")
- */
- private String importedTypeDeclaration(String typeDeclaration) {
- if (this.typeDeclarationIsMemberClass(typeDeclaration)) {
- // no need for an import, just return the partially-qualified name
- return this.memberClassTypeDeclaration(typeDeclaration);
- }
- int last = typeDeclaration.lastIndexOf('.');
- String pkg = (last == -1) ? "" : typeDeclaration.substring(0, last);
- String shortTypeDeclaration = typeDeclaration.substring(last + 1);
- String shortElementTypeName = shortTypeDeclaration;
- while (shortElementTypeName.endsWith("[]")) {
- shortElementTypeName = shortElementTypeName.substring(0, shortElementTypeName.length() - 2);
- }
- String prev = this.imports.get(shortElementTypeName);
- if (prev == null) {
- // this is the first class with this short element type name
- this.imports.put(shortElementTypeName, pkg);
- return shortTypeDeclaration;
- }
- if (prev.equals(pkg)) {
- // this element type has already been imported
- return shortTypeDeclaration;
- }
- // another class with the same short element type name has been
- // previously imported, so this one must be used fully-qualified
- return typeDeclaration;
- }
-
- /**
- * e.g. "foo.bar.Employee.PK" will return true
- */
- private boolean typeDeclarationIsMemberClass(String typeDeclaration) {
- return (typeDeclaration.length() > this.className.length())
- && typeDeclaration.startsWith(this.className)
- && (typeDeclaration.charAt(this.className.length()) == '.');
- }
-
- /**
- * e.g. "foo.bar.Employee.PK" will return "Employee.PK"
- * this prevents collisions with other imported classes (e.g. "joo.jar.PK")
- */
- private String memberClassTypeDeclaration(String typeDeclaration) {
- int index = this.packageName.length();
- if (index != 0) {
- index++; // bump past the '.'
- }
- return typeDeclaration.substring(index);
- }
-
- public Iterator<Map.Entry<String, String>> importEntries() {
- return new FilteringIterator<Map.Entry<String, String>, Map.Entry<String, String>>(this.sortedImportEntries()) {
- @Override
- protected boolean accept(Map.Entry<String, String> next) {
- String pkg = next.getValue();
- if (pkg.equals("")
- || pkg.equals("java.lang")
- || pkg.equals(EntitySourceWriter.this.packageName)) {
- return false;
- }
- return true;
- }
- };
- }
-
- private Iterator<Map.Entry<String, String>> sortedImportEntries() {
- TreeSet<Map.Entry<String, String>> sortedImports = new TreeSet<Map.Entry<String, String>>(this.buildImportEntriesComparator());
- sortedImports.addAll(this.imports.entrySet());
- return sortedImports.iterator();
- }
-
- private Comparator<Map.Entry<String, String>> buildImportEntriesComparator() {
- return new Comparator<Map.Entry<String, String>>() {
- public int compare(Map.Entry<String, String> e1, Map.Entry<String, String> e2) {
- Collator collator = Collator.getInstance();
- int pkg = collator.compare(e1.getValue(), e2.getValue());
- return (pkg == 0) ? collator.compare(e1.getKey(), e2.getKey()) : pkg;
- }
- };
- }
-
- void printGetterAndSetter(String propertyName, String typeDeclaration, String visibility) {
- this.printGetter(propertyName, typeDeclaration, visibility);
- this.println();
- this.println();
-
- this.printSetter(propertyName, typeDeclaration, visibility);
- this.println();
- this.println();
- }
-
- private void printGetter(String propertyName, String typeDeclaration, String visibility) {
- this.printVisibility(visibility);
- this.printTypeDeclaration(typeDeclaration);
- this.print(' ');
- this.print(typeDeclaration.equals("boolean") ? "is" : "get");
- this.print(StringTools.capitalize(propertyName));
- this.print("() {");
- this.println();
-
- this.indent();
- this.print("return this.");
- this.print(propertyName);
- this.print(';');
- this.println();
- this.undent();
-
- this.print('}');
- }
-
- private void printSetter(String propertyName, String typeDeclaration, String visibility) {
- this.printVisibility(visibility);
- this.print("void set");
- this.print(StringTools.capitalize(propertyName));
- this.print('(');
- this.printTypeDeclaration(typeDeclaration);
- this.print(' ');
- this.print(propertyName);
- this.print(") {");
- this.println();
-
- this.indent();
- this.print("this.");
- this.print(propertyName);
- this.print(" = ");
- this.print(propertyName);
- this.print(';');
- this.println();
- this.undent();
-
- this.print('}');
- }
-
- void printCollectionGetterAndSetter(String propertyName, String collectionTypeDeclaration, String elementTypeDeclaration, String visibility) {
- this.printCollectionGetter(propertyName, collectionTypeDeclaration, elementTypeDeclaration, visibility);
- this.println();
- this.println();
-
- this.printCollectionSetter(propertyName, collectionTypeDeclaration, elementTypeDeclaration, visibility);
- this.println();
- this.println();
- }
-
- private void printCollectionGetter(String propertyName, String collectionTypeDeclaration, String elementTypeDeclaration, String visibility) {
- this.printVisibility(visibility);
- this.printTypeDeclaration(collectionTypeDeclaration);
- this.print('<');
- this.printTypeDeclaration(elementTypeDeclaration);
- this.print("> get");
- this.print(StringTools.capitalize(propertyName));
- this.print("() {");
- this.println();
-
- this.indent();
- this.print("return this.");
- this.print(propertyName);
- this.print(';');
- this.println();
- this.undent();
-
- this.print('}');
- }
-
- private void printCollectionSetter(String propertyName, String collectionTypeDeclaration, String elementTypeDeclaration, String visibility) {
- this.printVisibility(visibility);
- this.print("void set");
- this.print(StringTools.capitalize(propertyName));
- this.print('(');
- this.printTypeDeclaration(collectionTypeDeclaration);
- this.print('<');
- this.printTypeDeclaration(elementTypeDeclaration);
- this.print('>');
- this.print(' ');
- this.print(propertyName);
- this.print(") {");
- this.println();
-
- this.indent();
- this.print("this.");
- this.print(propertyName);
- this.print(" = ");
- this.print(propertyName);
- this.print(';');
- this.println();
- this.undent();
-
- this.print('}');
- }
-
- public String source() {
- return this.out.toString();
- }
-
- public int length() {
- return ((StringWriter) this.out).getBuffer().length();
- }
-
- }
-
-
- // ********** config **********
-
- public static class Config {
- private boolean convertToCamelCase = true;
- private boolean propertyAccessType = false; // as opposed to "field"
- private String collectionTypeName = Set.class.getName();
- private int fieldVisibility = Modifier.PRIVATE;
- private int methodVisibility = Modifier.PUBLIC;
- private boolean generateGettersAndSetters = true;
- private boolean generateDefaultConstructor = true;
- private boolean serializable = true;
- private boolean generateSerialVersionUID = true;
- private boolean generateEmbeddedIdForCompoundPK = true; // as opposed to IdClass
- private Map<Table, String> overrideEntityNames = new HashMap<Table, String>();
-
- public static final int PRIVATE = 0;
- public static final int PACKAGE = 1;
- public static final int PROTECTED = 2;
- public static final int PUBLIC = 3;
-
-
- public boolean convertToCamelCase() {
- return this.convertToCamelCase;
- }
- public void setConvertToCamelCase(boolean convertToCamelCase) {
- this.convertToCamelCase = convertToCamelCase;
- }
-
- public boolean propertyAccessType() {
- return this.propertyAccessType;
- }
- public void setPropertyAccessType(boolean propertyAccessType) {
- this.propertyAccessType = propertyAccessType;
- }
-
- public boolean fieldAccessType() {
- return ! this.propertyAccessType;
- }
- public void setFieldAccessType(boolean fieldAccessType) {
- this.propertyAccessType = ! fieldAccessType;
- }
-
- public String getCollectionTypeName() {
- return this.collectionTypeName;
- }
- public void setCollectionTypeName(String collectionTypeName) {
- this.collectionTypeName = collectionTypeName;
- }
-
- public int getFieldVisibility() {
- return this.fieldVisibility;
- }
- /** entity fields cannot be 'public' */
- public void setFieldVisibility(int fieldVisibility) {
- switch (fieldVisibility) {
- case PRIVATE:
- case PACKAGE:
- case PROTECTED:
- this.fieldVisibility = fieldVisibility;
- break;
- default:
- throw new IllegalArgumentException("invalid field visibility: " + fieldVisibility);
- }
- }
- String fieldVisibility() {
- switch (this.fieldVisibility) {
- case PRIVATE:
- return "private";
- case PACKAGE:
- return "";
- case PROTECTED:
- return "protected";
- default:
- throw new IllegalStateException("invalid field visibility: " + this.fieldVisibility);
- }
- }
-
- public int getMethodVisibility() {
- return this.methodVisibility;
- }
- /** entity properties must be 'public' or 'protected' */
- public void setMethodVisibility(int methodVisibility) {
- switch (methodVisibility) {
- case PROTECTED:
- case PUBLIC:
- this.methodVisibility = methodVisibility;
- break;
- default:
- throw new IllegalArgumentException("invalid method visibility: " + methodVisibility);
- }
- }
- String methodVisibility() {
- switch (this.methodVisibility) {
- case PROTECTED:
- return "protected";
- case PUBLIC:
- return "public";
- default:
- throw new IllegalStateException("invalid method visibility: " + this.methodVisibility);
- }
- }
-
- public boolean generateGettersAndSetters() {
- return this.generateGettersAndSetters;
- }
- public void setGenerateGettersAndSetters(boolean generateGettersAndSetters) {
- this.generateGettersAndSetters = generateGettersAndSetters;
- }
-
- public boolean generateDefaultConstructor() {
- return this.generateDefaultConstructor;
- }
- public void setGenerateDefaultConstructor(boolean generateDefaultConstructor) {
- this.generateDefaultConstructor = generateDefaultConstructor;
- }
-
- public boolean serializable() {
- return this.serializable;
- }
- public void setSerializable(boolean serializable) {
- this.serializable = serializable;
- }
-
- public boolean generateSerialVersionUID() {
- return this.generateSerialVersionUID;
- }
- public void setGenerateSerialVersionUID(boolean generateSerialVersionUID) {
- this.generateSerialVersionUID = generateSerialVersionUID;
- }
-
- public boolean generateEmbeddedIdForCompoundPK() {
- return this.generateEmbeddedIdForCompoundPK;
- }
- public void setGenerateEmbeddedIdForCompoundPK(boolean generateEmbeddedIdForCompoundPK) {
- this.generateEmbeddedIdForCompoundPK = generateEmbeddedIdForCompoundPK;
- }
-
- public boolean generateIdClassForCompoundPK() {
- return ! this.generateEmbeddedIdForCompoundPK;
- }
- public void setGenerateIdClassForCompoundPK(boolean generateIdClassForCompoundPK) {
- this.generateEmbeddedIdForCompoundPK = ! generateIdClassForCompoundPK;
- }
-
- /**
- * key = table
- * value = user-supplied override entity name
- */
- public String getOverrideEntityName(Table table) {
- return this.overrideEntityNames.get(table);
- }
- public void setOverrideEntityName(Table table, String overrideEntityName) {
- this.overrideEntityNames.put(table, overrideEntityName);
- }
- public void clearOverrideEntityNames() {
- this.overrideEntityNames.clear();
- }
- public void setOverrideEntityNames(Map<Table, String> overrideEntityNames) {
- this.clearOverrideEntityNames();
- for (Map.Entry<Table, String> entry : overrideEntityNames.entrySet()) {
- this.setOverrideEntityName(entry.getKey(), entry.getValue());
- }
- }
-
- }
-
-
- // ********** config **********
-
- public static interface OverwriteConfirmer {
- /**
- * Return whether the entity generator should overwrite the specified
- * file.
- */
- boolean overwrite(String className);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenScope.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenScope.java
deleted file mode 100644
index a0bb794687..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenScope.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.gen.internal;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-
-class GenScope {
- private final Map<Table, GenTable> genTables = new HashMap<Table, GenTable>();
-
- private IProgressMonitor progressMonitor;
-
- // ********** construction/initialization **********
-
- GenScope(Collection<Table> tables, EntityGenerator.Config entityConfig, IProgressMonitor progressMonitor) {
- super();
- this.initialize(tables, entityConfig, progressMonitor);
- }
-
- private void checkCanceled() {
- if (this.progressMonitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- }
-
- private void initialize(Collection<Table> tables, EntityGenerator.Config entityConfig, IProgressMonitor monitor) {
- this.progressMonitor = monitor;
- this.buildGenTables(tables, entityConfig);
- checkCanceled();
- this.configureManyToManyRelations();
- checkCanceled();
- this.configureManyToOneRelations();
- checkCanceled();
- this.configureFieldNames();
- checkCanceled();
- }
-
- private void buildGenTables(Collection<Table> tables, EntityGenerator.Config entityConfig) {
- int size = tables.size();
- // pass around a growing list of the entity names so we can avoid duplicates
- Set<String> entityNames = new HashSet<String>(size);
- for (Table table : tables) {
- this.buildGenTable(table, entityConfig, entityNames);
- this.progressMonitor.worked(40/size);
- }
- }
-
- private void buildGenTable(Table table, EntityGenerator.Config entityConfig, Collection<String> entityNames) {
- this.genTables.put(table, new GenTable(this, table, entityConfig, entityNames));
- }
-
- /**
- * find all the "join" tables
- */
- private void configureManyToManyRelations() {
- int tablesSize = CollectionTools.size(this.tables());
-
- //first time takes the longest, should we take that into account?
- for (Iterator<GenTable> stream = this.tables(); stream.hasNext(); ) {
- checkCanceled();
- stream.next().configureManyToManyRelations();
- this.progressMonitor.worked(730/tablesSize);
- }
- // revert any "join" table that is referenced by another table back to an "entity" table
- Set<GenTable> referencedTables = this.buildReferencedTables();
- tablesSize = CollectionTools.size(this.joinTables());
- for (Iterator<GenTable> stream = this.joinTables(); stream.hasNext(); ) {
- GenTable joinGenTable = stream.next();
- if (referencedTables.contains(joinGenTable)) {
- joinGenTable.clearJoinTableRelation();
- }
- this.progressMonitor.worked(40/tablesSize);
- }
- }
-
- /**
- * find all the many-to-one and one-to-many relations
- */
- private void configureManyToOneRelations() {
- int tablesSize = CollectionTools.size(this.entityTables());
- for (Iterator<GenTable> stream = this.entityTables(); stream.hasNext(); ) {
- stream.next().configureManyToOneRelations();
- this.progressMonitor.worked(50/tablesSize);
- }
- }
-
- /**
- * determine all the Java field names up-front because we will
- * need them for things like 'mappedBy' annotation elements
- */
- private void configureFieldNames() {
- int tablesSize = CollectionTools.size(this.entityTables());
- for (Iterator<GenTable> stream = this.entityTables(); stream.hasNext(); ) {
- stream.next().configureFieldNames();
- this.progressMonitor.worked(50/tablesSize);
- }
- }
-
-
- // ********** package API **********
-
- /**
- * return only the gen tables that are suitable for generating
- * entities (i.e. exclude the "join" tables)
- */
- Iterator<GenTable> entityTables() {
- return new FilteringIterator<GenTable, GenTable>(this.tables()) {
- @Override
- protected boolean accept(GenTable next) {
- return ! next.isJoinTable();
- }
- };
- }
-
- int numEntityTables() {
- return CollectionTools.size(entityTables());
- }
-
- /**
- * return the gen table corresponding to the specified table
- */
- GenTable genTable(Table table) {
- return this.genTables.get(table);
- }
-
-
- // ********** internal API **********
-
- private Iterator<GenTable> tables() {
- return this.genTables.values().iterator();
- }
-
- /**
- * return only the "join" gen tables
- */
- private Iterator<GenTable> joinTables() {
- return new FilteringIterator<GenTable, GenTable>(this.tables()) {
- @Override
- protected boolean accept(GenTable next) {
- return next.isJoinTable();
- }
- };
- }
-
- /**
- * build a set of the tables that are referenced by other tables
- * in the scope
- */
- private Set<GenTable> buildReferencedTables() {
- int size = CollectionTools.size(this.tables());
- Set<GenTable> referencedTables = new HashSet<GenTable>(this.genTables.size());
- for (Iterator<GenTable> stream = this.tables(); stream.hasNext(); ) {
- stream.next().addReferencedTablesTo(referencedTables);
- this.progressMonitor.worked(20/size);
- }
- return referencedTables;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenTable.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenTable.java
deleted file mode 100644
index 395a51b94e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenTable.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.gen.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jpt.db.Column;
-import org.eclipse.jpt.db.ForeignKey;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.NameTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-
-/**
- * associate a table with the various relations that will be used when
- * generating the entity
- */
-class GenTable {
- private final GenScope scope;
- private final Table table;
- private final EntityGenerator.Config entityConfig;
- private final String entityName;
- private ManyToManyRelation joinTableRelation;
- private Collection<ManyToManyRelation> ownedManyToManyRelations = new ArrayList<ManyToManyRelation>();
- private Collection<ManyToManyRelation> nonOwnedManyToManyRelations = new ArrayList<ManyToManyRelation>();
- private Collection<ManyToOneRelation> manyToOneRelations = new ArrayList<ManyToOneRelation>();
- private Collection<OneToManyRelation> oneToManyRelations = new ArrayList<OneToManyRelation>();
- private Set<Column> foreignKeyColumns = new HashSet<Column>();
-
- // key=column/relation; value=name
- private final Map<Object, String> fieldNames = new HashMap<Object, String>();
-
- private static final Object EMBEDDED_ID_VIRTUAL_COLUMN = new Object();
-
-
- // ********** construction/initialization **********
-
- GenTable(GenScope scope, Table table, EntityGenerator.Config entityConfig, Collection<String> entityNames) {
- super();
- this.scope = scope;
- this.table = table;
- this.entityConfig = entityConfig;
- this.entityName = this.buildEntityName(entityNames);
- }
-
- private String buildEntityName(Collection<String> entityNames) {
- String name = this.table.getShortJavaClassName();
- String overrideEntityName = this.entityConfig.getOverrideEntityName(this.table);
- if (overrideEntityName == null) {
- if (this.entityConfig.convertToCamelCase()) {
- // camel-casing can convert a name back to a reserved word (e.g. "package_" -> "package")
- name = NameTools.convertToJavaIdentifier(StringTools.convertUnderscoresToCamelCase(name));
- }
- } else {
- name = overrideEntityName;
- }
- name = NameTools.uniqueNameForIgnoreCase(name, entityNames);
- entityNames.add(name);
- return name;
- }
-
-
- // ********** package API **********
-
- /**
- * determine whether the table is a "join" table within the table's scope
- */
- void configureManyToManyRelations() {
- if (this.table.foreignKeysSize() != 2) {
- // the table must have exactly 2 foreign keys
- return;
- }
- for (Iterator<Column> stream = this.table.columns(); stream.hasNext(); ) {
- if ( ! this.table.foreignKeyBaseColumnsContains(stream.next())) {
- // all the table's columns must belong to one (or both) of the 2 foreign keys
- return;
- }
- }
- Iterator<ForeignKey> fKeys = this.table.foreignKeys();
- ForeignKey owningFK = fKeys.next();
- ForeignKey nonOwningFK = fKeys.next();
- GenTable owningTable = this.scope.genTable(owningFK.getReferencedTable());
- GenTable nonOwningTable = this.scope.genTable(nonOwningFK.getReferencedTable());
- if ((owningTable == null) || (nonOwningTable == null)) {
- // both tables must be in the scope
- return;
- }
- this.joinTableRelation = new ManyToManyRelation(this, owningFK, owningTable, nonOwningFK, nonOwningTable);
- }
-
- void addReferencedTablesTo(Set<GenTable> referencedTables) {
- for (Iterator<ForeignKey> stream = this.table.foreignKeys(); stream.hasNext(); ) {
- ForeignKey fk = stream.next();
- GenTable genTable = this.scope.genTable(fk.getReferencedTable());
- if (genTable != null) {
- referencedTables.add(genTable);
- }
- }
- }
-
- void clearJoinTableRelation() {
- this.joinTableRelation.clear();
- this.joinTableRelation = null;
- }
-
- /**
- * find "in-scope" foreign keys
- */
- void configureManyToOneRelations() {
- for (Iterator<ForeignKey> stream = this.table.foreignKeys(); stream.hasNext(); ) {
- ForeignKey fk = stream.next();
- GenTable referencedtable = this.scope.genTable(fk.getReferencedTable());
- if (referencedtable == null) {
- continue; // skip to next FK
- }
- this.manyToOneRelations.add(new ManyToOneRelation(this, fk, referencedtable));
- }
- }
-
- /**
- * now that all the relations are in place, we can configure the Java
- * field names
- */
- void configureFieldNames() {
- Set<Column> columns = CollectionTools.set(this.table.columns());
- if ((this.table.primaryKeyColumnsSize() > 1) && this.entityConfig.generateEmbeddedIdForCompoundPK()) {
- // if we are going to generate an EmbeddedId field, add it to
- // 'fieldNames' so we don't collide with it later, when generating
- // field names for the columns etc.
- this.configureFieldName(EMBEDDED_ID_VIRTUAL_COLUMN, "pk");
- }
- this.configureManyToOneFieldNames(columns);
- this.configureBasicFieldNames(columns);
- this.configureOneToManyFieldNames();
- this.configureOwnedManyToManyFieldNames();
- this.configureNonOwnedManyToManyFieldNames();
- }
-
- /**
- * return the columns that are part of the table's primary key
- * but are also part of an "in-scope" foreign key
- */
- Iterator<Column> readOnlyPrimaryKeyColumns() {
- return new FilteringIterator<Column, Column>(this.table.primaryKeyColumns()) {
- @Override
- protected boolean accept(Column column) {
- return GenTable.this.foreignKeyColumnsContains(column);
- }
- };
- }
-
- /**
- * return the columns that are part of the table's primary key
- * but are NOT part of any "in-scope" foreign key
- */
- Iterator<Column> writablePrimaryKeyColumns() {
- return new FilteringIterator<Column, Column>(this.table.primaryKeyColumns()) {
- @Override
- protected boolean accept(Column column) {
- return ! GenTable.this.foreignKeyColumnsContains(column);
- }
- };
- }
-
- /**
- * return the columns that NEITHER part of the table's primary key
- * NOR part of any foreign key
- */
- Iterator<Column> nonPrimaryKeyBasicColumns() {
- return new FilteringIterator<Column, Column>(this.table.columns()) {
- @Override
- protected boolean accept(Column column) {
- return ! (GenTable.this.primaryKeyColumnsContains(column)
- || GenTable.this.foreignKeyColumnsContains(column));
- }
- };
- }
-
- Table getTable() {
- return this.table;
- }
-
- String getEntityName() {
- return this.entityName;
- }
-
- boolean isJoinTable() {
- return this.joinTableRelation != null;
- }
-
- void addOwnedManyToManyRelation(ManyToManyRelation relation) {
- this.ownedManyToManyRelations.add(relation);
- }
-
- void removeOwnedManyToManyRelation(ManyToManyRelation relation) {
- this.ownedManyToManyRelations.remove(relation);
- }
-
- void addNonOwnedManyToManyRelation(ManyToManyRelation relation) {
- this.nonOwnedManyToManyRelations.add(relation);
- }
-
- void removeNonOwnedManyToManyRelation(ManyToManyRelation relation) {
- this.nonOwnedManyToManyRelations.remove(relation);
- }
-
- void addOneToManyRelation(OneToManyRelation relation) {
- this.oneToManyRelations.add(relation);
- }
-
- String javaFieldName() {
- return this.table.getJavaFieldName();
- }
-
- Iterator<ManyToOneRelation> manyToOneRelations() {
- return this.manyToOneRelations.iterator();
- }
-
- Iterator<OneToManyRelation> oneToManyRelations() {
- return this.oneToManyRelations.iterator();
- }
-
- Iterator<ManyToManyRelation> ownedManyToManyRelations() {
- return this.ownedManyToManyRelations.iterator();
- }
-
- Iterator<ManyToManyRelation> nonOwnedManyToManyRelations() {
- return this.nonOwnedManyToManyRelations.iterator();
- }
-
- /**
- * the key can be a column or relation
- */
- private String fieldNameForInternal(Object o) {
- return this.fieldNames.get(o);
- }
-
- /**
- * this will return null if we don't want an embedded id field
- */
- String fieldNameForEmbeddedId() {
- return this.fieldNameForInternal(EMBEDDED_ID_VIRTUAL_COLUMN);
- }
-
- String fieldNameFor(Column column) {
- return this.fieldNameForInternal(column);
- }
-
- String fieldNameFor(ManyToOneRelation relation) {
- return this.fieldNameForInternal(relation);
- }
-
- String fieldNameFor(OneToManyRelation relation) {
- return this.fieldNameForInternal(relation);
- }
-
- String fieldNameFor(ManyToManyRelation relation) {
- return this.fieldNameForInternal(relation);
- }
-
- String name() {
- return this.table.getName();
- }
-
-
- // ********** internal API **********
-
- /**
- * while we are figuring out the names for the m:1 fields, remove from the
- * specified set of columns the columns that are only part of the foreign keys
- */
- private void configureManyToOneFieldNames(Set<Column> columns) {
- for (ManyToOneRelation relation : this.manyToOneRelations) {
- CollectionTools.removeAll(columns, relation.getForeignKey().nonPrimaryKeyBaseColumns());
- CollectionTools.addAll(this.foreignKeyColumns, relation.getForeignKey().baseColumns());
- relation.setMappedBy(this.configureFieldName(relation, relation.javaFieldName()));
- }
- }
-
- private String configureFieldName(Object o, String fieldName) {
- fieldName = this.camelCaseFieldName(fieldName);
- fieldName = NameTools.uniqueNameFor(fieldName, this.fieldNames.values());
- this.fieldNames.put(o, fieldName);
- return fieldName;
- }
-
- private String camelCaseFieldName(String name) {
- return this.entityConfig.convertToCamelCase() ?
- // camel-casing can convert a name back to a reserved word (e.g. "package_" -> "package")
- NameTools.convertToJavaIdentifier(StringTools.convertUnderscoresToCamelCase(name, false)) // false = don't capitalize first letter
- :
- name;
- }
-
- /**
- * build a unique field name for the specified "basic" columns,
- * checking for name collisions
- */
- private void configureBasicFieldNames(Set<Column> columns) {
- for (Column column : columns) {
- this.configureFieldName(column, column.getJavaFieldName());
- }
- }
-
- private void configureOneToManyFieldNames() {
- for (OneToManyRelation relation : this.oneToManyRelations) {
- this.configureFieldName(relation, relation.javaFieldName());
- }
- }
-
- private void configureOwnedManyToManyFieldNames() {
- for (ManyToManyRelation relation : this.ownedManyToManyRelations) {
- relation.setMappedBy(this.configureFieldName(relation, relation.javaFieldNameFor(this)));
- }
- }
-
- private void configureNonOwnedManyToManyFieldNames() {
- for (ManyToManyRelation relation : this.nonOwnedManyToManyRelations) {
- this.configureFieldName(relation, relation.javaFieldNameFor(this));
- }
- }
-
- boolean foreignKeyColumnsContains(Column column) {
- return this.foreignKeyColumns.contains(column);
- }
-
- boolean primaryKeyColumnsContains(Column column) {
- return this.table.primaryKeyColumnsContains(column);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToManyRelation.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToManyRelation.java
deleted file mode 100644
index 5d6c236756..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToManyRelation.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.gen.internal;
-
-import org.eclipse.jpt.db.ForeignKey;
-
-/**
- * This object is shared by the two gen tables that make up the relation.
- * Upon construction, 'mappedBy' will be 'null'. The first gen table to be
- * used to generate an entity will fill in 'mappedBy' with the appropriate
- * field/property name.
- */
-class ManyToManyRelation {
- private final GenTable joinTable;
- private final ForeignKey owningForeignKey;
- private final GenTable owningTable;
- private final ForeignKey nonOwningForeignKey;
- private final GenTable nonOwningTable;
- private String mappedBy;
-
-
- ManyToManyRelation(GenTable joinTable, ForeignKey owningForeignKey, GenTable owningTable, ForeignKey nonOwningForeignKey, GenTable nonOwningTable) {
- super();
- this.joinTable = joinTable;
-
- this.owningForeignKey = owningForeignKey;
- this.owningTable = owningTable;
- owningTable.addOwnedManyToManyRelation(this);
-
- this.nonOwningForeignKey = nonOwningForeignKey;
- this.nonOwningTable = nonOwningTable;
- nonOwningTable.addNonOwnedManyToManyRelation(this);
- }
-
- GenTable getJoinTable() {
- return this.joinTable;
- }
-
- ForeignKey getOwningForeignKey() {
- return this.owningForeignKey;
- }
-
- GenTable getOwningTable() {
- return this.owningTable;
- }
-
- ForeignKey getNonOwningForeignKey() {
- return this.nonOwningForeignKey;
- }
-
- GenTable getNonOwningTable() {
- return this.nonOwningTable;
- }
-
- private GenTable otherTable(GenTable table) {
- return (table == this.owningTable) ? this.nonOwningTable : this.owningTable;
- }
-
- String javaFieldNameFor(GenTable table) {
- // TODO i18n?
- return this.otherTable(table).javaFieldName() + "_collection";
- }
-
- void clear() {
- this.owningTable.removeOwnedManyToManyRelation(this);
- this.nonOwningTable.removeNonOwnedManyToManyRelation(this);
- }
-
- String getMappedBy() {
- return this.mappedBy;
- }
-
- void setMappedBy(String mappedBy) {
- this.mappedBy = mappedBy;
- }
-
- String owningEntityName() {
- return this.owningTable.getEntityName();
- }
-
- String nonOwningEntityName() {
- return this.nonOwningTable.getEntityName();
- }
-
- boolean joinTableNameIsDefault() {
- return this.joinTable.name().equals(this.getOwningTable().name() + "_" + this.getNonOwningTable().name());
- }
-
- boolean joinColumnsIsDefaultFor(String javaFieldName) {
- return this.owningForeignKey.isDefaultFor(javaFieldName);
- }
-
- boolean inverseJoinColumnsIsDefaultFor(String javaFieldName) {
- return this.nonOwningForeignKey.isDefaultFor(javaFieldName);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToOneRelation.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToOneRelation.java
deleted file mode 100644
index c512f44a04..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToOneRelation.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.gen.internal;
-
-import org.eclipse.jpt.db.ForeignKey;
-
-class ManyToOneRelation {
- private final GenTable baseTable; // the "many" side
- private final ForeignKey foreignKey;
- private final GenTable referencedTable; // the "one" side
- private String mappedBy;
-
-
- ManyToOneRelation(GenTable baseTable, ForeignKey foreignKey, GenTable referencedTable) {
- super();
- this.baseTable = baseTable;
- this.foreignKey = foreignKey;
- this.referencedTable = referencedTable;
- referencedTable.addOneToManyRelation(new OneToManyRelation(this));
- }
-
- GenTable getBaseTable() {
- return this.baseTable;
- }
-
- ForeignKey getForeignKey() {
- return this.foreignKey;
- }
-
- GenTable getReferencedTable() {
- return this.referencedTable;
- }
-
- String javaFieldName() {
- return this.foreignKey.getJavaFieldName();
- }
-
- String getMappedBy() {
- return this.mappedBy;
- }
-
- void setMappedBy(String mappedBy) {
- this.mappedBy = mappedBy;
- }
-
- String baseEntityName() {
- return this.baseTable.getEntityName();
- }
-
- String referencedEntityName() {
- return this.referencedTable.getEntityName();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/OneToManyRelation.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/OneToManyRelation.java
deleted file mode 100644
index 4656d00c12..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/OneToManyRelation.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.gen.internal;
-
-class OneToManyRelation {
- private final ManyToOneRelation manyToOneRelation;
-
- OneToManyRelation(ManyToOneRelation manyToOneRelation) {
- super();
- this.manyToOneRelation = manyToOneRelation;
- }
-
- ManyToOneRelation getManyToOneRelation() {
- return this.manyToOneRelation;
- }
-
- String javaFieldName() {
- // TODO i18n?
- return this.manyToOneRelation.getBaseTable().javaFieldName() + "_collection";
- }
-
- String mappedBy() {
- return this.manyToOneRelation.getMappedBy();
- }
-
- String referencedEntityName() {
- return this.manyToOneRelation.baseEntityName();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java
deleted file mode 100644
index 2025a0cf8d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.gen.internal;
-
-import java.util.Collection;
-import java.util.Iterator;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.gen.internal.EntityGenerator.OverwriteConfirmer;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-/**
- * This generator will generate a package of entities for a set of tables.
- */
-public class PackageGenerator {
- private final Config config;
- private final EntityGenerator.Config entityConfig;
- private final GenScope scope;
- private final OverwriteConfirmer overwriteConfirmer;
- private final IProgressMonitor monitor;
-
-
- // ********** public API **********
-
- public static void generateEntities(Config config, EntityGenerator.Config entityConfig, Collection<Table> tables, OverwriteConfirmer overwriteConfirmer, IProgressMonitor monitor) {
- if ((config == null) || (entityConfig == null) || (tables == null)) {
- throw new NullPointerException();
- }
- new PackageGenerator(config, entityConfig, tables, overwriteConfirmer, monitor).generateEntities();
- }
-
-
- // ********** construction/initialization **********
-
- private PackageGenerator(Config config, EntityGenerator.Config entityConfig, Collection<Table> tables, OverwriteConfirmer overwriteConfirmer, IProgressMonitor monitor) {
- super();
- this.config = config;
- this.entityConfig = entityConfig;
- this.scope = new GenScope(tables, entityConfig, monitor);
- this.overwriteConfirmer = overwriteConfirmer;
- this.monitor = monitor;
- }
-
-
- // ********** generation **********
-
- private void generateEntities() {
- int size = CollectionTools.size(this.scope.entityTables());
- for (Iterator<GenTable> stream = this.scope.entityTables(); stream.hasNext(); ) {
- checkCanceled();
- this.buildEntity(stream.next());
- this.monitor.worked(50/size);
- }
- }
-
- private void checkCanceled() {
- if (this.monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- }
-
-
- private void buildEntity(GenTable genTable) {
- EntityGenerator.generateEntity(this.entityConfig, this.config.getPackageFragment(), genTable, overwriteConfirmer, this.monitor);
- }
-
-
- // ********** config **********
-
- public static class Config {
- private IPackageFragment packageFragment;
-
- public IPackageFragment getPackageFragment() {
- return this.packageFragment;
- }
- public void setPackageFragment(IPackageFragment packageFragment) {
- this.packageFragment = packageFragment;
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/.classpath b/jpa/plugins/org.eclipse.jpt.utility/.classpath
deleted file mode 100644
index 304e86186a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/plugins/org.eclipse.jpt.utility/.cvsignore b/jpa/plugins/org.eclipse.jpt.utility/.cvsignore
deleted file mode 100644
index a128605b1f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/.cvsignore
+++ /dev/null
@@ -1,4 +0,0 @@
-bin
-@dot
-temp.folder
-build.xml \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.utility/.project b/jpa/plugins/org.eclipse.jpt.utility/.project
deleted file mode 100644
index 99b389b9c5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.utility</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.core.resources.prefs b/jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 8e5b2c2b65..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tue Jan 15 11:12:22 EST 2008
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.jdt.core.prefs b/jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 443826069d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Sun May 27 14:55:37 EDT 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF
deleted file mode 100644
index 8622f2de95..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,67 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.utility
-Bundle-Version: 1.2.0.qualifier
-Bundle-Localization: plugin
-Export-Package: org.eclipse.jpt.utility,
- org.eclipse.jpt.utility.internal;
- x-friends:="org.eclipse.jpt.core,
- org.eclipse.jpt.db,
- org.eclipse.jpt.db.ui,
- org.eclipse.jpt.gen,
- org.eclipse.jpt.ui",
- org.eclipse.jpt.utility.internal.iterators;
- x-friends:="org.eclipse.jpt.core,
- org.eclipse.jpt.db,
- org.eclipse.jpt.db.ui,
- org.eclipse.jpt.gen,
- org.eclipse.jpt.ui",
- org.eclipse.jpt.utility.internal.model;
- x-friends:="org.eclipse.jpt.core,
- org.eclipse.jpt.db,
- org.eclipse.jpt.db.ui,
- org.eclipse.jpt.gen,
- org.eclipse.jpt.ui",
- org.eclipse.jpt.utility.internal.model.listener.awt;
- x-friends:="org.eclipse.jpt.core,
- org.eclipse.jpt.db,
- org.eclipse.jpt.db.ui,
- org.eclipse.jpt.gen,
- org.eclipse.jpt.ui",
- org.eclipse.jpt.utility.internal.model.value;
- x-friends:="org.eclipse.jpt.core,
- org.eclipse.jpt.db,
- org.eclipse.jpt.db.ui,
- org.eclipse.jpt.gen,
- org.eclipse.jpt.ui",
- org.eclipse.jpt.utility.internal.model.value.prefs;
- x-friends:="org.eclipse.jpt.core,
- org.eclipse.jpt.db,
- org.eclipse.jpt.db.ui,
- org.eclipse.jpt.gen,
- org.eclipse.jpt.ui",
- org.eclipse.jpt.utility.internal.model.value.swing;
- x-friends:="org.eclipse.jpt.core,
- org.eclipse.jpt.db,
- org.eclipse.jpt.db.ui,
- org.eclipse.jpt.gen,
- org.eclipse.jpt.ui",
- org.eclipse.jpt.utility.internal.node;
- x-friends:="org.eclipse.jpt.core,
- org.eclipse.jpt.db,
- org.eclipse.jpt.db.ui,
- org.eclipse.jpt.gen,
- org.eclipse.jpt.ui",
- org.eclipse.jpt.utility.internal.swing;
- x-friends:="org.eclipse.jpt.core,
- org.eclipse.jpt.db,
- org.eclipse.jpt.db.ui,
- org.eclipse.jpt.gen,
- org.eclipse.jpt.ui",
- org.eclipse.jpt.utility.model,
- org.eclipse.jpt.utility.model.event,
- org.eclipse.jpt.utility.model.listener,
- org.eclipse.jpt.utility.model.value
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/jpa/plugins/org.eclipse.jpt.utility/about.html b/jpa/plugins/org.eclipse.jpt.utility/about.html
deleted file mode 100644
index 9e73bdabb6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>June 06, 2007</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/jpa/plugins/org.eclipse.jpt.utility/build.properties b/jpa/plugins/org.eclipse.jpt.utility/build.properties
deleted file mode 100644
index 11ab8d42f6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-################################################################################
-# Copyright (c) 2006, 2007 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-javacSource=1.5
-javacTarget=1.5
-source.. = src/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- about.html,\
- plugin.properties
diff --git a/jpa/plugins/org.eclipse.jpt.utility/component.xml b/jpa/plugins/org.eclipse.jpt.utility/component.xml
deleted file mode 100644
index b210b281dd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/component.xml
+++ /dev/null
@@ -1 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.jpt.utility"><description url=""></description><component-depends unrestricted="true"></component-depends><plugin id="org.eclipse.jpt.utility" fragment="false"/></component> \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.utility/plugin.properties b/jpa/plugins/org.eclipse.jpt.utility/plugin.properties
deleted file mode 100644
index 95c029d5d8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/plugin.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-################################################################################
-# Copyright (c) 2006, 2007 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName = Java Persistence API Tools - Utility
-providerName = Eclipse.org
-
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/Command.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/Command.java
deleted file mode 100644
index ffabf124af..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/Command.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility;
-
-/**
- * Simple interface for implementing the GOF Command design pattern.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface Command {
-
- /**
- * Execute the command. The semantics of the command
- * is determined by the contract between the client and server.
- */
- void execute();
-
- final class Null implements Command {
- public static final Command INSTANCE = new Null();
- public static Command instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void execute() {
- // do nothing
- }
- @Override
- public String toString() {
- return "Command.Null";
- }
- }
-
- final class Disabled implements Command {
- public static final Command INSTANCE = new Disabled();
- public static Command instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public void execute() {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return "Command.Disabled";
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/CommandExecutor.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/CommandExecutor.java
deleted file mode 100644
index f58dbf6674..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/CommandExecutor.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility;
-
-/**
- * This interface allows clients to control how a command is executed
- * (e.g. dispatching the command to the UI thread).
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface CommandExecutor {
-
- /**
- * Execute the specified command.
- */
- void execute(Command command);
-
-
- /**
- * Straightforward implementation of the command executor interface
- * that simply executes the command without any sort of enhancement.
- */
- final class Default implements CommandExecutor {
- public static final CommandExecutor INSTANCE = new Default();
- public static CommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- public void execute(Command command) {
- command.execute();
- }
- @Override
- public String toString() {
- return "CommandExecutor.Default";
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/CommandExecutorProvider.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/CommandExecutorProvider.java
deleted file mode 100644
index 03b62531e4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/CommandExecutorProvider.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility;
-
-/**
- * Yet another level of indirection to allow clients to control
- * how a command is executed by the server
- * (e.g. dispatching the command to the UI thread).
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface CommandExecutorProvider {
-
- /**
- * Return the appropriate command executor.
- */
- CommandExecutor getCommandExecutor();
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/Filter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/Filter.java
deleted file mode 100644
index b88c7f9a29..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/Filter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility;
-
-/**
- * Used by various "pluggable" classes to filter objects.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface Filter<T> {
-
- /**
- * Return whether the specified object is "accepted" by the
- * filter. The semantics of "accept" is determined by the
- * contract between the client and the server.
- */
- boolean accept(T o);
-
-
- final class Null<S> implements Filter<S> {
- @SuppressWarnings("unchecked")
- public static final Filter INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R> Filter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // nothing is filtered - everything is accepted
- public boolean accept(S next) {
- return true;
- }
- @Override
- public String toString() {
- return "Filter.Null";
- }
- }
-
- final class Disabled<S> implements Filter<S> {
- @SuppressWarnings("unchecked")
- public static final Filter INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> Filter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public boolean accept(S next) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return "Filter.Disabled";
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/JavaType.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/JavaType.java
deleted file mode 100644
index 9347dbdf39..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/JavaType.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility;
-
-import java.io.PrintWriter;
-
-/**
- * This interface describes a Java type; i.e. its "element type"
- * and its "array depth". The element type is referenced by name,
- * allowing us to reference classes that are not (or cannot be) loaded.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface JavaType
- extends Comparable<JavaType>
-{
-
- /**
- * Return the name of the type's "element type".
- * A member type will have one or more '$' characters in its name.
- */
- String getElementTypeName();
-
- /**
- * Return the type's "array depth".
- */
- int getArrayDepth();
-
- boolean isArray();
-
- /**
- * NB: void.class.isPrimitive() == true
- */
- boolean isPrimitive();
-
- /**
- * NB: void.class.isPrimitive() == true
- */
- boolean isPrimitiveWrapper();
-
- /**
- * NB: variables cannot be declared 'void'
- */
- boolean isVariablePrimitive();
-
- /**
- * NB: variables cannot be declared 'void'
- */
- boolean isVariablePrimitiveWrapper();
-
- /**
- * Return the class corresponding to the type's element type and array depth.
- */
- Class<?> getJavaClass() throws ClassNotFoundException;
-
- /**
- * Return the version of the type's name that matches that
- * returned by java.lang.Class#getName()
- * (e.g. "[[J", "[Ljava.lang.Object;", "java.util.Map$Entry").
- */
- String getJavaClassName();
-
- boolean equals(String otherElementTypeName, int otherArrayDepth);
-
- boolean describes(String className);
-
- boolean describes(Class<?> javaClass);
-
- boolean equals(JavaType other);
-
- /**
- * Return the version of the type's name that can be used in source code:
- * "[[J" => "long[][]"
- * "java.util.Map$Entry" => "java.util.Map.Entry"
- */
- String declaration();
-
- /**
- * Append the version of the type's name that can be used in source code:
- * "[[J" => "long[][]"
- * "java.util.Map$Entry" => "java.util.Map.Entry"
- */
- void appendDeclarationTo(StringBuilder sb);
-
- /**
- * Print the version of the type's name that can be used in source code:
- * "[[J" => "long[][]"
- * "java.util.Map$Entry" => "java.util.Map.Entry"
- */
- void printDeclarationOn(PrintWriter pw);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/AbstractAssociation.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/AbstractAssociation.java
deleted file mode 100644
index 8ffa61d1d2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/AbstractAssociation.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-/**
- * Implement some of the methods in Association that can
- * be defined in terms of the other methods.
- */
-public abstract class AbstractAssociation<K, V>
- implements Association<K, V>
-{
-
- /**
- * Default constructor.
- */
- protected AbstractAssociation() {
- super();
- }
-
- @Override
- public synchronized boolean equals(Object o) {
- if ( ! (o instanceof Association)) {
- return false;
- }
- Association<?, ?> other = (Association<?, ?>) o;
- return (this.key() == null ?
- other.key() == null : this.key().equals(other.key()))
- && (this.value() == null ?
- other.value() == null : this.value().equals(other.value()));
- }
-
- @Override
- public synchronized int hashCode() {
- return (this.key() == null ? 0 : this.key().hashCode())
- ^ (this.value() == null ? 0 : this.value().hashCode());
- }
-
- @Override
- public synchronized String toString() {
- return this.key() + " => " + this.value();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Association.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Association.java
deleted file mode 100644
index 03130e89be..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Association.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-/**
- * Straightforward definition of an object pairing.
- * The key is immutable.
- */
-public interface Association<K, V> {
-
- /**
- * Return the association's key.
- */
- K key();
-
- /**
- * Return the association's value.
- */
- V value();
-
- /**
- * Set the association's value.
- * Return the previous value.
- */
- V setValue(V value);
-
- /**
- * Return true if both the associations' keys and values
- * are equal.
- */
- boolean equals(Object o);
-
- /**
- * Return a hash code based on the association's
- * key and value.
- */
- int hashCode();
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Bag.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Bag.java
deleted file mode 100644
index 75905c81d4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Bag.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-import java.util.AbstractCollection;
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-
-/**
- * A collection that allows duplicate elements.
- * <p>
- * The <code>Bag</code> interface places additional stipulations,
- * beyond those inherited from the <code>java.util.Collection</code> interface,
- * on the contracts of the <code>equals</code> and <code>hashCode</code> methods.
- *
- * @see HashBag
- */
-
-public interface Bag<E> extends java.util.Collection<E> {
-
- /**
- * Compares the specified object with this bag for equality. Returns
- * <code>true</code> if the specified object is also a bag, the two bags
- * have the same size, and every member of the specified bag is
- * contained in this bag with the same number of occurrences (or equivalently,
- * every member of this bag is contained in the specified bag with the same
- * number of occurrences). This definition ensures that the
- * equals method works properly across different implementations of the
- * bag interface.
- */
- boolean equals(Object o);
-
- /**
- * Returns the hash code value for this bag. The hash code of a bag is
- * defined to be the sum of the hash codes of the elements in the bag,
- * where the hashcode of a <code>null</code> element is defined to be zero.
- * This ensures that <code>b1.equals(b2)</code> implies that
- * <code>b1.hashCode() == b2.hashCode()</code> for any two bags
- * <code>b1</code> and <code>b2</code>, as required by the general
- * contract of the <code>Object.hashCode</code> method.
- */
- int hashCode();
-
- /**
- * Return the number of times the specified object occurs in the bag.
- */
- int count(Object o);
-
- /**
- * Add the specified object the specified number of times to the bag.
- */
- boolean add(E o, int count);
-
- /**
- * Remove the specified number of occurrences of the specified object
- * from the bag. Return whether the bag changed.
- */
- boolean remove(Object o, int count);
-
- /**
- * Return an iterator that returns each item in the bag
- * once and only once, irrespective of how many times
- * the item was added to the bag.
- */
- java.util.Iterator<E> uniqueIterator();
-
-
- final class Empty<E> extends AbstractCollection<E> implements Bag<E>, Serializable {
- @SuppressWarnings("unchecked")
- public static final Bag INSTANCE = new Empty();
- @SuppressWarnings("unchecked")
- public static <T> Bag<T> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Empty() {
- super();
- }
- @Override
- public Iterator<E> iterator() {
- return EmptyIterator.instance();
- }
- @Override
- public int size() {
- return 0;
- }
- public Iterator<E> uniqueIterator() {
- return EmptyIterator.instance();
- }
- public int count(Object o) {
- return 0;
- }
- public boolean remove(Object o, int count) {
- return false;
- }
- public boolean add(E o, int count) {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if ( ! (o instanceof Bag)) {
- return false;
- }
- return ((Bag<?>) o).size() == 0;
- }
- @Override
- public int hashCode() {
- return 0;
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- return INSTANCE;
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BidiFilter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BidiFilter.java
deleted file mode 100644
index d102f9e267..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BidiFilter.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import org.eclipse.jpt.utility.Filter;
-
-/**
- * Used by various "pluggable" classes to filter objects
- * in both directions.
- *
- * If anyone can come up with a better class name
- * and/or method name, I would love to hear it. ~bjv
- */
-public interface BidiFilter<T> extends Filter<T> {
-
- /**
- * Return whether the specified object is "accepted" by the
- * "reverse" filter. What that means is determined by the client.
- */
- boolean reverseAccept(T o);
-
-
- final class Null<S> implements BidiFilter<S> {
- @SuppressWarnings("unchecked")
- public static final BidiFilter INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R> BidiFilter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // nothing is filtered - everything is accepted
- public boolean accept(S next) {
- return true;
- }
- // nothing is "reverse-filtered" - everything is accepted
- public boolean reverseAccept(S o) {
- return true;
- }
- @Override
- public String toString() {
- return "BidiFilter.Null";
- }
- }
-
- final class Disabled<S> implements BidiFilter<S> {
- @SuppressWarnings("unchecked")
- public static final BidiFilter INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> BidiFilter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public boolean accept(S next) {
- throw new UnsupportedOperationException();
- }
- // throw an exception
- public boolean reverseAccept(S o) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return "BidiFilter.Disabled";
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BidiStringConverter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BidiStringConverter.java
deleted file mode 100644
index fcd8f4a311..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BidiStringConverter.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-/**
- * Used by various "pluggable" classes to transform objects
- * into strings and vice versa.
- *
- * If anyone can come up with a better class name
- * and/or method name, I would love to hear it. ~bjv
- */
-public interface BidiStringConverter<T> extends StringConverter<T> {
-
- /**
- * Convert the specified string into an object.
- * The semantics of "convert to object" is determined by the
- * contract between the client and the server.
- * Typically, if the string is null, null is returned.
- */
- T convertToObject(String s);
-
-
- final class Default<S> implements BidiStringConverter<S> {
- @SuppressWarnings("unchecked")
- public static final BidiStringConverter INSTANCE = new Default();
- @SuppressWarnings("unchecked")
- public static <R> BidiStringConverter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- // simply return the object's #toString() result
- public String convertToString(S o) {
- return (o == null) ? null : o.toString();
- }
- // simply return the string
- @SuppressWarnings("unchecked")
- public S convertToObject(String s) {
- return (S) s;
- }
- @Override
- public String toString() {
- return "BidiStringConverter.Default";
- }
- }
-
- final class Disabled<S> implements BidiStringConverter<S> {
- @SuppressWarnings("unchecked")
- public static final BidiStringConverter INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> BidiStringConverter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public String convertToString(S o) {
- throw new UnsupportedOperationException();
- }
- // throw an exception
- public S convertToObject(String s) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return "BidiStringConverter.Disabled";
- }
- }
-
- final class BooleanConverter implements BidiStringConverter<Boolean> {
- public static final BidiStringConverter<Boolean> INSTANCE = new BooleanConverter();
- public static BidiStringConverter<Boolean> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private BooleanConverter() {
- super();
- }
- /** Return "true" if the Boolean is true, otherwise return "false". */
- public String convertToString(Boolean b) {
- return (b == null) ? null : b.toString();
- }
- /** Return Boolean.TRUE if the string is "true" (case-insensitive), otherwise return Boolean.FALSE. */
- public Boolean convertToObject(String s) {
- return (s == null) ? null : Boolean.valueOf(s);
- }
- @Override
- public String toString() {
- return "BidiStringConverter.BooleanConverter";
- }
- }
-
- final class IntegerConverter implements BidiStringConverter<Integer> {
- public static final BidiStringConverter<Integer> INSTANCE = new IntegerConverter();
- public static BidiStringConverter<Integer> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private IntegerConverter() {
- super();
- }
- /** Integer's #toString() works well. */
- public String convertToString(Integer integer) {
- return (integer == null) ? null : integer.toString();
- }
- /** Convert the string to an Integer, if possible. */
- public Integer convertToObject(String s) {
- return (s == null) ? null : Integer.valueOf(s);
- }
- @Override
- public String toString() {
- return "BidiStringConverter.IntegerConverter";
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BidiTransformer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BidiTransformer.java
deleted file mode 100644
index 5f6d3d221b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BidiTransformer.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-/**
- * Used by various "pluggable" classes to transform objects
- * in both directions.
- *
- * If anyone can come up with a better class name
- * and/or method name, I would love to hear it. ~bjv
- */
-public interface BidiTransformer<T1, T2> extends Transformer<T1, T2> {
-
- /**
- * Return the "reverse-transformed" object.
- * The semantics of "reverse-transform" is determined by the
- * contract between the client and the server.
- */
- T1 reverseTransform(T2 o);
-
-
- final class Null<S1, S2> implements BidiTransformer<S1, S2> {
- @SuppressWarnings("unchecked")
- public static final BidiTransformer INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R1, R2> BidiTransformer<R1, R2> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // simply return the object, unchanged
- @SuppressWarnings("unchecked")
- public S2 transform(S1 o) {
- return (S2) o;
- }
- // simply return the object, unchanged
- @SuppressWarnings("unchecked")
- public S1 reverseTransform(S2 o) {
- return (S1) o;
- }
- @Override
- public String toString() {
- return "BidiTransformer.Null";
- }
- }
-
- final class Disabled<S1, S2> implements BidiTransformer<S1, S2> {
- @SuppressWarnings("unchecked")
- public static final BidiTransformer INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R1, R2> BidiTransformer<R1, R2> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public S2 transform(S1 o) {
- throw new UnsupportedOperationException();
- }
- // throw an exception
- public S1 reverseTransform(S2 o) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return "BidiTransformer.Disabled";
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BitTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BitTools.java
deleted file mode 100644
index 544f5bba82..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BitTools.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-/**
- * Assorted bit tools
- */
-public class BitTools {
-
- /**
- * Return whether the specified 'flags' has the specified
- * 'flagToCheck' set.
- */
- public static boolean flagIsSet(int flags, int flagToCheck) {
- return allFlagsAreSet(flags, flagToCheck);
- }
-
- /**
- * Return whether the specified 'flags' has the specified
- * 'flagToCheck' turned off.
- */
- public static boolean flagIsOff(int flags, int flagToCheck) {
- return allFlagsAreOff(flags, flagToCheck);
- }
-
- /**
- * Return whether the specified 'flags' has ONLY the specified
- * 'flagToCheck' set.
- */
- public static boolean onlyFlagIsSet(int flags, int flagToCheck) {
- return onlyFlagsAreSet(flags, flagToCheck);
- }
-
- /**
- * Return whether the specified 'flags' has ONLY the specified
- * 'flagToCheck' turned off.
- */
- public static boolean onlyFlagIsOff(int flags, int flagToCheck) {
- return onlyFlagsAreOff(flags, flagToCheck);
- }
-
- /**
- * Return whether the specified 'flags' has all the specified
- * 'flagsToCheck' set.
- */
- public static boolean allFlagsAreSet(int flags, int flagsToCheck) {
- return (flags & flagsToCheck) == flagsToCheck;
- }
-
- /**
- * Return whether the specified 'flags' has all the specified
- * 'flagsToCheck' turned off.
- */
- public static boolean allFlagsAreOff(int flags, int flagsToCheck) {
- return (flags & flagsToCheck) == 0;
- }
-
- /**
- * Return whether the specified 'flags' has ONLY the specified
- * 'flagsToCheck' set.
- */
- public static boolean onlyFlagsAreSet(int flags, int flagsToCheck) {
- return allFlagsAreSet(flags, flagsToCheck) && allFlagsAreOff(flags, ~flagsToCheck);
- }
-
- /**
- * Return whether the specified 'flags' has ONLY the specified
- * 'flagsToCheck' turned off.
- */
- public static boolean onlyFlagsAreOff(int flags, int flagsToCheck) {
- return allFlagsAreOff(flags, flagsToCheck) && allFlagsAreSet(flags, ~flagsToCheck);
- }
-
- /**
- * Return whether the specified 'flags' has any one of the specified
- * 'flagsToCheck' set.
- */
- public static boolean anyFlagsAreSet(int flags, int flagsToCheck) {
- return (flags & flagsToCheck) != 0;
- }
-
- /**
- * Return whether the specified 'flags' has any one of the specified
- * 'flagsToCheck' turned off.
- */
- public static boolean anyFlagsAreOff(int flags, int flagsToCheck) {
- return (flags & flagsToCheck) != flagsToCheck;
- }
-
- /**
- * Return whether the specified 'flags' has all the specified
- * 'flagsToCheck' set.
- */
- public static boolean allFlagsAreSet(int flags, int[] flagsToCheck) {
- for (int i = flagsToCheck.length; i-- > 0; ) {
- if ( ! allFlagsAreSet(flags, flagsToCheck[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified 'flags' has all the specified
- * 'flagsToCheck' turned off.
- */
- public static boolean allFlagsAreOff(int flags, int[] flagsToCheck) {
- for (int i = flagsToCheck.length; i-- > 0; ) {
- if ( ! allFlagsAreOff(flags, flagsToCheck[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified 'flags' has ONLY the specified
- * 'flagsToCheck' set.
- */
- public static boolean onlyFlagsAreSet(int flags, int[] flagsToCheck) {
- int combinedFlags = orFlags(flagsToCheck);
- return allFlagsAreSet(flags, combinedFlags) && allFlagsAreOff(flags, ~combinedFlags);
- }
-
- /**
- * Return whether the specified 'flags' has ONLY the specified
- * 'flagsToCheck' turned off.
- */
- public static boolean onlyFlagsAreOff(int flags, int[] flagsToCheck) {
- int combinedFlags = orFlags(flagsToCheck);
- return allFlagsAreOff(flags, combinedFlags) && allFlagsAreSet(flags, ~combinedFlags);
- }
-
- /**
- * Return whether the specified 'flags' has any one of the specified
- * 'flagsToCheck' set.
- */
- public static boolean anyFlagsAreSet(int flags, int[] flagsToCheck) {
- for (int i = flagsToCheck.length; i-- > 0; ) {
- if (anyFlagsAreSet(flags, flagsToCheck[i])) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified 'flags' has any one of the specified
- * 'flagsToCheck' turned off.
- */
- public static boolean anyFlagsAreOff(int flags, int[] flagsToCheck) {
- for (int i = flagsToCheck.length; i-- > 0; ) {
- if (anyFlagsAreOff(flags, flagsToCheck[i])) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * OR all the specified 'flags' together and return the result.
- */
- public static int orFlags(int[] flags) {
- int last = flags.length - 1;
- int result = flags[last];
- for (int i = last; i-- > 0; ) {
- result |= flags[i];
- }
- return result;
- }
-
- /**
- * AND all the specified 'flags' together and return the result.
- */
- public static int andFlags(int[] flags) {
- int last = flags.length - 1;
- int result = flags[last];
- for (int i = last; i-- > 0; ) {
- result &= flags[i];
- }
- return result;
- }
-
- /**
- * XOR all the specified 'flags' together and return the result.
- */
- public static int xorFlags(int[] flags) {
- int last = flags.length - 1;
- int result = flags[last];
- for (int i = last; i-- > 0; ) {
- result ^= flags[i];
- }
- return result;
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private BitTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassTools.java
deleted file mode 100644
index c2b7c55f88..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassTools.java
+++ /dev/null
@@ -1,1678 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collections;
-import java.util.Stack;
-
-/**
- * Convenience methods related to the java.lang.reflect package.
- * These methods provide shortcuts for manipulating objects via
- * reflection; particularly when dealing with fields and/or methods that
- * are not publicly accessible or are inherited.
- *
- * In most cases, all the exceptions are handled and
- * wrapped in java.lang.RuntimeExceptions; so these methods should
- * be used when you are confident that you will not having any problems
- * using reflection.
- *
- * There are also a number of methods whose names
- * begin with "attempt". These methods will throw a NoSuchMethodException
- * or NoSuchFieldException when appropriate, allowing you to probe
- * for methods that should be present but might not.
- */
-public final class ClassTools {
-
- public static final Class<?>[] ZERO_PARAMETER_TYPES = new Class[0];
- public static final Object[] ZERO_PARAMETERS = new Object[0];
- private static final String CR = StringTools.CR;
-
- public static final char NESTED_CLASS_NAME_SEPARATOR = '$';
-
- public static final char ARRAY_INDICATOR = '[';
- public static final char TYPE_DECLARATION_ARRAY_OPEN = '[';
- public static final char TYPE_DECLARATION_ARRAY_CLOSE = ']';
-
- public static final char REFERENCE_CLASS_CODE = 'L';
- public static final char REFERENCE_CLASS_NAME_DELIMITER = ';';
-
- private static Primitive[] PRIMITIVES; // pseudo-'final' - lazy-initialized
- public static final char BYTE_CODE = 'B';
- public static final char CHAR_CODE = 'C';
- public static final char DOUBLE_CODE = 'D';
- public static final char FLOAT_CODE = 'F';
- public static final char INT_CODE = 'I';
- public static final char LONG_CODE = 'J';
- public static final char SHORT_CODE = 'S';
- public static final char BOOLEAN_CODE = 'Z';
- public static final char VOID_CODE = 'V';
- private static int MAX_PRIMITIVE_CLASS_NAME_LENGTH = -1; // pseudo-'final' - lazy-initialized
- private static int MAX_PRIMITIVE_WRAPPER_CLASS_NAME_LENGTH = -1; // pseudo-'final' - lazy-initialized
-
- public static final String VOID_CLASS_NAME = void.class.getName();
- public static final String VOID_WRAPPER_CLASS_NAME = java.lang.Void.class.getName();
-
-
- /**
- * Return all the fields for the
- * specified class, including inherited fields.
- * Class#allFields()
- */
- public static Field[] allFields(Class<?> javaClass) {
- Stack<Field> stack = new Stack<Field>();
- for (Class<?> tempClass = javaClass; tempClass != null; tempClass = tempClass.getSuperclass()) {
- pushDeclaredFields(tempClass, stack);
- }
- Collections.reverse(stack);
- return stack.toArray(new Field[stack.size()]);
- }
-
- /**
- * Return all the methods for the
- * specified class, including inherited methods.
- * Class#allMethods()
- */
- public static Method[] allMethods(Class<?> javaClass) {
- Stack<Method> stack = new Stack<Method>();
- for (Class<?> tempClass = javaClass; tempClass != null; tempClass = tempClass.getSuperclass()) {
- pushDeclaredMethods(tempClass, stack);
- }
- Collections.reverse(stack);
- return stack.toArray(new Method[stack.size()]);
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * using the class's default (zero-argument) constructor.
- * Throw an exception if the default constructor is not defined.
- * Class#newInstance() throws NoSuchMethodException
- */
- public static <T> T attemptNewInstance(Class<T> javaClass) throws NoSuchMethodException {
- return attemptNewInstance(javaClass, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter types and parameters.
- * Throw an exception if the constructor is not defined.
- * Class#newInstance(Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException
- */
- public static <T> T attemptNewInstance(Class<T> javaClass, Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException {
- try {
- return constructor(javaClass, parameterTypes).newInstance(parameters);
- } catch (InstantiationException ie) {
- throw new RuntimeException(ie + CR + fullyQualifiedConstructorSignature(javaClass, parameterTypes), ie);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + fullyQualifiedConstructorSignature(javaClass, parameterTypes), iae);
- } catch (InvocationTargetException ite) {
- throw new RuntimeException(fullyQualifiedConstructorSignature(javaClass, parameterTypes) + CR + ite.getTargetException(), ite);
- }
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * given the constructor parameter type and parameter.
- * Throw an exception if the constructor is not defined.
- * Class#newInstance(Class<?> parameterType, Object parameter) throws NoSuchMethodException
- */
- public static <T> T attemptNewInstance(Class<T> javaClass, Class<?> parameterType, Object parameter) throws NoSuchMethodException {
- return attemptNewInstance(javaClass, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Attempt to get a field value, given the containing object and field name.
- * Return its result.
- * Useful for accessing private, package, or protected fields.
- * Throw an exception if the field is not defined.
- * Object#getFieldValue(String fieldName) throws NoSuchFieldException
- */
- public static Object attemptToGetFieldValue(Object object, String fieldName) throws NoSuchFieldException {
- try {
- return field(object, fieldName).get(object);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + fullyQualifiedFieldName(object, fieldName), iae);
- }
- }
-
- /**
- * Attempt to get a static field value, given the containing object and field name.
- * Return its result.
- * Useful for accessing private, package, or protected fields.
- * Throw an exception if the field is not defined.
- * Class#getStaticFieldValue(String fieldName) throws NoSuchFieldException
- */
- public static Object attemptToGetStaticFieldValue(Class<?> javaClass, String fieldName) throws NoSuchFieldException {
- try {
- return field(javaClass, fieldName).get(null);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + fullyQualifiedFieldName(javaClass, fieldName), iae);
- }
- }
-
- /**
- * Convenience method.
- * Attempt to execute a zero-argument method,
- * given the receiver and method name.
- * Return its result.
- * Throw an exception if the method is not found.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName) throws NoSuchMethodException
- */
- public static Object attemptToExecuteMethod(Object receiver, String methodName) throws NoSuchMethodException {
- return attemptToExecuteMethod(receiver, methodName, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Convenience method.
- * Attempt to execute a method, given the receiver,
- * method name, parameter type, and parameter.
- * Return its result.
- * Throw an exception if the method is not found.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?> parameterType, Object parameter) throws NoSuchMethodException
- */
- public static Object attemptToExecuteMethod(Object receiver, String methodName, Class<?> parameterType, Object parameter) throws NoSuchMethodException {
- return attemptToExecuteMethod(receiver, methodName, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Attempt to execute a method, given the receiver,
- * method name, parameter types, and parameters.
- * Return its result.
- * Throw an exception if the method is not found.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException
- */
- public static Object attemptToExecuteMethod(Object receiver, String methodName, Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException {
- return executeMethod(method(receiver, methodName, parameterTypes), receiver, parameters);
- }
-
- /**
- * Attempt to execute a method, given the receiver,
- * method name, parameter types, and parameters.
- * Return its result.
- * Throw an exception if the method is not found.
- * If the executed method throws an exception, rethrow that exception.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException
- */
- public static Object attemptToExecuteMethodWithException(Object receiver, String methodName, Class<?>[] parameterTypes, Object[] parameters)
- throws Throwable, NoSuchMethodException
- {
- return executeMethodWithException(method(receiver, methodName, parameterTypes), receiver, parameters);
- }
-
- /**
- * Convenience method.
- * Attempt to execute a zero-argument static method,
- * given the class and method name.
- * Return its result.
- * Throw an exception if the method is not found.
- * Useful for invoking private, package, or protected methods.
- * Class#executeStaticMethod(String methodName) throws NoSuchMethodException
- */
- public static Object attemptToExecuteStaticMethod(Class<?> javaClass, String methodName) throws NoSuchMethodException {
- return attemptToExecuteStaticMethod(javaClass, methodName, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Attempt to execute a static method, given the class,
- * method name, parameter types, and parameters.
- * Return its result.
- * Throw an exception if the method is not found.
- * Useful for invoking private, package, or protected methods.
- * Class#executeStaticMethod(String methodName, Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException
- */
- public static Object attemptToExecuteStaticMethod(Class<?> javaClass, String methodName, Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException {
- return executeStaticMethod(staticMethod(javaClass, methodName, parameterTypes), parameters);
- }
-
- /**
- * Convenience method.
- * Attempt to execute a static method, given the class,
- * method name, parameter type, and parameter.
- * Return its result.
- * Throw an exception if the method is not found.
- * Useful for invoking private, package, or protected methods.
- * Class#executeStaticMethod(String methodName, Class<?> parameterType, Object parameter) throws NoSuchMethodException
- */
- public static Object attemptToExecuteStaticMethod(Class<?> javaClass, String methodName, Class<?> parameterType, Object parameter) throws NoSuchMethodException {
- return attemptToExecuteStaticMethod(javaClass, methodName, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Attempt to set a field value, given the
- * containing object, field name, and new field value.
- * Useful for accessing private, package, or protected fields.
- * Throw an exception if the field is not defined.
- * Object#setFieldValue(String fieldName, Object fieldValue) throws NoSuchFieldException
- */
- public static void attemptToSetFieldValue(Object object, String fieldName, Object fieldValue) throws NoSuchFieldException {
- try {
- field(object, fieldName).set(object, fieldValue);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + fullyQualifiedFieldName(object, fieldName), iae);
- }
- }
-
- /**
- * Attempt to set a static field value, given the
- * containing class, field name, and new field value.
- * Useful for accessing private, package, or protected fields.
- * Throw an exception if the field is not defined.
- * Class#setStaticFieldValue(String fieldName, Object fieldValue) throws NoSuchFieldException
- */
- public static void attemptToSetStaticFieldValue(Class<?> javaClass, String fieldName, Object fieldValue) throws NoSuchFieldException {
- try {
- field(javaClass, fieldName).set(null, fieldValue);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + fullyQualifiedFieldName(javaClass, fieldName), iae);
- }
- }
-
- /**
- * Convenience method.
- * Return the default (zero-argument) constructor
- * for the specified class.
- * Set accessible to true, so we can access
- * private/package/protected constructors.
- * Class#constructor() throws NoSuchMethodException
- */
- public static <T> Constructor<T> constructor(Class<T> javaClass) throws NoSuchMethodException {
- return constructor(javaClass, ZERO_PARAMETER_TYPES);
- }
-
- /**
- * Return the constructor for the specified class
- * and formal parameter types.
- * Set accessible to true, so we can access
- * private/package/protected constructors.
- * Class#constructor(Class<?>[] parameterTypes) throws NoSuchMethodException
- */
- public static <T> Constructor<T> constructor(Class<T> javaClass, Class<?>[] parameterTypes) throws NoSuchMethodException {
- Constructor<T> constructor = javaClass.getDeclaredConstructor(parameterTypes);
- constructor.setAccessible(true);
- return constructor;
- }
-
- /**
- * Convenience method.
- * Return the constructor for the specified class
- * and formal parameter type.
- * Set accessible to true, so we can access
- * private/package/protected constructors.
- * Class#constructor(Class<?> parameterType) throws NoSuchMethodException
- */
- public static <T> Constructor<T> constructor(Class<T> javaClass, Class<?> parameterType) throws NoSuchMethodException {
- return constructor(javaClass, new Class[] {parameterType});
- }
-
- /**
- * Return the declared fields for the specified class.
- * Set accessible to true, so we can access
- * private/package/protected fields.
- * Class#accessibleDeclaredFields()
- */
- public static Field[] declaredFields(Class<?> javaClass) {
- Field[] fields = javaClass.getDeclaredFields();
- for (Field field : fields) {
- field.setAccessible(true);
- }
- return fields;
- }
-
- /**
- * Return the declared methods for the
- * specified class.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- * Class#accessibleDeclaredMethods()
- */
- public static Method[] declaredMethods(Class<?> javaClass) {
- Method[] methods = javaClass.getDeclaredMethods();
- for (Method method : methods) {
- method.setAccessible(true);
- }
- return methods;
- }
-
- /**
- * Return the default (zero-argument) constructor
- * for the specified class.
- * Set accessible to true, so we can access
- * private/package/protected constructors.
- * Class#defaultConstructor()
- */
- public static <T> Constructor<T> defaultConstructor(Class<T> javaClass) throws NoSuchMethodException {
- return constructor(javaClass);
- }
-
- /**
- * Return a field for the specified class and field name.
- * If the class does not directly
- * define the field, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected fields.
- */
- public static Field field(Class<?> javaClass, String fieldName) throws NoSuchFieldException {
- Field field = null;
- try {
- field = javaClass.getDeclaredField(fieldName);
- } catch (NoSuchFieldException ex) {
- Class<?> superclass = javaClass.getSuperclass();
- if (superclass == null) {
- throw ex;
- }
- // recurse
- return field(superclass, fieldName);
- }
- field.setAccessible(true);
- return field;
- }
-
- /**
- * Convenience method.
- * Return a field for the specified object and field name.
- * If the object's class does not directly
- * define the field, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected fields.
- */
- public static Field field(Object object, String fieldName) throws NoSuchFieldException {
- return field(object.getClass(), fieldName);
- }
-
- /*
- * Return a string representation of the specified constructor.
- */
- private static String fullyQualifiedConstructorSignature(Class<?> javaClass, Class<?>[] parameterTypes) {
- return fullyQualifiedMethodSignature(javaClass, null, parameterTypes);
- }
-
- /*
- * Return a string representation of the specified field.
- */
- private static String fullyQualifiedFieldName(Class<?> javaClass, String fieldName) {
- StringBuilder sb = new StringBuilder(200);
- sb.append(javaClass.getName());
- sb.append('.');
- sb.append(fieldName);
- return sb.toString();
- }
-
- /*
- * Return a string representation of the specified field.
- */
- private static String fullyQualifiedFieldName(Object object, String fieldName) {
- return fullyQualifiedFieldName(object.getClass(), fieldName);
- }
-
- /*
- * Return a string representation of the specified method.
- */
- private static String fullyQualifiedMethodSignature(Class<?> javaClass, String methodName, Class<?>[] parameterTypes) {
- StringBuilder sb = new StringBuilder(200);
- sb.append(javaClass.getName());
- // this check allows us to use this code for constructors, where the methodName is null
- if (methodName != null) {
- sb.append('.');
- sb.append(methodName);
- }
- sb.append('(');
- int max = parameterTypes.length - 1;
- if (max != -1) {
- // stop one short of the end of the array
- for (int i = 0; i < max; i++) {
- sb.append(parameterTypes[i].getName());
- sb.append(", ");
- }
- sb.append(parameterTypes[max].getName());
- }
- sb.append(')');
- return sb.toString();
- }
-
- /*
- * Return a string representation of the specified method.
- */
- private static String fullyQualifiedMethodSignature(Object receiver, String methodName, Class<?>[] parameterTypes) {
- return fullyQualifiedMethodSignature(receiver.getClass(), methodName, parameterTypes);
- }
-
- /**
- * Get a field value, given the containing object and field name.
- * Return its result.
- * Useful for accessing private, package, or protected fields.
- * Object#getFieldValue(String fieldName)
- */
- public static Object fieldValue(Object object, String fieldName) {
- try {
- return attemptToGetFieldValue(object, fieldName);
- } catch (NoSuchFieldException nsfe) {
- throw new RuntimeException(nsfe + CR + fullyQualifiedFieldName(object, fieldName), nsfe);
- }
- }
-
- /**
- * Get a static field value, given the containing class and field name.
- * Return its result.
- * Useful for accessing private, package, or protected fields.
- * Class#getStaticFieldValue(String fieldName)
- */
- public static Object staticFieldValue(Class<?> javaClass, String fieldName) {
- try {
- return attemptToGetStaticFieldValue(javaClass, fieldName);
- } catch (NoSuchFieldException nsfe) {
- throw new RuntimeException(nsfe + CR + fullyQualifiedFieldName(javaClass, fieldName), nsfe);
- }
- }
-
- /**
- * Convenience method.
- * Execute a zero-argument method, given the receiver and method name.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName)
- */
- public static Object executeMethod(Object receiver, String methodName) {
- return executeMethod(receiver, methodName, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Execute a method, given the receiver,
- * method name, parameter types, and parameters.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?>[] parameterTypes, Object[] parameters)
- */
- public static Object executeMethod(Object receiver, String methodName, Class<?>[] parameterTypes, Object[] parameters) {
- try {
- return attemptToExecuteMethod(receiver, methodName, parameterTypes, parameters);
- } catch (NoSuchMethodException nsme) {
- throw new RuntimeException(nsme + CR + fullyQualifiedMethodSignature(receiver, methodName, parameterTypes), nsme);
- }
- }
-
- /**
- * Convenience method.
- * Execute a one-argument method, given the receiver,
- * method name, parameter type, and parameter.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?> parameterType, Object parameter)
- */
- public static Object executeMethod(Object receiver, String methodName, Class<?> parameterType, Object parameter) {
- return executeMethod(receiver, methodName, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Convenience method.
- * Execute a zero-argument method, given the receiver and method name.
- * Return its result.
- * If the method throws an exception, rethrow that exception.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName)
- */
- public static Object executeMethodWithException(Object receiver, String methodName)
- throws Throwable
- {
- return executeMethodWithException(receiver, methodName, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Convenience method.
- * Execute a one-argument method, given the receiver,
- * method name, parameter type, and parameter.
- * Return its result.
- * If the method throws an exception, rethrow that exception.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?> parameterType, Object parameter)
- */
- public static Object executeMethodWithException(Object receiver, String methodName, Class<?> parameterType, Object parameter)
- throws Throwable
- {
- return executeMethodWithException(receiver, methodName, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Execute a method, given the receiver,
- * method name, parameter types, and parameters.
- * Return its result.
- * If the method throws an exception, rethrow that exception.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?>[] parameterTypes, Object[] parameters)
- */
- public static Object executeMethodWithException(Object receiver, String methodName, Class<?>[] parameterTypes, Object[] parameters)
- throws Throwable
- {
- try {
- return attemptToExecuteMethodWithException(receiver, methodName, parameterTypes, parameters);
- } catch (NoSuchMethodException nsme) {
- throw new RuntimeException(nsme + CR + fullyQualifiedMethodSignature(receiver, methodName, parameterTypes), nsme);
- }
- }
-
- /**
- * Execute the specified method with the specified parameters.
- * Return its result.
- * Convert exceptions to RuntimeExceptions.
- */
- public static Object executeMethod(Method method, Object receiver, Object[] parameters) {
- try {
- return method.invoke(receiver, parameters);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + method, iae);
- } catch (InvocationTargetException ite) {
- throw new RuntimeException(method + CR + ite.getTargetException(), ite);
- }
- }
-
- /**
- * Execute the specified method with the specified parameters.
- * Return its result.
- * If the method throws an exception, rethrow that exception.
- * Convert all other exceptions to RuntimeExceptions.
- */
- public static Object executeMethodWithException(Method method, Object receiver, Object[] parameters)
- throws Throwable
- {
- try {
- return method.invoke(receiver, parameters);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + method, iae);
- } catch (InvocationTargetException ite) {
- Throwable cause = ite.getCause();
- if (cause == null) {
- throw new RuntimeException(method.toString(), ite);
- }
- throw cause;
- }
- }
-
- /**
- * Convenience method.
- * Execute a zero-argument static method,
- * given the class and method name.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * Class#executeStaticMethod(String methodName)
- */
- public static Object executeStaticMethod(Class<?> javaClass, String methodName) {
- return executeStaticMethod(javaClass, methodName, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Execute a static method, given the class,
- * method name, parameter types, and parameters.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * Class#executeStaticMethod(String methodName, Class<?>[] parameterTypes, Object[] parameters)
- */
- public static Object executeStaticMethod(Class<?> javaClass, String methodName, Class<?>[] parameterTypes, Object[] parameters) {
- try {
- return attemptToExecuteStaticMethod(javaClass, methodName, parameterTypes, parameters);
- } catch (NoSuchMethodException nsme) {
- throw new RuntimeException(nsme + CR + fullyQualifiedMethodSignature(javaClass, methodName, parameterTypes), nsme);
- }
- }
-
- /**
- * Convenience method.
- * Execute a static method, given the class,
- * method name, parameter type, and parameter.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * Class#executeStaticMethod(String methodName, Class<?> parameterType, Object parameter)
- */
- public static Object executeStaticMethod(Class<?> javaClass, String methodName, Class<?> parameterType, Object parameter) {
- return executeStaticMethod(javaClass, methodName, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Execute the specified static method with the specified parameters.
- * Return its result.
- * Convert exceptions to RuntimeExceptions.
- */
- public static Object executeStaticMethod(Method method, Object[] parameters) {
- return executeMethod(method, null, parameters);
- }
-
- /**
- * Convenience method.
- * Return a zero-argument method for the specified class
- * and method name. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method method(Class<?> javaClass, String methodName) throws NoSuchMethodException {
- return method(javaClass, methodName, ZERO_PARAMETER_TYPES);
- }
-
- /**
- * Return a method for the specified class, method name,
- * and formal parameter types. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method method(Class<?> javaClass, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException {
- Method method = null;
- try {
- method = javaClass.getDeclaredMethod(methodName, parameterTypes);
- } catch (NoSuchMethodException ex) {
- Class<?> superclass = javaClass.getSuperclass();
- if (superclass == null) {
- throw ex;
- }
- // recurse
- return method(superclass, methodName, parameterTypes);
- }
- method.setAccessible(true);
- return method;
- }
-
- /**
- * Convenience method.
- * Return a method for the specified class, method name,
- * and formal parameter type. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method method(Class<?> javaClass, String methodName, Class<?> parameterType) throws NoSuchMethodException {
- return method(javaClass, methodName, new Class[] {parameterType});
- }
-
- /**
- * Convenience method.
- * Return a zero-argument method for the specified object
- * and method name. If the object's class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method method(Object object, String methodName) throws NoSuchMethodException {
- return method(object.getClass(), methodName);
- }
-
- /**
- * Convenience method.
- * Return a method for the specified object, method name,
- * and formal parameter types. If the object's class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method method(Object object, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException {
- return method(object.getClass(), methodName, parameterTypes);
- }
-
- /**
- * Convenience method.
- * Return a method for the specified object, method name,
- * and formal parameter type. If the object's class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method method(Object object, String methodName, Class<?> parameterType) throws NoSuchMethodException {
- return method(object.getClass(), methodName, parameterType);
- }
-
- /**
- * Convenience method.
- * Return the specified class (without the checked exception).
- */
- public static Class<?> classForName(String className) {
- try {
- return Class.forName(className);
- } catch (ClassNotFoundException ex) {
- throw new RuntimeException(className, ex);
- }
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * using the class's default (zero-argument) constructor.
- * Class#newInstance()
- */
- public static <T> T newInstance(Class<T> javaClass) {
- return newInstance(javaClass, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * using the class's default (zero-argument) constructor.
- * Class#newInstance()
- */
- public static Object newInstance(String className) throws ClassNotFoundException {
- return newInstance(className, null);
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * using the class's default (zero-argument) constructor.
- * Class#newInstance()
- */
- public static Object newInstance(String className, ClassLoader classLoader) throws ClassNotFoundException {
- return newInstance(Class.forName(className, true, classLoader));
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter types and parameters.
- * Class#newInstance(Class<?>[] parameterTypes, Object[] parameters)
- */
- public static <T> T newInstance(Class<T> javaClass, Class<?>[] parameterTypes, Object[] parameters) {
- try {
- return attemptNewInstance(javaClass, parameterTypes, parameters);
- } catch (NoSuchMethodException nsme) {
- throw new RuntimeException(nsme + CR + fullyQualifiedConstructorSignature(javaClass, parameterTypes), nsme);
- }
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter types and parameters.
- * Class#newInstance(Class<?>[] parameterTypes, Object[] parameters)
- */
- public static Object newInstance(String className, Class<?>[] parameterTypes, Object[] parameters) throws ClassNotFoundException {
- return newInstance(className, parameterTypes, parameters, null);
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter types and parameters.
- * Class#newInstance(Class<?>[] parameterTypes, Object[] parameters)
- */
- public static Object newInstance(String className, Class<?>[] parameterTypes, Object[] parameters, ClassLoader classLoader) throws ClassNotFoundException {
- return newInstance(Class.forName(className, true, classLoader), parameterTypes, parameters);
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * given the constructor parameter type and parameter.
- * Class#newInstance(Class<?> parameterType, Object parameter)
- */
- public static <T> T newInstance(Class<T> javaClass, Class<?> parameterType, Object parameter) {
- return newInstance(javaClass, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter type and parameter.
- * Class#newInstance(Class<?> parameterType, Object parameter)
- */
- public static Object newInstance(String className, Class<?> parameterType, Object parameter) throws ClassNotFoundException {
- return newInstance(className, parameterType, parameter, null);
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter type and parameter.
- * Class#newInstance(Class<?> parameterType, Object parameter)
- */
- public static Object newInstance(String className, Class<?> parameterType, Object parameter, ClassLoader classLoader) throws ClassNotFoundException {
- return newInstance(Class.forName(className, false, classLoader), parameterType, parameter);
- }
-
- /*
- * Push the declared fields for the specified class
- * onto the top of the stack.
- */
- private static void pushDeclaredFields(Class<?> javaClass, Stack<Field> stack) {
- Field[] fields = declaredFields(javaClass);
- for (int i = fields.length; i-- > 0; ) {
- stack.push(fields[i]);
- }
- }
-
- /*
- * Push the declared methods for the specified class
- * onto the top of the stack.
- */
- private static void pushDeclaredMethods(Class<?> javaClass, Stack<Method> stack) {
- Method[] methods = declaredMethods(javaClass);
- for (int i = methods.length; i-- > 0; ) {
- stack.push(methods[i]);
- }
- }
-
- /**
- * Set a field value, given the containing object, field name, and new field value.
- * Useful for accessing private, package, or protected fields.
- * Object#setFieldValue(String fieldName, Object fieldValue)
- */
- public static void setFieldValue(Object object, String fieldName, Object fieldValue) {
- try {
- attemptToSetFieldValue(object, fieldName, fieldValue);
- } catch (NoSuchFieldException nsfe) {
- throw new RuntimeException(nsfe + CR + fullyQualifiedFieldName(object, fieldName), nsfe);
- }
- }
-
- /**
- * Set a static field value, given the containing class, field name, and new field value.
- * Useful for accessing private, package, or protected fields.
- * Class#setStaticFieldValue(String fieldName, Object fieldValue)
- */
- public static void setStaticFieldValue(Class<?> javaClass, String fieldName, Object fieldValue) {
- try {
- attemptToSetStaticFieldValue(javaClass, fieldName, fieldValue);
- } catch (NoSuchFieldException nsfe) {
- throw new RuntimeException(nsfe + CR + fullyQualifiedFieldName(javaClass, fieldName), nsfe);
- }
- }
-
- /**
- * Return the short name of the object's class.
- * Class#getShortName()
- */
- public static String shortClassNameForObject(Object object) {
- return shortNameFor(object.getClass());
- }
-
- /**
- * Return the short name of the class (e.g. "Object").
- * Class#getShortName()
- */
- public static String shortNameForClassNamed(String className) {
- return className.substring(className.lastIndexOf('.') + 1);
- }
-
- /**
- * Return the short name of the class (e.g. "Object").
- * Class#getShortName()
- */
- public static String shortNameFor(Class<?> javaClass) {
- return shortNameForClassNamed(javaClass.getName());
- }
-
- /**
- * Return the nested name of the object's class.
- * Class#getNestedName()
- */
- public static String nestedClassNameForObject(Object object) {
- return nestedNameFor(object.getClass());
- }
-
- /**
- * Return the nested name of the class (e.g. "Entry").
- * Class#getNestedName()
- */
- public static String nestedNameForClassNamed(String className) {
- return className.substring(className.lastIndexOf(NESTED_CLASS_NAME_SEPARATOR) + 1);
- }
-
- /**
- * Return the nested name of the class (e.g. "Entry").
- * Class#getNestedName()
- */
- public static String nestedNameFor(Class<?> javaClass) {
- return nestedNameForClassNamed(javaClass.getName());
- }
-
- /**
- * Return the "toString()" name of the object's class.
- */
- public static String toStringClassNameForObject(Object object) {
- return toStringNameFor(object.getClass());
- }
-
- /**
- * Return the "toString()" name of the class.
- * "Member" classes will return only the final name:
- * "com.foo.bar.TopLevelClass$MemberClass$NestedMemberClass"
- * => "NestedMemberClass"
- * "Local" and "anonymous" classes will still return the embedded '$'s:
- * "com.foo.bar.TopLevelClass$1LocalClass"
- * => "TopLevelClass$1LocalClass"
- * "com.foo.bar.TopLevelClass$1"
- * => "TopLevelClass$1"
- */
- public static String toStringNameForClassNamed(String className) {
- return classNamedIsMember(className) ?
- className.substring(className.lastIndexOf(NESTED_CLASS_NAME_SEPARATOR) + 1)
- :
- className.substring(className.lastIndexOf('.') + 1);
- }
-
- /**
- * Return the "toString()" name of the class.
- */
- public static String toStringNameFor(Class<?> javaClass) {
- return toStringNameForClassNamed(javaClass.getName());
- }
-
- /**
- * Return the package name of the class (e.g. "java.lang").
- * Class#getPackageName()
- */
- public static String packageNameFor(Class<?> javaClass) {
- return packageNameForClassNamed(javaClass.getName());
- }
-
- /**
- * Return the package name of the class (e.g. "java.lang").
- * Class#getPackageName()
- */
- public static String packageNameForClassNamed(String className) {
- int lastPeriod = className.lastIndexOf('.');
- if (lastPeriod == -1) {
- return "";
- }
- return className.substring(0, lastPeriod);
- }
-
- /**
- * Return the short name of the class,
- * followed by its package name (e.g. "Object (java.lang)").
- * Class#getShortNameWithPackage()
- */
- public static String shortNameWithPackage(Class<?> javaClass) {
- StringBuilder sb = new StringBuilder(200);
- sb.append(shortNameFor(javaClass));
- if ( ! javaClass.isPrimitive()) {
- sb.append(" (");
- sb.append(packageNameFor(javaClass));
- sb.append(')');
- }
- return sb.toString();
- }
-
- /**
- * Convenience method.
- * Return a zero-argument, static method for the specified class
- * and method name. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method staticMethod(Class<?> javaClass, String methodName) throws NoSuchMethodException {
- return staticMethod(javaClass, methodName, ZERO_PARAMETER_TYPES);
- }
-
- /**
- * Return a static method for the specified class, method name,
- * and formal parameter types. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method staticMethod(Class<?> javaClass, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException {
- Method method = method(javaClass, methodName, parameterTypes);
- if (Modifier.isStatic(method.getModifiers())) {
- return method;
- }
- throw new NoSuchMethodException(fullyQualifiedMethodSignature(javaClass, methodName, parameterTypes));
- }
-
- /**
- * Convenience method.
- * Return a static method for the specified class, method name,
- * and formal parameter type. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method staticMethod(Class<?> javaClass, String methodName, Class<?> parameterTypes) throws NoSuchMethodException {
- return staticMethod(javaClass, methodName, new Class[] {parameterTypes});
- }
-
- /**
- * Return whether the specified class can be "declared" in code;
- * i.e. it is either a "top-level" class or a "member" class, but it
- * is not an "array" class. This method rolls together all the checks
- * from the other methods for a bit of a performance tweak.
- * Class#isDeclarable()
- */
- public static boolean classNamedIsDeclarable(String className) {
- if (className.charAt(0) == ARRAY_INDICATOR) {
- return false; // it is an "array" class
- }
- int index = className.indexOf(NESTED_CLASS_NAME_SEPARATOR);
- if (index == -1) {
- return true; // it is a "top-level" class
- }
- do {
- // the character immediately after each dollar sign cannot be a digit
- index++;
- if (Character.isDigit(className.charAt(index))) {
- return false;
- }
- index = className.indexOf(NESTED_CLASS_NAME_SEPARATOR, index);
- } while (index != -1);
- return true;
- }
-
- /**
- * Return whether the specified class is a "top-level" class,
- * as opposed to a "member", "local", or "anonymous" class,
- * using the standard jdk naming conventions (i.e. the class
- * name does NOT contain a '$': "TopLevelClass").
- * Class#isTopLevel()
- */
- public static boolean classNamedIsTopLevel(String className) {
- if (classNamedIsArray(className)) {
- return false;
- }
- return className.indexOf(NESTED_CLASS_NAME_SEPARATOR) == -1;
- }
-
- /**
- * Return whether the specified class is a "member" class,
- * as opposed to a "top-level", "local", or "anonymous" class,
- * using the standard jdk naming conventions (i.e. the class
- * name contains at least one '$' and all the names between
- * each '$' are legal class names:
- * "TopLevelClass$MemberClass$NestedMemberClass").
- * Class#isMember()
- */
- public static boolean classNamedIsMember(String className) {
- if (classNamedIsArray(className)) {
- return false;
- }
- int index = className.indexOf(NESTED_CLASS_NAME_SEPARATOR);
- if (index == -1) {
- return false; // it is a "top-level" class
- }
- do {
- // the character immediately after each dollar sign cannot be a digit
- index++;
- if (Character.isDigit(className.charAt(index))) {
- return false;
- }
- index = className.indexOf(NESTED_CLASS_NAME_SEPARATOR, index);
- } while (index != -1);
- return true;
- }
-
- /**
- * Return whether the specified class is a "local" class,
- * as opposed to a "top-level", "member", or "anonymous" class,
- * using the standard jdk (or Eclipse) naming conventions.
- * In the jdk, the class name ends with '$nnnXXX' where the '$' is
- * followed by a series of numeric digits which are followed by the
- * local class name: "TopLevelClass$1LocalClass".
- * In Eclipse, the class name ends with '$nnn$XXX' where the '$' is
- * followed by a series of numeric digits which are separated from
- * the local class name by another '$': "TopLevelClass$1$LocalClass".
- * Class#isLocal()
- */
- public static boolean classNamedIsLocal(String className) {
- if (classNamedIsArray(className)) {
- return false;
- }
- int dollar = className.indexOf(NESTED_CLASS_NAME_SEPARATOR);
- if (dollar == -1) {
- return false;
- }
- if ( ! Character.isDigit(className.charAt(dollar + 1))) {
- return false;
- }
- int len = className.length();
- for (int i = dollar + 2; i < len; i++) {
- if (Character.isJavaIdentifierStart(className.charAt(i))) {
- return true;
- }
- }
- // all the characters past the $ are digits (anonymous)
- return false;
- }
-
- /**
- * Return whether the specified class is an "anonymous" class,
- * as opposed to a "top-level", "member", or "local" class,
- * using the standard jdk naming conventions (i.e. the class
- * name ends with '$nnn' where all the characters past the
- * last '$' are numeric digits: "TopLevelClass$1").
- * Class#isAnonymous()
- */
- public static boolean classNamedIsAnonymous(String className) {
- if (classNamedIsArray(className)) {
- return false;
- }
- int dollar = className.indexOf(NESTED_CLASS_NAME_SEPARATOR);
- if (dollar == -1) {
- return false;
- }
- int start = dollar + 1;
- for (int i = className.length(); i-- > start; ) {
- if ( ! Character.isDigit(className.charAt(i))) {
- return false;
- }
- }
- // all the characters past the $ are digits
- return true;
- }
-
- /**
- * Return the "array depth" of the specified class.
- * The depth is the number of dimensions for an array type.
- * Non-array types have a depth of zero.
- * Class#getArrayDepth()
- */
- public static int arrayDepthFor(Class<?> javaClass) {
- int depth = 0;
- while (javaClass.isArray()) {
- depth++;
- javaClass = javaClass.getComponentType();
- }
- return depth;
- }
-
- /**
- * Return the "array depth" of the specified object.
- * The depth is the number of dimensions for an array.
- * Non-arrays have a depth of zero.
- */
- public static int arrayDepthForObject(Object object) {
- return arrayDepthFor(object.getClass());
- }
-
- /**
- * Return the "array depth" of the specified class.
- * The depth is the number of dimensions for an array type.
- * Non-array types have a depth of zero.
- * @see java.lang.Class#getName()
- * Class#getArrayDepth()
- */
- public static int arrayDepthForClassNamed(String className) {
- int depth = 0;
- while (className.charAt(depth) == ARRAY_INDICATOR) {
- depth++;
- }
- return depth;
- }
-
- /**
- * Return whether the specified class is an array type.
- * @see java.lang.Class#getName()
- */
- public static boolean classNamedIsArray(String className) {
- return className.charAt(0) == ARRAY_INDICATOR;
- }
-
- /**
- * Return the "element type" of the specified class.
- * The element type is the base type held by an array type.
- * A non-array type simply returns itself.
- * Class#getElementType()
- */
- public static Class<?> elementTypeFor(Class<?> javaClass) {
- while (javaClass.isArray()) {
- javaClass = javaClass.getComponentType();
- }
- return javaClass;
- }
-
- /**
- * Return the "element type" of the specified object.
- * The element type is the base type held by an array.
- * A non-array simply returns its class.
- */
- public static Class<?> elementTypeForObject(Object object) {
- return elementTypeFor(object.getClass());
- }
-
- /**
- * Return the "element type" of the specified class.
- * The element type is the base type held by an array type.
- * Non-array types simply return themselves.
- * Class#getElementType()
- */
- public static String elementTypeNameFor(Class<?> javaClass) {
- return elementTypeFor(javaClass).getName();
- }
-
- /**
- * Return the "element type" of the specified class.
- * The element type is the base type held by an array type.
- * Non-array types simply return themselves.
- * @see java.lang.Class#getName()
- * Class#getElementType()
- */
- public static String elementTypeNameForClassNamed(String className) {
- int depth = arrayDepthForClassNamed(className);
- if (depth == 0) {
- // the name is in the form: "java.lang.Object" or "int"
- return className;
- }
- int last = className.length() - 1;
- if (className.charAt(depth) == REFERENCE_CLASS_CODE) {
- // the name is in the form: "[[[Ljava.lang.Object;"
- return className.substring(depth + 1, last); // drop the trailing ';'
- }
- // the name is in the form: "[[[I"
- return classNameForCode(className.charAt(last));
- }
-
- /**
- * Return whether the specified class is a "reference"
- * class (i.e. neither 'void' nor one of the primitive variable classes,
- * ['boolean', 'int', 'float', etc.]).
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classNamedIsReference(String className) {
- return ! classNamedIsPrimitive(className);
- }
-
- /**
- * Return whether the specified class is a primitive
- * class (i.e. 'void' or one of the primitive variable classes,
- * ['boolean', 'int', 'float', etc.]).
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classNamedIsPrimitive(String className) {
- if (classNamedIsArray(className) || (className.length() > maxPrimitiveClassNameLength())) {
- return false; // performance tweak
- }
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].javaClass.getName().equals(className)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified class is a "variable" primitive
- * class (i.e. 'boolean', 'int', 'float', etc., but not 'void').
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classNamedIsVariablePrimitive(String className) {
- return classNamedIsPrimitive(className)
- && ( ! className.equals(VOID_CLASS_NAME));
- }
-
- /**
- * Return whether the specified class is a primitive wrapper
- * class (i.e. 'java.lang.Void' or one of the primitive variable wrapper classes,
- * ['java.lang.Boolean', 'java.lang.Integer', 'java.lang.Float', etc.]).
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classNamedIsPrimitiveWrapperClass(String className) {
- if (classNamedIsArray(className) || (className.length() > maxPrimitiveWrapperClassNameLength())) {
- return false; // performance tweak
- }
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].wrapperClass.getName().equals(className)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified class is a "variable" primitive
- * class (i.e. 'boolean', 'int', 'float', etc., but not 'void').
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classNamedIsVariablePrimitiveWrapperClass(String className) {
- return classNamedIsPrimitiveWrapperClass(className)
- && ( ! className.equals(VOID_WRAPPER_CLASS_NAME));
- }
-
- /**
- * Return whether the specified class is a primitive wrapper
- * class (i.e. 'java.lang.Void' or one of the primitive variable wrapper classes,
- * ['java.lang.Boolean', 'java.lang.Integer', 'java.lang.Float', etc.]).
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classIsPrimitiveWrapperClass(Class<?> javaClass) {
- if (javaClass.isArray() || (javaClass.getName().length() > maxPrimitiveWrapperClassNameLength())) {
- return false; // performance tweak
- }
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].wrapperClass == javaClass) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified class is a "variable" primitive
- * class (i.e. 'boolean', 'int', 'float', etc., but not 'void').
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classIsVariablePrimitiveWrapperClass(Class<?> javaClass) {
- return classIsPrimitiveWrapperClass(javaClass)
- && (javaClass != java.lang.Void.class);
- }
-
- /**
- * Return the class name for the specified class code.
- * @see java.lang.Class#getName()
- */
- public static String classNameForCode(char classCode) {
- return classForCode(classCode).getName();
- }
-
- /**
- * Return the class name for the specified class code.
- * @see java.lang.Class#getName()
- */
- public static String classNameForCode(int classCode) {
- return classNameForCode((char) classCode);
- }
-
- /**
- * Return the class for the specified class code.
- * @see java.lang.Class#getName()
- */
- public static Class<?> classForCode(char classCode) {
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].code == classCode) {
- return codes[i].javaClass;
- }
- }
- throw new IllegalArgumentException(String.valueOf(classCode));
- }
-
- /**
- * Return the class for the specified class code.
- * @see java.lang.Class#getName()
- */
- public static Class<?> classForCode(int classCode) {
- return classForCode((char) classCode);
- }
-
- /**
- * Return the class code for the specified class.
- * @see java.lang.Class#getName()
- */
- public static char codeForClass(Class<?> javaClass) {
- if (( ! javaClass.isArray()) && (javaClass.getName().length() <= maxPrimitiveClassNameLength())) {
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].javaClass == javaClass) {
- return codes[i].code;
- }
- }
- }
- throw new IllegalArgumentException(javaClass.getName());
- }
-
- /**
- * Return the class code for the specified class.
- * @see java.lang.Class#getName()
- */
- public static char codeForClassNamed(String className) {
- if (( ! classNamedIsArray(className)) && (className.length() <= maxPrimitiveClassNameLength())) {
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].javaClass.getName().equals(className)) {
- return codes[i].code;
- }
- }
- }
- throw new IllegalArgumentException(className);
- }
-
- /**
- * Return the class for the specified "type declaration".
- */
- public static Class<?> classForTypeDeclaration(String typeDeclaration) throws ClassNotFoundException {
- return classForTypeDeclaration(typeDeclaration, ClassTools.class.getClassLoader());
- }
-
- /**
- * Return the class for the specified "type declaration",
- * using the specified class loader.
- */
- public static Class<?> classForTypeDeclaration(String typeDeclaration, ClassLoader classLoader) throws ClassNotFoundException {
- TypeDeclaration td = typeDeclaration(typeDeclaration);
- return classForTypeDeclaration(td.elementTypeName, td.arrayDepth);
- }
-
- private static TypeDeclaration typeDeclaration(String typeDeclaration) {
- typeDeclaration = StringTools.removeAllWhitespace(typeDeclaration);
- int arrayDepth = arrayDepthForTypeDeclaration_(typeDeclaration);
- String elementTypeName = typeDeclaration.substring(0, typeDeclaration.length() - (arrayDepth * 2));
- return new TypeDeclaration(elementTypeName, arrayDepth);
- }
-
- /**
- * Return the class for the specified "type declaration".
- */
- public static Class<?> classForTypeDeclaration(String elementTypeName, int arrayDepth) throws ClassNotFoundException {
- return classForTypeDeclaration(elementTypeName, arrayDepth, null);
- }
-
- /**
- * Return the class for the specified "type declaration",
- * using the specified class loader.
- */
- // see the "Evaluation" of jdk bug 6446627 for a discussion of loading classes
- public static Class<?> classForTypeDeclaration(String elementTypeName, int arrayDepth, ClassLoader classLoader) throws ClassNotFoundException {
- // primitives cannot be loaded via Class#forName(),
- // so check for a primitive class name first
- Primitive pcc = null;
- if (elementTypeName.length() <= maxPrimitiveClassNameLength()) { // performance tweak
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].javaClass.getName().equals(elementTypeName)) {
- pcc = codes[i];
- break;
- }
- }
- }
-
- // non-array
- if (arrayDepth == 0) {
- return (pcc == null) ? Class.forName(elementTypeName, false, classLoader) : pcc.javaClass;
- }
-
- // array
- StringBuilder sb = new StringBuilder(100);
- for (int i = arrayDepth; i-- > 0; ) {
- sb.append(ARRAY_INDICATOR);
- }
- if (pcc == null) {
- sb.append(REFERENCE_CLASS_CODE);
- sb.append(elementTypeName);
- sb.append(REFERENCE_CLASS_NAME_DELIMITER);
- } else {
- sb.append(pcc.code);
- }
- return Class.forName(sb.toString(), false, classLoader);
- }
-
- /**
- * Return the class name for the specified "type declaration"; e.g.
- * "int[]" -> "[I"
- * @see java.lang.Class#getName()
- */
- public static String classNameForTypeDeclaration(String typeDeclaration) {
- TypeDeclaration td = typeDeclaration(typeDeclaration);
- return classNameForTypeDeclaration(td.elementTypeName, td.arrayDepth);
- }
-
- /**
- * Return the array depth for the specified "type declaration"; e.g.
- * "int[]" -> 1
- */
- public static int arrayDepthForTypeDeclaration(String typeDeclaration) {
- return arrayDepthForTypeDeclaration_(StringTools.removeAllWhitespace(typeDeclaration));
- }
-
- /*
- * Assume no whitespace in the type declaration.
- */
- private static int arrayDepthForTypeDeclaration_(String typeDeclaration) {
- int last = typeDeclaration.length() - 1;
- int depth = 0;
- int close = last;
- while (typeDeclaration.charAt(close) == TYPE_DECLARATION_ARRAY_CLOSE) {
- if (typeDeclaration.charAt(close - 1) == TYPE_DECLARATION_ARRAY_OPEN) {
- depth++;
- } else {
- throw new IllegalArgumentException("invalid type declaration: " + typeDeclaration);
- }
- close = last - (depth * 2);
- }
- return depth;
- }
-
- /**
- * Return the class name for the specified "type declaration".
- * @see java.lang.Class#getName()
- */
- public static String classNameForTypeDeclaration(String elementTypeName, int arrayDepth) {
- // non-array
- if (arrayDepth == 0) {
- return elementTypeName;
- }
-
- if (elementTypeName.equals(VOID_CLASS_NAME)) {
- throw new IllegalArgumentException("'" + VOID_CLASS_NAME + "' must have an array depth of zero: " + arrayDepth + '.');
- }
- // array
- StringBuilder sb = new StringBuilder(100);
- for (int i = arrayDepth; i-- > 0; ) {
- sb.append(ARRAY_INDICATOR);
- }
-
- // look for a primitive first
- Primitive pcc = null;
- if (elementTypeName.length() <= maxPrimitiveClassNameLength()) { // performance tweak
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].javaClass.getName().equals(elementTypeName)) {
- pcc = codes[i];
- break;
- }
- }
- }
-
- if (pcc == null) {
- sb.append(REFERENCE_CLASS_CODE);
- sb.append(elementTypeName);
- sb.append(REFERENCE_CLASS_NAME_DELIMITER);
- } else {
- sb.append(pcc.code);
- }
-
- return sb.toString();
- }
-
- private static int maxPrimitiveClassNameLength() {
- if (MAX_PRIMITIVE_CLASS_NAME_LENGTH == -1) {
- MAX_PRIMITIVE_CLASS_NAME_LENGTH = calculateMaxPrimitiveClassNameLength();
- }
- return MAX_PRIMITIVE_CLASS_NAME_LENGTH;
- }
-
- private static int calculateMaxPrimitiveClassNameLength() {
- int max = -1;
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- int len = codes[i].javaClass.getName().length();
- if (len > max) {
- max = len;
- }
- }
- return max;
- }
-
- private static int maxPrimitiveWrapperClassNameLength() {
- if (MAX_PRIMITIVE_WRAPPER_CLASS_NAME_LENGTH == -1) {
- MAX_PRIMITIVE_WRAPPER_CLASS_NAME_LENGTH = calculateMaxPrimitiveWrapperClassNameLength();
- }
- return MAX_PRIMITIVE_WRAPPER_CLASS_NAME_LENGTH;
- }
-
- private static int calculateMaxPrimitiveWrapperClassNameLength() {
- int max = -1;
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- int len = codes[i].wrapperClass.getName().length();
- if (len > max) {
- max = len;
- }
- }
- return max;
- }
-
- private static Primitive[] primitives() {
- if (PRIMITIVES == null) {
- PRIMITIVES = buildPrimitives();
- }
- return PRIMITIVES;
- }
-
- /**
- * NB: void.class.isPrimitive() == true
- */
- private static Primitive[] buildPrimitives() {
- Primitive[] result = new Primitive[9];
- result[0] = new Primitive(BYTE_CODE, java.lang.Byte.class);
- result[1] = new Primitive(CHAR_CODE, java.lang.Character.class);
- result[2] = new Primitive(DOUBLE_CODE, java.lang.Double.class);
- result[3] = new Primitive(FLOAT_CODE, java.lang.Float.class);
- result[4] = new Primitive(INT_CODE, java.lang.Integer.class);
- result[5] = new Primitive(LONG_CODE, java.lang.Long.class);
- result[6] = new Primitive(SHORT_CODE, java.lang.Short.class);
- result[7] = new Primitive(BOOLEAN_CODE, java.lang.Boolean.class);
- result[8] = new Primitive(VOID_CODE, java.lang.Void.class);
- return result;
- }
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private ClassTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-
- // ********** member classes **********
-
- private static class Primitive {
- final char code;
- final Class<?> javaClass;
- final Class<?> wrapperClass;
- private static final String WRAPPER_CLASS_TYPE_FIELD_NAME = "TYPE";
- // e.g. java.lang.Boolean.TYPE => boolean.class
- Primitive(char code, Class<?> wrapperClass) {
- this.code = code;
- this.wrapperClass = wrapperClass;
- this.javaClass = (Class<?>) staticFieldValue(wrapperClass, WRAPPER_CLASS_TYPE_FIELD_NAME);
- }
- }
-
- private static class TypeDeclaration {
- final String elementTypeName;
- final int arrayDepth;
- TypeDeclaration(String elementTypeName, int arrayDepth) {
- this.elementTypeName = elementTypeName;
- this.arrayDepth = arrayDepth;
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Classpath.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Classpath.java
deleted file mode 100644
index ea8f3d659e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Classpath.java
+++ /dev/null
@@ -1,912 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-/**
- * TODO
- */
-public class Classpath
- implements Serializable
-{
- /** The entries in the classpath */
- private final Entry[] entries;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** static methods **********
-
- // ***** factory methods for "standard" classpaths *****
-
- /**
- * Return the Java "boot" classpath. This includes rt.jar.
- */
- public static Classpath bootClasspath() {
- return new Classpath(System.getProperty("sun.boot.class.path"));
- }
-
- /**
- * Return a "virtual classpath" that contains all the jars
- * that would be used by the Java Extension Mechanism.
- */
- public static Classpath javaExtensionClasspath() {
- File[] dirs = javaExtensionDirectories();
- List<String> jarFileNames = new ArrayList<String>();
- for (File dir : dirs) {
- if (dir.isDirectory()) {
- addJarFileNamesTo(dir, jarFileNames);
- }
- }
- return new Classpath(jarFileNames);
- }
-
- /**
- * Return the Java "system" classpath.
- */
- public static Classpath javaClasspath() {
- return new Classpath(System.getProperty("java.class.path"));
- }
-
- /**
- * Return the unretouched "complete" classpath.
- * This includes the boot classpath, the Java Extension
- * Mechanism classpath, and the normal "system" classpath.
- */
- public static Classpath completeClasspath() {
- return new Classpath(new Classpath[] {
- bootClasspath(),
- javaExtensionClasspath(),
- javaClasspath()
- });
- }
-
- /**
- * Return a classpath that contains the location of the specified class.
- */
- public static Classpath classpathFor(Class<?> javaClass) {
- return new Classpath(locationFor(javaClass));
- }
-
-
- // ***** file => class *****
-
- /**
- * Convert a relative file name to a class name; this will work for
- * any file that has a single extension beyond the base
- * class name.
- * e.g. "java/lang/String.class" is converted to "java.lang.String"
- * e.g. "java/lang/String.java" is converted to "java.lang.String"
- */
- public static String convertToClassName(String classFileName) {
- String className = FileTools.stripExtension(classFileName);
- // do this for archive entry names
- className = className.replace('/', '.');
- // do this for O/S-specific file names
- if (File.separatorChar != '/') {
- className = className.replace(File.separatorChar, '.');
- }
- return className;
- }
-
- /**
- * Convert a file to a class name;
- * e.g. File(java/lang/String.class) is converted to "java.lang.String"
- */
- public static String convertToClassName(File classFile) {
- return convertToClassName(classFile.getPath());
- }
-
- /**
- * Convert a relative file name to a class;
- * e.g. "java/lang/String.class" is converted to java.lang.String.class
- */
- public static Class<?> convertToClass(String classFileName) throws ClassNotFoundException {
- return Class.forName(convertToClassName(classFileName));
- }
-
- /**
- * Convert a relative file to a class;
- * e.g. File(java/lang/String.class) is converted to java.lang.String.class
- */
- public static Class<?> convertToClass(File classFile) throws ClassNotFoundException {
- return convertToClass(classFile.getPath());
- }
-
-
- // ***** class => JAR entry *****
-
- /**
- * Convert a class name to an archive entry name base;
- * e.g. "java.lang.String" is converted to "java/lang/String"
- */
- public static String convertToArchiveEntryNameBase(String className) {
- return className.replace('.', '/');
- }
-
- /**
- * Convert a class to an archive entry name base;
- * e.g. java.lang.String.class is converted to "java/lang/String"
- */
- public static String convertToArchiveEntryNameBase(Class<?> javaClass) {
- return convertToArchiveEntryNameBase(javaClass.getName());
- }
-
- /**
- * Convert a class name to an archive class file entry name;
- * e.g. "java.lang.String" is converted to "java/lang/String.class"
- */
- public static String convertToArchiveClassFileEntryName(String className) {
- return convertToArchiveEntryNameBase(className) + ".class";
- }
-
- /**
- * Convert a class to an archive class file entry name;
- * e.g. java.lang.String.class is converted to "java/lang/String.class"
- */
- public static String convertToArchiveClassFileEntryName(Class<?> javaClass) {
- return convertToArchiveClassFileEntryName(javaClass.getName());
- }
-
-
- // ***** class => file (.class or .java) *****
-
- /**
- * Convert a class name to a file name base for the current O/S;
- * e.g. "java.lang.String" is converted to "java/lang/String" on Unix
- * and "java\\lang\\String" on Windows
- */
- public static String convertToFileNameBase(String className) {
- return className.replace('.', File.separatorChar);
- }
-
- /**
- * Convert a class to a file name base for the current O/S;
- * e.g. java.lang.String.class is converted to "java/lang/String" on Unix
- * and "java\\lang\\String" on Windows
- */
- public static String convertToFileNameBase(Class<?> javaClass) {
- return convertToFileNameBase(javaClass.getName());
- }
-
- /**
- * Convert a class name to a class file name for the current O/S;
- * e.g. "java.lang.String" is converted to "java/lang/String.class" on Unix
- * and "java\\lang\\String.class" on Windows
- */
- public static String convertToClassFileName(String className) {
- return convertToFileNameBase(className) + ".class";
- }
-
- /**
- * Convert a class to a class file name for the current O/S;
- * e.g. java.lang.String.class is converted to "java/lang/String.class" on Unix
- * and "java\\lang\\String.class" on Windows
- */
- public static String convertToClassFileName(Class<?> javaClass) {
- return convertToClassFileName(javaClass.getName());
- }
-
- /**
- * Convert a class name to a class file for the current O/S;
- * e.g. "java.lang.String" is converted to File(java/lang/String.class)
- */
- public static File convertToClassFile(String className) {
- return new File(convertToClassFileName(className));
- }
-
- /**
- * Convert a class to a class file for the current O/S;
- * e.g. java.lang.String.class is converted to File(java/lang/String.class)
- */
- public static File convertToClassFile(Class<?> javaClass) {
- return convertToClassFile(javaClass.getName());
- }
-
- /**
- * Convert a class name to a java file name for the current O/S;
- * e.g. "java.lang.String" is converted to "java/lang/String.java" on Unix
- * and "java\\lang\\String.java" on Windows
- */
- public static String convertToJavaFileName(String className) {
- return convertToFileNameBase(className) + ".java";
- }
-
- /**
- * Convert a class to a java file name for the current O/S;
- * e.g. java.lang.String.class is converted to "java/lang/String.java" on Unix
- * and "java\\lang\\String.java" on Windows
- */
- public static String convertToJavaFileName(Class<?> javaClass) {
- return convertToJavaFileName(javaClass.getName());
- }
-
- /**
- * Convert a class name to a java file for the current O/S;
- * e.g. "java.lang.String" is converted to File(java/lang/String.java)
- */
- public static File convertToJavaFile(String className) {
- return new File(convertToJavaFileName(className));
- }
-
- /**
- * Convert a class to a java file for the current O/S;
- * e.g. java.lang.String.class is converted to File(java/lang/String.java)
- */
- public static File convertToJavaFile(Class<?> javaClass) {
- return convertToJavaFile(javaClass.getName());
- }
-
-
- // ***** class => resource *****
-
- /**
- * Convert a class to a resource name;
- * e.g. java.lang.String.class is converted to "/java/lang/String.class".
- */
- public static String convertToResourceName(Class<?> javaClass) {
- return '/' + convertToArchiveClassFileEntryName(javaClass);
- }
-
- /**
- * Convert a class to a resource;
- * e.g. java.lang.String.class is converted to
- * URL(jar:file:/C:/jdk/1.4.2_04/jre/lib/rt.jar!/java/lang/String.class).
- */
- public static URL convertToResource(Class<?> javaClass) {
- return javaClass.getResource(convertToResourceName(javaClass));
- }
-
-
- // ***** utilities *****
-
- /**
- * Return whether the specified file is an archive file;
- * i.e. its name ends with ".zip" or ".jar"
- */
- public static boolean fileNameIsArchive(String fileName) {
- String ext = FileTools.extension(fileName).toLowerCase();
- return ext.equals(".jar") || ext.equals(".zip");
- }
-
- /**
- * Return whether the specified file is an archive file;
- * i.e. its name ends with ".zip" or ".jar"
- */
- public static boolean fileIsArchive(File file) {
- return fileNameIsArchive(file.getName());
- }
-
- /**
- * Return what should be the fully-qualified file name
- * for the JRE runtime JAR;
- * e.g. "C:\jdk1.4.2_04\jre\lib\rt.jar".
- */
- public static String rtJarName() {
- return locationFor(java.lang.Object.class);
- }
-
- /**
- * Return the location from where the specified class was loaded.
- */
- public static String locationFor(Class<?> javaClass) {
- URL url = convertToResource(javaClass);
- String path;
- try {
- path = FileTools.buildFile(url).getPath();
- } catch (URISyntaxException ex) {
- throw new RuntimeException(ex);
- }
- String protocol = url.getProtocol().toLowerCase();
- if (protocol.equals("jar")) {
- // if the class is in a JAR, the URL will look something like this:
- // jar:file:/C:/jdk/1.4.2_04/jre/lib/rt.jar!/java/lang/String.class
- return path.substring(0, path.indexOf('!'));
- } else if (protocol.equals("file")) {
- // if the class is in a directory, the URL will look something like this:
- // file:/C:/dev/main/mwdev/class/org/eclipse/dali/utility/Classpath.class
- return path.substring(0, path.length() - convertToClassFileName(javaClass).length() - 1);
- } else if (protocol.equals("bundleresource")) {
- // if the class is in a bundle resource (Eclipse?), the URL will look something like this:
- // bundleresource://43/org/eclipse/dali/utility/Classpath.class
- return path.substring(0, path.length() - convertToClassFileName(javaClass).length() - 1);
- }
-
- throw new IllegalStateException(url.toString());
- }
-
- /**
- * Return the directories used by the Java Extension Mechanism.
- */
- public static File[] javaExtensionDirectories() {
- return convertToFiles(javaExtensionDirectoryNames());
- }
-
- /**
- * Return the directory names used by the Java Extension Mechanism.
- */
- public static String[] javaExtensionDirectoryNames() {
- return System.getProperty("java.ext.dirs").split(File.pathSeparator);
- }
-
-
- // ***** internal *****
-
- private static File[] convertToFiles(String[] fileNames) {
- File[] files = new File[fileNames.length];
- for (int i = fileNames.length; i-- > 0; ) {
- files[i] = new File(fileNames[i]);
- }
- return files;
- }
-
- private static void addJarFileNamesTo(File dir, List<String> jarFileNames) {
- File[] jarFiles = jarFilesIn(dir);
- for (File jarFile : jarFiles) {
- jarFileNames.add(FileTools.canonicalFile(jarFile).getPath());
- }
- }
-
- private static File[] jarFilesIn(File directory) {
- return directory.listFiles(jarFileFilter());
- }
-
- private static FileFilter jarFileFilter() {
- return new FileFilter() {
- public boolean accept(File file) {
- return FileTools.extension(file.getName()).toLowerCase().equals(".jar");
- }
- };
- }
-
-
- // ********** constructors **********
-
- /**
- * Construct a classpath with the specified entries.
- */
- private Classpath(Entry[] entries) {
- super();
- this.entries = entries;
- }
-
- /**
- * Construct a classpath with the specified entries.
- */
- public Classpath(String[] fileNames) {
- this(buildEntries(fileNames));
- }
-
- /**
- * Skip empty file names because they will end up expanding to the current
- * working directory, which is not what we want. Empty file names actually
- * occur with some frequency; such as when the classpath has been built up
- * dynamically with too many separators. For example:
- * "C:\dev\foo.jar;;C:\dev\bar.jar"
- * will be parsed into three file names:
- * { "C:\dev\foo.jar", "", "C:\dev\bar.jar" }
- */
- private static Entry[] buildEntries(String[] fileNames) {
- List<Entry> entries = new ArrayList<Entry>();
- for (String fileName : fileNames) {
- if ((fileName != null) && (fileName.length() != 0)) {
- entries.add(new Entry(fileName));
- }
- }
- return entries.toArray(new Entry[entries.size()]);
- }
-
- /**
- * Construct a classpath with the specified path.
- */
- public Classpath(String path) {
- this(path.split(File.pathSeparator));
- }
-
- /**
- * Construct a classpath with the specified entries.
- */
- public Classpath(List<String> fileNames) {
- this(fileNames.toArray(new String[fileNames.size()]));
- }
-
- /**
- * Consolidate the specified classpaths into a single classpath.
- */
- public Classpath(Classpath[] classpaths) {
- this(consolidateEntries(classpaths));
- }
-
- private static Entry[] consolidateEntries(Classpath[] classpaths) {
- List<Entry> entries = new ArrayList<Entry>();
- for (Classpath classpath : classpaths) {
- CollectionTools.addAll(entries, classpath.entries());
- }
- return entries.toArray(new Entry[entries.size()]);
- }
-
-
- // ********** public API **********
-
- /**
- * Return the classpath's entries.
- */
- public Entry[] entries() {
- return this.entries;
- }
-
- /**
- * Return the classpath's path.
- */
- public String path() {
- Entry[] localEntries = this.entries;
- int max = localEntries.length - 1;
- if (max == -1) {
- return "";
- }
- StringBuilder sb = new StringBuilder(2000);
- // stop one short of the end of the array
- for (int i = 0; i < max; i++) {
- sb.append(localEntries[i].fileName());
- sb.append(File.pathSeparatorChar);
- }
- sb.append(localEntries[max].fileName());
- return sb.toString();
- }
-
- /**
- * Search the classpath for the specified (unqualified) file
- * and return its entry. Return null if an entry is not found.
- * For example, you could use this method to find the entry
- * for "rt.jar" or "toplink.jar".
- */
- public Entry entryForFileNamed(String shortFileName) {
- Entry[] localEntries = this.entries;
- for (Entry entry : localEntries) {
- if (entry.file().getName().equals(shortFileName)) {
- return entry;
- }
- }
- return null;
- }
-
- /**
- * Return the first entry file in the classpath
- * that contains the specified class.
- * Return null if an entry is not found.
- */
- public Entry entryForClassNamed(String className) {
- String relativeClassFileName = convertToClassFileName(className);
- String archiveEntryName = convertToArchiveClassFileEntryName(className);
- Entry[] localEntries = this.entries;
- for (Entry entry : localEntries) {
- if (entry.contains(relativeClassFileName, archiveEntryName)) {
- return entry;
- }
- }
- return null;
- }
-
- /**
- * Return the names of all the classes discovered on the classpath,
- * with duplicates removed.
- */
- public String[] classNames() {
- return this.classNames(Filter.Null.<String>instance());
- }
-
- /**
- * Return the names of all the classes discovered on the classpath
- * and accepted by the specified filter, with duplicates removed.
- */
- public String[] classNames(Filter<String> filter) {
- Collection<String> classNames = new HashSet<String>(10000);
- this.addClassNamesTo(classNames, filter);
- return classNames.toArray(new String[classNames.size()]);
- }
-
- /**
- * Add the names of all the classes discovered on the classpath
- * to the specified collection.
- */
- public void addClassNamesTo(Collection<String> classNames) {
- this.addClassNamesTo(classNames, Filter.Null.<String>instance());
- }
-
- /**
- * Add the names of all the classes discovered on the classpath
- * and accepted by the specified filter to the specified collection.
- */
- public void addClassNamesTo(Collection<String> classNames, Filter<String> filter) {
- Entry[] localEntries = this.entries;
- for (Entry entry : localEntries) {
- entry.addClassNamesTo(classNames, filter);
- }
- }
-
- /**
- * Return the names of all the classes discovered on the classpath.
- * Just a bit more performant than #classNames().
- */
- public Iterator<String> classNamesStream() {
- return this.classNamesStream(Filter.Null.<String>instance());
- }
-
- /**
- * Return the names of all the classes discovered on the classpath
- * that are accepted by the specified filter.
- * Just a bit more performant than #classNames(Filter).
- */
- public Iterator<String> classNamesStream(Filter<String> filter) {
- return new CompositeIterator<String>(this.entryClassNamesStreams(filter));
- }
-
- private Iterator<Iterator<String>> entryClassNamesStreams(final Filter<String> filter) {
- return new TransformationIterator<Entry, Iterator<String>>(new ArrayIterator<Entry>(this.entries)) {
- @Override
- protected Iterator<String> transform(Entry entry) {
- return entry.classNamesStream(filter);
- }
- };
- }
-
- /**
- * Return a "compressed" version of the classpath with its
- * duplicate entries eliminated.
- */
- public Classpath compressed() {
- return new Classpath(CollectionTools.removeDuplicateElements(this.entries));
- }
-
- /**
- * Convert the classpath to an array of URLs
- * (that can be used to instantiate a URLClassLoader).
- */
- public URL[] urls() {
- Entry[] localEntries = this.entries;
- int len = localEntries.length;
- URL[] urls = new URL[len];
- for (int i = 0; i < len; i++) {
- urls[i] = localEntries[i].url();
- }
- return urls;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.path());
- }
-
-
- // ********** inner class **********
-
- /**
- * TODO
- */
- public static class Entry implements Serializable {
- private final String fileName;
- private final File file;
- private final File canonicalFile;
-
- private static final long serialVersionUID = 1L;
-
- Entry(String fileName) {
- super();
- if ((fileName == null) || (fileName.length() == 0)) {
- throw new IllegalArgumentException("'fileName' must be non-empty");
- }
- this.fileName = fileName;
- this.file = new File(fileName);
- this.canonicalFile = FileTools.canonicalFile(this.file);
- }
-
- public String fileName() {
- return this.fileName;
- }
-
- public File file() {
- return this.file;
- }
-
- public File canonicalFile() {
- return this.canonicalFile;
- }
-
- public String canonicalFileName() {
- return this.canonicalFile.getAbsolutePath();
- }
-
- @Override
- public boolean equals(Object o) {
- if ( ! (o instanceof Entry)) {
- return false;
- }
- return ((Entry) o).canonicalFile.equals(this.canonicalFile);
- }
-
- @Override
- public int hashCode() {
- return this.canonicalFile.hashCode();
- }
-
- /**
- * Return the entry's "canonical" URL.
- */
- public URL url() {
- try {
- return this.canonicalFile.toURL();
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * Return whether the entry contains the specified class.
- */
- public boolean contains(Class<?> javaClass) {
- return this.contains(javaClass.getName());
- }
-
- /**
- * Return whether the entry contains the specified class.
- */
- public boolean contains(String className) {
- return this.contains(convertToClassFileName(className), convertToArchiveClassFileEntryName(className));
- }
-
- /**
- * Return whether the entry contains either the specified relative
- * class file or the specified archive entry.
- * Not the prettiest signature, but it's internal....
- */
- boolean contains(String relativeClassFileName, String archiveEntryName) {
- if ( ! this.canonicalFile.exists()) {
- return false;
- }
- if (this.canonicalFile.isDirectory() && (new File(this.canonicalFile, relativeClassFileName)).exists()) {
- return true;
- }
- return (fileIsArchive(this.canonicalFile) && this.archiveContainsEntry(archiveEntryName));
- }
-
- /**
- * Return whether the entry's archive contains the specified entry.
- */
- private boolean archiveContainsEntry(String zipEntryName) {
- ZipFile zipFile = null;
- ZipEntry zipEntry = null;
- try {
- zipFile = new ZipFile(this.canonicalFile);
- zipEntry = zipFile.getEntry(zipEntryName);
- } catch (IOException ex) {
- // something is wrong, leave the entry null
- } finally {
- try {
- if (zipFile != null) {
- zipFile.close();
- }
- } catch (IOException ex) {
- zipEntry = null; // something is wrong, clear out the entry
- }
- }
- return zipEntry != null;
- }
-
- /**
- * Return the names of all the classes discovered in the entry.
- */
- public String[] classNames() {
- return this.classNames(Filter.Null.<String>instance());
- }
-
- /**
- * Return the names of all the classes discovered in the entry
- * and accepted by the specified filter.
- */
- public String[] classNames(Filter<String> filter) {
- Collection<String> classNames = new ArrayList<String>(2000);
- this.addClassNamesTo(classNames, filter);
- return classNames.toArray(new String[classNames.size()]);
- }
-
- /**
- * Add the names of all the classes discovered in the entry
- * to the specified collection.
- */
- public void addClassNamesTo(Collection<String> classNames) {
- this.addClassNamesTo(classNames, Filter.Null.<String>instance());
- }
-
- /**
- * Add the names of all the classes discovered in the entry
- * and accepted by the specified filter to the specified collection.
- */
- public void addClassNamesTo(Collection<String> classNames, Filter<String> filter) {
- if (this.canonicalFile.exists()) {
- if (this.canonicalFile.isDirectory()) {
- this.addClassNamesForDirectoryTo(classNames, filter);
- } else if (fileIsArchive(this.canonicalFile)) {
- this.addClassNamesForArchiveTo(classNames, filter);
- }
- }
- }
-
- /**
- * Add the names of all the classes discovered
- * under the entry's directory and accepted by
- * the specified filter to the specified collection.
- */
- private void addClassNamesForDirectoryTo(Collection<String> classNames, Filter<String> filter) {
- int start = this.canonicalFile.getAbsolutePath().length() + 1;
- for (Iterator<File> stream = this.classFilesForDirectory(); stream.hasNext(); ) {
- String className = convertToClassName(stream.next().getAbsolutePath().substring(start));
- if (filter.accept(className)) {
- classNames.add(className);
- }
- }
- }
-
- /**
- * Return an iterator on all the class files discovered
- * under the entry's directory.
- */
- private Iterator<File> classFilesForDirectory() {
- return new FilteringIterator<File, File>(FileTools.filesInTree(this.canonicalFile)) {
- @Override
- protected boolean accept(File next) {
- return Entry.this.fileNameMightBeForClassFile(next.getName());
- }
- };
- }
-
- /**
- * Add the names of all the classes discovered
- * in the entry's archive file and accepted by the
- * specified filter to the specified collection.
- */
- private void addClassNamesForArchiveTo(Collection<String> classNames, Filter<String> filter) {
- ZipFile zipFile = null;
- try {
- zipFile = new ZipFile(this.canonicalFile);
- } catch (IOException ex) {
- return;
- }
- for (Enumeration<? extends ZipEntry> stream = zipFile.entries(); stream.hasMoreElements(); ) {
- ZipEntry zipEntry = stream.nextElement();
- String zipEntryName = zipEntry.getName();
- if (this.fileNameMightBeForClassFile(zipEntryName)) {
- String className = convertToClassName(zipEntryName);
- if (filter.accept(className)) {
- classNames.add(className);
- }
- }
- }
- try {
- zipFile.close();
- } catch (IOException ex) {
- return;
- }
- }
-
- /**
- * Return whether the specified file might be a Java class file.
- * The file name must at least end with ".class" and contain no spaces.
- * (Neither class names nor package names may contain spaces.)
- * Whether it actually is a class file will need to be determined by
- * a class loader.
- */
- boolean fileNameMightBeForClassFile(String name) {
- return FileTools.extension(name).toLowerCase().equals(".class")
- && (name.indexOf(' ') == -1);
- }
-
- /**
- * Return the names of all the classes discovered on the classpath.
- * Just a bit more performant than #classNames().
- */
- public Iterator<String> classNamesStream() {
- return this.classNamesStream(Filter.Null.<String>instance());
- }
-
- /**
- * Return the names of all the classes discovered on the classpath
- * that are accepted by the specified filter.
- * Just a bit more performant than #classNames(Filter).
- */
- public Iterator<String> classNamesStream(Filter<String> filter) {
- if (this.canonicalFile.exists()) {
- if (this.canonicalFile.isDirectory()) {
- return this.classNamesForDirectory(filter);
- }
- if (fileIsArchive(this.canonicalFile)) {
- return this.classNamesForArchive(filter);
- }
- }
- return EmptyIterator.instance();
- }
-
- /**
- * Return the names of all the classes discovered
- * under the entry's directory and accepted by
- * the specified filter.
- */
- private Iterator<String> classNamesForDirectory(Filter<String> filter) {
- return new FilteringIterator<String, String>(this.classNamesForDirectory(), filter);
- }
-
- /**
- * Transform the class files to class names.
- */
- private Iterator<String> classNamesForDirectory() {
- final int start = this.canonicalFile.getAbsolutePath().length() + 1;
- return new TransformationIterator<File, String>(this.classFilesForDirectory()) {
- @Override
- protected String transform(File f) {
- return convertToClassName(f.getAbsolutePath().substring(start));
- }
- };
- }
-
- /**
- * Return the names of all the classes discovered
- * in the entry's archive file and accepted by the
- * specified filter.
- */
- private Iterator<String> classNamesForArchive(Filter<String> filter) {
- // we can't simply wrap iterators here because we need to close the archive file...
- ZipFile zipFile = null;
- try {
- zipFile = new ZipFile(this.canonicalFile);
- } catch (IOException ex) {
- return EmptyIterator.instance();
- }
- Collection<String> classNames = new HashSet<String>(zipFile.size());
- for (Enumeration<? extends ZipEntry> stream = zipFile.entries(); stream.hasMoreElements(); ) {
- ZipEntry zipEntry = stream.nextElement();
- String zipEntryName = zipEntry.getName();
- if (this.fileNameMightBeForClassFile(zipEntryName)) {
- String className = convertToClassName(zipEntryName);
- if (filter.accept(className)) {
- classNames.add(className);
- }
- }
- }
- try {
- zipFile.close();
- } catch (IOException ex) {
- return EmptyIterator.instance();
- }
- return classNames.iterator();
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/CollectionTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/CollectionTools.java
deleted file mode 100644
index 3b7ed63b3e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/CollectionTools.java
+++ /dev/null
@@ -1,3901 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Random;
-import java.util.RandomAccess;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.Vector;
-
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.utility.internal.iterators.GenericIteratorWrapper;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
-
-public final class CollectionTools {
-
- @SuppressWarnings("unchecked")
- private static <E> E[] newArray(E[] array, int length) {
- return (E[]) Array.newInstance(array.getClass().getComponentType(), length);
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array followed by the specified object to be added.
- * java.util.Arrays#add(Object[] array, Object o)
- */
- public static <E> E[] add(E[] array, E value) {
- int len = array.length;
- E[] result = newArray(array, len + 1);
- if (len > 0) {
- System.arraycopy(array, 0, result, 0, len);
- }
- result[len] = value;
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified object added at the specified index.
- * java.util.Arrays#add(Object[] array, int index, Object o)
- */
- public static <E> E[] add(E[] array, int index, E value) {
- int len = array.length;
- E[] result = newArray(array, len + 1);
- if (index > 0) {
- System.arraycopy(array, 0, result, 0, index);
- }
- result[index] = value;
- if (len > index) {
- System.arraycopy(array, index, result, index + 1, len - index);
- }
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array followed by the specified value to be added.
- * java.util.Arrays#add(char[] array, char value)
- */
- public static char[] add(char[] array, char value) {
- int len = array.length;
- char[] result = new char[len + 1];
- if (len > 0) {
- System.arraycopy(array, 0, result, 0, len);
- }
- result[len] = value;
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified value added at the specified index.
- * java.util.Arrays#add(char[] array, int index, char value)
- */
- public static char[] add(char[] array, int index, char value) {
- int len = array.length;
- char[] result = new char[len + 1];
- if (index > 0) {
- System.arraycopy(array, 0, result, 0, index);
- }
- result[index] = value;
- if (len > index) {
- System.arraycopy(array, index, result, index + 1, len - index);
- }
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array followed by the specified value to be added.
- * java.util.Arrays#add(int[] array, int value)
- */
- public static int[] add(int[] array, int value) {
- int len = array.length;
- int[] result = new int[len + 1];
- if (len > 0) {
- System.arraycopy(array, 0, result, 0, len);
- }
- result[len] = value;
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified value added at the specified index.
- * java.util.Arrays#add(int[] array, int index, int value)
- */
- public static int[] add(int[] array, int index, int value) {
- int len = array.length;
- int[] result = new int[len + 1];
- if (index > 0) {
- System.arraycopy(array, 0, result, 0, index);
- }
- result[index] = value;
- if (len > index) {
- System.arraycopy(array, index, result, index + 1, len - index);
- }
- return result;
- }
-
- /**
- * Add all the elements returned by the specified iterable
- * to the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#addAll(java.lang.Iterable iterable)
- */
- public static <E> boolean addAll(Collection<? super E> collection, Iterable<? extends E> iterable) {
- return addAll(collection, iterable.iterator());
- }
-
- /**
- * Add all the elements returned by the specified iterable
- * to the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#addAll(java.lang.Iterable iterable)
- */
- public static <E> boolean addAll(Collection<? super E> collection, Iterable<? extends E> iterable, int size) {
- return addAll(collection, iterable.iterator(), size);
- }
-
- /**
- * Add all the elements returned by the specified iterator
- * to the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#addAll(java.util.Iterator iterator)
- */
- public static <E> boolean addAll(Collection<? super E> collection, Iterator<? extends E> iterator) {
- return (iterator.hasNext()) ? collection.addAll(list(iterator)) : false;
- }
-
- /**
- * Add all the elements returned by the specified iterator
- * to the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#addAll(java.util.Iterator iterator)
- */
- public static <E> boolean addAll(Collection<? super E> collection, Iterator<? extends E> iterator, int size) {
- return (iterator.hasNext()) ? collection.addAll(list(iterator, size)) : false;
- }
-
- /**
- * Add all the elements in the specified array
- * to the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#addAll(Object[] array)
- */
- public static <E> boolean addAll(Collection<? super E> collection, E[] array) {
- return (array.length == 0) ? false : collection.addAll(Arrays.asList(array));
- }
-
- /**
- * Add all the elements returned by the specified iterable
- * to the specified list at the specified index.
- * Return whether the list changed as a result.
- * java.util.List#addAll(java.lang.Iterable iterable)
- */
- public static <E> boolean addAll(List<? super E> list, int index, Iterable<E> iterable) {
- return addAll(list, index, iterable.iterator());
- }
-
- /**
- * Add all the elements returned by the specified iterable
- * to the specified list at the specified index.
- * Return whether the list changed as a result.
- * java.util.List#addAll(java.lang.Iterable iterable)
- */
- public static <E> boolean addAll(List<? super E> list, int index, Iterable<E> iterable, int size) {
- return addAll(list, index, iterable.iterator(), size);
- }
-
- /**
- * Add all the elements returned by the specified iterator
- * to the specified list at the specified index.
- * Return whether the list changed as a result.
- * java.util.List#addAll(java.util.Iterator iterator)
- */
- public static <E> boolean addAll(List<? super E> list, int index, Iterator<? extends E> iterator) {
- return (iterator.hasNext()) ? list.addAll(index, list(iterator)) : false;
- }
-
- /**
- * Add all the elements returned by the specified iterator
- * to the specified list at the specified index.
- * Return whether the list changed as a result.
- * java.util.List#addAll(java.util.Iterator iterator)
- */
- public static <E> boolean addAll(List<? super E> list, int index, Iterator<? extends E> iterator, int size) {
- return (iterator.hasNext()) ? list.addAll(index, list(iterator, size)) : false;
- }
-
- /**
- * Add all the elements in the specified array
- * to the specified list at the specified index.
- * Return whether the list changed as a result.
- * java.util.List#addAll(Object[] array)
- */
- public static <E> boolean addAll(List<? super E> list, int index, E[] array) {
- return (array.length == 0) ? false : list.addAll(index, Arrays.asList(array));
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array followed by the elements
- * in the specified collection.
- * java.util.Arrays#addAll(Object[] array, java.util.Collection c)
- */
- public static <E> E[] addAll(E[] array, Collection<? extends E> collection) {
- int size = collection.size();
- return (size == 0) ? array : addAll(array, collection, size);
- }
-
- /**
- * assume collection is non-empty
- */
- private static <E> E[] addAll_(E[] array, Collection<? extends E> collection) {
- return addAll(array, collection, collection.size());
- }
-
- /**
- * assume collection is non-empty
- */
- private static <E> E[] addAll(E[] array, Collection<? extends E> collection, int collectionSize) {
- int len = array.length;
- E[] result = newArray(array, len + collectionSize);
- if (len > 0) {
- System.arraycopy(array, 0, result, 0, len);
- }
- int i = len;
- for (E item : collection) {
- result[i++] = item;
- }
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array followed by the elements
- * in the specified iterable.
- * java.util.Arrays#addAll(Object[] array, java.lang.Iterable iterable)
- */
- public static <E> E[] addAll(E[] array, Iterable<? extends E> iterable) {
- return addAll(array, iterable.iterator());
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array followed by the elements
- * in the specified iterable.
- * java.util.Arrays#addAll(Object[] array, java.lang.Iterable iterable)
- */
- public static <E> E[] addAll(E[] array, Iterable<? extends E> iterable, int size) {
- return addAll(array, iterable.iterator(), size);
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array followed by the elements
- * in the specified iterator.
- * java.util.Arrays#addAll(Object[] array, java.util.Iterator iterator)
- */
- public static <E> E[] addAll(E[] array, Iterator<? extends E> iterator) {
- return (iterator.hasNext()) ? addAll_(array, list(iterator)) : array;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array followed by the elements
- * in the specified iterator.
- * java.util.Arrays#addAll(Object[] array, java.util.Iterator iterator)
- */
- public static <E> E[] addAll(E[] array, Iterator<? extends E> iterator, int size) {
- return (iterator.hasNext()) ? addAll_(array, list(iterator, size)) : array;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array 1 followed by the elements
- * in the specified array 2.
- * java.util.Arrays#addAll(Object[] array1, Object[] array2)
- */
- public static <E> E[] addAll(E[] array1, E[] array2) {
- int array2Length = array2.length;
- return (array2Length == 0) ? array1 : addAll(array1, array2, array2Length);
- }
-
- /**
- * assume array2Length > 0
- */
- private static <E> E[] addAll(E[] array1, E[] array2, int array2Length) {
- int array1Length = array1.length;
- return (array1Length == 0) ? array2 : addAll(array1, array2, array1Length, array2Length);
- }
-
- /**
- * assume array1Length > 0 and array2Length > 0
- */
- private static <E> E[] addAll(E[] array1, E[] array2, int array1Length, int array2Length) {
- E[] result = newArray(array1, array1Length + array2Length);
- System.arraycopy(array1, 0, result, 0, array1Length);
- System.arraycopy(array2, 0, result, array1Length, array2Length);
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * first specified array with the objects in the second
- * specified array added at the specified index.
- * java.util.Arrays#add(Object[] array1, int index, Object[] array2)
- */
- public static <E> E[] addAll(E[] array1, int index, E[] array2) {
- int array2Length = array2.length;
- return (array2Length == 0) ? array1 : addAll(array1, index, array2, array2Length);
- }
-
- /**
- * assume array2Length > 0
- */
- private static <E> E[] addAll(E[] array1, int index, E[] array2, int array2Length) {
- int array1Length = array1.length;
- return (index == array1Length) ? // array2 added to end of array1
- (array1Length == 0) ? array2 : addAll(array1, array2, array1Length, array2Length)
- :
- addAll(array1, index, array2, array1Length, array2Length);
- }
-
- /**
- * assume array1Length > 0 and array2Length > 0
- */
- private static <E> E[] addAll(E[] array1, int index, E[] array2, int array1Length, int array2Length) {
- E[] result = newArray(array1, array1Length + array2Length);
- System.arraycopy(array1, 0, result, 0, index);
- System.arraycopy(array2, 0, result, index, array2Length);
- System.arraycopy(array1, index, result, index + array2Length, array1Length - index);
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the elements
- * in the specified collection inserted at the specified index.
- * java.util.Arrays#addAll(Object[] array, int index, java.util.Collection c)
- */
- public static <E> E[] addAll(E[] array, int index, Collection<? extends E> collection) {
- int size = collection.size();
- return (size == 0) ? array : addAll(array, index, collection, size);
- }
-
- /**
- * assume collection is non-empty
- */
- private static <E> E[] addAll_(E[] array, int index, Collection<? extends E> collection) {
- return addAll(array, index, collection, collection.size());
- }
-
- /**
- * assume collection is non-empty
- */
- private static <E> E[] addAll(E[] array, int index, Collection<? extends E> collection, int collectionSize) {
- int arrayLength = array.length;
- E[] result = newArray(array, arrayLength + collectionSize);
- if ((arrayLength == 0) && (index == 0)) {
- return collection.toArray(result);
- }
- System.arraycopy(array, 0, result, 0, index);
- int i = index;
- for (E item : collection) {
- result[i++] = item;
- }
- System.arraycopy(array, index, result, index + collectionSize, arrayLength - index);
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the elements
- * in the specified iterable inserted at the specified index.
- * java.util.Arrays#addAll(Object[] array, int index, java.lang.Iterable iterable)
- */
- public static <E> E[] addAll(E[] array, int index, Iterable<? extends E> iterable) {
- return addAll(array, index, iterable.iterator());
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the elements
- * in the specified iterable inserted at the specified index.
- * java.util.Arrays#addAll(Object[] array, int index, java.lang.Iterable iterable)
- */
- public static <E> E[] addAll(E[] array, int index, Iterable<? extends E> iterable, int size) {
- return addAll(array, index, iterable.iterator(), size);
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the elements
- * in the specified iterator inserted at the specified index.
- * java.util.Arrays#addAll(Object[] array, int index, java.util.Iterator iterator)
- */
- public static <E> E[] addAll(E[] array, int index, Iterator<? extends E> iterator) {
- return (iterator.hasNext()) ? addAll_(array, index, list(iterator)) : array;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the elements
- * in the specified iterator inserted at the specified index.
- * java.util.Arrays#addAll(Object[] array, int index, java.util.Iterator iterator)
- */
- public static <E> E[] addAll(E[] array, int index, Iterator<? extends E> iterator, int size) {
- return (iterator.hasNext()) ? addAll_(array, index, list(iterator, size)) : array;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array 1 followed by the elements
- * in the specified array 2.
- * java.util.Arrays#addAll(char[] array1, char[] array2)
- */
- public static char[] addAll(char[] array1, char[] array2) {
- int array2Length = array2.length;
- return (array2Length == 0) ? array1 : addAll(array1, array2, array2Length);
- }
-
- /**
- * assume array2Length > 0
- */
- private static char[] addAll(char[] array1, char[] array2, int array2Length) {
- int array1Length = array1.length;
- return (array1Length == 0) ? array2 : addAll(array1, array2, array1Length, array2Length);
- }
-
- /**
- * assume array1Length > 0 and array2Length > 0
- */
- private static char[] addAll(char[] array1, char[] array2, int array1Length, int array2Length) {
- char[] result = new char[array1Length + array2Length];
- System.arraycopy(array1, 0, result, 0, array1Length);
- System.arraycopy(array2, 0, result, array1Length, array2Length);
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * first specified array with the objects in the second
- * specified array added at the specified index.
- * java.util.Arrays#add(char[] array1, int index, char[] array2)
- */
- public static char[] addAll(char[] array1, int index, char[] array2) {
- int array2Length = array2.length;
- return (array2Length == 0) ? array1 : addAll(array1, index, array2, array2Length);
- }
-
- /**
- * assume array2Length > 0
- */
- private static char[] addAll(char[] array1, int index, char[] array2, int array2Length) {
- int array1Length = array1.length;
- return (index == array1Length) ? // array2 added to end of array1
- (array1Length == 0) ? array2 : addAll(array1, array2, array1Length, array2Length)
- :
- addAll(array1, index, array2, array1Length, array2Length);
- }
-
- /**
- * assume array1Length > 0 and array2Length > 0
- */
- private static char[] addAll(char[] array1, int index, char[] array2, int array1Length, int array2Length) {
- char[] result = new char[array1Length + array2Length];
- System.arraycopy(array1, 0, result, 0, index);
- System.arraycopy(array2, 0, result, index, array2Length);
- System.arraycopy(array1, index, result, index + array2Length, array1Length - index);
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array 1 followed by the elements
- * in the specified array 2.
- * java.util.Arrays#addAll(int[] array1, int[] array2)
- */
- public static int[] addAll(int[] array1, int[] array2) {
- int array2Length = array2.length;
- return (array2Length == 0) ? array1 : addAll(array1, array2, array2Length);
- }
-
- /**
- * assume array2Length > 0
- */
- private static int[] addAll(int[] array1, int[] array2, int array2Length) {
- int array1Length = array1.length;
- return (array1Length == 0) ? array2 : addAll(array1, array2, array1Length, array2Length);
- }
-
- /**
- * assume array1Length > 0 and array2Length > 0
- */
- private static int[] addAll(int[] array1, int[] array2, int array1Length, int array2Length) {
- int[] result = new int[array1Length + array2Length];
- System.arraycopy(array1, 0, result, 0, array1Length);
- System.arraycopy(array2, 0, result, array1Length, array2Length);
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * first specified array with the objects in the second
- * specified array added at the specified index.
- * java.util.Arrays#add(int[] array1, int index, int[] array2)
- */
- public static int[] addAll(int[] array1, int index, int[] array2) {
- int array2Length = array2.length;
- return (array2Length == 0) ? array1 : addAll(array1, index, array2, array2Length);
- }
-
- /**
- * assume array2Length > 0
- */
- private static int[] addAll(int[] array1, int index, int[] array2, int array2Length) {
- int array1Length = array1.length;
- return (index == array1Length) ? // array2 added to end of array1
- (array1Length == 0) ? array2 : addAll(array1, array2, array1Length, array2Length)
- :
- addAll(array1, index, array2, array1Length, array2Length);
- }
-
- /**
- * assume array1Length > 0 and array2Length > 0
- */
- private static int[] addAll(int[] array1, int index, int[] array2, int array1Length, int array2Length) {
- int[] result = new int[array1Length + array2Length];
- System.arraycopy(array1, 0, result, 0, index);
- System.arraycopy(array2, 0, result, index, array2Length);
- System.arraycopy(array1, index, result, index + array2Length, array1Length - index);
- return result;
- }
-
- /**
- * Return an array corresponding to the specified iterable.
- * @see java.util.Collection#toArray()
- * java.lang.Iterable#toArray()
- */
- public static Object[] array(Iterable<?> iterable) {
- return array(iterable.iterator());
- }
-
- /**
- * Return an array corresponding to the specified iterable.
- * @see java.util.Collection#toArray()
- * java.lang.Iterable#toArray()
- */
- public static Object[] array(Iterable<?> iterable, int size) {
- return array(iterable.iterator(), size);
- }
-
- /**
- * Return an array corresponding to the specified iterable;
- * the runtime type of the returned array is that of the specified array.
- * If the collection fits in the specified array, it is returned therein.
- * Otherwise, a new array is allocated with the runtime type of the
- * specified array and the size of this collection.
- * @see java.util.Collection#toArray(java.lang.Object[])
- * java.lang.Iterable#toArray(Object[])
- */
- public static <E> E[] array(Iterable<? extends E> iterable, E[] array) {
- return array(iterable.iterator(), array);
- }
-
- /**
- * Return an array corresponding to the specified iterable;
- * the runtime type of the returned array is that of the specified array.
- * If the collection fits in the specified array, it is returned therein.
- * Otherwise, a new array is allocated with the runtime type of the
- * specified array and the size of this collection.
- * @see java.util.Collection#toArray(java.lang.Object[])
- * java.lang.Iterable#toArray(Object[])
- */
- public static <E> E[] array(Iterable<? extends E> iterable, int size, E[] array) {
- return array(iterable.iterator(), size, array);
- }
-
- /**
- * Return an array corresponding to the specified iterator.
- * @see java.util.Collection#toArray()
- * java.util.Iterator#toArray()
- */
- public static Object[] array(Iterator<?> iterator) {
- return (iterator.hasNext()) ? list(iterator).toArray() : EMPTY_OBJECT_ARRAY;
- }
- private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
-
- /**
- * Return an array corresponding to the specified iterator.
- * @see java.util.Collection#toArray()
- * java.util.Iterator#toArray()
- */
- public static Object[] array(Iterator<?> iterator, int size) {
- return (iterator.hasNext()) ? list(iterator, size).toArray() : EMPTY_OBJECT_ARRAY;
- }
-
- /**
- * Return an array corresponding to the specified iterator;
- * the runtime type of the returned array is that of the specified array.
- * If the collection fits in the specified array, it is returned therein.
- * Otherwise, a new array is allocated with the runtime type of the
- * specified array and the size of this collection.
- * @see java.util.Collection#toArray(java.lang.Object[])
- * java.util.Iterator#toArray(Object[])
- */
- public static <E> E[] array(Iterator<? extends E> iterator, E[] array) {
- return (iterator.hasNext()) ? list(iterator).toArray(array) : newArray(array, 0);
- }
-
- /**
- * Return an array corresponding to the specified iterator;
- * the runtime type of the returned array is that of the specified array.
- * If the collection fits in the specified array, it is returned therein.
- * Otherwise, a new array is allocated with the runtime type of the
- * specified array and the size of this collection.
- * @see java.util.Collection#toArray(java.lang.Object[])
- * java.util.Iterator#toArray(Object[])
- */
- public static <E> E[] array(Iterator<? extends E> iterator, int size, E[] array) {
- return (iterator.hasNext()) ? list(iterator, size).toArray(array) : newArray(array, 0);
- }
-
- /**
- * Return a bag corresponding to the specified enumeration.
- * HashBag(java.util.Enumeration enumeration)
- */
- public static <E> Bag<E> bag(Enumeration<? extends E> enumeration) {
- return (enumeration.hasMoreElements()) ?
- bag(enumeration, new HashBag<E>())
- :
- Bag.Empty.<E>instance();
- }
-
- /**
- * Return a bag corresponding to the specified enumeration.
- * HashBag(java.util.Enumeration enumeration)
- */
- public static <E> Bag<E> bag(Enumeration<? extends E> enumeration, int size) {
- return (enumeration.hasMoreElements()) ?
- bag(enumeration, new HashBag<E>(size))
- :
- Bag.Empty.<E>instance();
- }
-
- private static <E> Bag<E> bag(Enumeration<? extends E> enumeration, HashBag<E> bag) {
- while (enumeration.hasMoreElements()) {
- bag.add(enumeration.nextElement());
- }
- return bag;
- }
-
- /**
- * Return a bag corresponding to the specified iterable.
- * HashBag(java.lang.Iterable iterable)
- */
- public static <E> Bag<E> bag(Iterable<? extends E> iterable) {
- return bag(iterable.iterator());
- }
-
- /**
- * Return a bag corresponding to the specified iterable.
- * HashBag(java.lang.Iterable iterable)
- */
- public static <E> Bag<E> bag(Iterable<? extends E> iterable, int size) {
- return bag(iterable.iterator(), size);
- }
-
- /**
- * Return a bag corresponding to the specified iterator.
- * HashBag(java.util.Iterator iterator)
- */
- public static <E> Bag<E> bag(Iterator<? extends E> iterator) {
- return (iterator.hasNext()) ?
- bag(iterator, new HashBag<E>())
- :
- Bag.Empty.<E>instance();
- }
-
- /**
- * Return a bag corresponding to the specified iterator.
- * HashBag(java.util.Iterator iterator)
- */
- public static <E> Bag<E> bag(Iterator<? extends E> iterator, int size) {
- return (iterator.hasNext()) ?
- bag(iterator, new HashBag<E>(size))
- :
- Bag.Empty.<E>instance();
- }
-
- private static <E> Bag<E> bag(Iterator<? extends E> iterator, HashBag<E> bag) {
- while (iterator.hasNext()) {
- bag.add(iterator.next());
- }
- return bag;
- }
-
- /**
- * Return a bag corresponding to the specified array.
- * HashBag(Object[] array)
- */
- public static <E> Bag<E> bag(E... array) {
- int len = array.length;
- if (len == 0) {
- return Bag.Empty.<E>instance();
- }
- Bag<E> bag = new HashBag<E>(len);
- for (E item : array) {
- bag.add(item);
- }
- return bag;
- }
-
- /**
- * Return a collection corresponding to the specified enumeration.
- */
- public static <E> Collection<E> collection(Enumeration<? extends E> enumeration) {
- return bag(enumeration);
- }
-
- /**
- * Return a collection corresponding to the specified enumeration.
- */
- public static <E> Collection<E> collection(Enumeration<? extends E> enumeration, int size) {
- return bag(enumeration, size);
- }
-
- /**
- * Return a collection corresponding to the specified iterable.
- */
- public static <E> Collection<E> collection(Iterable<? extends E> iterable) {
- return collection(iterable.iterator());
- }
-
- /**
- * Return a collection corresponding to the specified iterable.
- */
- public static <E> Collection<E> collection(Iterable<? extends E> iterable, int size) {
- return collection(iterable.iterator(), size);
- }
-
- /**
- * Return a collection corresponding to the specified iterator.
- */
- public static <E> Collection<E> collection(Iterator<? extends E> iterator) {
- return bag(iterator);
- }
-
- /**
- * Return a collection corresponding to the specified iterator.
- */
- public static <E> Collection<E> collection(Iterator<? extends E> iterator, int size) {
- return bag(iterator, size);
- }
-
- /**
- * Return a collection corresponding to the specified array.
- */
- public static <E> Collection<E> collection(E... array) {
- return bag(array);
- }
-
- /**
- * Return whether the specified enumeration contains the
- * specified element.
- * java.util.Enumeration#contains(Object o)
- */
- public static boolean contains(Enumeration<?> enumeration, Object value) {
- if (value == null) {
- while (enumeration.hasMoreElements()) {
- if (enumeration.nextElement() == null) {
- return true;
- }
- }
- } else {
- while (enumeration.hasMoreElements()) {
- if (value.equals(enumeration.nextElement())) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified iterable contains the
- * specified element.
- * java.lang.Iterable#contains(Object o)
- */
- public static boolean contains(Iterable<?> iterable, Object value) {
- return contains(iterable.iterator(), value);
- }
-
- /**
- * Return whether the specified iterator contains the
- * specified element.
- * java.util.Iterator#contains(Object o)
- */
- public static boolean contains(Iterator<?> iterator, Object value) {
- if (value == null) {
- while (iterator.hasNext()) {
- if (iterator.next() == null) {
- return true;
- }
- }
- } else {
- while (iterator.hasNext()) {
- if (value.equals(iterator.next())) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified array contains the
- * specified element.
- * java.util.Arrays#contains(Object[] array, Object o)
- */
- public static boolean contains(Object[] array, Object value) {
- if (value == null) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == null) {
- return true;
- }
- }
- } else {
- for (int i = array.length; i-- > 0; ) {
- if (value.equals(array[i])) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified array contains the
- * specified element.
- * java.util.Arrays#contains(char[] array, char value)
- */
- public static boolean contains(char[] array, char value) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified array contains the
- * specified element.
- * java.util.Arrays#contains(int[] array, int value)
- */
- public static boolean contains(int[] array, int value) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified collection contains all of the
- * elements in the specified iterable.
- * java.util.Collection#containsAll(java.lang.Iterable iterable)
- */
- public static boolean containsAll(Collection<?> collection, Iterable<?> iterable) {
- return containsAll(collection, iterable.iterator());
- }
-
- /**
- * Return whether the specified collection contains all of the
- * elements in the specified iterator.
- * java.util.Collection#containsAll(java.util.Iterator iterator)
- */
- public static boolean containsAll(Collection<?> collection, Iterator<?> iterator) {
- while (iterator.hasNext()) {
- if ( ! collection.contains(iterator.next())) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified collection contains all of the
- * elements in the specified array.
- * java.util.Collection#containsAll(Object[] array)
- */
- public static boolean containsAll(Collection<?> collection, Object[] array) {
- for (int i = array.length; i-- > 0; ) {
- if ( ! collection.contains(array[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified iterable contains all of the
- * elements in the specified collection.
- * java.lang.Iterable#containsAll(java.util.Collection collection)
- */
- public static boolean containsAll(Iterable<?> iterable, Collection<?> collection) {
- return containsAll(iterable.iterator(), collection);
- }
-
- /**
- * Return whether the specified iterable contains all of the
- * elements in the specified collection.
- * java.lang.Iterable#containsAll(java.util.Collection collection)
- */
- public static boolean containsAll(Iterable<?> iterable, int size, Collection<?> collection) {
- return containsAll(iterable.iterator(), size, collection);
- }
-
- /**
- * Return whether the specified iterable 1 contains all of the
- * elements in the specified iterable 2.
- * java.lang.Iterable#containsAll(java.lang.Iterable iterable)
- */
- public static boolean containsAll(Iterable<?> iterable1, Iterable<?> iterable2) {
- return containsAll(iterable1.iterator(), iterable2.iterator());
- }
-
- /**
- * Return whether the specified iterable 1 contains all of the
- * elements in the specified iterable 2.
- * java.lang.Iterable#containsAll(java.lang.Iterable iterable)
- */
- public static boolean containsAll(Iterable<?> iterable1, int size, Iterable<?> iterable2) {
- return containsAll(iterable1.iterator(), size, iterable2.iterator());
- }
-
- /**
- * Return whether the specified iterable contains all of the
- * elements in the specified iterator.
- * java.lang.Iterable#containsAll(java.util.Iterator iterator)
- */
- public static boolean containsAll(Iterable<?> iterable, Iterator<?> iterator) {
- return containsAll(iterable.iterator(), iterator);
- }
-
- /**
- * Return whether the specified iterable contains all of the
- * elements in the specified iterator.
- * java.lang.Iterable#containsAll(java.util.Iterator iterator)
- */
- public static boolean containsAll(Iterable<?> iterable, int size, Iterator<?> iterator) {
- return containsAll(iterable.iterator(), size, iterator);
- }
-
- /**
- * Return whether the specified iterable contains all of the
- * elements in the specified array.
- * java.lang.Iterable#containsAll(Object[] array)
- */
- public static boolean containsAll(Iterable<?> iterable, Object[] array) {
- return containsAll(iterable.iterator(), array);
- }
-
- /**
- * Return whether the specified iterable contains all of the
- * elements in the specified array.
- * java.lang.Iterable#containsAll(Object[] array)
- */
- public static boolean containsAll(Iterable<?> iterable, int size, Object[] array) {
- return containsAll(iterable.iterator(), size, array);
- }
-
- /**
- * Return whether the specified iterator contains all of the
- * elements in the specified collection.
- * java.util.Iterator#containsAll(java.util.Collection collection)
- */
- public static boolean containsAll(Iterator<?> iterator, Collection<?> collection) {
- return collection(iterator).containsAll(collection);
- }
-
- /**
- * Return whether the specified iterator contains all of the
- * elements in the specified collection.
- * java.util.Iterator#containsAll(java.util.Collection collection)
- */
- public static boolean containsAll(Iterator<?> iterator, int size, Collection<?> collection) {
- return collection(iterator, size).containsAll(collection);
- }
-
- /**
- * Return whether the specified iterator contains all of the
- * elements in the specified iterable.
- * java.util.Iterator#containsAll(java.lang.Iterable iterable)
- */
- public static boolean containsAll(Iterator<?> iterator, Iterable<?> iterable) {
- return containsAll(collection(iterator), iterable);
- }
-
- /**
- * Return whether the specified iterator contains all of the
- * elements in the specified iterable.
- * java.util.Iterator#containsAll(java.lang.Iterable iterable)
- */
- public static boolean containsAll(Iterator<?> iterator, int size, Iterable<?> iterable) {
- return containsAll(collection(iterator, size), iterable);
- }
-
- /**
- * Return whether the specified iterator 1 contains all of the
- * elements in the specified iterator 2.
- * java.util.Iterator#containsAll(java.util.Iterator iterator)
- */
- public static boolean containsAll(Iterator<?> iterator1, Iterator<?> iterator2) {
- return containsAll(collection(iterator1), iterator2);
- }
-
- /**
- * Return whether the specified iterator 1 contains all of the
- * elements in the specified iterator 2.
- * java.util.Iterator#containsAll(java.util.Iterator iterator)
- */
- public static boolean containsAll(Iterator<?> iterator1, int size, Iterator<?> iterator2) {
- return containsAll(collection(iterator1, size), iterator2);
- }
-
- /**
- * Return whether the specified iterator contains all of the
- * elements in the specified array.
- * java.util.Iterator#containsAll(Object[] array)
- */
- public static boolean containsAll(Iterator<?> iterator, Object[] array) {
- return containsAll(collection(iterator), array);
- }
-
- /**
- * Return whether the specified iterator contains all of the
- * elements in the specified array.
- * java.util.Iterator#containsAll(Object[] array)
- */
- public static boolean containsAll(Iterator<?> iterator, int size, Object[] array) {
- return containsAll(collection(iterator, size), array);
- }
-
- /**
- * Return whether the specified array contains all of the
- * elements in the specified collection.
- * java.util.Arrays#containsAll(Object[] array, java.util.Collection collection)
- */
- public static boolean containsAll(Object[] array, Collection<?> collection) {
- return containsAll(array, collection.iterator());
- }
-
- /**
- * Return whether the specified array contains all of the
- * elements in the specified iterable.
- * java.util.Arrays#containsAll(Object[] array, java.lang.Iterable iterable)
- */
- public static boolean containsAll(Object[] array, Iterable<?> iterable) {
- return containsAll(array, iterable.iterator());
- }
-
- /**
- * Return whether the specified array contains all of the
- * elements in the specified iterator.
- * java.util.Arrays#containsAll(Object[] array, java.util.Iterator iterator)
- */
- public static boolean containsAll(Object[] array, Iterator<?> iterator) {
- while (iterator.hasNext()) {
- if ( ! contains(array, iterator.next())) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified array 1 contains all of the
- * elements in the specified array 2.
- * java.util.Arrays#containsAll(Object[] array1, Object[] array2)
- */
- public static boolean containsAll(Object[] array1, Object[] array2) {
- for (int i = array2.length; i-- > 0; ) {
- if ( ! contains(array1, array2[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified array 1 contains all of the
- * elements in the specified array 2.
- * java.util.Arrays#containsAll(char[] array1, char[] array2)
- */
- public static boolean containsAll(char[] array1, char[] array2) {
- for (int i = array2.length; i-- > 0; ) {
- if ( ! contains(array1, array2[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified array 1 contains all of the
- * elements in the specified array 2.
- * java.util.Arrays#containsAll(int[] array1, int[] array2)
- */
- public static boolean containsAll(int[] array1, int[] array2) {
- for (int i = array2.length; i-- > 0; ) {
- if ( ! contains(array1, array2[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return the index of the first elements in the specified
- * arrays that are different, beginning at the end.
- * If the arrays are identical, return -1.
- * If the arrays are different sizes, return the index of the
- * last element in the longer array.
- * Use the elements' #equals() method to compare the
- * elements.
- */
- public static int diffEnd(Object[] array1, Object[] array2) {
- return diffEnd(Arrays.asList(array1), Arrays.asList(array2));
- }
-
- /**
- * Return the index of the first elements in the specified
- * lists that are different, beginning at the end.
- * If the lists are identical, return -1.
- * If the lists are different sizes, return the index of the
- * last element in the longer list.
- * Use the elements' #equals() method to compare the
- * elements.
- */
- public static int diffEnd(List<?> list1, List<?> list2) {
- int size1 = list1.size();
- int size2 = list2.size();
- if (size1 != size2) {
- return Math.max(size1, size2) - 1;
- }
- int end = size1 - 1;
- while (end > -1) {
- Object o = list1.get(end);
- if (o == null) {
- if (list2.get(end) == null) {
- end--;
- } else {
- return end;
- }
- } else {
- if (o.equals(list2.get(end))) {
- end--;
- } else {
- return end;
- }
- }
- }
- return end;
- }
-
- /**
- * Return the range of elements in the specified
- * arrays that are different.
- * If the arrays are identical, return [size, -1].
- * Use the elements' #equals() method to compare the
- * elements.
- * @see #diffStart(Object[], Object[])
- * @see #diffEnd(Object[], Object[])
- */
- public static Range diffRange(Object[] array1, Object[] array2) {
- return diffRange(Arrays.asList(array1), Arrays.asList(array2));
- }
-
- /**
- * Return the range of elements in the specified
- * arrays that are different.
- * If the arrays are identical, return [size, -1].
- * Use the elements' #equals() method to compare the
- * elements.
- * @see #diffStart(java.util.List, java.util.List)
- * @see #diffEnd(java.util.List, java.util.List)
- */
- public static Range diffRange(List<?> list1, List<?> list2) {
- int end = diffEnd(list1, list2);
- if (end == -1) {
- // the lists are identical, the start is the size of the two lists
- return new Range(list1.size(), end);
- }
- // the lists are different, calculate the start of the range
- return new Range(diffStart(list1, list2), end);
- }
-
- /**
- * Return the index of the first elements in the specified
- * arrays that are different. If the arrays are identical, return
- * the size of the two arrays (i.e. one past the last index).
- * If the arrays are different sizes and all the elements in
- * the shorter array match their corresponding elements in
- * the longer array, return the size of the shorter array
- * (i.e. one past the last index of the shorter array).
- * Use the elements' #equals() method to compare the
- * elements.
- */
- public static int diffStart(Object[] array1, Object[] array2) {
- return diffStart(Arrays.asList(array1), Arrays.asList(array2));
- }
-
- /**
- * Return the index of the first elements in the specified
- * lists that are different. If the lists are identical, return
- * the size of the two lists (i.e. one past the last index).
- * If the lists are different sizes and all the elements in
- * the shorter list match their corresponding elements in
- * the longer list, return the size of the shorter list
- * (i.e. one past the last index of the shorter list).
- * Use the elements' #equals() method to compare the
- * elements.
- */
- public static int diffStart(List<?> list1, List<?> list2) {
- int end = Math.min(list1.size(), list2.size());
- int start = 0;
- while (start < end) {
- Object o = list1.get(start);
- if (o == null) {
- if (list2.get(start) == null) {
- start++;
- } else {
- return start;
- }
- } else {
- if (o.equals(list2.get(start))) {
- start++;
- } else {
- return start;
- }
- }
- }
- return start;
- }
-
- /**
- * Return whether the specified iterators return equal elements.
- * java.util.Iterator#equals(java.util.Iterator iterator)
- */
- public static boolean equals(Iterator<?> iterator1, Iterator<?> iterator2) {
- while (iterator1.hasNext() && iterator2.hasNext()) {
- Object o1 = iterator1.next();
- Object o2 = iterator2.next();
- if ( ! (o1 == null ? o2 == null : o1.equals(o2))) {
- return false;
- }
- }
- return ! (iterator1.hasNext() || iterator2.hasNext());
- }
-
- /**
- * Return the element corresponding to the specified index
- * in the specified iterator.
- * java.util.ListIterator#get(int index)
- */
- public static <E> E get(ListIterator<? extends E> iterator, int index) {
- while (iterator.hasNext()) {
- E next = iterator.next();
- if (iterator.previousIndex() == index) {
- return next;
- }
- }
- throw new IndexOutOfBoundsException(String.valueOf(index) + ':' + String.valueOf(iterator.previousIndex()));
- }
-
- /**
- * Return whether the specified arrays contain the same elements.
- * java.util.Arrays#identical(Object[] array1, Object[] array2)
- */
- public static boolean identical(Object[] array1, Object[] array2) {
- if (array1 == array2) {
- return true;
- }
- if (array1 == null || array2 == null) {
- return false;
- }
- int length = array1.length;
- if (array2.length != length) {
- return false;
- }
- for (int i = length; i-- > 0; ) {
- if (array1[i] != array2[i]) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified iterators return the same elements.
- * java.util.Iterator#identical(java.util.Iterator iterator)
- */
- public static boolean identical(Iterator<?> iterator1, Iterator<?> iterator2) {
- while (iterator1.hasNext() && iterator2.hasNext()) {
- if (iterator1.next() != iterator2.next()) {
- return false;
- }
- }
- return ! (iterator1.hasNext() || iterator2.hasNext());
- }
-
- /**
- * Return the index of the first elements in the specified
- * arrays that are different, beginning at the end.
- * If the arrays are identical, return -1.
- * If the arrays are different sizes, return the index of the
- * last element in the longer array.
- * Use object identity to compare the elements.
- */
- public static int identityDiffEnd(Object[] array1, Object[] array2) {
- return identityDiffEnd(Arrays.asList(array1), Arrays.asList(array2));
- }
-
- /**
- * Return the index of the first elements in the specified
- * lists that are different, beginning at the end.
- * If the lists are identical, return -1.
- * If the lists are different sizes, return the index of the
- * last element in the longer list.
- * Use object identity to compare the elements.
- */
- public static int identityDiffEnd(List<?> list1, List<?> list2) {
- int size1 = list1.size();
- int size2 = list2.size();
- if (size1 != size2) {
- return Math.max(size1, size2) - 1;
- }
- int end = size1 - 1;
- while (end > -1) {
- if (list1.get(end) == list2.get(end)) {
- end--;
- } else {
- return end;
- }
- }
- return end;
- }
-
- /**
- * Return the range of elements in the specified
- * arrays that are different.
- * If the arrays are identical, return [size, -1].
- * Use object identity to compare the elements.
- * @see #identityDiffStart(Object[], Object[])
- * @see #identityDiffEnd(Object[], Object[])
- */
- public static Range identityDiffRange(Object[] array1, Object[] array2) {
- return identityDiffRange(Arrays.asList(array1), Arrays.asList(array2));
- }
-
- /**
- * Return the range of elements in the specified
- * arrays that are different.
- * If the arrays are identical, return [size, -1].
- * Use object identity to compare the elements.
- * @see #identityDiffStart(java.util.List, java.util.List)
- * @see #identityDiffEnd(java.util.List, java.util.List)
- */
- public static Range identityDiffRange(List<?> list1, List<?> list2) {
- int end = identityDiffEnd(list1, list2);
- if (end == -1) {
- // the lists are identical, the start is the size of the two lists
- return new Range(list1.size(), end);
- }
- // the lists are different, calculate the start of the range
- return new Range(identityDiffStart(list1, list2), end);
- }
-
- /**
- * Return the index of the first elements in the specified
- * arrays that are different. If the arrays are identical, return
- * the size of the two arrays (i.e. one past the last index).
- * If the arrays are different sizes and all the elements in
- * the shorter array match their corresponding elements in
- * the longer array, return the size of the shorter array
- * (i.e. one past the last index of the shorter array).
- * Use object identity to compare the elements.
- */
- public static int identityDiffStart(Object[] array1, Object[] array2) {
- return identityDiffStart(Arrays.asList(array1), Arrays.asList(array2));
- }
-
- /**
- * Return the index of the first elements in the specified
- * lists that are different. If the lists are identical, return
- * the size of the two lists (i.e. one past the last index).
- * If the lists are different sizes and all the elements in
- * the shorter list match their corresponding elements in
- * the longer list, return the size of the shorter list
- * (i.e. one past the last index of the shorter list).
- * Use object identity to compare the elements.
- */
- public static int identityDiffStart(List<?> list1, List<?> list2) {
- int end = Math.min(list1.size(), list2.size());
- int start = 0;
- while (start < end) {
- if (list1.get(start) == list2.get(start)) {
- start++;
- } else {
- return start;
- }
- }
- return start;
- }
-
- /**
- * Return the index of the first occurrence of the
- * specified element in the specified iterator,
- * or return -1 if there is no such index.
- * java.util.Iterator#indexOf(Object o)
- */
- public static int indexOf(Iterator<?> iterator, Object value) {
- if (value == null) {
- for (int i = 0; iterator.hasNext(); i++) {
- if (iterator.next() == null) {
- return i;
- }
- }
- } else {
- for (int i = 0; iterator.hasNext(); i++) {
- if (value.equals(iterator.next())) {
- return i;
- }
- }
- }
- return -1;
- }
-
- /**
- * Return the index of the first occurrence of the
- * specified element in the specified array,
- * or return -1 if there is no such index.
- * java.util.Arrays#indexOf(Object[] array, Object o)
- */
- public static int indexOf(Object[] array, Object value) {
- int len = array.length;
- if (value == null) {
- for (int i = 0; i < len; i++) {
- if (array[i] == null) {
- return i;
- }
- }
- } else {
- for (int i = 0; i < len; i++) {
- if (value.equals(array[i])) {
- return i;
- }
- }
- }
- return -1;
- }
-
- /**
- * Return the index of the first occurrence of the
- * specified element in the specified array,
- * or return -1 if there is no such index.
- * java.util.Arrays#indexOf(char[] array, char value)
- */
- public static int indexOf(char[] array, char value) {
- int len = array.length;
- for (int i = 0; i < len; i++) {
- if (array[i] == value) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Return the index of the first occurrence of the
- * specified element in the specified array,
- * or return -1 if there is no such index.
- * java.util.Arrays#indexOf(int[] array, int value)
- */
- public static int indexOf(int[] array, int value) {
- int len = array.length;
- for (int i = 0; i < len; i++) {
- if (array[i] == value) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Return the maximum index of where the specified comparable object
- * should be inserted into the specified sorted list and still keep
- * the list sorted.
- */
- public static <E extends Comparable<? super E>> int insertionIndexOf(List<E> sortedList, Comparable<E> value) {
- int len = sortedList.size();
- for (int i = 0; i < len; i++) {
- if (value.compareTo(sortedList.get(i)) < 0) {
- return i;
- }
- }
- return len;
- }
-
- /**
- * Return the maximum index of where the specified object
- * should be inserted into the specified sorted list and still keep
- * the list sorted.
- */
- public static <E> int insertionIndexOf(List<E> sortedList, E value, Comparator<? super E> comparator) {
- int len = sortedList.size();
- for (int i = 0; i < len; i++) {
- if (comparator.compare(value, sortedList.get(i)) < 0) {
- return i;
- }
- }
- return len;
- }
-
- /**
- * Return the maximum index of where the specified comparable object
- * should be inserted into the specified sorted array and still keep
- * the array sorted.
- */
- public static <E extends Comparable<? super E>> int insertionIndexOf(E[] sortedArray, Comparable<E> value) {
- int len = sortedArray.length;
- for (int i = 0; i < len; i++) {
- if (value.compareTo(sortedArray[i]) < 0) {
- return i;
- }
- }
- return len;
- }
-
- /**
- * Return the maximum index of where the specified comparable object
- * should be inserted into the specified sorted array and still keep
- * the array sorted.
- */
- public static <E> int insertionIndexOf(E[] sortedArray, E value, Comparator<? super E> comparator) {
- int len = sortedArray.length;
- for (int i = 0; i < len; i++) {
- if (comparator.compare(value, sortedArray[i]) < 0) {
- return i;
- }
- }
- return len;
- }
-
- /**
- * Return a one-use Iterable for the Iterator given.
- * Throws an IllegalStateException if iterable() is called more than once.
- * As such, this utility should only be used in one-use situations, such as
- * a "for" loop.
- */
- public static <E> Iterable<E> iterable(Iterator<? extends E> iterator) {
- return new SingleUseIterable<E>(iterator);
- }
-
- /**
- * Return an iterable on the elements in the specified array.
- * java.util.Arrays#iterable(Object[] array)
- */
- public static <E> Iterable<E> iterable(E... array) {
- return Arrays.asList(array);
- }
-
- /**
- * Return an iterator on the elements in the specified array.
- * java.util.Arrays#iterator(Object[] array)
- */
- public static <E> Iterator<E> iterator(E... array) {
- return new ArrayIterator<E>(array);
- }
-
- /**
- * Return the index of the last occurrence of the
- * specified element in the specified iterator,
- * or return -1 if there is no such index.
- * java.util.Iterator#lastIndexOf(Object o)
- */
- public static int lastIndexOf(Iterator<?> iterator, Object value) {
- return (iterator.hasNext()) ? list(iterator).lastIndexOf(value) : -1;
- }
-
- /**
- * Return the index of the last occurrence of the
- * specified element in the specified iterator,
- * or return -1 if there is no such index.
- * java.util.Iterator#lastIndexOf(Object o)
- */
- public static int lastIndexOf(Iterator<?> iterator, int size, Object value) {
- return (iterator.hasNext()) ? list(iterator, size).lastIndexOf(value) : -1;
- }
-
- /**
- * Return the index of the last occurrence of the
- * specified element in the specified array,
- * or return -1 if there is no such index.
- * java.util.Arrays#lastIndexOf(Object[] array, Object o)
- */
- public static int lastIndexOf(Object[] array, Object value) {
- int len = array.length;
- if (value == null) {
- for (int i = len; i-- > 0; ) {
- if (array[i] == null) {
- return i;
- }
- }
- } else {
- for (int i = len; i-- > 0; ) {
- if (value.equals(array[i])) {
- return i;
- }
- }
- }
- return -1;
- }
-
- /**
- * Return the index of the last occurrence of the
- * specified element in the specified array,
- * or return -1 if there is no such index.
- * java.util.Arrays#lastIndexOf(char[] array, char value)
- */
- public static int lastIndexOf(char[] array, char value) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == value) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Return the index of the last occurrence of the
- * specified element in the specified array,
- * or return -1 if there is no such index.
- * java.util.Arrays#lastIndexOf(int[] array, int value)
- */
- public static int lastIndexOf(int[] array, int value) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == value) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Return a list corresponding to the specified iterable.
- * java.lang.Iterable#toList()
- */
- public static <E> List<E> list(Iterable<? extends E> iterable) {
- return list(iterable.iterator());
- }
-
- /**
- * Return a list corresponding to the specified iterable.
- * java.lang.Iterable#toList()
- */
- public static <E> List<E> list(Iterable<? extends E> iterable, int size) {
- return list(iterable.iterator(), size);
- }
-
- /**
- * Return a list corresponding to the specified iterator.
- * java.util.Iterator#toList()
- */
- public static <E> List<E> list(Iterator<? extends E> iterator) {
- return (iterator.hasNext()) ? list(iterator, new ArrayList<E>()) : Collections.<E>emptyList();
- }
-
- /**
- * Return a list corresponding to the specified iterator.
- * java.util.Iterator#toList()
- */
- public static <E> List<E> list(Iterator<? extends E> iterator, int size) {
- return (iterator.hasNext()) ? list(iterator, new ArrayList<E>(size)) : Collections.<E>emptyList();
- }
-
- private static <E> List<E> list(Iterator<? extends E> iterator, ArrayList<E> list) {
- while (iterator.hasNext()) {
- list.add(iterator.next());
- }
- return list;
- }
-
- /**
- * Return a list corresponding to the specified array.
- * Unlike java.util.Arrays.asList(Object[]), the list
- * is modifiable and is not backed by the array.
- */
- public static <E> List<E> list(E... array) {
- List<E> list = new ArrayList<E>(array.length);
- for (E item : array) {
- list.add(item);
- }
- return list;
- }
-
- /**
- * Return a list iterator for the specified array.
- * java.util.Arrays#listIterator(Object[] array)
- */
- public static <E> ListIterator<E> listIterator(E... array) {
- return listIterator(array, 0);
- }
-
- /**
- * Return a list iterator for the specified array
- * starting at the specified position in the array.
- * java.util.Arrays#listIterator(Object[] array, int index)
- */
- public static <E> ListIterator<E> listIterator(E[] array, int index) {
- return Arrays.asList(array).listIterator(index);
- }
-
- /**
- * Return the character from the specified array with the maximum value.
- * java.util.Arrays#max(char[] array)
- */
- public static char max(char... array) {
- int len = array.length;
- if (len == 0) {
- throw new IndexOutOfBoundsException();
- }
- char max = array[0];
- // start at 1
- for (int i = 1; i < len; i++) {
- char next = array[i];
- if (next > max) {
- max = next;
- }
- }
- return max;
- }
-
- /**
- * Return the integer from the specified array with the maximum value.
- * java.util.Arrays#max(int[] array)
- */
- public static int max(int... array) {
- int len = array.length;
- if (len == 0) {
- throw new IndexOutOfBoundsException();
- }
- int max = array[0];
- // start at 1
- for (int i = 1; i < len; i++) {
- int next = array[i];
- if (next > max) {
- max = next;
- }
- }
- return max;
- }
-
- /**
- * Return the character from the specified array with the minimum value.
- * java.util.Arrays#min(char[] array)
- */
- public static char min(char... array) {
- int len = array.length;
- if (len == 0) {
- throw new IndexOutOfBoundsException();
- }
- char min = array[0];
- // start at 1
- for (int i = 1; i < len; i++) {
- char next = array[i];
- if (next < min) {
- min = next;
- }
- }
- return min;
- }
-
- /**
- * Return the integer from the specified array with the minimum value.
- * java.util.Arrays#min(int[] array)
- */
- public static int min(int... array) {
- int len = array.length;
- if (len == 0) {
- throw new IndexOutOfBoundsException();
- }
- int min = array[0];
- // start at 1
- for (int i = 1; i < len; i++) {
- int next = array[i];
- if (next < min) {
- min = next;
- }
- }
- return min;
- }
-
- /**
- * Move an element from the specified source index to the specified target
- * index. Return the altered array.
- * java.util.Arrays#move(Object[] array, int targetIndex, int sourceIndex)
- */
- public static <E> E[] move(E[] array, int targetIndex, int sourceIndex) {
- return (targetIndex == sourceIndex) ? array : move_(array, targetIndex, sourceIndex);
- }
-
- /**
- * assume targetIndex != sourceIndex
- */
- private static <E> E[] move_(E[] array, int targetIndex, int sourceIndex) {
- E temp = array[sourceIndex];
- if (targetIndex < sourceIndex) {
- System.arraycopy(array, targetIndex, array, targetIndex + 1, sourceIndex - targetIndex);
- } else {
- System.arraycopy(array, sourceIndex + 1, array, sourceIndex, targetIndex - sourceIndex);
- }
- array[targetIndex] = temp;
- return array;
- }
-
- /**
- * Move elements from the specified source index to the specified target
- * index. Return the altered array.
- * java.util.Arrays#move(Object[] array, int targetIndex, int sourceIndex, int length)
- */
- public static <E> E[] move(E[] array, int targetIndex, int sourceIndex, int length) {
- if ((targetIndex == sourceIndex) || (length == 0)) {
- return array;
- }
- if (length == 1) {
- return move_(array, targetIndex, sourceIndex);
- }
- E[] temp = newArray(array, length);
- System.arraycopy(array, sourceIndex, temp, 0, length);
- if (targetIndex < sourceIndex) {
- System.arraycopy(array, targetIndex, array, targetIndex + length, sourceIndex - targetIndex);
- } else {
- System.arraycopy(array, sourceIndex + length, array, sourceIndex, targetIndex - sourceIndex);
- }
- System.arraycopy(temp, 0, array, targetIndex, length);
- return array;
- }
-
- /**
- * Move an element from the specified source index to the specified target
- * index. Return the altered array.
- * java.util.Arrays#move(int[] array, int targetIndex, int sourceIndex)
- */
- public static int[] move(int[] array, int targetIndex, int sourceIndex) {
- return (targetIndex == sourceIndex) ? array : move_(array, targetIndex, sourceIndex);
- }
-
- /**
- * assume targetIndex != sourceIndex
- */
- private static int[] move_(int[] array, int targetIndex, int sourceIndex) {
- int temp = array[sourceIndex];
- if (targetIndex < sourceIndex) {
- System.arraycopy(array, targetIndex, array, targetIndex + 1, sourceIndex - targetIndex);
- } else {
- System.arraycopy(array, sourceIndex + 1, array, sourceIndex, targetIndex - sourceIndex);
- }
- array[targetIndex] = temp;
- return array;
- }
-
- /**
- * Move elements from the specified source index to the specified target
- * index. Return the altered array.
- * java.util.Arrays#move(int[] array, int targetIndex, int sourceIndex, int length)
- */
- public static int[] move(int[] array, int targetIndex, int sourceIndex, int length) {
- if ((targetIndex == sourceIndex) || (length == 0)) {
- return array;
- }
- if (length == 1) {
- return move_(array, targetIndex, sourceIndex);
- }
- int[] temp = new int[length];
- System.arraycopy(array, sourceIndex, temp, 0, length);
- if (targetIndex < sourceIndex) {
- System.arraycopy(array, targetIndex, array, targetIndex + length, sourceIndex - targetIndex);
- } else {
- System.arraycopy(array, sourceIndex + length, array, sourceIndex, targetIndex - sourceIndex);
- }
- System.arraycopy(temp, 0, array, targetIndex, length);
- return array;
- }
-
- /**
- * Move an element from the specified source index to the specified target
- * index. Return the altered array.
- * java.util.Arrays#move(char[] array, int targetIndex, int sourceIndex)
- */
- public static char[] move(char[] array, int targetIndex, int sourceIndex) {
- return (targetIndex == sourceIndex) ? array : move_(array, targetIndex, sourceIndex);
- }
-
- /**
- * assume targetIndex != sourceIndex
- */
- private static char[] move_(char[] array, int targetIndex, int sourceIndex) {
- char temp = array[sourceIndex];
- if (targetIndex < sourceIndex) {
- System.arraycopy(array, targetIndex, array, targetIndex + 1, sourceIndex - targetIndex);
- } else {
- System.arraycopy(array, sourceIndex + 1, array, sourceIndex, targetIndex - sourceIndex);
- }
- array[targetIndex] = temp;
- return array;
- }
-
- /**
- * Move elements from the specified source index to the specified target
- * index. Return the altered array.
- * java.util.Arrays#move(char[] array, int targetIndex, int sourceIndex, int length)
- */
- public static char[] move(char[] array, int targetIndex, int sourceIndex, int length) {
- if ((targetIndex == sourceIndex) || (length == 0)) {
- return array;
- }
- if (length == 1) {
- return move_(array, targetIndex, sourceIndex);
- }
- char[] temp = new char[length];
- System.arraycopy(array, sourceIndex, temp, 0, length);
- if (targetIndex < sourceIndex) {
- System.arraycopy(array, targetIndex, array, targetIndex + length, sourceIndex - targetIndex);
- } else {
- System.arraycopy(array, sourceIndex + length, array, sourceIndex, targetIndex - sourceIndex);
- }
- System.arraycopy(temp, 0, array, targetIndex, length);
- return array;
- }
-
- /**
- * Move an element from the specified source index to the specified target
- * index. Return the altered list.
- * java.util.List#move(int targetIndex, int sourceIndex)
- */
- public static <E> List<E> move(List<E> list, int targetIndex, int sourceIndex) {
- return (targetIndex == sourceIndex) ? list : move_(list, targetIndex, sourceIndex);
- }
-
- /**
- * assume targetIndex != sourceIndex
- */
- private static <E> List<E> move_(List<E> list, int targetIndex, int sourceIndex) {
- if (list instanceof RandomAccess) {
- // move elements, leaving the list in place
- E temp = list.get(sourceIndex);
- if (targetIndex < sourceIndex) {
- for (int i = sourceIndex; i-- > targetIndex; ) {
- list.set(i + 1, list.get(i));
- }
- } else {
- for (int i = sourceIndex; i < targetIndex; i++) {
- list.set(i, list.get(i + 1));
- }
- }
- list.set(targetIndex, temp);
- } else {
- // remove the element and re-add it at the target index
- list.add(targetIndex, list.remove(sourceIndex));
- }
- return list;
- }
-
- /**
- * Move elements from the specified source index to the specified target
- * index. Return the altered list.
- * java.util.List#move(int targetIndex, int sourceIndex, int length)
- */
- public static <E> List<E> move(List<E> list, int targetIndex, int sourceIndex, int length) {
- if ((targetIndex == sourceIndex) || (length == 0)) {
- return list;
- }
- if (length == 1) {
- return move_(list, targetIndex, sourceIndex);
- }
- if (list instanceof RandomAccess) {
- // move elements, leaving the list in place
- ArrayList<E> temp = new ArrayList<E>(list.subList(sourceIndex, sourceIndex + length));
- if (targetIndex < sourceIndex) {
- for (int i = sourceIndex; i-- > targetIndex; ) {
- list.set(i + length, list.get(i));
- }
- } else {
- for (int i = sourceIndex; i < targetIndex; i++) {
- list.set(i, list.get(i + length));
- }
- }
- for (int i = 0; i < length; i++) {
- list.set(targetIndex + i, temp.get(i));
- }
- } else {
- // remove the elements and re-add them at the target index
- list.addAll(targetIndex, removeElementsAtIndex(list, sourceIndex, length));
- }
- return list;
- }
-
- /**
- * Replace all occurrences of the specified old value with
- * the specified new value.
- * java.util.Arrays#replaceAll(Object[] array, Object oldValue, Object newValue)
- */
- public static <E> E[] replaceAll(E[] array, Object oldValue, E newValue) {
- if (oldValue == null) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == null) {
- array[i] = newValue;
- }
- }
- } else {
- for (int i = array.length; i-- > 0; ) {
- if (oldValue.equals(array[i])) {
- array[i] = newValue;
- }
- }
- }
- return array;
- }
-
- /**
- * Replace all occurrences of the specified old value with
- * the specified new value.
- * java.util.Arrays#replaceAll(int[] array, int oldValue, int newValue)
- */
- public static int[] replaceAll(int[] array, int oldValue, int newValue) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == oldValue) {
- array[i] = newValue;
- }
- }
- return array;
- }
-
- /**
- * Replace all occurrences of the specified old value with
- * the specified new value.
- * java.util.Arrays#replaceAll(char[] array, char oldValue, char newValue)
- */
- public static char[] replaceAll(char[] array, char oldValue, char newValue) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == oldValue) {
- array[i] = newValue;
- }
- }
- return array;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified element removed.
- * java.util.Arrays#remove(Object[] array, Object value)
- */
- public static <E> E[] remove(E[] array, Object value) {
- return removeElementAtIndex(array, indexOf(array, value));
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified element removed.
- * java.util.Arrays#remove(char[] array, char value)
- */
- public static char[] remove(char[] array, char value) {
- return removeElementAtIndex(array, indexOf(array, value));
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified element removed.
- * java.util.Arrays#remove(int[] array, int value)
- */
- public static int[] remove(int[] array, int value) {
- return removeElementAtIndex(array, indexOf(array, value));
- }
-
- /**
- * Remove all the elements returned by the specified iterable
- * from the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#removeAll(java.lang.Iterable iterable)
- */
- public static boolean removeAll(Collection<?> collection, Iterable<?> iterable) {
- return removeAll(collection, iterable.iterator());
- }
-
- /**
- * Remove all the elements returned by the specified iterable
- * from the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#removeAll(java.lang.Iterable iterable)
- */
- public static boolean removeAll(Collection<?> collection, Iterable<?> iterable, int size) {
- return removeAll(collection, iterable.iterator(), size);
- }
-
- /**
- * Remove all the elements returned by the specified iterator
- * from the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#removeAll(java.util.Iterator iterator)
- */
- public static boolean removeAll(Collection<?> collection, Iterator<?> iterator) {
- return (iterator.hasNext()) ? collection.removeAll(set(iterator)) : false;
- }
-
- /**
- * Remove all the elements returned by the specified iterator
- * from the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#removeAll(java.util.Iterator iterator)
- */
- public static boolean removeAll(Collection<?> collection, Iterator<?> iterator, int size) {
- return (iterator.hasNext()) ? collection.removeAll(set(iterator, size)) : false;
- }
-
- /**
- * Remove all the elements in the specified array
- * from the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#removeAll(Object[] array)
- */
- public static boolean removeAll(Collection<?> collection, Object[] array) {
- return collection.removeAll(set(array));
- }
-
- /**
- * Remove from the specified array all the elements in
- * the specified iterable and return the result.
- * java.util.Arrays#removeAll(Object[] array, Iterable iterable)
- */
- public static <E> E[] removeAll(E[] array, Iterable<?> iterable) {
- return removeAll(array, iterable.iterator());
- }
-
- /**
- * Remove from the specified array all the elements in
- * the specified iterable and return the result.
- * java.util.Arrays#removeAll(Object[] array, Iterable iterable)
- */
- public static <E> E[] removeAll(E[] array, Iterable<?> iterable, int size) {
- return removeAll(array, iterable.iterator(), size);
- }
-
- /**
- * Remove from the specified array all the elements in
- * the specified iterator and return the result.
- * java.util.Arrays#removeAll(Object[] array, Iterator iterator)
- */
- public static <E> E[] removeAll(E[] array, Iterator<?> iterator) {
- return (iterator.hasNext()) ? removeAll_(array, set(iterator)) : array;
- }
-
- /**
- * Remove from the specified array all the elements in
- * the specified iterator and return the result.
- * java.util.Arrays#removeAll(Object[] array, Iterator iterator)
- */
- public static <E> E[] removeAll(E[] array, Iterator<?> iterator, int size) {
- return (iterator.hasNext()) ? removeAll_(array, set(iterator, size)) : array;
- }
-
- /**
- * Remove from the specified array all the elements in
- * the specified collection and return the result.
- * java.util.Arrays#removeAll(Object[] array, Collection collection)
- */
- public static <E> E[] removeAll(E[] array, Collection<?> collection) {
- return (collection.isEmpty()) ? array : removeAll_(array, collection);
- }
-
- /**
- * assume the collection is non-empty
- */
- private static <E> E[] removeAll_(E[] array, Collection<?> collection) {
- int arrayLength = array.length;
- return (arrayLength == 0) ? array : removeAll(array, collection, arrayLength);
- }
-
- /**
- * assume the collection is non-empty and arrayLength > 0
- */
- private static <E> E[] removeAll(E[] array, Collection<?> collection, int arrayLength) {
- int[] indices = new int[arrayLength];
- int j = 0;
- for (int i = 0; i < arrayLength; i++) {
- if ( ! collection.contains(array[i])) {
- indices[j++] = i;
- }
- }
- if (j == arrayLength) {
- return array; // nothing was removed
- }
- E[] result = newArray(array, j);
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove from the first specified array all the elements in
- * the second specified array and return the result.
- * java.util.Arrays#removeAll(Object[] array1, Object[] array2)
- */
- public static <E> E[] removeAll(E[] array1, Object[] array2) {
- // convert to a bag to take advantage of hashed look-up
- return (array2.length == 0) ? array1 : removeAll_(array1, set(array2));
- }
-
- /**
- * Remove from the first specified array all the elements in
- * the second specified array and return the result.
- * java.util.Arrays#removeAll(char[] array1, char[] array2)
- */
- public static char[] removeAll(char[] array1, char[] array2) {
- if (array2.length == 0) {
- return array1;
- }
- int array1Length = array1.length;
- if (array1Length == 0) {
- return array1;
- }
- int[] indices = new int[array1Length];
- int j = 0;
- for (int i = 0; i < array1Length; i++) {
- if ( ! contains(array2, array1[i])) {
- indices[j++] = i;
- }
- }
- if (j == array1Length) {
- return array1; // nothing was removed
- }
- char[] result = new char[j];
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array1[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove from the first specified array all the elements in
- * the second specified array and return the result.
- * java.util.Arrays#removeAll(int[] array1, int[] array2)
- */
- public static int[] removeAll(int[] array1, int[] array2) {
- if (array2.length == 0) {
- return array1;
- }
- int array1Length = array1.length;
- if (array1Length == 0) {
- return array1;
- }
- int[] indices = new int[array1Length];
- int j = 0;
- for (int i = 0; i < array1Length; i++) {
- if ( ! contains(array2, array1[i])) {
- indices[j++] = i;
- }
- }
- if (j == array1Length) {
- return array1; // nothing was removed
- }
- int[] result = new int[j];
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array1[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove all occurrences of the specified element
- * from the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#removeAllOccurrences(Object value)
- */
- public static boolean removeAllOccurrences(Collection<?> collection, Object value) {
- boolean modified = false;
- Iterator<?> stream = collection.iterator();
- if (value == null) {
- while (stream.hasNext()) {
- if (stream.next() == null) {
- stream.remove();
- modified = true;
- }
- }
- } else {
- while (stream.hasNext()) {
- if (value.equals(stream.next())) {
- stream.remove();
- modified = true;
- }
- }
- }
- return modified;
- }
-
- /**
- * Remove from the specified array all occurrences of
- * the specified element and return the result.
- * java.util.Arrays#removeAllOccurrences(Object[] array, Object value)
- */
- public static <E> E[] removeAllOccurrences(E[] array, Object value) {
- int arrayLength = array.length;
- if (arrayLength == 0) {
- return array;
- }
- int[] indices = new int[arrayLength];
- int j = 0;
- if (value == null) {
- for (int i = arrayLength; i-- > 0; ) {
- if (array[i] != null) {
- indices[j++] = i;
- }
- }
- } else {
- for (int i = array.length; i-- > 0; ) {
- if ( ! value.equals(array[i])) {
- indices[j++] = i;
- }
- }
- }
- if (j == arrayLength) {
- return array; // nothing was removed
- }
- E[] result = newArray(array, j);
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove from the specified array all occurrences of
- * the specified element and return the result.
- * java.util.Arrays#removeAllOccurrences(char[] array, char value)
- */
- public static char[] removeAllOccurrences(char[] array, char value) {
- int arrayLength = array.length;
- if (arrayLength == 0) {
- return array;
- }
- int[] indices = new int[arrayLength];
- int j = 0;
- for (int i = arrayLength; i-- > 0; ) {
- if (array[i] != value) {
- indices[j++] = i;
- }
- }
- if (j == arrayLength) {
- return array; // nothing was removed
- }
- char[] result = new char[j];
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove from the specified array all occurrences of
- * the specified element and return the result.
- * java.util.Arrays#removeAllOccurrences(int[] array, int value)
- */
- public static int[] removeAllOccurrences(int[] array, int value) {
- int arrayLength = array.length;
- if (arrayLength == 0) {
- return array;
- }
- int[] indices = new int[arrayLength];
- int j = 0;
- for (int i = arrayLength; i-- > 0; ) {
- if (array[i] != value) {
- indices[j++] = i;
- }
- }
- if (j == arrayLength) {
- return array; // nothing was removed
- }
- int[] result = new int[j];
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array[indices[i]];
- }
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified element removed.
- * java.util.Arrays#removeElementAtIndex(Object[] array, int index)
- */
- public static <E> E[] removeElementAtIndex(E[] array, int index) {
- return removeElementsAtIndex(array, index, 1);
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified element removed.
- * java.util.Arrays#removeElementAtIndex(char[] array, int index)
- */
- public static char[] removeElementAtIndex(char[] array, int index) {
- return removeElementsAtIndex(array, index, 1);
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified element removed.
- * java.util.Arrays#removeElementAtIndex(int[] array, int index)
- */
- public static int[] removeElementAtIndex(int[] array, int index) {
- return removeElementsAtIndex(array, index, 1);
- }
-
- /**
- * Remove the elements at the specified index.
- * Return the removed elements.
- * java.util.List#remove(int index, int length)
- */
- public static <E> List<E> removeElementsAtIndex(List<E> list, int index, int length) {
- List<E> subList = list.subList(index, index + length);
- ArrayList<E> result = new ArrayList<E>(subList);
- subList.clear();
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified elements removed.
- * java.util.Arrays#removeElementsAtIndex(Object[] array, int index, int length)
- */
- public static <E> E[] removeElementsAtIndex(E[] array, int index, int length) {
- int arrayLength = array.length;
- int newLength = arrayLength - length;
- E[] result = newArray(array, newLength);
- if ((newLength == 0) && (index == 0)) {
- return result; // performance tweak
- }
- System.arraycopy(array, 0, result, 0, index);
- System.arraycopy(array, index + length, result, index, newLength - index);
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified elements removed.
- * java.util.Arrays#removeElementAtIndex(char[] array, int index, int length)
- */
- public static char[] removeElementsAtIndex(char[] array, int index, int length) {
- int arrayLength = array.length;
- int newLength = arrayLength - length;
- if ((newLength == 0) && (index == 0)) {
- return EMPTY_CHAR_ARRAY; // performance tweak
- }
- char[] result = new char[newLength];
- System.arraycopy(array, 0, result, 0, index);
- System.arraycopy(array, index + length, result, index, newLength - index);
- return result;
- }
- private static final char[] EMPTY_CHAR_ARRAY = new char[0];
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified elements removed.
- * java.util.Arrays#removeElementAtIndex(int[] array, int index, int length)
- */
- public static int[] removeElementsAtIndex(int[] array, int index, int length) {
- int arrayLength = array.length;
- int newLength = arrayLength - length;
- if ((newLength == 0) && (index == 0)) {
- return EMPTY_INT_ARRAY; // performance tweak
- }
- int[] result = new int[newLength];
- System.arraycopy(array, 0, result, 0, index);
- System.arraycopy(array, index + length, result, index, newLength - index);
- return result;
- }
- private static final int[] EMPTY_INT_ARRAY = new int[0];
-
- /**
- * Remove any duplicate elements from the specified array,
- * while maintaining the order.
- */
- public static <E> E[] removeDuplicateElements(E... array) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- List<E> list = removeDuplicateElements(Arrays.asList(array), len);
- return list.toArray(newArray(array, list.size()));
- }
-
- /**
- * Remove any duplicate elements from the specified list,
- * while maintaining the order.
- */
- public static <E> List<E> removeDuplicateElements(List<E> list) {
- int size = list.size();
- if ((size == 0) || (size == 1)) {
- return list;
- }
- return removeDuplicateElements(list, size);
- }
-
- /**
- * assume list is non-empty
- */
- private static <E> List<E> removeDuplicateElements(List<E> list, int size) {
- List<E> result = new ArrayList<E>(size);
- Set<E> set = new HashSet<E>(size); // take advantage of hashed look-up
- for (E item : list) {
- if (set.add(item)) {
- result.add(item);
- }
- }
- return result;
- }
-
- /**
- * Retain only the elements in the specified iterable
- * in the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#retainAll(java.lang.Iterable iterable)
- */
- public static boolean retainAll(Collection<?> collection, Iterable<?> iterable) {
- return retainAll(collection, iterable.iterator());
- }
-
- /**
- * Retain only the elements in the specified iterable
- * in the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#retainAll(java.lang.Iterable iterable)
- */
- public static boolean retainAll(Collection<?> collection, Iterable<?> iterable, int size) {
- return retainAll(collection, iterable.iterator(), size);
- }
-
- /**
- * Retain only the elements in the specified iterator
- * in the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#retainAll(java.util.Iterator iterator)
- */
- public static boolean retainAll(Collection<?> collection, Iterator<?> iterator) {
- if (iterator.hasNext()) {
- return collection.retainAll(set(iterator));
- }
- if (collection.isEmpty()) {
- return false;
- }
- collection.clear();
- return true;
- }
-
- /**
- * Retain only the elements in the specified iterator
- * in the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#retainAll(java.util.Iterator iterator)
- */
- public static boolean retainAll(Collection<?> collection, Iterator<?> iterator, int size) {
- if (iterator.hasNext()) {
- return collection.retainAll(set(iterator, size));
- }
- if (collection.isEmpty()) {
- return false;
- }
- collection.clear();
- return true;
- }
-
- /**
- * Retain only the elements in the specified array
- * in the specified collection.
- * Return whether the collection changed as a result.
- * java.util.Collection#retainAll(Object[] array)
- */
- public static boolean retainAll(Collection<?> collection, Object[] array) {
- if (array.length > 0) {
- return collection.retainAll(set(array));
- }
- if (collection.isEmpty()) {
- return false;
- }
- collection.clear();
- return true;
- }
-
- /**
- * Retain in the specified array all the elements in
- * the specified iterable and return the result.
- * java.util.Arrays#retainAll(Object[] array, Iterable iterable)
- */
- public static <E> E[] retainAll(E[] array, Iterable<?> iterable) {
- int arrayLength = array.length;
- return (arrayLength == 0) ? array : retainAll(array, arrayLength, iterable.iterator());
- }
-
- /**
- * Retain in the specified array all the elements in
- * the specified iterable and return the result.
- * java.util.Arrays#retainAll(Object[] array, Iterable iterable)
- */
- public static <E> E[] retainAll(E[] array, Iterable<?> iterable, int size) {
- int arrayLength = array.length;
- return (arrayLength == 0) ? array : retainAll(array, arrayLength, iterable.iterator(), size);
- }
-
- /**
- * Retain in the specified array all the elements in
- * the specified iterator and return the result.
- * java.util.Arrays#retainAll(Object[] array, Iterator iterator)
- */
- public static <E> E[] retainAll(E[] array, Iterator<?> iterator) {
- int arrayLength = array.length;
- return (arrayLength == 0) ? array : retainAll(array, arrayLength, iterator);
- }
-
- /**
- * Retain in the specified array all the elements in
- * the specified iterator and return the result.
- * java.util.Arrays#retainAll(Object[] array, Iterator iterator)
- */
- public static <E> E[] retainAll(E[] array, Iterator<?> iterator, int size) {
- int arrayLength = array.length;
- return (arrayLength == 0) ? array : retainAll(array, arrayLength, iterator, size);
- }
-
- /**
- * assume arrayLength > 0
- */
- private static <E> E[] retainAll(E[] array, int arrayLength, Iterator<?> iterator) {
- return (iterator.hasNext()) ?
- retainAll_(array, set(iterator), arrayLength)
- :
- newArray(array, 0);
- }
-
- /**
- * assume arrayLength > 0
- */
- private static <E> E[] retainAll(E[] array, int arrayLength, Iterator<?> iterator, int iteratorSize) {
- return (iterator.hasNext()) ?
- retainAll_(array, set(iterator, iteratorSize), arrayLength)
- :
- newArray(array, 0);
- }
-
- /**
- * Retain in the specified array all the elements in
- * the specified collection and return the result.
- * java.util.Arrays#retainAll(Object[] array, Collection collection)
- */
- public static <E> E[] retainAll(E[] array, Collection<?> collection) {
- int arrayLength = array.length;
- return (arrayLength == 0) ? array : retainAll(array, collection, arrayLength);
- }
-
- /**
- * assume arrayLength > 0
- */
- private static <E> E[] retainAll(E[] array, Collection<?> collection, int arrayLength) {
- return (collection.isEmpty()) ?
- newArray(array, 0)
- :
- retainAll_(array, collection, arrayLength);
- }
-
- /**
- * assume collection is non-empty and arrayLength > 0
- */
- private static <E> E[] retainAll_(E[] array, Collection<?> collection, int arrayLength) {
- int[] indices = new int[arrayLength];
- int j = 0;
- for (int i = 0; i < arrayLength; i++) {
- if (collection.contains(array[i])) {
- indices[j++] = i;
- }
- }
- if (j == arrayLength) {
- return array; // everything was retained
- }
- E[] result = newArray(array, j);
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove from the first specified array all the elements in
- * the second specified array and return the result.
- * java.util.Arrays#retainAll(Object[] array1, Object[] array2)
- */
- public static <E> E[] retainAll(E[] array1, Object[] array2) {
- int array1Length = array1.length;
- return (array2.length == 0) ?
- (array1Length == 0) ? array1 : newArray(array1, 0)
- :
- retainAll(array1, set(array2), array1Length);
- }
-
- /**
- * Remove from the first specified array all the elements in
- * the second specified array and return the result.
- * java.util.Arrays#retainAll(char[] array1, char[] array2)
- */
- public static char[] retainAll(char[] array1, char[] array2) {
- int array1Length = array1.length;
- return (array1Length == 0) ? array1 : retainAll(array1, array2, array1Length);
- }
-
- /**
- * assume array1Length > 0
- */
- private static char[] retainAll(char[] array1, char[] array2, int array1Length) {
- int array2Length = array2.length;
- return (array2Length == 0) ? EMPTY_CHAR_ARRAY : retainAll(array1, array2, array1Length, array2Length);
- }
-
- /**
- * assume array1Length > 0 and array2Length > 0
- */
- private static char[] retainAll(char[] array1, char[] array2, int array1Length, int array2Length) {
- int[] indices = new int[array1Length];
- int j = 0;
- for (int i = 0; i < array1Length; i++) {
- if (contains(array2, array1[i])) {
- indices[j++] = i;
- }
- }
- if (j == array1Length) {
- return array1; // everything was retained
- }
- char[] result = new char[j];
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array1[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove from the first specified array all the elements in
- * the second specified array and return the result.
- * java.util.Arrays#retainAll(int[] array1, int[] array2)
- */
- public static int[] retainAll(int[] array1, int[] array2) {
- int array1Length = array1.length;
- return (array1Length == 0) ? array1 : retainAll(array1, array2, array1Length);
- }
-
- /**
- * assume array1Length > 0
- */
- private static int[] retainAll(int[] array1, int[] array2, int array1Length) {
- int array2Length = array2.length;
- return (array2Length == 0) ? EMPTY_INT_ARRAY : retainAll(array1, array2, array1Length, array2Length);
- }
-
- /**
- * assume array1Length > 0 and array2Length > 0
- */
- private static int[] retainAll(int[] array1, int[] array2, int array1Length, int array2Length) {
- int[] indices = new int[array1Length];
- int j = 0;
- for (int i = 0; i < array1Length; i++) {
- if (contains(array2, array1[i])) {
- indices[j++] = i;
- }
- }
- if (j == array1Length) {
- return array1; // everything was retained
- }
- int[] result = new int[j];
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array1[indices[i]];
- }
- return result;
- }
-
- /**
- * Return the array reversed.
- * java.util.Arrays.reverse(Object[] array)
- */
- public static <E> E[] reverse(E... array) {
- int len = array.length;
- for (int i = 0, mid = len >> 1, j = len - 1; i < mid; i++, j--) {
- swap(array, i, j);
- }
- return array;
- }
-
- /**
- * Return the array reversed.
- * java.util.Arrays.reverse(char[] array)
- */
- public static char[] reverse(char... array) {
- int len = array.length;
- for (int i = 0, mid = len >> 1, j = len - 1; i < mid; i++, j--) {
- swap(array, i, j);
- }
- return array;
- }
-
- /**
- * Return the array reversed.
- * java.util.Arrays.reverse(int[] array)
- */
- public static int[] reverse(int... array) {
- int len = array.length;
- for (int i = 0, mid = len >> 1, j = len - 1; i < mid; i++, j--) {
- swap(array, i, j);
- }
- return array;
- }
-
- /**
- * Return a list with entries in reverse order from those
- * returned by the specified iterable.
- */
- public static <E> List<E> reverseList(Iterable<? extends E> iterable) {
- return reverse(list(iterable));
- }
-
- /**
- * Return a list with entries in reverse order from those
- * returned by the specified iterable.
- */
- public static <E> List<E> reverseList(Iterable<? extends E> iterable, int size) {
- return reverse(list(iterable, size));
- }
-
- /**
- * Return a list with entries in reverse order from those
- * returned by the specified iterator.
- */
- public static <E> List<E> reverseList(Iterator<? extends E> iterator) {
- return reverse(list(iterator));
- }
-
- /**
- * Return a list with entries in reverse order from those
- * returned by the specified iterator.
- */
- public static <E> List<E> reverseList(Iterator<? extends E> iterator, int size) {
- return reverse(list(iterator, size));
- }
-
- /**
- * Return the rotated array after rotating it one position.
- * java.util.Arrays.rotate(Object[] array)
- */
- public static <E> E[] rotate(E... array) {
- return rotate(array, 1);
- }
-
- /**
- * Return the rotated array after rotating it the specified distance.
- * java.util.Arrays.rotate(Object[] array, int distance)
- */
- public static <E> E[] rotate(E[] array, int distance) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- distance = distance % len;
- if (distance < 0) {
- distance += len;
- }
- if (distance == 0) {
- return array;
- }
- for (int cycleStart = 0, nMoved = 0; nMoved != len; cycleStart++) {
- E displaced = array[cycleStart];
- int i = cycleStart;
- do {
- i += distance;
- if (i >= len) {
- i -= len;
- }
- E temp = array[i];
- array[i] = displaced;
- displaced = temp;
- nMoved ++;
- } while (i != cycleStart);
- }
- return array;
- }
-
- /**
- * Return the rotated array after rotating it one position.
- * java.util.Arrays.rotate(char[] array)
- */
- public static char[] rotate(char... array) {
- return rotate(array, 1);
- }
-
- /**
- * Return the rotated array after rotating it the specified distance.
- * java.util.Arrays.rotate(char[] array, int distance)
- */
- public static char[] rotate(char[] array, int distance) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- distance = distance % len;
- if (distance < 0) {
- distance += len;
- }
- if (distance == 0) {
- return array;
- }
- for (int cycleStart = 0, nMoved = 0; nMoved != len; cycleStart++) {
- char displaced = array[cycleStart];
- int i = cycleStart;
- do {
- i += distance;
- if (i >= len) {
- i -= len;
- }
- char temp = array[i];
- array[i] = displaced;
- displaced = temp;
- nMoved ++;
- } while (i != cycleStart);
- }
- return array;
- }
-
- /**
- * Return the rotated array after rotating it one position.
- * java.util.Arrays.rotate(int[] array)
- */
- public static int[] rotate(int... array) {
- return rotate(array, 1);
- }
-
- /**
- * Return the rotated array after rotating it the specified distance.
- * java.util.Arrays.rotate(int[] array, int distance)
- */
- public static int[] rotate(int[] array, int distance) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- distance = distance % len;
- if (distance < 0) {
- distance += len;
- }
- if (distance == 0) {
- return array;
- }
- for (int cycleStart = 0, nMoved = 0; nMoved != len; cycleStart++) {
- int displaced = array[cycleStart];
- int i = cycleStart;
- do {
- i += distance;
- if (i >= len) {
- i -= len;
- }
- int temp = array[i];
- array[i] = displaced;
- displaced = temp;
- nMoved ++;
- } while (i != cycleStart);
- }
- return array;
- }
-
- /**
- * Return a set corresponding to the specified iterable.
- * java.util.HashSet(java.lang.Iterable iterable)
- */
- public static <E> Set<E> set(Iterable<? extends E> iterable) {
- return set(iterable.iterator());
- }
-
- /**
- * Return a set corresponding to the specified iterable.
- * java.util.HashSet(java.lang.Iterable iterable)
- */
- public static <E> Set<E> set(Iterable<? extends E> iterable, int size) {
- return set(iterable.iterator(), size);
- }
-
- /**
- * Return a set corresponding to the specified iterator.
- * java.util.HashSet(java.util.Iterator iterator)
- */
- public static <E> Set<E> set(Iterator<? extends E> iterator) {
- return set(iterator, new HashSet<E>());
- }
-
- /**
- * Return a set corresponding to the specified iterator.
- * java.util.HashSet(java.util.Iterator iterator)
- */
- public static <E> Set<E> set(Iterator<? extends E> iterator, int size) {
- return set(iterator, new HashSet<E>(size));
- }
-
- private static <E> Set<E> set(Iterator<? extends E> iterator, HashSet<E> set) {
- while (iterator.hasNext()) {
- set.add(iterator.next());
- }
- return set;
- }
-
- /**
- * Return a set corresponding to the specified array.
- * java.util.HashSet(Object[] array)
- */
- public static <E> Set<E> set(E... array) {
- Set<E> set = new HashSet<E>(array.length);
- for (E item : array) {
- set.add(item);
- }
- return set;
- }
-
- private static final Random RANDOM = new Random();
-
- /**
- * Return the array after "shuffling" it.
- * java.util.Arrays#shuffle(Object[] array)
- */
- public static <E> E[] shuffle(E... array) {
- return shuffle(array, RANDOM);
- }
-
- /**
- * Return the array after "shuffling" it.
- * java.util.Arrays#shuffle(Object[] array, Random r)
- */
- public static <E> E[] shuffle(E[] array, Random random) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- for (int i = len; i-- > 0; ) {
- swap(array, i, random.nextInt(len));
- }
- return array;
- }
-
- /**
- * Return the array after "shuffling" it.
- * java.util.Arrays#shuffle(char[] array)
- */
- public static char[] shuffle(char... array) {
- return shuffle(array, RANDOM);
- }
-
- /**
- * Return the array after "shuffling" it.
- * java.util.Arrays#shuffle(char[] array, Random r)
- */
- public static char[] shuffle(char[] array, Random random) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- for (int i = len; i-- > 0; ) {
- swap(array, i, random.nextInt(len));
- }
- return array;
- }
-
- /**
- * Return the array after "shuffling" it.
- * java.util.Arrays#shuffle(int[] array)
- */
- public static int[] shuffle(int... array) {
- return shuffle(array, RANDOM);
- }
-
- /**
- * Return the array after "shuffling" it.
- * java.util.Arrays#shuffle(int[] array, Random r)
- */
- public static int[] shuffle(int[] array, Random random) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- for (int i = len; i-- > 0; ) {
- swap(array, i, random.nextInt(len));
- }
- return array;
- }
-
- /**
- * Return an iterator that returns only the single,
- * specified object.
- * Object#toIterator() ?!
- */
- public static <E> Iterator<E> singletonIterator(E value) {
- return new SingleElementIterator<E>(value);
- }
-
- /**
- * Return the number of elements returned by the specified iterable.
- * java.lang.Iterable#size()
- */
- public static int size(Iterable<?> iterable) {
- return size(iterable.iterator());
- }
-
- /**
- * Return the number of elements returned by the specified iterator.
- * java.util.Iterator#size()
- */
- public static int size(Iterator<?> iterator) {
- int size = 0;
- while (iterator.hasNext()) {
- iterator.next();
- size++;
- }
- return size;
- }
-
- /**
- * Return a sorted set corresponding to the specified iterable.
- * java.util.TreeSet(java.lang.Iterable iterable)
- */
- public static <E extends Comparable<? super E>> SortedSet<E> sortedSet(Iterable<? extends E> iterable) {
- return sortedSet(iterable, null);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterable.
- * java.util.TreeSet(java.lang.Iterable iterable)
- */
- public static <E extends Comparable<? super E>> SortedSet<E> sortedSet(Iterable<? extends E> iterable, int size) {
- return sortedSet(iterable, size, null);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterable
- * and comparator.
- * java.util.TreeSet(java.lang.Iterable iterable, java.util.Comparator c)
- */
- public static <E> SortedSet<E> sortedSet(Iterable<? extends E> iterable, Comparator<? super E> comparator) {
- return sortedSet(iterable.iterator(), comparator);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterable
- * and comparator.
- * java.util.TreeSet(java.lang.Iterable iterable, java.util.Comparator c)
- */
- public static <E> SortedSet<E> sortedSet(Iterable<? extends E> iterable, int size, Comparator<? super E> comparator) {
- return sortedSet(iterable.iterator(), size, comparator);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterator.
- * java.util.TreeSet(java.util.Iterator iterator)
- */
- public static <E extends Comparable<? super E>> SortedSet<E> sortedSet(Iterator<? extends E> iterator) {
- return sortedSet(iterator, null);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterator.
- * java.util.TreeSet(java.util.Iterator iterator)
- */
- public static <E extends Comparable<? super E>> SortedSet<E> sortedSet(Iterator<? extends E> iterator, int size) {
- return sortedSet(iterator, size, null);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterator
- * and comparator.
- * java.util.TreeSet(java.util.Iterator iterator, java.util.Comparator c)
- */
- public static <E> SortedSet<E> sortedSet(Iterator<? extends E> iterator, Comparator<? super E> comparator) {
- return sortedSet(list(iterator), comparator);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterator
- * and comparator.
- * java.util.TreeSet(java.util.Iterator iterator, java.util.Comparator c)
- */
- public static <E> SortedSet<E> sortedSet(Iterator<? extends E> iterator, int size, Comparator<? super E> comparator) {
- return sortedSet(list(iterator, size), comparator);
- }
-
- private static <E> SortedSet<E> sortedSet(List<E> list, Comparator<? super E> comparator) {
- SortedSet<E> sortedSet = new TreeSet<E>(comparator);
- sortedSet.addAll(list);
- return sortedSet;
- }
-
- /**
- * Return a sorted set corresponding to the specified array.
- * java.util.TreeSet(Object[] array)
- */
- public static <E extends Comparable<? super E>> SortedSet<E> sortedSet(E... array) {
- return sortedSet(array, null);
- }
-
- /**
- * Return a sorted set corresponding to the specified array
- * and comparator.
- * java.util.TreeSet(Object[] array, java.util.Comparator c)
- */
- public static <E> SortedSet<E> sortedSet(E[] array, Comparator<? super E> comparator) {
- SortedSet<E> sortedSet = new TreeSet<E>(comparator);
- sortedSet.addAll(Arrays.asList(array));
- return sortedSet;
- }
-
- /**
- * Return a sub-array of the specified array, starting at the specified
- * position with the specified length.
- * java.util.Arrays#subArray(E[] array, int start, int length)
- */
- public static <E> E[] subArray(E[] array, int start, int length) {
- E[] result = newArray(array, length);
- if (length > 0) {
- System.arraycopy(array, start, result, 0, length);
- }
- return result;
- }
-
- /**
- * Return a sub-array of the specified array, starting at the specified
- * position with the specified length.
- * java.util.Arrays#subArray(int[] array, int start, int length)
- */
- public static int[] subArray(int[] array, int start, int length) {
- int[] result = new int[length];
- if (length > 0) {
- System.arraycopy(array, start, result, 0, length);
- }
- return result;
- }
-
- /**
- * Return a sub-array of the specified array, starting at the specified
- * position with the specified length.
- * java.util.Arrays#subArray(char[] array, int start, int length)
- */
- public static char[] subArray(char[] array, int start, int length) {
- char[] result = new char[length];
- if (length > 0) {
- System.arraycopy(array, start, result, 0, length);
- }
- return result;
- }
-
- /**
- * Return the array after the specified elements have been "swapped".
- * java.util.Arrays#swap(Object[] array, int i, int j)
- */
- public static <E> E[] swap(E[] array, int i, int j) {
- E temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- return array;
- }
-
- /**
- * Return the array after the specified elements have been "swapped".
- * java.util.Arrays#swap(char[] array, int i, int j)
- */
- public static char[] swap(char[] array, int i, int j) {
- char temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- return array;
- }
-
- /**
- * Return the array after the specified elements have been "swapped".
- * java.util.Arrays#swap(int[] array, int i, int j)
- */
- public static int[] swap(int[] array, int i, int j) {
- int temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- return array;
- }
-
- /**
- * Return a vector corresponding to the specified iterable.
- * This is useful for legacy code that requires a java.util.Vector.
- * java.util.Vector(java.lang.Iterable iterable)
- */
- public static <E> Vector<E> vector(Iterable<? extends E> iterable) {
- return vector(iterable.iterator());
- }
-
- /**
- * Return a vector corresponding to the specified iterable.
- * This is useful for legacy code that requires a java.util.Vector.
- * java.util.Vector(java.lang.Iterable iterable)
- */
- public static <E> Vector<E> vector(Iterable<? extends E> iterable, int size) {
- return vector(iterable.iterator(), size);
- }
-
- /**
- * Return a vector corresponding to the specified iterator.
- * This is useful for legacy code that requires a java.util.Vector.
- * java.util.Vector(java.util.Iterator iterator)
- */
- public static <E> Vector<E> vector(Iterator<? extends E> iterator) {
- return vector(iterator, new Vector<E>());
- }
-
- /**
- * Return a vector corresponding to the specified iterator.
- * This is useful for legacy code that requires a java.util.Vector.
- * java.util.Vector(java.util.Iterator iterator)
- */
- public static <E> Vector<E> vector(Iterator<? extends E> iterator, int size) {
- return vector(iterator, new Vector<E>(size));
- }
-
- private static <E> Vector<E> vector(Iterator<? extends E> iterator, Vector<E> v) {
- while (iterator.hasNext()) {
- v.addElement(iterator.next());
- }
- return v;
- }
-
- /**
- * Return a vector corresponding to the specified array.
- * This is useful for legacy code that requires a java.util.Vector.
- * java.util.Vector(Object[] array)
- */
- public static <E> Vector<E> vector(E... array) {
- Vector<E> v = new Vector<E>(array.length);
- for (E item : array) {
- v.addElement(item);
- }
- return v;
- }
-
-
- // ********** single-use Iterable **********
-
- /**
- * This is a one-time use iterable that can return a single iterator.
- * Once the iterator is returned the iterable is no longer valid.
- * As such, this utility should only be used in one-time use situations,
- * such as a 'for-each' loop.
- */
- public static class SingleUseIterable<E> implements Iterable<E> {
- private Iterator<E> iterator;
-
- public SingleUseIterable(Iterator<? extends E> iterator) {
- super();
- if (iterator == null) {
- throw new NullPointerException();
- }
- this.iterator = new GenericIteratorWrapper<E>(iterator);
- }
-
- public Iterator<E> iterator() {
- if (this.iterator == null) {
- throw new IllegalStateException("This method has already been called.");
- }
- Iterator<E> result = this.iterator;
- this.iterator = null;
- return result;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterator);
- }
-
- }
-
-
- // ********** java.util.Collections enhancements **********
-
- /**
- * Return the destination list after the source list has been copied into it.
- * @see java.util.Collections#copy(java.util.List, java.util.List)
- */
- public static <E> List<? super E> copy(List<? super E> dest, List<? extends E> src) {
- Collections.copy(dest, src);
- return dest;
- }
-
- /**
- * Return the list after it has been "filled".
- * @see java.util.Collections#fill(java.util.List, java.lang.Object)
- */
- public static <E> List<? super E> fill(List<? super E> list, E value) {
- Collections.fill(list, value);
- return list;
- }
-
- /**
- * Return the list after it has been "reversed".
- * @see java.util.Collections#reverse(java.util.List)
- */
- public static <E> List<E> reverse(List<E> list) {
- Collections.reverse(list);
- return list;
- }
-
- /**
- * Return the list after it has been "rotated" by one position.
- * @see java.util.Collections#rotate(java.util.List, int)
- */
- public static <E> List<E> rotate(List<E> list) {
- return rotate(list, 1);
- }
-
- /**
- * Return the list after it has been "rotated".
- * @see java.util.Collections#rotate(java.util.List, int)
- */
- public static <E> List<E> rotate(List<E> list, int distance) {
- Collections.rotate(list, distance);
- return list;
- }
-
- /**
- * Return the list after it has been "shuffled".
- * @see java.util.Collections#shuffle(java.util.List)
- */
- public static <E> List<E> shuffle(List<E> list) {
- Collections.shuffle(list);
- return list;
- }
-
- /**
- * Return the list after it has been "shuffled".
- * @see java.util.Collections#shuffle(java.util.List, java.util.Random)
- */
- public static <E> List<E> shuffle(List<E> list, Random random) {
- Collections.shuffle(list, random);
- return list;
- }
-
- /**
- * Return the list after it has been "sorted".
- * @see java.util.Collections#sort(java.util.List)
- */
- public static <E extends Comparable<? super E>> List<E> sort(List<E> list) {
- Collections.sort(list);
- return list;
- }
-
- /**
- * Return the list after it has been "sorted".
- * @see java.util.Collections#sort(java.util.List, java.util.Comparator)
- */
- public static <E> List<E> sort(List<E> list, Comparator<? super E> comparator) {
- Collections.sort(list, comparator);
- return list;
- }
-
- /**
- * Return the iterable after it has been "sorted".
- */
- public static <E extends Comparable<? super E>> Iterable<E> sort(Iterable<E> iterable) {
- return sort(iterable, null);
- }
-
- /**
- * Return the iterable after it has been "sorted".
- */
- public static <E> Iterable<E> sort(Iterable<E> iterable, Comparator<? super E> comparator) {
- return sort(list(iterable), comparator);
- }
-
- /**
- * Return the iterator after it has been "sorted".
- */
- public static <E extends Comparable<? super E>> Iterator<E> sort(Iterator<? extends E> iterator) {
- return sort(iterator, null);
- }
-
- /**
- * Return the iterator after it has been "sorted".
- */
- public static <E> Iterator<E> sort(Iterator<? extends E> iterator, Comparator<? super E> comparator) {
- return sort(list(iterator), comparator).iterator();
- }
-
- /**
- * Return the list after the specified elements have been "swapped".
- * @see java.util.Collections#swap(java.util.List, int, int)
- */
- public static <E> List<E> swap(List<E> list, int i, int j) {
- Collections.swap(list, i, j);
- return list;
- }
-
-
- // ********** java.util.Arrays enhancements **********
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(boolean[], boolean)
- */
- public static boolean[] fill(boolean[] array, boolean value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(boolean[], int, int, boolean)
- */
- public static boolean[] fill(boolean[] array, int fromIndex, int toIndex, boolean value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(byte[], byte)
- */
- public static byte[] fill(byte[] array, byte value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(byte[], int, int, byte)
- */
- public static byte[] fill(byte[] array, int fromIndex, int toIndex, byte value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(char[], char)
- */
- public static char[] fill(char[] array, char value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(char[], int, int, char)
- */
- public static char[] fill(char[] array, int fromIndex, int toIndex, char value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(double[], double)
- */
- public static double[] fill(double[] array, double value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(double[], int, int, double)
- */
- public static double[] fill(double[] array, int fromIndex, int toIndex, double value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(float[], float)
- */
- public static float[] fill(float[] array, float value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(float[], int, int, float)
- */
- public static float[] fill(float[] array, int fromIndex, int toIndex, float value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(int[], int)
- */
- public static int[] fill(int[] array, int value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(int[], int, int, int)
- */
- public static int[] fill(int[] array, int fromIndex, int toIndex, int value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(Object[], Object)
- */
- public static <E> E[] fill(E[] array, E value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(Object[], int, int, Object)
- */
- public static <E> E[] fill(E[] array, int fromIndex, int toIndex, E value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(long[], long)
- */
- public static long[] fill(long[] array, long value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(long[], int, int, long)
- */
- public static long[] fill(long[] array, int fromIndex, int toIndex, long value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(short[], short)
- */
- public static short[] fill(short[] array, short value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see java.util.Arrays#fill(short[], int, int, short)
- */
- public static short[] fill(short[] array, int fromIndex, int toIndex, short value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(byte[])
- */
- public static byte[] sort(byte... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(byte[], int, int)
- */
- public static byte[] sort(byte[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(char[])
- */
- public static char[] sort(char... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(char[], int, int)
- */
- public static char[] sort(char[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(double[])
- */
- public static double[] sort(double... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(double[], int, int)
- */
- public static double[] sort(double[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(float[])
- */
- public static float[] sort(float... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(float[], int, int)
- */
- public static float[] sort(float[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(int[])
- */
- public static int[] sort(int... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(int[], int, int)
- */
- public static int[] sort(int[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(Object[])
- */
- public static <E> E[] sort(E... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(Object[], java.util.Comparator)
- */
- public static <E> E[] sort(E[] array, Comparator<? super E> comparator) {
- Arrays.sort(array, comparator);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(Object[], int, int)
- */
- public static <E> E[] sort(E[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(Object[], int, int, java.util.Comparator)
- */
- public static <E> E[] sort(E[] array, int fromIndex, int toIndex, Comparator<? super E> comparator) {
- Arrays.sort(array, fromIndex, toIndex, comparator);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(long[])
- */
- public static long[] sort(long... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(long[], int, int)
- */
- public static long[] sort(long[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(short[])
- */
- public static short[] sort(short... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see java.util.Arrays#sort(short[], int, int)
- */
- public static short[] sort(short[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private CollectionTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Counter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Counter.java
deleted file mode 100644
index fbe3cde738..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Counter.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * This class can be used wherever a mutable integer object is needed.
- * It is a cross between an int and an Integer. It can be stored in a standard
- * container (e.g. Collection) but can be modified.
- */
-public final class Counter
- implements Cloneable, Serializable
-{
- private int count = 0;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a counter with the specified initial value.
- */
- public Counter(int count) {
- super();
- this.count = count;
- }
-
- /**
- * Construct a counter with an initial value of zero.
- */
- public Counter() {
- this(0);
- }
-
- /**
- * Return the current count of the counter.
- */
- public synchronized int count() {
- return this.count;
- }
-
- /**
- * Increment and return the current count of the counter.
- */
- public synchronized int increment() {
- return ++this.count;
- }
-
- /**
- * Increment and return the current count of the counter.
- */
- public synchronized int increment(int increment) {
- return this.count += increment;
- }
-
- /**
- * Derement and return the current count of the counter.
- */
- public synchronized int decrement() {
- return --this.count;
- }
-
- /**
- * Derement and return the current count of the counter.
- */
- public synchronized int decrement(int decrement) {
- return this.count -= decrement;
- }
-
- @Override
- public synchronized boolean equals(Object o) {
- if ( ! (o instanceof Counter)) {
- return false;
- }
- return this.count == ((Counter) o).count;
- }
-
- @Override
- public synchronized int hashCode() {
- return this.count;
- }
-
- @Override
- public synchronized Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public synchronized String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append(ClassTools.shortClassNameForObject(this));
- sb.append('(');
- sb.append(this.count);
- sb.append(')');
- return sb.toString();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/EmptyIterable.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/EmptyIterable.java
deleted file mode 100644
index 36155692e6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/EmptyIterable.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-
-/**
- * An <code>EmptyIterable</code> is just that.
- */
-public final class EmptyIterable<E>
- implements Iterable<E>
-{
-
- // singleton
- @SuppressWarnings("unchecked")
- private static final EmptyIterable INSTANCE = new EmptyIterable();
-
- /**
- * Return the singleton.
- */
- @SuppressWarnings("unchecked")
- public static <T> Iterable<T> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private EmptyIterable() {
- super();
- }
-
- public Iterator<E> iterator() {
- return EmptyIterator.instance();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/FileTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/FileTools.java
deleted file mode 100644
index 44154c4ed5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/FileTools.java
+++ /dev/null
@@ -1,1006 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.channels.FileChannel;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-/**
- * Assorted file tools:
- * - delete entire trees of directories and files
- * - build iterators on entire trees of directories and files
- * - build a temporary directory
- * - "canonize" files
- */
-public final class FileTools {
-
- public static final String USER_HOME_DIRECTORY_NAME = System.getProperty("user.home");
- public static final String USER_TEMPORARY_DIRECTORY_NAME = System.getProperty("java.io.tmpdir");
- public static String DEFAULT_TEMPORARY_DIRECTORY_NAME = "tmpdir";
- public static final String CURRENT_WORKING_DIRECTORY_NAME = System.getProperty("user.dir");
-
- /** A list of some invalid file name characters.
- : is the filename separator in MacOS and the drive indicator in DOS
- * is a DOS wildcard character
- | is a DOS redirection character
- & is our own escape character
- / is the filename separator in Unix and the command option tag in DOS
- \ is the filename separator in DOS/Windows and the escape character in Unix
- ; is ???
- ? is a DOS wildcard character
- [ is ???
- ] is ???
- = is ???
- + is ???
- < is a DOS redirection character
- > is a DOS redirection character
- " is used by DOS to delimit file names with spaces
- , is ???
- */
- public static final char[] INVALID_FILENAME_CHARACTERS = { ':', '*', '|', '&', '/', '\\', ';', '?', '[', ']', '=', '+', '<', '>', '"', ',' };
-
- /** This encoder will convert strings into valid file names. */
- public static final XMLStringEncoder FILE_NAME_ENCODER = new XMLStringEncoder(INVALID_FILENAME_CHARACTERS);
-
- /** Windows files that are redirected to devices etc. */
- private static final String[] WINDOWS_RESERVED_FILE_NAMES = {
- "con",
- "aux",
- "com1", "com2", "com3", "com4", "com5", "com6", "com7", "com8", "com9",
- "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9",
- "prn",
- "nul"
- };
-
- /** The default length of a shortened file name. */
- public static final int MAXIMUM_SHORTENED_FILE_NAME_LENGTH = 60;
-
-
- // ********** deleting directories **********
-
- /**
- * Delete the specified directory and all of its contents.
- * <em>USE WITH CARE.</em>
- * File#deleteAll()?
- */
- public static void deleteDirectory(String directoryName) {
- deleteDirectory(new File(directoryName));
- }
-
- /**
- * Delete the specified directory and all of its contents.
- * <em>USE WITH CARE.</em>
- * File#deleteAll()?
- */
- public static void deleteDirectory(File directory) {
- deleteDirectoryContents(directory);
- if ( ! directory.delete()) {
- throw new RuntimeException("unable to delete directory: " + directory.getAbsolutePath());
- }
- }
-
- /**
- * Delete the contents of the specified directory
- * (but not the directory itself).
- * <em>USE WITH CARE.</em>
- * File#deleteFiles()
- */
- public static void deleteDirectoryContents(String directoryName) {
- deleteDirectoryContents(new File(directoryName));
- }
-
- /**
- * Delete the contents of the specified directory
- * (but not the directory itself).
- * <em>USE WITH CARE.</em>
- * File#deleteFiles()
- */
- public static void deleteDirectoryContents(File directory) {
- for (File file : directory.listFiles()) {
- if (file.isDirectory()) {
- deleteDirectory(file); // recurse through subdirectories
- } else {
- if ( ! file.delete()) {
- throw new RuntimeException("unable to delete file: " + file.getAbsolutePath());
- }
- }
- }
- }
-
-
- // ********** copying files **********
-
- /**
- * Copies the content of the source file to the destination file.
- * File#copy(File destinationFile)
- */
- public static void copyToFile(File sourceFile, File destinationFile)
- throws IOException
- {
- FileChannel sourceChannel = new FileInputStream(sourceFile).getChannel();
- FileChannel destinationChannel = new FileOutputStream(destinationFile).getChannel();
- try {
- destinationChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
- } finally {
- sourceChannel.close();
- destinationChannel.close();
- }
- }
-
- /**
- * Copies the content of the source file to a file by
- * the same name in the destination directory.
- * File#copyToDirectory(File destinationDirectory)
- */
- public static void copyToDirectory(File sourceFile, File destinationDirectory)
- throws IOException
- {
- File destinationFile = new File(destinationDirectory, sourceFile.getName());
- destinationFile.createNewFile();
- copyToFile(sourceFile, destinationFile);
- }
-
-
- // ********** iteratoring over files and directories **********
-
- /**
- * Return an iterator on all the files in the specified directory.
- * The iterator will skip over subdirectories.
- * File#files()
- */
- public static Iterator<File> filesIn(String directoryName) {
- return filesIn(new File(directoryName));
- }
-
- /**
- * Return an iterator on all the files in the specified directory.
- * The iterator will skip over subdirectories.
- * File#files()
- */
- public static Iterator<File> filesIn(File directory) {
- return filesIn(directory.listFiles());
- }
-
- private static Iterator<File> filesIn(File[] files) {
- return new FilteringIterator<File, File>(new ArrayIterator<File>(files)) {
- @Override
- protected boolean accept(File next) {
- return next.isFile();
- }
- };
- }
-
- /**
- * Return an iterator on all the subdirectories
- * in the specified directory.
- * File#subDirectories()
- */
- public static Iterator<File> directoriesIn(String directoryName) {
- return directoriesIn(new File(directoryName));
- }
-
- /**
- * Return an iterator on all the subdirectories
- * in the specified directory.
- * File#subDirectories()
- */
- public static Iterator<File> directoriesIn(File directory) {
- return directoriesIn(directory.listFiles());
- }
-
- private static Iterator<File> directoriesIn(File[] files) {
- return new FilteringIterator<File, File>(new ArrayIterator<File>(files)) {
- @Override
- protected boolean accept(File next) {
- return next.isDirectory();
- }
- };
- }
-
- /**
- * Return an iterator on all the files under the specified
- * directory, recursing into subdirectories.
- * The iterator will skip over the subdirectories themselves.
- * File#filesRecurse()
- */
- public static Iterator<File> filesInTree(String directoryName) {
- return filesInTree(new File(directoryName));
- }
-
- /**
- * Return an iterator on all the files under the specified
- * directory, recursing into subdirectories.
- * The iterator will skip over the subdirectories themselves.
- * File#filesRecurse()
- */
- public static Iterator<File> filesInTree(File directory) {
- return filesInTreeAsSet(directory).iterator();
- }
-
- private static Set<File> filesInTreeAsSet(File directory) {
- Set<File> files = new HashSet<File>(10000);
- addFilesInTreeTo(directory, files);
- return files;
- }
-
- private static void addFilesInTreeTo(File directory, Collection<File> allFiles) {
- for (File file : directory.listFiles()) {
- if (file.isFile()) {
- allFiles.add(file);
- } else if (file.isDirectory()) {
- addFilesInTreeTo(file, allFiles);
- }
- }
- }
-
- /**
- * Return an iterator on all the directories under the specified
- * directory, recursing into subdirectories.
- * File#subDirectoriesRecurse()
- */
- public static Iterator<File> directoriesInTree(String directoryName) {
- return directoriesInTree(new File(directoryName));
- }
-
- /**
- * Return an iterator on all the directories under the specified
- * directory, recursing into subdirectories.
- * File#subDirectoriesRecurse()
- */
- @SuppressWarnings("unchecked")
- public static Iterator<File> directoriesInTree(File directory) {
- File[] files = directory.listFiles();
- return new CompositeIterator<File>(directoriesIn(files), directoriesInTrees(directoriesIn(files)));
- }
-
- private static Iterator<File> directoriesInTrees(Iterator<File> directories) {
- return new CompositeIterator<File>(
- new TransformationIterator<File, Iterator<File>>(directories) {
- @Override
- protected Iterator<File> transform(File next) {
- return FileTools.directoriesInTree(next);
- }
- }
- );
- }
-
-
- // ********** short file name manipulation **********
-
- /**
- * Strip the extension from the specified file name
- * and return the result. If the file name has no
- * extension, it is returned unchanged
- * File#basePath()
- */
- public static String stripExtension(String fileName) {
- int index = fileName.lastIndexOf('.');
- if (index == -1) {
- return fileName;
- }
- return fileName.substring(0, index);
- }
-
- /**
- * Strip the extension from the specified file's name
- * and return the result. If the file's name has no
- * extension, it is returned unchanged
- * File#basePath()
- */
- public static String stripExtension(File file) {
- return stripExtension(file.getPath());
- }
-
- /**
- * Return the extension, including the dot, of the specified file name.
- * If the file name has no extension, return an empty string.
- * File#extension()
- */
- public static String extension(String fileName) {
- int index = fileName.lastIndexOf('.');
- if (index == -1) {
- return "";
- }
- return fileName.substring(index);
- }
-
- /**
- * Return the extension, including the dot, of the specified file's name.
- * If the file's name has no extension, return an empty string.
- * File#extension()
- */
- public static String extension(File file) {
- return extension(file.getPath());
- }
-
-
- // ********** temporary directories **********
-
- /**
- * Build and return an empty temporary directory with the specified
- * name. If the directory already exists, it will be cleared out.
- * This directory will be a subdirectory of the Java temporary directory,
- * as indicated by the System property "java.io.tmpdir".
- */
- public static File emptyTemporaryDirectory(String name) {
- File dir = new File(userTemporaryDirectory(), name);
- if (dir.exists()) {
- deleteDirectoryContents(dir);
- } else {
- dir.mkdirs();
- }
- return dir;
- }
-
- /**
- * Build and return an empty temporary directory with a
- * name of "tmpdir". If the directory already exists, it will be cleared out.
- * This directory will be a subdirectory of the Java temporary directory,
- * as indicated by the System property "java.io.tmpdir".
- */
- public static File emptyTemporaryDirectory() {
- return emptyTemporaryDirectory(DEFAULT_TEMPORARY_DIRECTORY_NAME);
- }
-
- /**
- * Build and return a temporary directory with the specified
- * name. If the directory already exists, it will be left unchanged;
- * if it does not already exist, it will be created.
- * This directory will be a subdirectory of the Java temporary directory,
- * as indicated by the System property "java.io.tmpdir".
- */
- public static File temporaryDirectory(String name) {
- File dir = new File(userTemporaryDirectory(), name);
- if ( ! dir.exists()) {
- dir.mkdirs();
- }
- return dir;
- }
-
- /**
- * Build and return a temporary directory with a name of
- * "tmpdir". If the directory already exists, it will be left unchanged;
- * if it does not already exist, it will be created.
- * This directory will be a subdirectory of the Java temporary directory,
- * as indicated by the System property "java.io.tmpdir".
- */
- public static File temporaryDirectory() {
- return temporaryDirectory(DEFAULT_TEMPORARY_DIRECTORY_NAME);
- }
-
- /**
- * Build and return a *new* temporary directory with the specified
- * prefix. The prefix will be appended with a number that
- * is incremented, starting with 1, until a non-pre-existing directory
- * is found and successfully created. This directory will be a
- * subdirectory of the Java temporary directory, as indicated by
- * the System property "java.io.tmpdir".
- */
- public static File newTemporaryDirectory(String prefix) {
- if ( ! prefix.endsWith(".")) {
- prefix = prefix + ".";
- }
- File dir;
- int i = 0;
- do {
- i++;
- dir = new File(userTemporaryDirectory(), prefix + i);
- } while ( ! dir.mkdirs());
- return dir;
- }
-
- /**
- * Build and return a *new* temporary directory with a
- * prefix of "tmpdir". This prefix will be appended with a number that
- * is incremented, starting with 1, until a non-pre-existing directory
- * is found and successfully created. This directory will be a
- * subdirectory of the Java temporary directory, as indicated by
- * the System property "java.io.tmpdir".
- */
- public static File newTemporaryDirectory() {
- return newTemporaryDirectory(DEFAULT_TEMPORARY_DIRECTORY_NAME);
- }
-
-
- // ********** resource files **********
-
- /**
- * Build and return a file for the specified resource.
- * The resource name must be fully-qualified, i.e. it cannot be relative
- * to the package name/directory.
- * NB: There is a bug in jdk1.4.x the prevents us from getting
- * a resource that has spaces (or other special characters) in
- * its name.... (see Sun's Java bug 4466485)
- */
- public static File resourceFile(String resourceName) throws URISyntaxException {
- if ( ! resourceName.startsWith("/")) {
- throw new IllegalArgumentException(resourceName);
- }
- return resourceFile(resourceName, FileTools.class);
- }
-
- /**
- * Build and return a file for the specified resource.
- * NB: There is a bug in jdk1.4.x the prevents us from getting
- * a resource that has spaces (or other special characters) in
- * its name.... (see Sun's Java bug 4466485)
- */
- public static File resourceFile(String resourceName, Class<?> javaClass) throws URISyntaxException {
- URL url = javaClass.getResource(resourceName);
- return buildFile(url);
- }
-
- /**
- * Build and return a file for the specified URL.
- * NB: There is a bug in jdk1.4.x the prevents us from getting
- * a resource that has spaces (or other special characters) in
- * its name.... (see Sun's Java bug 4466485)
- */
- public static File buildFile(URL url) throws URISyntaxException {
- return buildFile(url.getFile());
- }
-
- /**
- * Build and return a file for the specified file name.
- * NB: There is a bug in jdk1.4.x the prevents us from getting
- * a resource that has spaces (or other special characters) in
- * its name.... (see Sun's Java bug 4466485)
- */
- public static File buildFile(String fileName) throws URISyntaxException {
- URI uri = new URI(fileName);
- File file = new File(uri.getPath());
- return file;
- }
-
-
- // ********** "canonical" files **********
-
- /**
- * Convert the specified file into a "canonical" file.
- */
- public static File canonicalFile(File file) {
- try {
- return file.getCanonicalFile();
- } catch (IOException ioexception) {
- // settle for the absolute file
- return file.getAbsoluteFile();
- }
- }
-
- /**
- * Build an iterator that will convert the specified files
- * into "canonical" files.
- */
- public static Iterator<File> canonicalFiles(Iterator<File> files) {
- return new TransformationIterator<File, File>(files) {
- @Override
- protected File transform(File next) {
- return canonicalFile(next);
- }
- };
- }
-
- /**
- * Build an iterator that will convert the specified files
- * into "canonical" files.
- */
- public static Iterator<File> canonicalFiles(Collection<File> files) {
- return canonicalFiles(files.iterator());
- }
-
- /**
- * Convert the specified file name into a "canonical" file name.
- */
- public static String canonicalFileName(String fileName) {
- return canonicalFile(new File(fileName)).getAbsolutePath();
- }
-
- /**
- * Build an iterator that will convert the specified file names
- * into "canonical" file names.
- */
- public static Iterator<String> canonicalFileNames(Iterator<String> fileNames) {
- return new TransformationIterator<String, String>(fileNames) {
- @Override
- protected String transform(String next) {
- return canonicalFileName(next);
- }
- };
- }
-
- /**
- * Build an iterator that will convert the specified file names
- * into "canonical" file names.
- */
- public static Iterator<String> canonicalFileNames(Collection<String> fileNames) {
- return canonicalFileNames(fileNames.iterator());
- }
-
-
- // ********** file name validation **********
-
- /**
- * Return whether the specified file name is invalid.
- */
- public static boolean fileNameIsInvalid(String filename) {
- return ! fileNameIsValid(filename);
- }
-
- /**
- * Return whether the specified file name is valid.
- */
- public static boolean fileNameIsValid(String filename) {
- int len = filename.length();
- for (int i = 0; i < len; i++) {
- char filenameChar = filename.charAt(i);
- if (CollectionTools.contains(INVALID_FILENAME_CHARACTERS, filenameChar)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Convert the illegal characters in the specified file name to
- * the specified character and return the result.
- */
- public static String convertToValidFileName(String filename, char replacementChar) {
- int len = filename.length();
- StringBuilder sb = new StringBuilder(len);
- for (int i = 0; i < len; i++) {
- char filenameChar = filename.charAt(i);
- if (CollectionTools.contains(INVALID_FILENAME_CHARACTERS, filenameChar)) {
- sb.append(replacementChar);
- } else {
- sb.append(filenameChar);
- }
- }
- return sb.toString();
- }
-
- /**
- * Convert the illegal characters in the specified file name to
- * periods ('.') and return the result.
- */
- public static String convertToValidFileName(String filename) {
- return convertToValidFileName(filename, '.');
- }
-
- /**
- * Return whether the specified file name is "reserved"
- * (i.e. it cannot be used for "user" files). Windows reserves
- * a number of file names (e.g. CON, AUX, PRN).
- */
- public static boolean fileNameIsReserved(String fileName) {
- if (executingOnWindows()) {
- return CollectionTools.contains(WINDOWS_RESERVED_FILE_NAMES, fileName.toLowerCase());
- }
- return false; // Unix does not have any "reserved" file names (I think...)
- }
-
- /**
- * Return whether the specified file contains any "reserved"
- * components.
- * Windows reserves a number of file names (e.g. CON, AUX, PRN);
- * and these file names cannot be used for either the names of
- * files or directories.
- */
- public static boolean fileHasAnyReservedComponents(File file) {
- File temp = file;
- while (temp != null) {
- if (fileNameIsReserved(temp.getName())) {
- return true;
- }
- temp = temp.getParentFile();
- }
- return false;
- }
-
-
- // ********** shortened file names **********
-
- /**
- * Return a shorter version of the absolute file name for the specified file.
- * The shorter version will not be longer than the maximum length.
- * The first directory (usually the drive letter) and the file name or the
- * last directory will always be added to the generated string regardless of
- * the maximum length allowed.
- */
- public static String shortenFileName(URL url) {
- return shortenFileName(url, MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
- }
-
- /**
- * Return a shorter version of the absolute file name for the specified file.
- * The shorter version will not be longer than the maximum length.
- * The first directory (usually the drive letter) and the file name or the
- * last directory will always be added to the generated string regardless of
- * the maximum length allowed.
- */
- public static String shortenFileName(URL url, int maxLength) {
- File file;
- try {
- file = buildFile(url);
- } catch (URISyntaxException e) {
- file = new File(url.getFile());
- }
- return shortenFileName(file, maxLength);
- }
-
- /**
- * Return a shorter version of the absolute file name for the specified file.
- * The shorter version will not be longer than the maximum length.
- * The first directory (usually the drive letter) and the file name or the
- * last directory will always be added to the generated string regardless of
- * the maximum length allowed.
- */
- public static String shortenFileName(File file) {
- return shortenFileName(file, MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
- }
-
- /**
- * Return a shorter version of the absolute file name for the specified file.
- * The shorter version will not be longer than the maximum length.
- * The first directory (usually the drive letter) and the file name or the
- * last directory will always be added to the generated string regardless of
- * the maximum length allowed.
- */
- public static String shortenFileName(File file, int maxLength) {
- String absoluteFileName = canonicalFile(file).getAbsolutePath();
- if (absoluteFileName.length() <= maxLength) {
- // no need to shorten
- return absoluteFileName;
- }
-
- // break down the path into its components
- String fs = File.separator;
- String[] paths = absoluteFileName.split("\\" + fs);
-
- if (paths.length <= 1) {
- // e.g. "C:\"
- return paths[0];
- }
-
- if (paths.length == 2) {
- // e.g. "C:\MyReallyLongFileName.ext" or "C:\MyReallyLongDirectoryName"
- // return the complete file name since this is a minimum requirement,
- // regardless of the maximum length allowed
- return absoluteFileName;
- }
-
- StringBuilder sb = new StringBuilder();
- sb.append(paths[0]); // always add the first directory, which is usually the drive letter
-
- // Keep the index of insertion into the string buffer
- int insertIndex = sb.length();
-
- sb.append(fs);
- sb.append(paths[paths.length - 1]); // append the file name or the last directory
-
- maxLength -= 4; // -4 for "/..."
-
- int currentLength = sb.length() - 4; // -4 for "/..."
- int leftIndex = 1; // 1 to skip the root directory
- int rightIndex = paths.length - 2; // -1 for the file name or the last directory
-
- boolean canAddFromLeft = true;
- boolean canAddFromRight = true;
-
- // Add each directory, the insertion is going in both direction: left and
- // right, once a side can't be added, the other side is still continuing
- // until both can't add anymore
- while (true) {
- if (!canAddFromLeft && !canAddFromRight)
- break;
-
- if (canAddFromRight) {
- String rightDirectory = paths[rightIndex];
- int rightLength = rightDirectory.length();
-
- // Add the directory on the right side of the loop
- if (currentLength + rightLength + 1 <= maxLength) {
- sb.insert(insertIndex, fs);
- sb.insert(insertIndex + 1, rightDirectory);
-
- currentLength += rightLength + 1;
- rightIndex--;
-
- // The right side is now overlapping the left side, that means
- // we can't add from the right side anymore
- if (leftIndex >= rightIndex) {
- canAddFromRight = false;
- }
- } else {
- canAddFromRight = false;
- }
- }
-
- if (canAddFromLeft) {
- String leftDirectory = paths[leftIndex];
- int leftLength = leftDirectory.length();
-
- // Add the directory on the left side of the loop
- if (currentLength + leftLength + 1 <= maxLength) {
- sb.insert(insertIndex, fs);
- sb.insert(insertIndex + 1, leftDirectory);
-
- insertIndex += leftLength + 1;
- currentLength += leftLength + 1;
- leftIndex++;
-
- // The left side is now overlapping the right side, that means
- // we can't add from the left side anymore
- if (leftIndex >= rightIndex) {
- canAddFromLeft = false;
- }
- } else {
- canAddFromLeft = false;
- }
- }
- }
-
- if (leftIndex <= rightIndex) {
- sb.insert(insertIndex, fs);
- sb.insert(insertIndex + 1, "...");
- }
-
- return sb.toString();
- }
-
-
- // ********** system properties **********
-
- /**
- * Return a file representing the user's home directory.
- */
- public static File userHomeDirectory() {
- return new File(USER_HOME_DIRECTORY_NAME);
- }
-
- /**
- * Return a file representing the user's temporary directory.
- */
- public static File userTemporaryDirectory() {
- return new File(USER_TEMPORARY_DIRECTORY_NAME);
- }
-
- /**
- * Return a file representing the current working directory.
- */
- public static File currentWorkingDirectory() {
- return new File(CURRENT_WORKING_DIRECTORY_NAME);
- }
-
-
- // ********** miscellaneous **********
-
- private static boolean executingOnWindows() {
- return executingOn("Windows");
- }
-
-// private static boolean executingOnLinux() {
-// return executingOn("Linux");
-// }
-//
- private static boolean executingOn(String osName) {
- return System.getProperty("os.name").indexOf(osName) != -1;
- }
-
- /**
- * Return only the files that fit the filter.
- * File#files(FileFilter fileFilter)
- */
- public static Iterator<File> filter(Iterator<File> files, final FileFilter fileFilter) {
- return new FilteringIterator<File, File>(files) {
- @Override
- protected boolean accept(File next) {
- return fileFilter.accept(next);
- }
- };
- }
-
- /**
- * Return a file that is a re-specification of the specified
- * file, relative to the specified directory.
- * Linux/Unix/Mac:
- * convertToRelativeFile(/foo/bar/baz.java, /foo)
- * => bar/baz.java
- * Windows:
- * convertToRelativeFile(C:\foo\bar\baz.java, C:\foo)
- * => bar/baz.java
- * The file can be either a file or a directory; the directory
- * *should* be a directory.
- * If the file is already relative or it cannot be made relative
- * to the directory, it will be returned unchanged.
- *
- * NB: This method has been tested on Windows and Linux,
- * but not Mac (but the Mac is Unix-based these days, so
- * it shouldn't be a problem...).
- */
- public static File convertToRelativeFile(final File file, final File dir) {
- // check whether the file is already relative
- if ( ! file.isAbsolute()) {
- return file; // return unchanged
- }
-
- File cFile = canonicalFile(file);
- File cDir = canonicalFile(dir);
-
- // the two are the same directory
- if (cFile.equals(cDir)) {
- return new File(".");
- }
-
- File[] filePathFiles = pathFiles(cFile);
- File[] dirPathFiles = pathFiles(cDir);
-
- // Windows only (?): the roots are different - e.g. D:\ vs. C:\
- if ( ! dirPathFiles[0].equals(filePathFiles[0])) {
- return file; // return unchanged
- }
-
- // at this point we know the root is the same, now find how much is in common
- int i = 0; // this will point at the first miscompare
- while ((i < dirPathFiles.length) && (i < filePathFiles.length)) {
- if (dirPathFiles[i].equals(filePathFiles[i])) {
- i++;
- } else {
- break;
- }
- }
- // save our current position
- int firstMismatch = i;
-
- // check whether the file is ABOVE the directory: ../..
- if (firstMismatch == filePathFiles.length) {
- return relativeParentFile(dirPathFiles.length - firstMismatch);
- }
-
- // build a new file from the path beyond the matching portions
- File diff = new File(filePathFiles[i].getName());
- while (++i < filePathFiles.length) {
- diff = new File(diff, filePathFiles[i].getName());
- }
-
- // check whether the file is BELOW the directory: subdir1/subdir2/file.ext
- if (firstMismatch == dirPathFiles.length) {
- return diff;
- }
-
- // the file must be a PEER of the directory: ../../subdir1/subdir2/file.ext
- return new File(relativeParentFile(dirPathFiles.length - firstMismatch), diff.getPath());
- }
-
- /**
- * Return a file that is a re-specification of the specified
- * file, relative to the current working directory.
- * Linux/Unix/Mac (CWD = /foo):
- * convertToRelativeFile(/foo/bar/baz.java)
- * => bar/baz.java
- * Windows (CWD = C:\foo):
- * convertToRelativeFile(C:\foo\bar\baz.java)
- * => bar/baz.java
- * The file can be either a file or a directory.
- * If the file is already relative or it cannot be made relative
- * to the directory, it will be returned unchanged.
- *
- * NB: This method has been tested on Windows and Linux,
- * but not Mac (but the Mac is Unix-based these days, so
- * it shouldn't be a problem...).
- */
- public static File convertToRelativeFile(final File file) {
- return convertToRelativeFile(file, currentWorkingDirectory());
- }
-
- /**
- * Return an array of files representing the path to the specified
- * file. For example:
- * C:/foo/bar/baz.txt =>
- * { C:/, C:/foo, C:/foo/bar, C:/foo/bar/baz.txt }
- */
- private static File[] pathFiles(File file) {
- List<File> path = new ArrayList<File>();
- for (File f = file; f != null; f = f.getParentFile()) {
- path.add(f);
- }
- Collections.reverse(path);
- return path.toArray(new File[path.size()]);
- }
-
- /**
- * Return a file with the specified (non-zero) number of relative
- * file names, e.g. xxx(3) => ../../..
- */
- private static File relativeParentFile(int len) {
- if (len <= 0) {
- throw new IllegalArgumentException("length must be greater than zero: " + len);
- }
- File result = new File("..");
- for (int i = len - 1; i-- > 0; ) {
- result = new File(result, "..");
- }
- return result;
- }
-
- /**
- * Return a file that is a re-specification of the specified
- * file, absolute to the specified directory.
- * Linux/Unix/Mac:
- * convertToAbsoluteFile(bar/baz.java, /foo)
- * => /foo/bar/baz.java
- * Windows:
- * convertToAbsoluteFile(bar/baz.java, C:\foo)
- * => C:\foo\bar\baz.java
- * The file can be either a file or a directory; the directory
- * *should* be a directory.
- * If the file is already absolute, it will be returned unchanged.
- *
- * NB: This method has been tested on Windows and Linux,
- * but not Mac (but the Mac is Unix-based these days, so
- * it shouldn't be a problem...).
- */
- public static File convertToAbsoluteFile(final File file, final File dir) {
- // check whether the file is already absolute
- if (file.isAbsolute()) {
- return file; // return unchanged
- }
- return canonicalFile(new File(dir, file.getPath()));
- }
-
- /**
- * Return a file that is a re-specification of the specified
- * file, absolute to the current working directory.
- * Linux/Unix/Mac (CWD = /foo):
- * convertToAbsoluteFile(bar/baz.java)
- * => /foo/bar/baz.java
- * Windows (CWD = C:\foo):
- * convertToAbsoluteFile(bar/baz.java)
- * => C:\foo\bar\baz.java
- * The file can be either a file or a directory.
- * If the file is already absolute, it will be returned unchanged.
- *
- * NB: This method has been tested on Windows and Linux,
- * but not Mac (but the Mac is Unix-based these days, so
- * it shouldn't be a problem...).
- */
- public static File convertToAbsoluteFile(final File file) {
- return convertToAbsoluteFile(file, currentWorkingDirectory());
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private FileTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java
deleted file mode 100644
index 45dba9a781..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java
+++ /dev/null
@@ -1,842 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-import java.util.AbstractCollection;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * This class implements the <code>Bag</code> interface, backed by a
- * hash table. It makes no guarantees as to the iteration order of
- * the bag's elements; in particular, it does not guarantee that the order
- * will remain constant over time. This class permits the <code>null</code>
- * element.
- * <p>
- * This class offers constant time performance for the basic operations
- * (<code>add</code>, <code>remove</code>, <code>contains</code> and
- * <code>size</code>), assuming the hash function disperses the elements
- * properly among the buckets. Iterating over this bag requires time
- * proportional to the sum of the bag's size (the number of elements) plus the
- * "capacity" of the backing hash table (the number of buckets). Thus, it is
- * important not to set the initial capacity too high (or the load factor too
- * low) if iteration performance is important.
- * <p>
- * <b>Note that this implementation is not synchronized.</b> If multiple
- * threads access a bag concurrently, and at least one of the threads modifies
- * the bag, it <i>must</i> be synchronized externally. This is typically
- * accomplished by synchronizing on some object that naturally encapsulates
- * the bag. If no such object exists, the bag should be "wrapped" using the
- * <code>Collections.synchronizedCollection</code> method. This is
- * best done at creation time, to prevent accidental unsynchronized access
- * to the bag:
- * <pre>
- * Collection c = Collections.synchronizedCollection(new HashBag(...));
- * </pre>
- * <p>
- * The iterators returned by this class's <code>iterator</code> method are
- * <i>fail-fast</i>: if the bag is modified at any time after the iterator is
- * created, in any way except through the iterator's own <code>remove</code>
- * method, the iterator throws a <code>ConcurrentModificationException</code>.
- * Thus, in the face of concurrent modification, the iterator fails quickly
- * and cleanly, rather than risking arbitrary, non-deterministic behavior at
- * an undetermined time in the future.
- *
- * @see Collections#synchronizedCollection(Collection)
- */
-
-public class HashBag<E> extends AbstractCollection<E>
- implements Bag<E>, Cloneable, Serializable {
-
- /** The hash table. */
- transient Entry<E>[] table;
-
- /** The total number of entries in the bag. */
- transient int count = 0;
-
- /** The number of unique entries in the bag. */
- transient int uniqueCount = 0;
-
- /**
- * The hash table is rehashed when its size exceeds this threshold. (The
- * value of this field is (int)(capacity * loadFactor).)
- *
- * @serial
- */
- private int threshold;
-
- /**
- * The load factor for the hash table.
- *
- * @serial
- */
- private float loadFactor;
-
- /**
- * The number of times this bag has been structurally modified.
- * Structural modifications are those that change the number of entries in
- * the bag or otherwise modify its internal structure (e.g. rehash).
- * This field is used to make iterators on this bag fail-fast.
- *
- * @see java.util.ConcurrentModificationException
- */
- transient int modCount = 0;
-
- /**
- * Constructs a new, empty bag with the
- * default capacity, which is 11, and load factor, which is 0.75.
- */
- public HashBag() {
- this(11, 0.75f);
- }
-
- /**
- * Constructs a new, empty bag with the specified initial capacity
- * and default load factor, which is 0.75.
- *
- * @param initialCapacity the initial capacity of the backing map.
- * @throws IllegalArgumentException if the initial capacity is less
- * than zero.
- */
- public HashBag(int initialCapacity) {
- this(initialCapacity, 0.75f);
- }
-
- /**
- * Constructs a new, empty bag with
- * the specified initial capacity and the specified load factor.
- *
- * @param initialCapacity the initial capacity of the backing map.
- * @param loadFactor the load factor of the backing map.
- * @throws IllegalArgumentException if the initial capacity is less
- * than zero, or if the load factor is nonpositive.
- */
- public HashBag(int initialCapacity, float loadFactor) {
- if (initialCapacity < 0) {
- throw new IllegalArgumentException("Illegal Initial Capacity: " + initialCapacity);
- }
- if (loadFactor <= 0 || Float.isNaN(loadFactor)) {
- throw new IllegalArgumentException("Illegal Load factor: " + loadFactor);
- }
- if (initialCapacity == 0) {
- initialCapacity = 1;
- }
- this.loadFactor = loadFactor;
- this.table = this.buildTable(initialCapacity);
- this.threshold = (int) (initialCapacity * loadFactor);
- }
-
- /**
- * Constructs a new bag containing the elements in the specified
- * collection. The capacity of the bag is
- * twice the size of the specified collection or 11 (whichever is
- * greater), and the default load factor, which is 0.75, is used.
- *
- * @param c the collection whose elements are to be placed into this bag.
- */
- public HashBag(Collection<? extends E> c) {
- this(Math.max(2*c.size(), 11));
- this.addAll(c);
- }
-
- /**
- * This implementation simply returns the maintained count.
- */
- @Override
- public int size() {
- return this.count;
- }
-
- /**
- * This implementation simply compares the maintained count to zero.
- */
- @Override
- public boolean isEmpty() {
- return this.count == 0;
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- @Override
- public boolean contains(Object o) {
- Entry<E>[] tab = this.table;
- if (o == null) {
- for (Entry<E> e = tab[0]; e != null; e = e.next) {
- if (e.object == null) {
- return true;
- }
- }
- } else {
- int hash = o.hashCode();
- int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[index]; e != null; e = e.next) {
- if ((e.hash == hash) && o.equals(e.object)) {
- return true;
- }
- }
- }
- return false;
- }
-
- public int count(Object o) {
- Entry<E>[] tab = this.table;
- if (o == null) {
- for (Entry<E> e = tab[0]; e != null; e = e.next) {
- if (e.object == null) {
- return e.count;
- }
- }
- } else {
- int hash = o.hashCode();
- int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[index]; e != null; e = e.next) {
- if ((e.hash == hash) && o.equals(e.object)) {
- return e.count;
- }
- }
- }
- return 0;
- }
-
- /**
- * Rehashes the contents of this bag into a new hash table
- * with a larger capacity. This method is called when the
- * number of different elements in this map exceeds its
- * capacity and load factor.
- */
- private void rehash() {
- Entry<E>[] oldMap = this.table;
- int oldCapacity = oldMap.length;
-
- int newCapacity = oldCapacity * 2 + 1;
- Entry<E>[] newTable = this.buildTable(newCapacity);
-
- this.modCount++;
- this.threshold = (int) (newCapacity * this.loadFactor);
- this.table = newTable;
-
- for (int i = oldCapacity; i-- > 0; ) {
- for (Entry<E> old = oldMap[i]; old != null; ) {
- Entry<E> e = old;
- old = old.next;
-
- int index = (e.hash & 0x7FFFFFFF) % newCapacity;
- e.next = newTable[index];
- newTable[index] = e;
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- private Entry<E>[] buildTable(int capacity) {
- return new Entry[capacity];
- }
-
- @SuppressWarnings("unchecked")
- private <T> Entry<E> buildEntry(int hash, Object o, Entry<T> next) {
- return new Entry(hash, o, next);
- }
-
- @SuppressWarnings("unchecked")
- private <T> Entry<E> buildEntry(int hash, Object o, int cnt, Entry<T> next) {
- return new Entry(hash, o, cnt, next);
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- @Override
- public boolean add(E o) {
- this.modCount++;
- Entry<E>[] tab = this.table;
- int hash = 0;
- int index = 0;
-
- // if the object is already in the bag, simply bump its count
- if (o == null) {
- for (Entry<E> e = tab[0]; e != null; e = e.next) {
- if (e.object == null) {
- e.count++;
- this.count++;
- return true;
- }
- }
- } else {
- hash = o.hashCode();
- index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[index]; e != null; e = e.next) {
- if ((e.hash == hash) && o.equals(e.object)) {
- e.count++;
- this.count++;
- return true;
- }
- }
- }
-
- // rehash the table if the threshold is exceeded
- if (this.uniqueCount >= this.threshold) {
- this.rehash();
- tab = this.table;
- index = (hash & 0x7FFFFFFF) % tab.length;
- }
-
- // create the new entry and put it in the table
- Entry<E> e = this.buildEntry(hash, o, tab[index]);
- tab[index] = e;
- this.count++;
- this.uniqueCount++;
- return true;
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- public boolean add(E o, int cnt) {
- if (cnt <= 0) {
- return false;
- }
- this.modCount++;
- Entry<E>[] tab = this.table;
- int hash = 0;
- int index = 0;
-
- // if the object is already in the bag, simply bump its count
- if (o == null) {
- for (Entry<E> e = tab[0]; e != null; e = e.next) {
- if (e.object == null) {
- e.count += cnt;
- this.count += cnt;
- return true;
- }
- }
- } else {
- hash = o.hashCode();
- index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[index]; e != null; e = e.next) {
- if ((e.hash == hash) && o.equals(e.object)) {
- e.count += cnt;
- this.count += cnt;
- return true;
- }
- }
- }
-
- // rehash the table if the threshold is exceeded
- if (this.uniqueCount >= this.threshold) {
- this.rehash();
- tab = this.table;
- index = (hash & 0x7FFFFFFF) % tab.length;
- }
-
- // create the new entry and put it in the table
- Entry<E> e = this.buildEntry(hash, o, cnt, tab[index]);
- tab[index] = e;
- this.count += cnt;
- this.uniqueCount++;
- return true;
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- @Override
- public boolean remove(Object o) {
- Entry<E>[] tab = this.table;
- if (o == null) {
- for (Entry<E> e = tab[0], prev = null; e != null; prev = e, e = e.next) {
- if (e.object == null) {
- this.modCount++;
- e.count--;
- // if we are removing the last one, remove the entry from the table
- if (e.count == 0) {
- if (prev == null) {
- tab[0] = e.next;
- } else {
- prev.next = e.next;
- }
- this.uniqueCount--;
- }
- this.count--;
- return true;
- }
- }
- } else {
- int hash = o.hashCode();
- int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[index], prev = null; e != null; prev = e, e = e.next) {
- if ((e.hash == hash) && o.equals(e.object)) {
- this.modCount++;
- e.count--;
- // if we are removing the last one, remove the entry from the table
- if (e.count == 0) {
- if (prev == null) {
- tab[index] = e.next;
- } else {
- prev.next = e.next;
- }
- this.uniqueCount--;
- }
- this.count--;
- return true;
- }
- }
- }
-
- return false;
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- public boolean remove(Object o, int cnt) {
- if (cnt <= 0) {
- return false;
- }
- Entry<E>[] tab = this.table;
- if (o == null) {
- for (Entry<E> e = tab[0], prev = null; e != null; prev = e, e = e.next) {
- if (e.object == null) {
- this.modCount++;
- int cnt2 = (cnt < e.count) ? cnt : e.count;
- e.count -= cnt2;
- // if we are removing the last element(s), remove the entry from the table
- if (e.count == 0) {
- if (prev == null) {
- tab[0] = e.next;
- } else {
- prev.next = e.next;
- }
- this.uniqueCount--;
- }
- this.count -= cnt2;
- return true;
- }
- }
- } else {
- int hash = o.hashCode();
- int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[index], prev = null; e != null; prev = e, e = e.next) {
- if ((e.hash == hash) && o.equals(e.object)) {
- this.modCount++;
- int cnt2 = (cnt < e.count) ? cnt : e.count;
- e.count -= cnt2;
- // if we are removing the last element(s), remove the entry from the table
- if (e.count == 0) {
- if (prev == null) {
- tab[index] = e.next;
- } else {
- prev.next = e.next;
- }
- this.uniqueCount--;
- }
- this.count -= cnt2;
- return true;
- }
- }
- }
-
- return false;
- }
-
- /**
- * This implementation simply clears out all of the hash table buckets.
- */
- @Override
- public void clear() {
- Entry<E>[] tab = this.table;
- this.modCount++;
- for (int i = tab.length; --i >= 0; ) {
- tab[i] = null;
- }
- this.count = 0;
- this.uniqueCount = 0;
- }
-
- /**
- * Returns a shallow copy of this bag: the elements
- * themselves are not cloned.
- *
- * @return a shallow copy of this bag.
- */
- @Override
- public HashBag<E> clone() {
- try {
- @SuppressWarnings("unchecked")
- HashBag<E> clone = (HashBag<E>) super.clone();
- clone.table = this.buildTable(this.table.length);
- for (int i = this.table.length; i-- > 0; ) {
- clone.table[i] = (this.table[i] == null)
- ? null : (Entry<E>) this.table[i].clone();
- }
- clone.modCount = 0;
- return clone;
- } catch (CloneNotSupportedException e) {
- throw new InternalError();
- }
- }
-
- /**
- * Hash table collision list entry.
- */
- private static class Entry<E> {
- int hash;
- E object;
- int count;
- Entry<E> next;
-
- Entry(int hash, E object, Entry<E> next) {
- this(hash, object, 1, next);
- }
-
- Entry(int hash, E object, int count, Entry<E> next) {
- this.hash = hash;
- this.object = object;
- this.count = count;
- this.next = next;
- }
-
- /**
- * Cascade the clone to all the entries in the same bucket.
- */
- @Override
- @SuppressWarnings("unchecked")
- protected Entry<E> clone() {
- return new Entry(this.hash, this.object, this.count,
- (this.next == null ? null : this.next.clone()));
- }
-
- @Override
- public String toString() {
- return this.object + "=>" + this.count;
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Iterator<E> iterator() {
- if (this.count == 0) {
- return EMPTY_ITERATOR;
- }
- return new HashIterator();
- }
-
- @SuppressWarnings("unchecked")
- public Iterator<E> uniqueIterator() {
- if (this.count == 0) {
- return EMPTY_ITERATOR;
- }
- return new UniqueIterator();
- }
-
- /**
- * Empty iterator that does just about nothing.
- */
- @SuppressWarnings("unchecked")
- private static final Iterator EMPTY_ITERATOR = new EmptyIterator();
-
- @SuppressWarnings("unchecked")
- private static class EmptyIterator implements Iterator {
-
- EmptyIterator() {
- super();
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public Object next() {
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new IllegalStateException();
- }
- }
-
- private class HashIterator implements Iterator<E> {
- Entry<E>[] localTable = HashBag.this.table;
- int index = this.localTable.length; // start at the end of the table
- Entry<E> nextEntry = null;
- int nextEntryCount = 0;
- Entry<E> lastReturnedEntry = null;
-
- /**
- * The modCount value that the iterator believes that the backing
- * bag should have. If this expectation is violated, the iterator
- * has detected a concurrent modification.
- */
- private int expectedModCount = HashBag.this.modCount;
-
- HashIterator() {
- super();
- }
-
- public boolean hasNext() {
- Entry<E> e = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = this.localTable;
- // Use locals for faster loop iteration
- while ((e == null) && (i > 0)) {
- e = tab[--i]; // move backwards through the table
- }
- this.nextEntry = e;
- this.index = i;
- return e != null;
- }
-
- public E next() {
- if (HashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- Entry<E> et = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = this.localTable;
- // Use locals for faster loop iteration
- while ((et == null) && (i > 0)) {
- et = tab[--i]; // move backwards through the table
- }
- this.nextEntry = et;
- this.index = i;
- if (et == null) {
- throw new NoSuchElementException();
- }
- Entry<E> e = this.lastReturnedEntry = this.nextEntry;
- this.nextEntryCount++;
- if (this.nextEntryCount == e.count) {
- this.nextEntry = e.next;
- this.nextEntryCount = 0;
- }
- return e.object;
- }
-
- public void remove() {
- if (this.lastReturnedEntry == null) {
- throw new IllegalStateException();
- }
- if (HashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- Entry<E>[] tab = this.localTable;
- int slot = (this.lastReturnedEntry.hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[slot], prev = null; e != null; prev = e, e = e.next) {
- if (e == this.lastReturnedEntry) {
- HashBag.this.modCount++;
- this.expectedModCount++;
- e.count--;
- if (e.count == 0) {
- // if we are removing the last one, remove the entry from the table
- if (prev == null) {
- tab[slot] = e.next;
- } else {
- prev.next = e.next;
- }
- HashBag.this.uniqueCount--;
- } else {
- // slide back the count to account for the just-removed element
- this.nextEntryCount--;
- }
- HashBag.this.count--;
- this.lastReturnedEntry = null; // it cannot be removed again
- return;
- }
- }
- throw new ConcurrentModificationException();
- }
-
- }
-
-
- private class UniqueIterator implements Iterator<E> {
- Entry<E>[] localTable = HashBag.this.table;
- int index = this.localTable.length; // start at the end of the table
- Entry<E> nextEntry = null;
- Entry<E> lastReturnedEntry = null;
-
- /**
- * The modCount value that the iterator believes that the backing
- * bag should have. If this expectation is violated, the iterator
- * has detected a concurrent modification.
- */
- private int expectedModCount = HashBag.this.modCount;
-
- UniqueIterator() {
- super();
- }
-
- public boolean hasNext() {
- Entry<E> e = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = this.localTable;
- // Use locals for faster loop iteration
- while ((e == null) && (i > 0)) {
- e = tab[--i]; // move backwards through the table
- }
- this.nextEntry = e;
- this.index = i;
- return e != null;
- }
-
- public E next() {
- if (HashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- Entry<E> et = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = this.localTable;
- // Use locals for faster loop iteration
- while ((et == null) && (i > 0)) {
- et = tab[--i]; // move backwards through the table
- }
- this.nextEntry = et;
- this.index = i;
- if (et == null) {
- throw new NoSuchElementException();
- }
- Entry<E> e = this.lastReturnedEntry = this.nextEntry;
- this.nextEntry = e.next;
- return e.object;
- }
-
- public void remove() {
- if (this.lastReturnedEntry == null) {
- throw new IllegalStateException();
- }
- if (HashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- Entry<E>[] tab = this.localTable;
- int slot = (this.lastReturnedEntry.hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[slot], prev = null; e != null; prev = e, e = e.next) {
- if (e == this.lastReturnedEntry) {
- HashBag.this.modCount++;
- this.expectedModCount++;
- // remove the entry from the table
- if (prev == null) {
- tab[slot] = e.next;
- } else {
- prev.next = e.next;
- }
- HashBag.this.uniqueCount--;
- HashBag.this.count -= this.lastReturnedEntry.count;
- this.lastReturnedEntry = null; // it cannot be removed again
- return;
- }
- }
- throw new ConcurrentModificationException();
- }
-
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if ( ! (o instanceof Bag)) {
- return false;
- }
- @SuppressWarnings("unchecked")
- Bag<E> b = (Bag<E>) o;
- if (b.size() != this.size()) {
- return false;
- }
- Bag<E> clone = this.clone();
- for (E e : b) {
- if ( ! clone.remove(e)) {
- return false;
- }
- }
- return clone.isEmpty();
- }
-
- @Override
- public int hashCode() {
- int h = 0;
- for (Iterator<E> stream = this.iterator(); stream.hasNext(); ) {
- Object next = stream.next();
- if (next != null) {
- h += next.hashCode();
- }
- }
- return h;
- }
-
- /**
- * Save the state of this bag to a stream (i.e. serialize it).
- *
- * @serialData Emit the capacity of the bag (int),
- * followed by the number of unique elements in the bag (int),
- * followed by all of the bag's elements (each an Object) and
- * their counts (each an int), in no particular order.
- */
- private synchronized void writeObject(java.io.ObjectOutputStream s)
- throws java.io.IOException {
- // write out the threshold, load factor, and any hidden stuff
- s.defaultWriteObject();
-
- // write out number of buckets
- s.writeInt(this.table.length);
-
- // write out number of unique elements
- s.writeInt(this.uniqueCount);
-
- Entry<E>[] tab = this.table;
- // write out elements and counts (alternating)
- for (Entry<E> entry : tab) {
- while (entry != null) {
- s.writeObject(entry.object);
- s.writeInt(entry.count);
- entry = entry.next;
- }
- }
- }
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Reconstitute the bag from a stream (i.e. deserialize it).
- */
- private synchronized void readObject(java.io.ObjectInputStream s)
- throws java.io.IOException, ClassNotFoundException {
- // read in the threshold, loadfactor, and any hidden stuff
- s.defaultReadObject();
-
- // read in number of buckets and allocate the bucket array
- this.table = this.buildTable(s.readInt());
-
- // read in number of unique elements
- int unique = s.readInt();
-
- // read the elements and counts, and put the elements in the bag
- for (int i = 0; i < unique; i++) {
- @SuppressWarnings("unchecked")
- E element = (E) s.readObject();
- int elementCount = s.readInt();
- this.add(element, elementCount);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IdentityHashBag.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IdentityHashBag.java
deleted file mode 100644
index 25023fd564..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IdentityHashBag.java
+++ /dev/null
@@ -1,814 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-import java.util.AbstractCollection;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * This class implements the <code>Bag</code> interface with a
- * hash table, using object-identity in place of object-equality when
- * comparing elements. In other words, in an <code>IdentityHashBag</code>,
- * two objects <code>k1</code> and <code>k2</code> are considered
- * equal if and only if <code>(k1 == k2)</code>. (In normal <code>Bag</code>
- * implementations (like <code>HashBag</code>) two objects <code>k1</code>
- * and <code>k2</code> are considered equal if and only if
- * <code>(k1 == null ? k2 == null : k1.equals(k2))</code>.)
- * <p>
- * <b>
- * This class is <i>not</i> a general-purpose <code>Bag</code>
- * implementation! While this class implements the <code>Bag</code> interface, it
- * intentionally violates <code>Bag's</code> general contract, which mandates the
- * use of the <code>equals</code> method when comparing objects. This class is
- * designed for use only in the rare cases wherein object-identity
- * semantics are required.
- * </b>
- * <p>
- * This class makes no guarantees as to the iteration order of
- * the bag's elements; in particular, it does not guarantee that the order
- * will remain constant over time. This class permits the <code>null</code>
- * element.
- * <p>
- * This class offers constant time performance for the basic operations
- * (<code>add</code>, <code>remove</code>, <code>contains</code> and
- * <code>size</code>), assuming the system identity hash function
- * ({@link System#identityHashCode(Object)}) disperses elements properly
- * among the buckets. Iterating over this bag requires time
- * proportional to the sum of the bag's size (the number of elements) plus the
- * "capacity" of the backing hash table (the number of buckets). Thus, it is
- * important not to set the initial capacity too high (or the load factor too
- * low) if iteration performance is important.
- * <p>
- * <b>Note that this implementation is not synchronized.</b> If multiple
- * threads access a bag concurrently, and at least one of the threads modifies
- * the bag, it <i>must</i> be synchronized externally. This is typically
- * accomplished by synchronizing on some object that naturally encapsulates
- * the bag. If no such object exists, the bag should be "wrapped" using the
- * <code>Collections.synchronizedCollection</code> method. This is
- * best done at creation time, to prevent accidental unsynchronized access
- * to the bag:
- * <pre>
- * Collection c = Collections.synchronizedCollection(new IdentityHashBag(...));
- * </pre>
- * <p>
- * The iterators returned by this class's <code>iterator</code> method are
- * <i>fail-fast</i>: if the bag is modified at any time after the iterator is
- * created, in any way except through the iterator's own <code>remove</code>
- * method, the iterator throws a <code>ConcurrentModificationException</code>.
- * Thus, in the face of concurrent modification, the iterator fails quickly
- * and cleanly, rather than risking arbitrary, non-deterministic behavior at
- * an undetermined time in the future.
- *
- * @see Collections#synchronizedCollection(Collection)
- */
-
-public class IdentityHashBag<E> extends AbstractCollection<E>
- implements Bag<E>, Cloneable, Serializable {
-
- /** The hash table. */
- transient Entry<E>[] table;
-
- /** The total number of entries in the bag. */
- transient int count = 0;
-
- /** The number of unique entries in the bag. */
- transient int uniqueCount = 0;
-
- /**
- * The hash table is rehashed when its size exceeds this threshold. (The
- * value of this field is (int)(capacity * loadFactor).)
- *
- * @serial
- */
- private int threshold;
-
- /**
- * The load factor for the hash table.
- *
- * @serial
- */
- private float loadFactor;
-
- /**
- * The number of times this bag has been structurally modified.
- * Structural modifications are those that change the number of entries in
- * the bag or otherwise modify its internal structure (e.g. rehash).
- * This field is used to make iterators on this bag fail-fast.
- *
- * @see java.util.ConcurrentModificationException
- */
- transient int modCount = 0;
-
- /**
- * Constructs a new, empty bag with the
- * default capacity, which is 11, and load factor, which is 0.75.
- */
- public IdentityHashBag() {
- this(11, 0.75f);
- }
-
- /**
- * Constructs a new, empty bag with the specified initial capacity
- * and default load factor, which is 0.75.
- *
- * @param initialCapacity the initial capacity of the backing map.
- * @throws IllegalArgumentException if the initial capacity is less
- * than zero.
- */
- public IdentityHashBag(int initialCapacity) {
- this(initialCapacity, 0.75f);
- }
-
- /**
- * Constructs a new, empty bag with
- * the specified initial capacity and the specified load factor.
- *
- * @param initialCapacity the initial capacity of the backing map.
- * @param loadFactor the load factor of the backing map.
- * @throws IllegalArgumentException if the initial capacity is less
- * than zero, or if the load factor is nonpositive.
- */
- public IdentityHashBag(int initialCapacity, float loadFactor) {
- if (initialCapacity < 0) {
- throw new IllegalArgumentException("Illegal Initial Capacity: " + initialCapacity);
- }
- if (loadFactor <= 0 || Float.isNaN(loadFactor)) {
- throw new IllegalArgumentException("Illegal Load factor: " + loadFactor);
- }
- if (initialCapacity == 0) {
- initialCapacity = 1;
- }
- this.loadFactor = loadFactor;
- this.table = this.buildTable(initialCapacity);
- this.threshold = (int) (initialCapacity * loadFactor);
- }
-
- /**
- * Constructs a new bag containing the elements in the specified
- * collection. The capacity of the bag is
- * twice the size of the specified collection or 11 (whichever is
- * greater), and the default load factor, which is 0.75, is used.
- *
- * @param c the collection whose elements are to be placed into this bag.
- */
- public IdentityHashBag(Collection<? extends E> c) {
- this(Math.max(2*c.size(), 11));
- this.addAll(c);
- }
-
- /**
- * This implementation simply returns the maintained count.
- */
- @Override
- public int size() {
- return this.count;
- }
-
- /**
- * This implementation simply compares the maintained count to zero.
- */
- @Override
- public boolean isEmpty() {
- return this.count == 0;
- }
-
- /**
- * This implementation searches for the object in the hash table by
- * calculating the object's identity hash code and examining the
- * entries in the corresponding hash table bucket.
- */
- @Override
- public boolean contains(Object o) {
- Entry<E>[] tab = this.table;
- int hash = System.identityHashCode(o);
- int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[index]; e != null; e = e.next) {
- if ((e.hash == hash) && (e.object == o)) {
- return true;
- }
- }
- return false;
- }
-
- public int count(Object o) {
- Entry<E>[] tab = this.table;
- int hash = System.identityHashCode(o);
- int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[index]; e != null; e = e.next) {
- if ((e.hash == hash) && (e.object == o)) {
- return e.count;
- }
- }
- return 0;
- }
-
- /**
- * Rehashes the contents of this bag into a new hash table
- * with a larger capacity. This method is called when the
- * number of different elements in this map exceeds its
- * capacity and load factor.
- */
- private void rehash() {
- Entry<E>[] oldMap = this.table;
- int oldCapacity = oldMap.length;
-
- int newCapacity = oldCapacity * 2 + 1;
- Entry<E>[] newTable = this.buildTable(newCapacity);
-
- this.modCount++;
- this.threshold = (int) (newCapacity * this.loadFactor);
- this.table = newTable;
-
- for (int i = oldCapacity; i-- > 0; ) {
- for (Entry<E> old = oldMap[i]; old != null; ) {
- Entry<E> e = old;
- old = old.next;
-
- int index = (e.hash & 0x7FFFFFFF) % newCapacity;
- e.next = newTable[index];
- newTable[index] = e;
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- private Entry<E>[] buildTable(int capacity) {
- return new Entry[capacity];
- }
-
- @SuppressWarnings("unchecked")
- private <T> Entry<E> buildEntry(int hash, Object o, Entry<T> next) {
- return new Entry(hash, o, next);
- }
-
- @SuppressWarnings("unchecked")
- private <T> Entry<E> buildEntry(int hash, Object o, int cnt, Entry<T> next) {
- return new Entry(hash, o, cnt, next);
- }
-
- /**
- * This implementation searches for the object in the hash table by
- * calculating the object's identity hash code and examining the
- * entries in the corresponding hash table bucket.
- */
- @Override
- public boolean add(E o) {
- this.modCount++;
- Entry<E>[] tab = this.table;
- int hash = 0;
- int index = 0;
-
- // if the object is already in the bag, simply bump its count
- hash = System.identityHashCode(o);
- index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[index]; e != null; e = e.next) {
- if ((e.hash == hash) && (e.object == o)) {
- e.count++;
- this.count++;
- return true;
- }
- }
-
- // rehash the table if the threshold is exceeded
- if (this.uniqueCount >= this.threshold) {
- this.rehash();
- tab = this.table;
- index = (hash & 0x7FFFFFFF) % tab.length;
- }
-
- // create the new entry and put it in the table
- Entry<E> e = this.buildEntry(hash, o, tab[index]);
- tab[index] = e;
- this.count++;
- this.uniqueCount++;
- return true;
- }
-
- /**
- * This implementation searches for the object in the hash table by
- * calculating the object's identity hash code and examining the
- * entries in the corresponding hash table bucket.
- */
- public boolean add(E o, int cnt) {
- if (cnt <= 0) {
- return false;
- }
- this.modCount++;
- Entry<E>[] tab = this.table;
- int hash = 0;
- int index = 0;
-
- // if the object is already in the bag, simply bump its count
- hash = System.identityHashCode(o);
- index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[index]; e != null; e = e.next) {
- if ((e.hash == hash) && (e.object == o)) {
- e.count += cnt;
- this.count += cnt;
- return true;
- }
- }
-
- // rehash the table if the threshold is exceeded
- if (this.uniqueCount >= this.threshold) {
- this.rehash();
- tab = this.table;
- index = (hash & 0x7FFFFFFF) % tab.length;
- }
-
- // create the new entry and put it in the table
- Entry<E> e = this.buildEntry(hash, o, cnt, tab[index]);
- tab[index] = e;
- this.count += cnt;
- this.uniqueCount++;
- return true;
- }
-
- /**
- * This implementation searches for the object in the hash table by
- * calculating the object's identity hash code and examining the
- * entries in the corresponding hash table bucket.
- */
- @Override
- public boolean remove(Object o) {
- Entry<E>[] tab = this.table;
- int hash = System.identityHashCode(o);
- int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[index], prev = null; e != null; prev = e, e = e.next) {
- if ((e.hash == hash) && (e.object == o)) {
- this.modCount++;
- e.count--;
- // if we are removing the last one, remove the entry from the table
- if (e.count == 0) {
- if (prev == null) {
- tab[index] = e.next;
- } else {
- prev.next = e.next;
- }
- this.uniqueCount--;
- }
- this.count--;
- return true;
- }
- }
- return false;
- }
-
- /**
- * This implementation searches for the object in the hash table by
- * calculating the object's identity hash code and examining the
- * entries in the corresponding hash table bucket.
- */
- public boolean remove(Object o, int cnt) {
- if (cnt <= 0) {
- return false;
- }
- Entry<E>[] tab = this.table;
- int hash = System.identityHashCode(o);
- int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[index], prev = null; e != null; prev = e, e = e.next) {
- if ((e.hash == hash) && (e.object == o)) {
- this.modCount++;
- int cnt2 = (cnt < e.count) ? cnt : e.count;
- e.count -= cnt2;
- // if we are removing the last element(s), remove the entry from the table
- if (e.count == 0) {
- if (prev == null) {
- tab[index] = e.next;
- } else {
- prev.next = e.next;
- }
- this.uniqueCount--;
- }
- this.count -= cnt2;
- return true;
- }
- }
- return false;
- }
-
- /**
- * This implementation uses object-identity to determine whether
- * specified collection contains a particular element.
- */
- @Override
- public boolean removeAll(Collection<?> c) {
- return super.removeAll(this.buildIdentityHashBag(c));
- }
-
- /**
- * This implementation uses object-identity to determine whether
- * specified collection contains a particular element.
- */
- @Override
- public boolean retainAll(Collection<?> c) {
- return super.retainAll(this.buildIdentityHashBag(c));
- }
-
- @SuppressWarnings("unchecked")
- private Collection<?> buildIdentityHashBag(Collection<?> c) {
- return new IdentityHashBag(c);
- }
-
- /**
- * This implementation simply clears out all of the hash table buckets.
- */
- @Override
- public void clear() {
- Entry<E>[] tab = this.table;
- this.modCount++;
- for (int i = tab.length; --i >= 0; ) {
- tab[i] = null;
- }
- this.count = 0;
- this.uniqueCount = 0;
- }
-
- /**
- * Returns a shallow copy of this bag: the elements
- * themselves are not cloned.
- *
- * @return a shallow copy of this bag.
- */
- @Override
- public IdentityHashBag<E> clone() {
- try {
- @SuppressWarnings("unchecked")
- IdentityHashBag<E> clone = (IdentityHashBag<E>) super.clone();
- clone.table = this.buildTable(this.table.length);
- for (int i = this.table.length; i-- > 0; ) {
- clone.table[i] = (this.table[i] == null)
- ? null : (Entry<E>) this.table[i].clone();
- }
- clone.modCount = 0;
- return clone;
- } catch (CloneNotSupportedException e) {
- throw new InternalError();
- }
- }
-
- /**
- * Hash table collision list entry.
- */
- private static class Entry<E> {
- int hash;
- E object;
- int count;
- Entry<E> next;
-
- Entry(int hash, E object, Entry<E> next) {
- this(hash, object, 1, next);
- }
-
- Entry(int hash, E object, int count, Entry<E> next) {
- this.hash = hash;
- this.object = object;
- this.count = count;
- this.next = next;
- }
-
- /**
- * Cascade the clone to all the entries in the same bucket.
- */
- @Override
- @SuppressWarnings("unchecked")
- protected Entry<E> clone() {
- return new Entry(this.hash, this.object, this.count,
- (this.next == null ? null : this.next.clone()));
- }
-
- @Override
- public String toString() {
- return this.object + "=>" + this.count;
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Iterator<E> iterator() {
- if (this.count == 0) {
- return EMPTY_ITERATOR;
- }
- return new HashIterator();
- }
-
- /**
- * Return an iterator that returns each item in the bag
- * once and only once, irrespective of how many times
- * the item was added to the bag.
- */
- @SuppressWarnings("unchecked")
- public Iterator<E> uniqueIterator() {
- if (this.count == 0) {
- return EMPTY_ITERATOR;
- }
- return new UniqueIterator();
- }
-
- /**
- * Empty iterator that does just about nothing.
- */
- @SuppressWarnings("unchecked")
- private static final Iterator EMPTY_ITERATOR = new EmptyIterator();
-
- @SuppressWarnings("unchecked")
- private static class EmptyIterator implements Iterator {
-
- EmptyIterator() {
- super();
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public Object next() {
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new IllegalStateException();
- }
- }
-
- private class HashIterator implements Iterator<E> {
- Entry<E>[] localTable = IdentityHashBag.this.table;
- int index = this.localTable.length; // start at the end of the table
- Entry<E> nextEntry = null;
- int nextEntryCount = 0;
- Entry<E> lastReturnedEntry = null;
-
- /**
- * The modCount value that the iterator believes that the backing
- * bag should have. If this expectation is violated, the iterator
- * has detected a concurrent modification.
- */
- private int expectedModCount = IdentityHashBag.this.modCount;
-
- HashIterator() {
- super();
- }
-
- public boolean hasNext() {
- Entry<E> e = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = this.localTable;
- // Use locals for faster loop iteration
- while ((e == null) && (i > 0)) {
- e = tab[--i]; // move backwards through the table
- }
- this.nextEntry = e;
- this.index = i;
- return e != null;
- }
-
- public E next() {
- if (IdentityHashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- Entry<E> et = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = this.localTable;
- // Use locals for faster loop iteration
- while ((et == null) && (i > 0)) {
- et = tab[--i]; // move backwards through the table
- }
- this.nextEntry = et;
- this.index = i;
- if (et == null) {
- throw new NoSuchElementException();
- }
- Entry<E> e = this.lastReturnedEntry = this.nextEntry;
- this.nextEntryCount++;
- if (this.nextEntryCount == e.count) {
- this.nextEntry = e.next;
- this.nextEntryCount = 0;
- }
- return e.object;
- }
-
- public void remove() {
- if (this.lastReturnedEntry == null) {
- throw new IllegalStateException();
- }
- if (IdentityHashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- Entry<E>[] tab = this.localTable;
- int slot = (this.lastReturnedEntry.hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[slot], prev = null; e != null; prev = e, e = e.next) {
- if (e == this.lastReturnedEntry) {
- IdentityHashBag.this.modCount++;
- this.expectedModCount++;
- e.count--;
- if (e.count == 0) {
- // if we are removing the last one, remove the entry from the table
- if (prev == null) {
- tab[slot] = e.next;
- } else {
- prev.next = e.next;
- }
- IdentityHashBag.this.uniqueCount--;
- } else {
- // slide back the count to account for the just-removed element
- this.nextEntryCount--;
- }
- IdentityHashBag.this.count--;
- this.lastReturnedEntry = null; // it cannot be removed again
- return;
- }
- }
- throw new ConcurrentModificationException();
- }
- }
-
- private class UniqueIterator implements Iterator<E> {
- Entry<E>[] localTable = IdentityHashBag.this.table;
- int index = this.localTable.length; // start at the end of the table
- Entry<E> nextEntry = null;
- Entry<E> lastReturnedEntry = null;
-
- /**
- * The modCount value that the iterator believes that the backing
- * bag should have. If this expectation is violated, the iterator
- * has detected a concurrent modification.
- */
- private int expectedModCount = IdentityHashBag.this.modCount;
-
- UniqueIterator() {
- super();
- }
-
- public boolean hasNext() {
- Entry<E> e = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = this.localTable;
- // Use locals for faster loop iteration
- while ((e == null) && (i > 0)) {
- e = tab[--i]; // move backwards through the table
- }
- this.nextEntry = e;
- this.index = i;
- return e != null;
- }
-
- public E next() {
- if (IdentityHashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- Entry<E> et = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = this.localTable;
- // Use locals for faster loop iteration
- while ((et == null) && (i > 0)) {
- et = tab[--i]; // move backwards through the table
- }
- this.nextEntry = et;
- this.index = i;
- if (et == null) {
- throw new NoSuchElementException();
- }
- Entry<E> e = this.lastReturnedEntry = this.nextEntry;
- this.nextEntry = e.next;
- return e.object;
- }
-
- public void remove() {
- if (this.lastReturnedEntry == null) {
- throw new IllegalStateException();
- }
- if (IdentityHashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- Entry<E>[] tab = this.localTable;
- int slot = (this.lastReturnedEntry.hash & 0x7FFFFFFF) % tab.length;
- for (Entry<E> e = tab[slot], prev = null; e != null; prev = e, e = e.next) {
- if (e == this.lastReturnedEntry) {
- IdentityHashBag.this.modCount++;
- this.expectedModCount++;
- // remove the entry from the table
- if (prev == null) {
- tab[slot] = e.next;
- } else {
- prev.next = e.next;
- }
- IdentityHashBag.this.uniqueCount--;
- IdentityHashBag.this.count -= this.lastReturnedEntry.count;
- this.lastReturnedEntry = null; // it cannot be removed again
- return;
- }
- }
- throw new ConcurrentModificationException();
- }
-
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- } else if (o instanceof IdentityHashBag) {
- @SuppressWarnings("unchecked")
- IdentityHashBag<E> b = (IdentityHashBag<E>) o;
- if (b.size() != this.size()) {
- return false;
- }
- IdentityHashBag<E> clone = this.clone();
- for (E e : b) {
- if ( ! clone.remove(e)) {
- return false;
- }
- }
- return clone.isEmpty();
- } else if (o instanceof Bag) {
- // hmmm...
- return this.buildBag().equals(o);
- } else {
- return false;
- }
- }
-
- @SuppressWarnings("unchecked")
- private Bag<E> buildBag() {
- return new HashBag(this);
- }
-
- @Override
- public int hashCode() {
- int h = 0;
- for (E e : this) {
- h += System.identityHashCode(e);
- }
- return h;
- }
-
- /**
- * Save the state of this bag to a stream (i.e. serialize it).
- *
- * @serialData Emit the capacity of the bag (int),
- * followed by the number of unique elements in the bag (int),
- * followed by all of the bag's elements (each an Object) and
- * their counts (each an int), in no particular order.
- */
- private synchronized void writeObject(java.io.ObjectOutputStream s)
- throws java.io.IOException {
- // write out the threshold, load factor, and any hidden stuff
- s.defaultWriteObject();
-
- // write out number of buckets
- s.writeInt(this.table.length);
-
- // write out number of unique elements
- s.writeInt(this.uniqueCount);
-
- Entry<E>[] tab = this.table;
- // write out elements and counts (alternating)
- for (Entry<E> entry : tab) {
- while (entry != null) {
- s.writeObject(entry.object);
- s.writeInt(entry.count);
- entry = entry.next;
- }
- }
- }
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Reconstitute the bag from a stream (i.e. deserialize it).
- */
- private synchronized void readObject(java.io.ObjectInputStream s)
- throws java.io.IOException, ClassNotFoundException {
- // read in the threshold, loadfactor, and any hidden stuff
- s.defaultReadObject();
-
- // read in number of buckets and allocate the bucket array
- this.table = this.buildTable(s.readInt());
-
- // read in number of unique elements
- int unique = s.readInt();
-
- // read the elements and counts, and put the elements in the bag
- for (int i = 0; i < unique; i++) {
- @SuppressWarnings("unchecked")
- E element = (E) s.readObject();
- int elementCount = s.readInt();
- for (int j = 0; j < elementCount; j++) {
- this.add(element);
- }
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IndentingPrintWriter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IndentingPrintWriter.java
deleted file mode 100644
index f2afb1d4e6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IndentingPrintWriter.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.PrintWriter;
-import java.io.Writer;
-
-/**
- * Extend PrintWriter to automatically indent new lines.
- */
-public class IndentingPrintWriter extends PrintWriter {
-
- private final String indent;
- private int indentLevel;
- private boolean needsIndent;
-
- public static String DEFAULT_INDENT = "\t";
-
-
- /**
- * Construct a writer that indents with tabs.
- */
- public IndentingPrintWriter(Writer out) {
- this(out, DEFAULT_INDENT);
- }
-
- /**
- * Construct a writer that indents with the specified string.
- */
- public IndentingPrintWriter(Writer out, String indent) {
- super(out);
- this.indent = indent;
- this.indentLevel = 0;
- this.needsIndent = true;
- }
-
- /**
- * Set flag so following line is indented.
- */
- @Override
- public void println() {
- synchronized (this.lock) {
- super.println();
- this.needsIndent = true;
- }
- }
-
- /**
- * Print the appropriate indent.
- */
- private void printIndent() {
- if (this.needsIndent) {
- this.needsIndent = false;
- for (int i = this.indentLevel; i-- > 0; ) {
- this.print(this.indent);
- }
- }
- }
-
- /**
- * Write a portion of an array of characters.
- */
- @Override
- public void write(char buf[], int off, int len) {
- synchronized (this.lock) {
- this.printIndent();
- super.write(buf, off, len);
- }
- }
-
- /**
- * Write a single character.
- */
- @Override
- public void write(int c) {
- synchronized (this.lock) {
- this.printIndent();
- super.write(c);
- }
- }
-
- /**
- * Write a portion of a string.
- */
- @Override
- public void write(String s, int off, int len) {
- synchronized (this.lock) {
- this.printIndent();
- super.write(s, off, len);
- }
- }
-
- /**
- * Bump the indent level.
- */
- public void indent() {
- this.incrementIndentLevel();
- }
-
- /**
- * Decrement the indent level.
- */
- public void undent() {
- this.decrementIndentLevel();
- }
-
- /**
- * Bump the indent level.
- */
- public void incrementIndentLevel() {
- synchronized (this.lock) {
- this.indentLevel++;
- }
- }
-
- /**
- * Decrement the indent level.
- */
- public void decrementIndentLevel() {
- synchronized (this.lock) {
- this.indentLevel--;
- }
- }
-
- /**
- * Return the current indent level.
- */
- public int indentLevel() {
- return this.indentLevel;
- }
-
- /**
- * Allow the indent level to be set directly.
- */
- public void setIndentLevel(int indentLevel) {
- synchronized (this.lock) {
- this.indentLevel = indentLevel;
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCTools.java
deleted file mode 100644
index 99736472d7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCTools.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.sql.Types;
-import java.util.HashMap;
-
-import org.eclipse.jpt.utility.JavaType;
-
-/**
- * Helper methods for dealing with the JDBC API.
- */
-public final class JDBCTools {
-
-
- /**
- * Return the JDBC type corresponding to the specified class.
- * @see java.sql.Types
- */
- public static JDBCType jdbcTypeForClassNamed(String className) {
- JavaToJDBCTypeMapping mapping = javaToJDBCTypeMapping(className);
- return (mapping == null) ? DEFAULT_JDBC_TYPE : mapping.getJDBCType();
- }
-
- /**
- * Return the JDBC type corresponding to the specified class.
- * @see java.sql.Types
- */
- public static JDBCType jdbcTypeFor(Class<?> javaClass) {
- return jdbcTypeForClassNamed(javaClass.getName());
- }
-
- /**
- * Return the JDBC type corresponding to the specified class.
- * @see java.sql.Types
- */
- public static JDBCType jdbcTypeFor(JavaType javaType) {
- return jdbcTypeForClassNamed(javaType.getJavaClassName());
- }
-
- /**
- * Return the Java type corresponding to the specified JDBC type.
- * @see java.sql.Types
- */
- public static JavaType javaTypeForJDBCTypeNamed(String jdbcTypeName) {
- JDBCToJavaTypeMapping mapping = jdbcToJavaTypeMapping(jdbcTypeName);
- return (mapping == null) ? DEFAULT_JAVA_TYPE : mapping.getJavaType();
- }
-
- /**
- * Return the Java type corresponding to the specified JDBC type.
- * @see java.sql.Types
- */
- public static JavaType javaTypeFor(JDBCType jdbcType) {
- return javaTypeForJDBCTypeNamed(jdbcType.name());
- }
-
- /**
- * Return the Java type corresponding to the specified JDBC type.
- * @see java.sql.Types
- */
- public static JavaType javaTypeForJDBCTypeCode(int jdbcTypeCode) {
- return javaTypeFor(JDBCType.type(jdbcTypeCode));
- }
-
-
- // ********** internal stuff **********
-
-
- // ********** JDBC => Java **********
-
- /**
- * JDBC => Java type mappings, keyed by JDBC type name (e.g. "VARCHAR")
- */
- private static HashMap<String, JDBCToJavaTypeMapping> JDBC_TO_JAVA_TYPE_MAPPINGS; // pseudo 'final' - lazy-initialized
- private static final JavaType DEFAULT_JAVA_TYPE = new SimpleJavaType(java.lang.Object.class); // TODO Object is the default?
-
-
- private static JDBCToJavaTypeMapping jdbcToJavaTypeMapping(String jdbcTypeName) {
- return jdbcToJavaTypeMappings().get(jdbcTypeName);
- }
-
- private static synchronized HashMap<String, JDBCToJavaTypeMapping> jdbcToJavaTypeMappings() {
- if (JDBC_TO_JAVA_TYPE_MAPPINGS == null) {
- JDBC_TO_JAVA_TYPE_MAPPINGS = buildJDBCToJavaTypeMappings();
- }
- return JDBC_TO_JAVA_TYPE_MAPPINGS;
- }
-
- private static HashMap<String, JDBCToJavaTypeMapping> buildJDBCToJavaTypeMappings() {
- HashMap<String, JDBCToJavaTypeMapping> mappings = new HashMap<String, JDBCToJavaTypeMapping>();
- addJDBCToJavaTypeMappingsTo(mappings);
- return mappings;
- }
-
- /**
- * hard code the default mappings from the JDBC types to the
- * appropriate Java types
- * @see java.sql.Types
- * see "JDBC 3.0 Specification" Appendix B
- */
- private static void addJDBCToJavaTypeMappingsTo(HashMap<String, JDBCToJavaTypeMapping> mappings) {
- addJDBCToJavaTypeMappingTo(Types.ARRAY, java.sql.Array.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.BIGINT, long.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.BINARY, byte[].class, mappings);
- addJDBCToJavaTypeMappingTo(Types.BIT, boolean.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.BLOB, java.sql.Blob.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.BOOLEAN, boolean.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.CHAR, java.lang.String.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.CLOB, java.sql.Clob.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.DATALINK, java.net.URL.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.DATE, java.sql.Date.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.DECIMAL, java.math.BigDecimal.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.DISTINCT, java.lang.Object.class, mappings); // ???
- addJDBCToJavaTypeMappingTo(Types.DOUBLE, double.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.FLOAT, double.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.INTEGER, int.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.JAVA_OBJECT, java.lang.Object.class, mappings); // ???
- addJDBCToJavaTypeMappingTo(Types.LONGVARBINARY, byte[].class, mappings);
- addJDBCToJavaTypeMappingTo(Types.LONGVARCHAR, java.lang.String.class, mappings);
- // not sure why this is defined in java.sql.Types
-// addJDBCToJavaTypeMappingTo(Types.NULL, java.lang.Object.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.NUMERIC, java.math.BigDecimal.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.OTHER, java.lang.Object.class, mappings); // ???
- addJDBCToJavaTypeMappingTo(Types.REAL, float.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.REF, java.sql.Ref.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.SMALLINT, short.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.STRUCT, java.sql.Struct.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.TIME, java.sql.Time.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.TIMESTAMP, java.sql.Timestamp.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.TINYINT, byte.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.VARBINARY, byte[].class, mappings);
- addJDBCToJavaTypeMappingTo(Types.VARCHAR, java.lang.String.class, mappings);
- }
-
- private static void addJDBCToJavaTypeMappingTo(int jdbcTypeCode, Class<?> javaClass, HashMap<String, JDBCToJavaTypeMapping> mappings) {
- // check for duplicates
- JDBCType jdbcType = JDBCType.type(jdbcTypeCode);
- Object prev = mappings.put(jdbcType.name(), buildJDBCToJavaTypeMapping(jdbcType, javaClass));
- if (prev != null) {
- throw new IllegalArgumentException("duplicate JDBC type: " + jdbcType.name());
- }
- }
-
- private static JDBCToJavaTypeMapping buildJDBCToJavaTypeMapping(JDBCType jdbcType, Class<?> javaClass) {
- return new JDBCToJavaTypeMapping(jdbcType, new SimpleJavaType(javaClass));
- }
-
-
- // ********** Java => JDBC **********
-
- /**
- * Java => JDBC type mappings, keyed by Java class name (e.g. "java.lang.Object")
- */
- private static HashMap<String, JavaToJDBCTypeMapping> JAVA_TO_JDBC_TYPE_MAPPINGS; // pseudo 'final' - lazy-initialized
- private static final JDBCType DEFAULT_JDBC_TYPE = JDBCType.type(Types.VARCHAR); // TODO VARCHAR is the default?
-
-
- private static JavaToJDBCTypeMapping javaToJDBCTypeMapping(String className) {
- return javaToJDBCTypeMappings().get(className);
- }
-
- private static synchronized HashMap<String, JavaToJDBCTypeMapping> javaToJDBCTypeMappings() {
- if (JAVA_TO_JDBC_TYPE_MAPPINGS == null) {
- JAVA_TO_JDBC_TYPE_MAPPINGS = buildJavaToJDBCTypeMappings();
- }
- return JAVA_TO_JDBC_TYPE_MAPPINGS;
- }
-
- private static HashMap<String, JavaToJDBCTypeMapping> buildJavaToJDBCTypeMappings() {
- HashMap<String, JavaToJDBCTypeMapping> mappings = new HashMap<String, JavaToJDBCTypeMapping>();
- addJavaToJDBCTypeMappingsTo(mappings);
- return mappings;
- }
-
- /**
- * hard code the default mappings from the Java types to the
- * appropriate JDBC types
- * @see java.sql.Types
- * see "JDBC 3.0 Specification" Appendix B
- */
- private static void addJavaToJDBCTypeMappingsTo(HashMap<String, JavaToJDBCTypeMapping> mappings) {
- // primitives
- addJavaToJDBCTypeMappingTo(boolean.class, Types.BIT, mappings);
- addJavaToJDBCTypeMappingTo(byte.class, Types.TINYINT, mappings);
- addJavaToJDBCTypeMappingTo(double.class, Types.DOUBLE, mappings);
- addJavaToJDBCTypeMappingTo(float.class, Types.REAL, mappings);
- addJavaToJDBCTypeMappingTo(int.class, Types.INTEGER, mappings);
- addJavaToJDBCTypeMappingTo(long.class, Types.BIGINT, mappings);
- addJavaToJDBCTypeMappingTo(short.class, Types.SMALLINT, mappings);
-
- // reference classes
- addJavaToJDBCTypeMappingTo(java.lang.Boolean.class, Types.BIT, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Byte.class, Types.TINYINT, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Double.class, Types.DOUBLE, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Float.class, Types.REAL, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Integer.class, Types.INTEGER, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Long.class, Types.BIGINT, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Short.class, Types.SMALLINT, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.String.class, Types.VARCHAR, mappings);
- addJavaToJDBCTypeMappingTo(java.math.BigDecimal.class, Types.NUMERIC, mappings);
- addJavaToJDBCTypeMappingTo(java.net.URL.class, Types.DATALINK, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Array.class, Types.ARRAY, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Blob.class, Types.BLOB, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Clob.class, Types.CLOB, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Date.class, Types.DATE, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Ref.class, Types.REF, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Struct.class, Types.STRUCT, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Time.class, Types.TIME, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Timestamp.class, Types.TIMESTAMP, mappings);
-
- // arrays
- addJavaToJDBCTypeMappingTo(byte[].class, Types.VARBINARY, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Byte[].class, Types.VARBINARY, mappings);
- }
-
- private static void addJavaToJDBCTypeMappingTo(Class<?> javaClass, int jdbcTypeCode, HashMap<String, JavaToJDBCTypeMapping> mappings) {
- // check for duplicates
- Object prev = mappings.put(javaClass.getName(), buildJavaToJDBCTypeMapping(javaClass, jdbcTypeCode));
- if (prev != null) {
- throw new IllegalArgumentException("duplicate Java class: " + ((JavaToJDBCTypeMapping) prev).getJavaType().declaration());
- }
- }
-
- private static JavaToJDBCTypeMapping buildJavaToJDBCTypeMapping(Class<?> javaClass, int jdbcTypeCode) {
- return new JavaToJDBCTypeMapping(new SimpleJavaType(javaClass), JDBCType.type(jdbcTypeCode));
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private JDBCTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-
- // ********** member classes **********
-
- /**
- * JDBC => Java
- */
- private static class JDBCToJavaTypeMapping {
- private final JDBCType jdbcType;
- private final JavaType javaType;
-
- JDBCToJavaTypeMapping(JDBCType jdbcType, JavaType javaType) {
- super();
- this.jdbcType = jdbcType;
- this.javaType = javaType;
- }
-
- public JDBCType getJDBCType() {
- return this.jdbcType;
- }
-
- public JavaType getJavaType() {
- return this.javaType;
- }
-
- public boolean maps(int jdbcTypeCode) {
- return this.jdbcType.code() == jdbcTypeCode;
- }
-
- public boolean maps(String jdbcTypeName) {
- return this.jdbcType.name().equals(jdbcTypeName);
- }
-
- public boolean maps(JDBCType type) {
- return this.jdbcType == type;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- this.appendTo(sb);
- return sb.toString();
- }
-
- public void appendTo(StringBuilder sb) {
- this.jdbcType.appendTo(sb);
- sb.append(" => ");
- this.javaType.appendDeclarationTo(sb);
- }
-
- }
-
- /**
- * Java => JDBC
- */
- private static class JavaToJDBCTypeMapping {
- private final JavaType javaType;
- private final JDBCType jdbcType;
-
- JavaToJDBCTypeMapping(JavaType javaType, JDBCType jdbcType) {
- super();
- this.javaType = javaType;
- this.jdbcType = jdbcType;
- }
-
- public JavaType getJavaType() {
- return this.javaType;
- }
-
- public JDBCType getJDBCType() {
- return this.jdbcType;
- }
-
- public boolean maps(JavaType jt) {
- return this.javaType.equals(jt);
- }
-
- public boolean maps(String elementTypeName, int arrayDepth) {
- return this.javaType.equals(elementTypeName, arrayDepth);
- }
-
- public boolean maps(String javaClassName) {
- return this.javaType.describes(javaClassName);
- }
-
- public boolean maps(Class<?> javaClass) {
- return this.javaType.describes(javaClass);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- this.appendTo(sb);
- return sb.toString();
- }
-
- public void appendTo(StringBuilder sb) {
- this.javaType.appendDeclarationTo(sb);
- sb.append(" => ");
- this.jdbcType.appendTo(sb);
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCType.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCType.java
deleted file mode 100644
index 82ae294c34..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCType.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.sql.Types;
-import java.text.Collator;
-
-/**
- * Associate the Java constant and the JDBC type name.
- * These are derived from java.sql.Types.
- *
- * @see java.sql.Types
- */
-public final class JDBCType
- implements Comparable<JDBCType>, Cloneable, Serializable
-{
-
- /**
- * the constant name (e.g. VARCHAR)
- */
- private final String name;
-
- /**
- * the JDBC code used by JDBC drivers
- */
- private final int code;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a JDBC type with the specified name and type code.
- * This is private because all the possible JDBC types are built and
- * stored in the static array TYPES.
- * @see #types()
- */
- private JDBCType(String name, int code) {
- super();
- this.name = name;
- this.code = code;
- }
-
-
- // ********** accessors **********
-
- /**
- * Return the name of the type, as defined in java.sql.Types.
- */
- public String name() {
- return this.name;
- }
-
-
- /**
- * Return the type code, as defined in java.sql.Types.
- */
- public int code() {
- return this.code;
- }
-
-
- // ********** printing and displaying **********
-
- public void appendTo(StringBuilder sb) {
- sb.append(this.name);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(ClassTools.shortClassNameForObject(this));
- sb.append('(');
- this.appendTo(sb);
- sb.append(')');
- return sb.toString();
- }
-
- @Override
- public JDBCType clone() {
- try {
- return (JDBCType) super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- public int compareTo(JDBCType type) {
- return Collator.getInstance().compare(this.name, type.name);
- }
-
-
- // ********** static stuff **********
-
- /**
- * all the JDBC type defined in java.sql.Types
- */
- private static JDBCType[] TYPES; // pseudo 'final' - lazy-initialized
-
-
- public synchronized static JDBCType[] types() {
- if (TYPES == null) {
- TYPES = buildTypes();
- }
- return TYPES;
- }
-
- /**
- * Return the JDBC type for the specified type code (e.g. Types.VARCHAR).
- * @see java.sql.Types
- */
- public static JDBCType type(int code) {
- JDBCType[] types = types();
- for (int i = types.length; i-- > 0; ) {
- if (types[i].code() == code) {
- return types[i];
- }
- }
- throw new IllegalArgumentException("invalid JDBC type code: " + code);
- }
-
- /**
- * Return the JDBC type for the specified type name (e.g. "VARCHAR").
- * @see java.sql.Types
- */
- public static JDBCType type(String name) {
- JDBCType[] types = types();
- for (int i = types.length; i-- > 0; ) {
- if (types[i].name().equals(name)) {
- return types[i];
- }
- }
- throw new IllegalArgumentException("invalid JDBC type name: " + name);
- }
-
- /**
- * build up the JDBC types via reflection
- * @see java.sql.Types
- */
- private static JDBCType[] buildTypes() {
- Field[] fields = Types.class.getDeclaredFields();
- int len = fields.length;
- JDBCType[] types = new JDBCType[len];
- for (int i = len; i-- > 0; ) {
- String name = fields[i].getName();
- int code;
- try {
- code = ((Integer) fields[i].get(null)).intValue();
- } catch (IllegalAccessException ex) {
- throw new RuntimeException(ex); // shouldn't happen...
- }
- types[i] = new JDBCType(name, code);
- }
- return types;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java
deleted file mode 100644
index fa8b5609c8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-/**
- * Various helper methods for generating names.
- */
-public final class NameTools {
-
- /**
- * Given a "root" name and a set of existing names, generate a unique,
- * Java-legal name that is either the "root" name or some variation on
- * the "root" name (e.g. "root2", "root3",...).
- * The names are case-sensitive.
- */
- public static String uniqueJavaNameFor(String rootName, Iterator<String> existingNames) {
- Collection<String> existingNames2 = CollectionTools.set(existingNames);
- existingNames2.addAll(JAVA_RESERVED_WORDS_SET);
- return uniqueNameFor(rootName, existingNames2, rootName);
- }
-
- /**
- * Given a "root" name and a set of existing names, generate a unique,
- * Java-legal name that is either the "root" name or some variation on
- * the "root" name (e.g. "root2", "root3",...).
- * The names are case-sensitive.
- */
- public static String uniqueJavaNameFor(String rootName, Collection<String> existingNames) {
- Collection<String> existingNames2 = new HashSet<String>(existingNames);
- existingNames2.addAll(JAVA_RESERVED_WORDS_SET);
- return uniqueNameFor(rootName, existingNames2, rootName);
- }
-
- /**
- * Given a "root" name and a set of existing names, generate a unique
- * name that is either the "root" name or some variation on the "root"
- * name (e.g. "root2", "root3",...). The names are case-sensitive.
- */
- public static String uniqueNameFor(String rootName, Iterator<String> existingNames) {
- return uniqueNameFor(rootName, CollectionTools.set(existingNames));
- }
-
- /**
- * Given a "root" name and a set of existing names, generate a unique
- * name that is either the "root" name or some variation on the "root"
- * name (e.g. "root2", "root3",...). The names are case-sensitive.
- */
- public static String uniqueNameFor(String rootName, Collection<String> existingNames) {
- return uniqueNameFor(rootName, existingNames, rootName);
- }
-
- /**
- * Given a "root" name and a set of existing names, generate a unique
- * name that is either the "root" name or some variation on the "root"
- * name (e.g. "root2", "root3",...). The names are NOT case-sensitive.
- */
- public static String uniqueNameForIgnoreCase(String rootName, Iterator<String> existingNames) {
- return uniqueNameForIgnoreCase(rootName, CollectionTools.set(existingNames));
- }
-
- /**
- * Given a "root" name and a set of existing names, generate a unique
- * name that is either the "root" name or some variation on the "root"
- * name (e.g. "root2", "root3",...). The names are NOT case-sensitive.
- */
- public static String uniqueNameForIgnoreCase(String rootName, Collection<String> existingNames) {
- return uniqueNameFor(rootName, convertToLowerCase(existingNames), rootName.toLowerCase());
- }
-
- /**
- * use the suffixed "template" name to perform the comparisons, but RETURN
- * the suffixed "root" name; this allows case-insensitive comparisons
- * (i.e. the "template" name has been morphed to the same case as
- * the "existing" names, while the "root" name has not, but the "root" name
- * is what the client wants morphed to be unique)
- */
- private static String uniqueNameFor(String rootName, Collection<String> existingNames, String templateName) {
- if ( ! existingNames.contains(templateName)) {
- return rootName;
- }
- String uniqueName = templateName;
- for (int suffix = 2; true; suffix++) {
- if ( ! existingNames.contains(uniqueName + suffix)) {
- return rootName.concat(String.valueOf(suffix));
- }
- }
- }
-
- /**
- * Convert the specified collection of strings to a collection of the same
- * strings converted to lower case.
- */
- private static Collection<String> convertToLowerCase(Collection<String> strings) {
- Collection<String> result = new HashBag<String>(strings.size());
- for (String string : strings) {
- result.add(string.toLowerCase());
- }
- return result;
- }
-
- /**
- * Build a fully-qualified name for the specified database object.
- * Variations:
- * catalog.schema.name
- * catalog..name
- * schema.name
- * name
- */
- public static String buildQualifiedDatabaseObjectName(String catalog, String schema, String name) {
- if (name == null) {
- return null;
- }
- if ((catalog == null) && (schema == null)) {
- return name;
- }
-
- StringBuilder sb = new StringBuilder(100);
- if (catalog != null) {
- sb.append(catalog);
- sb.append('.');
- }
- if (schema != null) {
- sb.append(schema);
- }
- sb.append('.');
- sb.append(name);
- return sb.toString();
- }
-
- /**
- * The set of reserved words in the Java programming language.
- * These words cannot be used as identifiers (i.e. names).
- * http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
- */
- public static final String[] JAVA_RESERVED_WORDS = new String[] {
- "abstract",
- "assert", // jdk 1.4
- "boolean",
- "break",
- "byte",
- "case",
- "catch",
- "char",
- "class",
- "const", // unused
- "continue",
- "default",
- "do",
- "double",
- "else",
- "enum", // jdk 1.5
- "extends",
- "false",
- "final",
- "finally",
- "float",
- "for",
- "goto", // unused
- "if",
- "implements",
- "import",
- "instanceof",
- "int",
- "interface",
- "long",
- "native",
- "new",
- "null",
- "package",
- "private",
- "protected",
- "public",
- "return",
- "short",
- "static",
- "strictfp", // jdk 1.2
- "super",
- "switch",
- "synchronized",
- "this",
- "throw",
- "throws",
- "transient",
- "true",
- "try",
- "void",
- "volatile",
- "while"
- };
-
- /**
- * The set of reserved words in the Java programming language.
- * These words cannot be used as identifiers (i.e. names).
- * http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
- */
- public static final Set<String> JAVA_RESERVED_WORDS_SET = CollectionTools.set(JAVA_RESERVED_WORDS);
-
- /**
- * Return the set of Java programming language reserved words.
- * These words cannot be used as identifiers (i.e. names).
- * http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
- */
- public static Iterator<String> javaReservedWords() {
- return new ArrayIterator<String>(JAVA_RESERVED_WORDS);
- }
-
- /**
- * Convert the specified string to a valid Java identifier
- * by substituting an underscore '_' for any invalid characters
- * in the string and appending an underscore '_' to the string if
- * it is a Java reserved word.
- */
- public static String convertToJavaIdentifier(String string) {
- return convertToJavaIdentifier(string, '_');
- }
-
- /**
- * Convert the specified string to a valid Java identifier
- * by substituting the specified character for any invalid characters
- * in the string and, if necessary, appending the specified character
- * to the string until it is not a Java reserved word.
- */
- public static String convertToJavaIdentifier(String string, char c) {
- if (string.length() == 0) {
- return string;
- }
- if (JAVA_RESERVED_WORDS_SET.contains(string)) {
- // a reserved word is a valid identifier, we just need to tweak it a bit
- checkCharIsJavaIdentifierPart(c);
- return convertToJavaIdentifier(string + c, c);
- }
- char[] array = string.toCharArray();
- return (convertToJavaIdentifier_(array, c)) ? new String(array) : string;
- }
-
- /**
- * Convert the specified string to a valid Java identifier
- * by substituting an underscore '_' for any invalid characters
- * in the string and appending an underscore '_' to the string if
- * it is a Java reserved word.
- */
- public static char[] convertToJavaIdentifier(char[] string) {
- return convertToJavaIdentifier(string, '_');
- }
-
- /**
- * Convert the specified string to a valid Java identifier
- * by substituting the specified character for any invalid characters
- * in the string and, if necessary, appending the specified character
- * to the string until it is not a Java reserved word.
- */
- public static char[] convertToJavaIdentifier(char[] string, char c) {
- int length = string.length;
- if (length == 0) {
- return string;
- }
- if (JAVA_RESERVED_WORDS_SET.contains(new String(string))) {
- // a reserved word is a valid identifier, we just need to tweak it a bit
- checkCharIsJavaIdentifierPart(c);
- return convertToJavaIdentifier(CollectionTools.add(string, c), c);
- }
- convertToJavaIdentifier_(string, c);
- return string;
- }
-
- /**
- * The specified must not be empty.
- * Return whether the string was modified.
- */
- private static boolean convertToJavaIdentifier_(char[] string, char c) {
- boolean mod = false;
- if ( ! Character.isJavaIdentifierStart(string[0])) {
- checkCharIsJavaIdentifierStart(c);
- string[0] = c;
- mod = true;
- }
- checkCharIsJavaIdentifierPart(c);
- for (int i = string.length; i-- > 1; ) { // NB: end with 1
- if ( ! Character.isJavaIdentifierPart(string[i])) {
- string[i] = c;
- mod = true;
- }
- }
- return mod;
- }
-
- private static void checkCharIsJavaIdentifierStart(char c) {
- if ( ! Character.isJavaIdentifierStart(c)) {
- throw new IllegalArgumentException("invalid Java identifier start char: '" + c + "'");
- }
- }
-
- private static void checkCharIsJavaIdentifierPart(char c) {
- if ( ! Character.isJavaIdentifierPart(c)) {
- throw new IllegalArgumentException("invalid Java identifier part char: '" + c + "'");
- }
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private NameTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NullList.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NullList.java
deleted file mode 100644
index c60d4e5969..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NullList.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-
-/**
- * A "null" list is a bit different from an "empty" list: it allows clients to
- * add/remove elements to/from it but never changes. This is useful
- * for passing to methods that require a "collecting parameter" but the
- * client will ignore the resulting "collection".
- *
- * NB: We return 'null' from the following methods (as opposed to throwing
- * an exception):
- * get(int) : E
- * remove(int) : E
- * set(int, E) : E
- */
-public final class NullList<E> implements List<E> {
-
- // singleton
- @SuppressWarnings("unchecked")
- private static final NullList INSTANCE = new NullList();
-
- /**
- * Return the singleton.
- */
- @SuppressWarnings("unchecked")
- public static <E> List<E> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private NullList() {
- super();
- }
-
- public boolean add(E o) {
- return false; // the list did not change
- }
-
- public void add(int index, E element) {
- // ignore
- }
-
- public boolean addAll(Collection<? extends E> c) {
- return false; // the list did not change
- }
-
- public boolean addAll(int index, Collection<? extends E> c) {
- return false; // the list did not change
- }
-
- public void clear() {
- // ignore
- }
-
- public boolean contains(Object o) {
- return false;
- }
-
- public boolean containsAll(Collection<?> c) {
- return c.isEmpty();
- }
-
- public E get(int index) {
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: 0");
- }
-
- public int indexOf(Object o) {
- return -1;
- }
-
- public boolean isEmpty() {
- return true;
- }
-
- public Iterator<E> iterator() {
- return EmptyIterator.instance();
- }
-
- public int lastIndexOf(Object o) {
- return -1;
- }
-
- public ListIterator<E> listIterator() {
- return EmptyListIterator.instance();
- }
-
- public ListIterator<E> listIterator(int index) {
- return EmptyListIterator.instance();
- }
-
- public boolean remove(Object o) {
- return false; // the list did not change
- }
-
- public E remove(int index) {
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: 0");
- }
-
- public boolean removeAll(Collection<?> c) {
- return false; // the list did not change
- }
-
- public boolean retainAll(Collection<?> c) {
- return false; // the list did not change
- }
-
- public E set(int index, E element) {
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: 0");
- }
-
- public int size() {
- return 0;
- }
-
- public List<E> subList(int fromIndex, int toIndex) {
- return this;
- }
-
- private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
- public Object[] toArray() {
- return EMPTY_OBJECT_ARRAY;
- }
-
- public <T> T[] toArray(T[] a) {
- return a;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Range.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Range.java
deleted file mode 100644
index 4dbe48618a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Range.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * This simple container class simply puts a bit of semantics
- * around a pair of numbers.
- */
-public class Range
- implements Cloneable, Serializable
-{
- /** The starting index of the range. */
- public final int start;
-
- /** The ending index of the range. */
- public final int end;
-
- /**
- * The size can be negative if the ending index
- * is less than the starting index.
- */
- public final int size;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct with the specified start and end,
- * both of which are immutable.
- */
- public Range(int start, int end) {
- super();
- this.start = start;
- this.end = end;
- this.size = end - start + 1;
- }
-
- /**
- * Return whether the range includes the specified
- * index.
- */
- public boolean includes(int index) {
- return (this.start <= index) && (index <= this.end);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if ( ! (o instanceof Range)) {
- return false;
- }
- Range otherRange = (Range) o;
- return (this.start == otherRange.start)
- && (this.end == otherRange.end);
- }
-
- @Override
- public int hashCode() {
- return this.start ^ this.end;
- }
-
- @Override
- public Range clone() {
- try {
- return (Range) super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public String toString() {
- return "[" + this.start + ", " + this.end + ']';
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ReverseComparator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ReverseComparator.java
deleted file mode 100644
index 10c01f80f0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ReverseComparator.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-/**
- * This comparator will reverse the order of the specified comparator.
- * If the comparator is null, the natural ordering of the objects will be used.
- */
-public class ReverseComparator<E extends Comparable<? super E>>
- implements Comparator<E>, Serializable
-{
- private final Comparator<E> comparator;
-
- public ReverseComparator() {
- this(null);
- }
-
- public ReverseComparator(Comparator<E> comparator) {
- super();
- this.comparator = comparator;
- }
-
- public int compare(E e1, E e2) {
- return (this.comparator == null) ?
- e2.compareTo(e1)
- :
- this.comparator.compare(e2, e1);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleAssociation.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleAssociation.java
deleted file mode 100644
index 7c9b0a7401..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleAssociation.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * Straightforward implementation of Association.
- */
-public class SimpleAssociation<K, V>
- extends AbstractAssociation<K, V>
- implements Cloneable, Serializable
-{
- private final K key;
- private V value;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct an association with the specified key
- * and a null value.
- */
- public SimpleAssociation(K key) {
- super();
- this.key = key;
- }
-
- /**
- * Construct an association with the specified key and value.
- */
- public SimpleAssociation(K key, V value) {
- this(key);
- this.value = value;
- }
-
-
- public K key() {
- return this.key;
- }
-
- public synchronized V value() {
- return this.value;
- }
-
- public synchronized V setValue(V value) {
- V old = this.value;
- this.value = value;
- return old;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public synchronized SimpleAssociation<K, V> clone() {
- try {
- return (SimpleAssociation<K, V>) super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleFilter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleFilter.java
deleted file mode 100644
index 8cf6bb2650..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleFilter.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-
-import org.eclipse.jpt.utility.Filter;
-
-/**
- * Simple, abstract implementation of <code>Filter</code>
- * that holds on to a criterion object that can be used in the
- * <code>accept(Object)</code> or <code>reject(Object)</code>
- * methods. Subclasses can override either of these methods,
- * depending on which is easier to implement. Note that at least
- * one of these methods <em>must</em> be overridden or
- * an infinite loop will occur. If both of them are overridden,
- * only the <code>accept(Object)</code> method will be used.
- * <p>
- * Simplifies the implementation of straightforward inner classes.
- * Here is an example of a filter that can be used by a
- * <code>FilteringIterator</code> to return only those strings
- * in the nested iterator start with "prefix":
- * <pre>
- * Filter<String> filter = new SimpleFilter<String>("prefix") {
- * public boolean accept(String o) {
- * return o.startsWith((String) criterion);
- * }
- * };
- * </pre>
- */
-public abstract class SimpleFilter<T, S>
- implements Filter<T>, Cloneable, Serializable
-{
- protected final S criterion;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * More useful constructor. The specified criterion can
- * be used by a subclass to "accept" or "reject" objects.
- */
- protected SimpleFilter(S criterion) {
- super();
- this.criterion = criterion;
- }
-
- /**
- * Construct a simple filter with a null criterion
- */
- protected SimpleFilter() {
- this(null);
- }
-
- /**
- * Return whether the the specified object should be "rejected".
- * The semantics of "rejected" is determined by the client.
- */
- protected boolean reject(T o) {
- return ! this.accept(o);
- }
-
- /**
- * Return whether the the specified object should be "accepted".
- * The semantics of "accepted" is determined by the client.
- */
- public boolean accept(T o) {
- return ! this.reject(o);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public SimpleFilter<T, S> clone() {
- try {
- return (SimpleFilter<T, S>) super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public boolean equals(Object o) {
- if ( ! (o instanceof SimpleFilter)) {
- return false;
- }
- SimpleFilter<?, ?> other = (SimpleFilter<?, ?>) o;
- return (this.criterion == null) ?
- (other.criterion == null) : this.criterion.equals(other.criterion);
- }
-
- @Override
- public int hashCode() {
- return (this.criterion == null) ? 0 : this.criterion.hashCode();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.criterion);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleJavaType.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleJavaType.java
deleted file mode 100644
index faa3177b91..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleJavaType.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.text.Collator;
-
-import org.eclipse.jpt.utility.JavaType;
-
-/**
- * Straightforward implementation of the JavaType interface.
- */
-public final class SimpleJavaType
- implements JavaType, Cloneable, Serializable
-{
-
- /**
- * store the type as a name, so we can reference classes
- * that are not loaded
- */
- private final String elementTypeName;
-
- /**
- * non-array types have an array depth of zero
- */
- private final int arrayDepth;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a Java type with the specified element type and array depth.
- */
- public SimpleJavaType(String elementTypeName, int arrayDepth) {
- super();
- if ((elementTypeName == null) || (elementTypeName.length() == 0)) {
- throw new IllegalArgumentException("The element type name is required.");
- }
- if (ClassTools.arrayDepthForClassNamed(elementTypeName) != 0) { // e.g. "[Ljava.lang.Object;"
- throw new IllegalArgumentException("The element type must not be an array: " + elementTypeName + '.');
- }
- if (arrayDepth < 0) {
- throw new IllegalArgumentException("The array depth must be greater than or equal to zero: " + arrayDepth + '.');
- }
- if (elementTypeName.equals(void.class.getName()) && (arrayDepth != 0)) {
- throw new IllegalArgumentException("'void' must have an array depth of zero: " + arrayDepth + '.');
- }
- this.elementTypeName = elementTypeName;
- this.arrayDepth = arrayDepth;
- }
-
- /**
- * Construct a Java type for the specified class.
- * The class name can be in one of the following forms:
- * java.lang.Object
- * int
- * java.util.Map$Entry
- * [Ljava.lang.Object;
- * [I
- * [Ljava.util.Map$Entry;
- */
- public SimpleJavaType(String javaClassName) {
- this(ClassTools.elementTypeNameForClassNamed(javaClassName), ClassTools.arrayDepthForClassNamed(javaClassName));
- }
-
- /**
- * Construct a Java type for the specified class.
- */
- public SimpleJavaType(Class<?> javaClass) {
- this(javaClass.getName());
- }
-
-
- // ********** accessors **********
-
- public String getElementTypeName() {
- return this.elementTypeName;
- }
-
- public int getArrayDepth() {
- return this.arrayDepth;
- }
-
-
- // ********** queries **********
-
- public boolean isArray() {
- return this.arrayDepth > 0;
- }
-
- public boolean isPrimitive() {
- return (this.arrayDepth == 0) && ClassTools.classNamedIsPrimitive(this.elementTypeName);
- }
-
- public boolean isPrimitiveWrapper() {
- return (this.arrayDepth == 0) && ClassTools.classNamedIsPrimitiveWrapperClass(this.elementTypeName);
- }
-
- public boolean isVariablePrimitive() {
- return (this.arrayDepth == 0) && ClassTools.classNamedIsVariablePrimitive(this.elementTypeName);
- }
-
- public boolean isVariablePrimitiveWrapper() {
- return (this.arrayDepth == 0) && ClassTools.classNamedIsVariablePrimitiveWrapperClass(this.elementTypeName);
- }
-
- public Class<?> getJavaClass() throws ClassNotFoundException {
- return ClassTools.classForTypeDeclaration(this.elementTypeName, this.arrayDepth);
- }
-
- public String getJavaClassName() {
- return ClassTools.classNameForTypeDeclaration(this.elementTypeName, this.arrayDepth);
- }
-
-
- // ********** comparison **********
-
- public boolean equals(String otherElementTypeName, int otherArrayDepth) {
- return (this.arrayDepth == otherArrayDepth)
- && this.elementTypeName.equals(otherElementTypeName);
- }
-
- public boolean describes(String className) {
- return this.equals(ClassTools.elementTypeNameForClassNamed(className), ClassTools.arrayDepthForClassNamed(className));
- }
-
- public boolean describes(Class<?> javaClass) {
- return this.describes(javaClass.getName());
- }
-
- public boolean equals(JavaType other) {
- return this.equals(other.getElementTypeName(), other.getArrayDepth());
- }
-
- @Override
- public boolean equals(Object o) {
- return (o instanceof JavaType) ? this.equals((JavaType) o) : false;
- }
-
- @Override
- public int hashCode() {
- return this.elementTypeName.hashCode() ^ this.arrayDepth;
- }
-
- public int compareTo(JavaType jt) {
- int x = Collator.getInstance().compare(this.elementTypeName, jt.getElementTypeName());
- return (x != 0) ? x : (this.arrayDepth - jt.getArrayDepth());
- }
-
-
- // ********** printing and displaying **********
-
- /**
- * Return the version of the type's name that can be used in source code:
- * "[[J" => "long[][]"
- * "java.util.Map$Entry" => "java.util.Map.Entry"
- */
- public String declaration() {
- if (this.arrayDepth == 0) {
- return this.elementTypeNameDeclaration();
- }
- StringBuilder sb = new StringBuilder(this.elementTypeName.length() + (2 * this.arrayDepth));
- this.appendDeclarationTo(sb);
- return sb.toString();
- }
-
- /**
- * Append the version of the type's name that can be used in source code:
- * "[[J" => "long[][]"
- * "java.util.Map$Entry" => "java.util.Map.Entry"
- */
- public void appendDeclarationTo(StringBuilder sb) {
- sb.append(this.elementTypeNameDeclaration());
- for (int i = this.arrayDepth; i-- > 0; ) {
- sb.append("[]");
- }
- }
-
- /**
- * Print the version of the type's name that can be used in source code:
- * "[[J" => "long[][]"
- * "java.util.Map$Entry" => "java.util.Map.Entry"
- */
- public void printDeclarationOn(PrintWriter pw) {
- pw.print(this.elementTypeNameDeclaration());
- for (int i = this.arrayDepth; i-- > 0; ) {
- pw.print("[]");
- }
- }
-
- /**
- * The '$' version of the name is used in Class.forName(String),
- * but the '.' verions of the name is used in source code.
- * Very irritating....
- */
- private String elementTypeNameDeclaration() {
- return this.elementTypeName.replace('$', '.');
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(ClassTools.shortClassNameForObject(this));
- sb.append('(');
- this.appendDeclarationTo(sb);
- sb.append(')');
- return sb.toString();
- }
-
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStack.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStack.java
deleted file mode 100644
index f183943d9a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStack.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.EmptyStackException;
-import java.util.LinkedList;
-import java.util.NoSuchElementException;
-
-/**
- * Straightforward implementation of the Stack interface.
- */
-public class SimpleStack<E>
- implements Stack<E>, Cloneable, Serializable
-{
- private LinkedList<E> elements;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct an empty stack.
- */
- public SimpleStack() {
- super();
- this.elements = new LinkedList<E>();
- }
-
- /**
- * Construct a stack containing the elements of the specified
- * collection. The stack will pop its elements in reverse of the
- * order they are returned by the collection's iterator (i.e. the
- * last element returned by the collection's iterator will be the
- * first element returned by #pop()).
- */
- public SimpleStack(Collection<? extends E> c) {
- super();
- this.elements = new LinkedList<E>(c);
- }
-
-
- // ********** Stack implementation **********
-
- public void push(E o) {
- this.elements.addLast(o);
- }
-
- public E pop() {
- try {
- return this.elements.removeLast();
- } catch (NoSuchElementException ex) {
- throw new EmptyStackException();
- }
- }
-
- public E peek() {
- try {
- return this.elements.getLast();
- } catch (NoSuchElementException ex) {
- throw new EmptyStackException();
- }
- }
-
- public boolean isEmpty() {
- return this.elements.isEmpty();
- }
-
-
- // ********** Cloneable implementation **********
-
- @Override
- public SimpleStack<E> clone() {
- try {
- @SuppressWarnings("unchecked")
- SimpleStack<E> clone = (SimpleStack<E>) super.clone();
- @SuppressWarnings("unchecked")
- LinkedList<E> ll = (LinkedList<E>) this.elements.clone();
- clone.elements = ll;
- return clone;
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStringMatcher.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStringMatcher.java
deleted file mode 100644
index ea5595c4b0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStringMatcher.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-import java.util.regex.Pattern;
-
-import org.eclipse.jpt.utility.Filter;
-
-// TODO the regex code is not very fast - we could probably do better,
-// hand-coding the matching algorithm (eclipse StringMatcher?)
-/**
- * This class implements a simple string-matching algorithm that is a little
- * more user-friendly than standard regular expressions. Instantiate a
- * string matcher with a filter pattern and then you can use the matcher
- * to determine whether another string (or object) matches the pattern.
- * You can also specify whether the matching should be case-sensitive.
- *
- * The pattern can contain two "meta-characters":
- * '*' will match any set of zero or more characters
- * '?' will match any single character
- *
- * Subclasses can override #prefix() and/or #suffix() to change what
- * strings are prepended or appended to the original pattern string.
- * This can offer a slight performance improvement over concatenating
- * strings before calling #setPatternString(String).
- * By default, a '*' is appended to every string.
- *
- * This class also uses the string-matching algorithm to "filter" objects
- * (and, as a result, also implements the Filter interface).
- * A string converter is used to determine what string aspect of the
- * object is compared to the pattern. By default the string returned
- * by the object's #toString() method is passed to the pattern matcher.
- */
-public class SimpleStringMatcher<T>
- implements StringMatcher, Filter<T>, Serializable
-{
-
- /** An adapter that converts the objects into strings to be matched with the pattern. */
- private StringConverter<T> stringConverter;
-
- /** The string used to construct the regular expression pattern. */
- private String patternString;
-
- /** Whether the matcher ignores case - the default is true. */
- private boolean ignoresCase;
-
- /** The regular expression pattern built from the pattern string. */
- private Pattern pattern;
-
- /** A list of the meta-characters we need to escape if found in the pattern string. */
- public static final char[] REG_EX_META_CHARS = { '(', '[', '{', '\\', '^', '$', '|', ')', '?', '*', '+', '.' };
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a string matcher with an pattern that will match
- * any string and ignore case.
- */
- public SimpleStringMatcher() {
- this("*");
- }
-
- /**
- * Construct a string matcher with the specified pattern
- * that will ignore case.
- */
- public SimpleStringMatcher(String patternString) {
- this(patternString, true);
- }
-
- /**
- * Construct a string matcher with the specified pattern that will
- * ignore case as specified.
- */
- public SimpleStringMatcher(String patternString, boolean ignoresCase) {
- super();
- this.patternString = patternString;
- this.ignoresCase = ignoresCase;
- this.initialize();
- }
-
-
- // ********** initialization **********
-
- protected void initialize() {
- this.stringConverter = StringConverter.Default.instance();
- this.rebuildPattern();
- }
-
- /**
- * Given the current pattern string and case-sensitivity setting,
- * re-build the regular expression pattern.
- */
- protected synchronized void rebuildPattern() {
- this.pattern = this.buildPattern();
- }
-
- /**
- * Given the current pattern string and case-sensitivity setting,
- * build and return a regular expression pattern that can be used
- * to match strings.
- */
- protected Pattern buildPattern() {
- int patternFlags = 0x0;
- if (this.ignoresCase) {
- patternFlags = Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE;
- }
- return Pattern.compile(this.convertToRegEx(this.patternString), patternFlags);
- }
-
-
- // ********** StringMatcher implementation **********
-
- public synchronized void setPatternString(String patternString) {
- this.patternString = patternString;
- this.rebuildPattern();
- }
-
- /**
- * Return whether the specified string matches the pattern.
- */
- public synchronized boolean matches(String string) {
- return this.pattern.matcher(string).matches();
- }
-
-
- // ********** Filter implementation **********
-
- public synchronized boolean accept(T o) {
- return this.matches(this.stringConverter.convertToString(o));
- }
-
-
- // ********** accessors **********
-
- /**
- * Return the string converter used to convert the objects
- * passed to the matcher into strings.
- */
- public synchronized StringConverter<T> stringConverter() {
- return this.stringConverter;
- }
-
- /**
- * Set the string converter used to convert the objects
- * passed to the matcher into strings.
- */
- public synchronized void setStringConverter(StringConverter<T> stringConverter) {
- this.stringConverter = stringConverter;
- }
-
- /**
- * Return the original pattern string.
- */
- public synchronized String patternString() {
- return this.patternString;
- }
-
- /**
- * Return whether the matcher ignores case.
- */
- public synchronized boolean ignoresCase() {
- return this.ignoresCase;
- }
-
- /**
- * Set whether the matcher ignores case.
- */
- public synchronized void setIgnoresCase(boolean ignoresCase) {
- this.ignoresCase = ignoresCase;
- this.rebuildPattern();
- }
-
- /**
- * Return the regular expression pattern.
- */
- public synchronized Pattern pattern() {
- return this.pattern;
- }
-
-
- // ********** other public API **********
-
- /**
- * Return the regular expression corresponding to
- * the original pattern string.
- */
- public synchronized String regularExpression() {
- return this.convertToRegEx(this.patternString);
- }
-
-
- // ********** converting **********
-
- /**
- * Convert the specified string to a regular expression.
- */
- protected String convertToRegEx(String string) {
- StringBuffer sb = new StringBuffer(string.length() + 10);
- this.convertToRegExOn(this.prefix(), sb);
- this.convertToRegExOn(string, sb);
- this.convertToRegExOn(this.suffix(), sb);
- return sb.toString();
- }
-
- /**
- * Return any prefix that should be prepended to the original
- * string. By default, there is no prefix.
- */
- protected String prefix() {
- return "";
- }
-
- /**
- * Return any suffix that should be appended to the original
- * string. Since this class is typically used in UI situation where
- * the user is typing in a pattern used to filter a list, the default
- * suffix is a wildcard character.
- */
- protected String suffix() {
- return "*";
- }
-
- /**
- * Convert the specified string to a regular expression.
- */
- protected void convertToRegExOn(String string, StringBuffer sb) {
- char[] charArray = string.toCharArray();
- int length = charArray.length;
- for (int i = 0; i < length; i++) {
- char c = charArray[i];
- // convert user-friendly meta-chars into regex meta-chars
- if (c == '*') {
- sb.append(".*");
- continue;
- }
- if (c == '?') {
- sb.append('.');
- continue;
- }
- // escape regex meta-chars
- if (CollectionTools.contains(REG_EX_META_CHARS, c)) {
- sb.append('\\');
- }
- sb.append(c);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Stack.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Stack.java
deleted file mode 100644
index 93bef64f4b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Stack.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-import java.util.EmptyStackException;
-
-/**
- * Interface defining the classic stack behavior,
- * without the backdoors allowed by java.util.Stack.
- * E is the type of elements contained by the Stack.
- */
-public interface Stack<E> {
-
- /**
- * "Push" the specified item on to the top of the stack.
- */
- void push(E o);
-
- /**
- * "Pop" an item from the top of the stack.
- */
- E pop();
-
- /**
- * Return the item on the top of the stack
- * without removing it from the stack.
- */
- E peek();
-
- /**
- * Return whether the stack is empty.
- */
- boolean isEmpty();
-
-
- final class Empty<E> implements Stack<E>, Serializable {
- @SuppressWarnings("unchecked")
- public static final Stack INSTANCE = new Empty();
- @SuppressWarnings("unchecked")
- public static <T> Stack<T> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Empty() {
- super();
- }
- public void push(E o) {
- throw new UnsupportedOperationException();
- }
- public E pop() {
- throw new EmptyStackException();
- }
- public E peek() {
- throw new EmptyStackException();
- }
- public boolean isEmpty() {
- return true;
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- return INSTANCE;
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringConverter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringConverter.java
deleted file mode 100644
index 556b530862..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringConverter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-/**
- * Used by various "pluggable" classes to transform objects
- * into strings.
- */
-public interface StringConverter<T> {
-
- /**
- * Convert the specified object into a string.
- * The semantics of "convert" is determined by the
- * contract between the client and the server.
- */
- String convertToString(T o);
-
-
- final class Default<S> implements StringConverter<S> {
- @SuppressWarnings("unchecked")
- public static final StringConverter INSTANCE = new Default();
- @SuppressWarnings("unchecked")
- public static <R> StringConverter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- // simply return the object's #toString() result
- public String convertToString(S o) {
- return (o == null) ? null : o.toString();
- }
- @Override
- public String toString() {
- return "StringConverter.Default";
- }
- }
-
- final class Disabled<S> implements StringConverter<S> {
- @SuppressWarnings("unchecked")
- public static final StringConverter INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> StringConverter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public String convertToString(S o) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return "StringConverter.Disabled";
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringMatcher.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringMatcher.java
deleted file mode 100644
index 5f769d7040..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringMatcher.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-/**
- * This interface defines a simple API for allowing "pluggable"
- * string matchers that can be configured with a pattern string
- * then used to determine what strings match the pattern.
- */
-public interface StringMatcher {
-
- /**
- * Set the pattern string used to determine future
- * matches. The format and semantics of the pattern
- * string are determined by the contract between the
- * client and the server.
- */
- void setPatternString(String patternString);
-
- /**
- * Return whether the specified string matches the
- * established pattern string. The semantics of a match
- * is determined by the contract between the
- * client and the server.
- */
- boolean matches(String string);
-
-
- final class Null implements StringMatcher {
- public static final StringMatcher INSTANCE = new Null();
- public static StringMatcher instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void setPatternString(String patternString) {
- // ignore the pattern string
- }
- public boolean matches(String string) {
- // everything is a match
- return true;
- }
- @Override
- public String toString() {
- return "StringMatcher.Null";
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringTools.java
deleted file mode 100644
index a7cc25a96c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringTools.java
+++ /dev/null
@@ -1,3243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-/**
- * Convenience methods related to the java.lang.String class.
- */
-public final class StringTools {
-
- /** carriage return */
- public static final String CR = System.getProperty("line.separator");
-
- /** double quote */
- public static final char QUOTE = '"';
-
-
-
- // ********** padding/truncating **********
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#pad(int)
- */
- public static String pad(String string, int length) {
- return pad(string, length, ' ');
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOn(int, Writer)
- */
- public static void padOn(String string, int length, Writer writer) {
- padOn(string, length, ' ', writer);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOn(int, StringBuffer)
- */
- public static void padOn(String string, int length, StringBuffer sb) {
- padOn(string, length, ' ', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOn(int, StringBuilder)
- */
- public static void padOn(String string, int length, StringBuilder sb) {
- padOn(string, length, ' ', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#pad(int, char)
- */
- public static String pad(String string, int length, char c) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- return string;
- }
- return pad_(string, length, c);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOn(int, char, Writer)
- */
- public static void padOn(String string, int length, char c, Writer writer) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else {
- padOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOn(int, char, StringBuffer)
- */
- public static void padOn(String string, int length, char c, StringBuffer sb) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOn(int, char, StringBuilder)
- */
- public static void padOn(String string, int length, char c, StringBuilder sb) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#pad(int)
- */
- public static char[] pad(char[] string, int length) {
- return pad(string, length, ' ');
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOn(int, writer)
- */
- public static void padOn(char[] string, int length, Writer writer) {
- padOn(string, length, ' ', writer);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOn(int, StringBuffer)
- */
- public static void padOn(char[] string, int length, StringBuffer sb) {
- padOn(string, length, ' ', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOn(int, StringBuilder)
- */
- public static void padOn(char[] string, int length, StringBuilder sb) {
- padOn(string, length, ' ', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#pad(int, char)
- */
- public static char[] pad(char[] string, int length, char c) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- return string;
- }
- return pad_(string, length, c);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOn(int, char, Writer)
- */
- public static void padOn(char[] string, int length, char c, Writer writer) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else {
- padOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOn(int, char, StringBuffer)
- */
- public static void padOn(char[] string, int length, char c, StringBuffer sb) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOn(int, char, StringBuilder)
- */
- public static void padOn(char[] string, int length, char c, StringBuilder sb) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOrTruncate(int)
- */
- public static String padOrTruncate(String string, int length) {
- return padOrTruncate(string, length, ' ');
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOrTruncateOn(int, Writer)
- */
- public static void padOrTruncateOn(String string, int length, Writer writer) {
- padOrTruncateOn(string, length, ' ', writer);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOrTruncateOn(int, StringBuffer)
- */
- public static void padOrTruncateOn(String string, int length, StringBuffer sb) {
- padOrTruncateOn(string, length, ' ', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOrTruncateOn(int, StringBuilder)
- */
- public static void padOrTruncateOn(String string, int length, StringBuilder sb) {
- padOrTruncateOn(string, length, ' ', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOrTruncate(int, char)
- */
- public static String padOrTruncate(String string, int length, char c) {
- int stringLength = string.length();
- if (stringLength == length) {
- return string;
- }
- if (stringLength > length) {
- return string.substring(0, length);
- }
- return pad_(string, length, c);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOrTruncateOn(int, char, Writer)
- */
- public static void padOrTruncateOn(String string, int length, char c, Writer writer) {
- int stringLength = string.length();
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else if (stringLength > length) {
- writeStringOn(string.substring(0, length), writer);
- } else {
- padOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOrTruncateOn(int, char, StringBuffer)
- */
- public static void padOrTruncateOn(String string, int length, char c, StringBuffer sb) {
- int stringLength = string.length();
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string.substring(0, length));
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOrTruncateOn(int, char, StringBuilder)
- */
- public static void padOrTruncateOn(String string, int length, char c, StringBuilder sb) {
- int stringLength = string.length();
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string.substring(0, length));
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOrTruncate(int)
- */
- public static char[] padOrTruncate(char[] string, int length) {
- return padOrTruncate(string, length, ' ');
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOrTruncateOn(int, Writer)
- */
- public static void padOrTruncateOn(char[] string, int length, Writer writer) {
- padOrTruncateOn(string, length, ' ', writer);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOrTruncateOn(int, StringBuffer)
- */
- public static void padOrTruncate(char[] string, int length, StringBuffer sb) {
- padOrTruncateOn(string, length, ' ', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * String#padOrTruncateOn(int, StringBuilder)
- */
- public static void padOrTruncate(char[] string, int length, StringBuilder sb) {
- padOrTruncateOn(string, length, ' ', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOrTruncate(int, char)
- */
- public static char[] padOrTruncate(char[] string, int length, char c) {
- int stringLength = string.length;
- if (stringLength == length) {
- return string;
- }
- if (stringLength > length) {
- char[] result = new char[length];
- System.arraycopy(string, 0, result, 0, length);
- return result;
- }
- return pad_(string, length, c);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOrTruncateOn(int, char, Writer)
- */
- public static void padOrTruncateOn(char[] string, int length, char c, Writer writer) {
- int stringLength = string.length;
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else if (stringLength > length) {
- writeStringOn(string, 0, length, writer);
- } else {
- padOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOrTruncateOn(int, char, StringBuffer)
- */
- public static void padOrTruncateOn(char[] string, int length, char c, StringBuffer sb) {
- int stringLength = string.length;
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string, 0, length);
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * String#padOrTruncateOn(int, char, StringBuilder)
- */
- public static void padOrTruncateOn(char[] string, int length, char c, StringBuilder sb) {
- int stringLength = string.length;
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string, 0, length);
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static String pad_(String string, int length, char c) {
- return new String(pad_(string.toCharArray(), length, c));
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void padOn_(String string, int length, char c, Writer writer) {
- writeStringOn(string, writer);
- fill_(string, length, c, writer);
- }
-
- /*
- * Add enough characters to the specified writer to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(String string, int length, char c, Writer writer) {
- fill_(string.length(), length, c, writer);
- }
-
- /*
- * Add enough characters to the specified writer to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(char[] string, int length, char c, Writer writer) {
- fill_(string.length, length, c, writer);
- }
-
- /*
- * Add enough characters to the specified writer to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(int stringLength, int length, char c, Writer writer) {
- writeStringOn(CollectionTools.fill(new char[length - stringLength], c), writer);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void padOn_(String string, int length, char c, StringBuffer sb) {
- sb.append(string);
- fill_(string, length, c, sb);
- }
-
- /*
- * Add enough characters to the specified string buffer to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(String string, int length, char c, StringBuffer sb) {
- fill_(string.length(), length, c, sb);
- }
-
- /*
- * Add enough characters to the specified string buffer to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(char[] string, int length, char c, StringBuffer sb) {
- fill_(string.length, length, c, sb);
- }
-
- /*
- * Add enough characters to the specified string buffer to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(int stringLength, int length, char c, StringBuffer sb) {
- sb.append(CollectionTools.fill(new char[length - stringLength], c));
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void padOn_(String string, int length, char c, StringBuilder sb) {
- sb.append(string);
- fill_(string, length, c, sb);
- }
-
- /*
- * Add enough characters to the specified string builder to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(String string, int length, char c, StringBuilder sb) {
- fill_(string.length(), length, c, sb);
- }
-
- /*
- * Add enough characters to the specified string builder to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(char[] string, int length, char c, StringBuilder sb) {
- fill_(string.length, length, c, sb);
- }
-
- /*
- * Add enough characters to the specified string builder to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(int stringLength, int length, char c, StringBuilder sb) {
- sb.append(CollectionTools.fill(new char[length - stringLength], c));
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static char[] pad_(char[] string, int length, char c) {
- char[] result = new char[length];
- int stringLength = string.length;
- System.arraycopy(string, 0, result, 0, stringLength);
- Arrays.fill(result, stringLength, length, c);
- return result;
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void padOn_(char[] string, int length, char c, Writer writer) {
- writeStringOn(string, writer);
- fill_(string, length, c, writer);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void padOn_(char[] string, int length, char c, StringBuffer sb) {
- sb.append(string);
- fill_(string, length, c, sb);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void padOn_(char[] string, int length, char c, StringBuilder sb) {
- sb.append(string);
- fill_(string, length, c, sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPad(int)
- */
- public static String zeroPad(String string, int length) {
- return frontPad(string, length, '0');
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOn(int, Writer)
- */
- public static void zeroPadOn(String string, int length, Writer writer) {
- frontPadOn(string, length, '0', writer);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOn(int, StringBuffer)
- */
- public static void zeroPadOn(String string, int length, StringBuffer sb) {
- frontPadOn(string, length, '0', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOn(int, StringBuilder)
- */
- public static void zeroPadOn(String string, int length, StringBuilder sb) {
- frontPadOn(string, length, '0', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPad(int, char)
- */
- public static String frontPad(String string, int length, char c) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- return string;
- }
- return frontPad_(string, length, c);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOn(int, char, Writer)
- */
- public static void frontPadOn(String string, int length, char c, Writer writer) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else {
- frontPadOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOn(int, char, StringBuffer)
- */
- public static void frontPadOn(String string, int length, char c, StringBuffer sb) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOn(int, char, StringBuilder)
- */
- public static void frontPadOn(String string, int length, char c, StringBuilder sb) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPad(int)
- */
- public static char[] zeroPad(char[] string, int length) {
- return frontPad(string, length, '0');
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOn(int, Writer)
- */
- public static void zeroPadOn(char[] string, int length, Writer writer) {
- frontPadOn(string, length, '0', writer);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOn(int, StringBuffer)
- */
- public static void zeroPadOn(char[] string, int length, StringBuffer sb) {
- frontPadOn(string, length, '0', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOn(int, StringBuilder)
- */
- public static void zeroPadOn(char[] string, int length, StringBuilder sb) {
- frontPadOn(string, length, '0', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPad(int, char)
- */
- public static char[] frontPad(char[] string, int length, char c) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- return string;
- }
- return frontPad_(string, length, c);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOn(int, char, Writer)
- */
- public static void frontPadOn(char[] string, int length, char c, Writer writer) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else {
- frontPadOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOn(int, char, StringBuffer)
- */
- public static void frontPadOn(char[] string, int length, char c, StringBuffer sb) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOn(int, char, StringBuilder)
- */
- public static void frontPadOn(char[] string, int length, char c, StringBuilder sb) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length);
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOrTruncate(int)
- */
- public static String zeroPadOrTruncate(String string, int length) {
- return frontPadOrTruncate(string, length, '0');
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOrTruncateOn(int, Writer)
- */
- public static void zeroPadOrTruncateOn(String string, int length, Writer writer) {
- frontPadOrTruncateOn(string, length, '0', writer);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOrTruncateOn(int, StringBuffer)
- */
- public static void zeroPadOrTruncateOn(String string, int length, StringBuffer sb) {
- frontPadOrTruncateOn(string, length, '0', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOrTruncateOn(int, StringBuilder)
- */
- public static void zeroPadOrTruncateOn(String string, int length, StringBuilder sb) {
- frontPadOrTruncateOn(string, length, '0', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOrTruncate(int, char)
- */
- public static String frontPadOrTruncate(String string, int length, char c) {
- int stringLength = string.length();
- if (stringLength == length) {
- return string;
- }
- if (stringLength > length) {
- return string.substring(stringLength - length);
- }
- return frontPad_(string, length, c);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOrTruncateOn(int, char, Writer)
- */
- public static void frontPadOrTruncateOn(String string, int length, char c, Writer writer) {
- int stringLength = string.length();
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else if (stringLength > length) {
- writeStringOn(string.substring(stringLength - length), writer);
- } else {
- frontPadOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOrTruncateOn(int, char, StringBuffer)
- */
- public static void frontPadOrTruncateOn(String string, int length, char c, StringBuffer sb) {
- int stringLength = string.length();
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string.substring(stringLength - length));
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOrTruncateOn(int, char, StringBuilder)
- */
- public static void frontPadOrTruncateOn(String string, int length, char c, StringBuilder sb) {
- int stringLength = string.length();
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string.substring(stringLength - length));
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOrTruncate(int)
- */
- public static char[] zeroPadOrTruncate(char[] string, int length) {
- return frontPadOrTruncate(string, length, '0');
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOrTruncateOn(int, Writer)
- */
- public static void zeroPadOrTruncateOn(char[] string, int length, Writer writer) {
- frontPadOrTruncateOn(string, length, '0', writer);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOrTruncateOn(int, StringBuffer)
- */
- public static void zeroPadOrTruncateOn(char[] string, int length, StringBuffer sb) {
- frontPadOrTruncateOn(string, length, '0', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * String#zeroPadOrTruncateOn(int, StringBuilder)
- */
- public static void zeroPadOrTruncateOn(char[] string, int length, StringBuilder sb) {
- frontPadOrTruncateOn(string, length, '0', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOrTruncate(int, char)
- */
- public static char[] frontPadOrTruncate(char[] string, int length, char c) {
- int stringLength = string.length;
- if (stringLength == length) {
- return string;
- }
- if (stringLength > length) {
- char[] result = new char[length];
- System.arraycopy(string, stringLength - length, result, 0, length);
- return result;
- }
- return frontPad_(string, length, c);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOrTruncateOn(int, char, Writer)
- */
- public static void frontPadOrTruncateOn(char[] string, int length, char c, Writer writer) {
- int stringLength = string.length;
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else if (stringLength > length) {
- writeStringOn(string, stringLength - length, length, writer);
- } else {
- frontPadOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOrTruncateOn(int, char, StringBuffer)
- */
- public static void frontPadOrTruncateOn(char[] string, int length, char c, StringBuffer sb) {
- int stringLength = string.length;
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string, stringLength - length, length);
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * String#frontPadOrTruncateOn(int, char, StringBuilder)
- */
- public static void frontPadOrTruncateOn(char[] string, int length, char c, StringBuilder sb) {
- int stringLength = string.length;
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string, stringLength - length, length);
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /*
- * Front-pad the specified string without validating the parms.
- */
- private static String frontPad_(String string, int length, char c) {
- return new String(frontPad_(string.toCharArray(), length, c));
- }
-
- /*
- * Zero-pad the specified string without validating the parms.
- */
- private static char[] frontPad_(char[] string, int length, char c) {
- char[] result = new char[length];
- int stringLength = string.length;
- int padLength = length - stringLength;
- System.arraycopy(string, 0, result, padLength, stringLength);
- Arrays.fill(result, 0, padLength, c);
- return result;
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void frontPadOn_(String string, int length, char c, Writer writer) {
- fill_(string, length, c, writer);
- writeStringOn(string, writer);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void frontPadOn_(char[] string, int length, char c, Writer writer) {
- fill_(string, length, c, writer);
- writeStringOn(string, writer);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void frontPadOn_(String string, int length, char c, StringBuffer sb) {
- fill_(string, length, c, sb);
- sb.append(string);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void frontPadOn_(char[] string, int length, char c, StringBuffer sb) {
- fill_(string, length, c, sb);
- sb.append(string);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void frontPadOn_(String string, int length, char c, StringBuilder sb) {
- fill_(string, length, c, sb);
- sb.append(string);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void frontPadOn_(char[] string, int length, char c, StringBuilder sb) {
- fill_(string, length, c, sb);
- sb.append(string);
- }
-
-
- // ********** wrapping/quoting **********
-
- /**
- * Wrap the specified string with double quotes.
- */
- public static String quote(String string) {
- return wrap(string, QUOTE);
- }
-
- /**
- * Wrap the specified string with double quotes.
- */
- public static void quoteOn(String string, Writer writer) {
- wrapOn(string, QUOTE, writer);
- }
-
- /**
- * Wrap the specified string with double quotes.
- */
- public static void quoteOn(String string, StringBuffer sb) {
- wrapOn(string, QUOTE, sb);
- }
-
- /**
- * Wrap the specified string with double quotes.
- */
- public static void quoteOn(String string, StringBuilder sb) {
- wrapOn(string, QUOTE, sb);
- }
-
- /**
- * Wrap each of the specified strings with double quotes.
- */
- public static Iterator<String> quote(Iterator<String> strings) {
- return new TransformationIterator<String, String>(strings) {
- @Override
- protected String transform(String string) {
- return StringTools.quote(string);
- }
- };
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static String wrap(String string, char wrap) {
- return new String(wrap(string.toCharArray(), wrap));
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static void wrapOn(String string, char wrap, Writer writer) {
- writeCharOn(wrap, writer);
- writeStringOn(string, writer);
- writeCharOn(wrap, writer);
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static void wrapOn(String string, char wrap, StringBuffer sb) {
- sb.append(wrap);
- sb.append(string);
- sb.append(wrap);
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static void wrapOn(String string, char wrap, StringBuilder sb) {
- sb.append(wrap);
- sb.append(string);
- sb.append(wrap);
- }
-
- /**
- * Wrap each of the specified strings with the specified wrap; i.e. put a
- * copy of the wrap at the front and back of the resulting string.
- */
- public static Iterator<String> wrap(Iterator<String> strings, final char wrap) {
- return new TransformationIterator<String, String>(strings) {
- @Override
- protected String transform(String string) {
- return StringTools.wrap(string, wrap);
- }
- };
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static String wrap(String string, String wrap) {
- return new String(wrap(string.toCharArray(), wrap.toCharArray()));
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static void wrapOn(String string, String wrap, Writer writer) {
- writeStringOn(wrap, writer);
- writeStringOn(string, writer);
- writeStringOn(wrap, writer);
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static void wrapOn(String string, String wrap, StringBuffer sb) {
- sb.append(wrap);
- sb.append(string);
- sb.append(wrap);
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static void wrapOn(String string, String wrap, StringBuilder sb) {
- sb.append(wrap);
- sb.append(string);
- sb.append(wrap);
- }
-
- /**
- * Wrap each of the specified strings with the specified wrap; i.e. put a
- * copy of the wrap at the front and back of the resulting string.
- */
- public static Iterator<String> wrap(Iterator<String> strings, final String wrap) {
- return new TransformationIterator<String, String>(strings) {
- @Override
- protected String transform(String string) {
- return StringTools.wrap(string, wrap);
- }
- };
- }
-
- /**
- * Wrap the specified string with double quotes.
- */
- public static char[] quote(char[] string) {
- return wrap(string, QUOTE);
- }
-
- /**
- * Wrap the specified string with double quotes.
- */
- public static void quoteOn(char[] string, Writer writer) {
- wrapOn(string, QUOTE, writer);
- }
-
- /**
- * Wrap the specified string with double quotes.
- */
- public static void quoteOn(char[] string, StringBuffer sb) {
- wrapOn(string, QUOTE, sb);
- }
-
- /**
- * Wrap the specified string with double quotes.
- */
- public static void quoteOn(char[] string, StringBuilder sb) {
- wrapOn(string, QUOTE, sb);
- }
-
- /**
- * Wrap each of the specified strings with double quotes.
- */
- public static Iterator<char[]> quoteCharArrays(Iterator<char[]> strings) {
- return new TransformationIterator<char[], char[]>(strings) {
- @Override
- protected char[] transform(char[] string) {
- return StringTools.quote(string);
- }
- };
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static char[] wrap(char[] string, char wrap) {
- int len = string.length;
- char[] result = new char[len+2];
- result[0] = wrap;
- System.arraycopy(string, 0, result, 1, len);
- result[len+1] = wrap;
- return result;
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static void wrapOn(char[] string, char wrap, Writer writer) {
- writeCharOn(wrap, writer);
- writeStringOn(string, writer);
- writeCharOn(wrap, writer);
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static void wrapOn(char[] string, char wrap, StringBuffer sb) {
- sb.append(wrap);
- sb.append(string);
- sb.append(wrap);
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static void wrapOn(char[] string, char wrap, StringBuilder sb) {
- sb.append(wrap);
- sb.append(string);
- sb.append(wrap);
- }
-
- /**
- * Wrap each of the specified strings with the specified wrap; i.e. put a
- * copy of the wrap at the front and back of the resulting string.
- */
- public static Iterator<char[]> wrapCharArrays(Iterator<char[]> strings, final char wrap) {
- return new TransformationIterator<char[], char[]>(strings) {
- @Override
- protected char[] transform(char[] string) {
- return StringTools.wrap(string, wrap);
- }
- };
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static char[] wrap(char[] string, char[] wrap) {
- int stringLength = string.length;
- int wrapLength = wrap.length;
- char[] result = new char[stringLength+(2*wrapLength)];
- System.arraycopy(wrap, 0, result, 0, wrapLength);
- System.arraycopy(string, 0, result, wrapLength, stringLength);
- System.arraycopy(wrap, 0, result, stringLength+wrapLength, wrapLength);
- return result;
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static void wrapOn(char[] string, char[] wrap, Writer writer) {
- writeStringOn(wrap, writer);
- writeStringOn(string, writer);
- writeStringOn(wrap, writer);
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static void wrapOn(char[] string, char[] wrap, StringBuffer sb) {
- sb.append(wrap);
- sb.append(string);
- sb.append(wrap);
- }
-
- /**
- * Wrap the specified string with the specified wrap; i.e. put a copy of
- * the wrap at the front and back of the resulting string.
- */
- public static void wrapOn(char[] string, char[] wrap, StringBuilder sb) {
- sb.append(wrap);
- sb.append(string);
- sb.append(wrap);
- }
-
- /**
- * Wrap each of the specified strings with the specified wrap; i.e. put a
- * copy of the wrap at the front and back of the resulting string.
- */
- public static Iterator<char[]> wrapCharArrays(Iterator<char[]> strings, final char[] wrap) {
- return new TransformationIterator<char[], char[]>(strings) {
- @Override
- protected char[] transform(char[] string) {
- return StringTools.wrap(string, wrap);
- }
- };
- }
-
-
- // ********** removing characters **********
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and return the result.
- * String#removeFirstOccurrence(char)
- */
- public static String removeFirstOccurrence(String string, char c) {
- int index = string.indexOf(c);
- if (index == -1) {
- // character not found
- return string;
- }
- if (index == 0) {
- // character found at the front of string
- return string.substring(1);
- }
- int last = string.length() - 1;
- if (index == last) {
- // character found at the end of string
- return string.substring(0, last);
- }
- // character found somewhere in the middle of the string
- return string.substring(0, index).concat(string.substring(index + 1));
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and print the result on the specified stream.
- * String#removeFirstOccurrenceOn(char, Writer)
- */
- public static void removeFirstOccurrenceOn(String string, char c, Writer writer) {
- int index = string.indexOf(c);
- if (index == -1) {
- writeStringOn(string, writer);
- } else {
- removeFirstOccurrenceOn_(string.toCharArray(), c, writer, index);
- }
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and print the result on the specified stream.
- * String#removeFirstOccurrenceOn(char, StringBuffer)
- */
- public static void removeFirstOccurrenceOn(String string, char c, StringBuffer sb) {
- int index = string.indexOf(c);
- if (index == -1) {
- sb.append(string);
- } else {
- removeFirstOccurrenceOn_(string.toCharArray(), c, sb, index);
- }
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and print the result on the specified stream.
- * String#removeFirstOccurrenceOn(char, StringBuilder)
- */
- public static void removeFirstOccurrenceOn(String string, char c, StringBuilder sb) {
- int index = string.indexOf(c);
- if (index == -1) {
- sb.append(string);
- } else {
- removeFirstOccurrenceOn_(string.toCharArray(), c, sb, index);
- }
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and return the result.
- * String#removeFirstOccurrence(char)
- */
- public static char[] removeFirstOccurrence(char[] string, char c) {
- int index = CollectionTools.indexOf(string, c);
- if (index == -1) {
- // character not found
- return string;
- }
- int last = string.length - 1;
- char[] result = new char[last];
- if (index == 0) {
- // character found at the front of string
- System.arraycopy(string, 1, result, 0, last);
- } else if (index == last) {
- // character found at the end of string
- System.arraycopy(string, 0, result, 0, last);
- } else {
- // character found somewhere in the middle of the string
- System.arraycopy(string, 0, result, 0, index);
- System.arraycopy(string, index + 1, result, index, last - index);
- }
- return result;
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and print the result on the specified stream.
- * String#removeFirstOccurrenceOn(char, Writer)
- */
- public static void removeFirstOccurrenceOn(char[] string, char c, Writer writer) {
- int index = CollectionTools.indexOf(string, c);
- if (index == -1) {
- writeStringOn(string, writer);
- } else {
- removeFirstOccurrenceOn_(string, c, writer, index);
- }
- }
-
- private static void removeFirstOccurrenceOn_(char[] string, char c, Writer writer, int index) {
- int last = string.length - 1;
- if (index == 0) {
- // character found at the front of string
- writeStringOn(string, 1, last, writer);
- } else if (index == last) {
- // character found at the end of string
- writeStringOn(string, 0, last, writer);
- } else {
- // character found somewhere in the middle of the string
- writeStringOn(string, 0, index, writer);
- writeStringOn(string, index + 1, last - index, writer);
- }
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and print the result on the specified stream.
- * String#removeFirstOccurrenceOn(char, StringBuffer)
- */
- public static void removeFirstOccurrenceOn(char[] string, char c, StringBuffer sb) {
- int index = CollectionTools.indexOf(string, c);
- if (index == -1) {
- sb.append(string);
- } else {
- removeFirstOccurrenceOn_(string, c, sb, index);
- }
- }
-
- private static void removeFirstOccurrenceOn_(char[] string, char c, StringBuffer sb, int index) {
- int last = string.length - 1;
- if (index == 0) {
- // character found at the front of string
- sb.append(string, 1, last);
- } else if (index == last) {
- // character found at the end of string
- sb.append(string, 0, last);
- } else {
- // character found somewhere in the middle of the string
- sb.append(string, 0, index);
- sb.append(string, index + 1, last - index);
- }
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and print the result on the specified stream.
- * String#removeFirstOccurrenceOn(char, StringBuilder)
- */
- public static void removeFirstOccurrenceOn(char[] string, char c, StringBuilder sb) {
- int index = CollectionTools.indexOf(string, c);
- if (index == -1) {
- sb.append(string);
- } else {
- removeFirstOccurrenceOn_(string, c, sb, index);
- }
- }
-
- private static void removeFirstOccurrenceOn_(char[] string, char c, StringBuilder sb, int index) {
- int last = string.length - 1;
- if (index == 0) {
- // character found at the front of string
- sb.append(string, 1, last);
- } else if (index == last) {
- // character found at the end of string
- sb.append(string, 0, last);
- } else {
- // character found somewhere in the middle of the string
- sb.append(string, 0, index);
- sb.append(string, index + 1, last - index);
- }
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and return the result.
- * String#removeAllOccurrences(char)
- */
- public static String removeAllOccurrences(String string, char c) {
- int first = string.indexOf(c);
- return (first == -1) ? string : new String(removeAllOccurrences_(string.toCharArray(), c, first));
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and write the result to the specified stream.
- * String#removeAllOccurrencesOn(char, Writer)
- */
- public static void removeAllOccurrencesOn(String string, char c, Writer writer) {
- int first = string.indexOf(c);
- if (first == -1) {
- writeStringOn(string, writer);
- } else {
- removeAllOccurrencesOn_(string.toCharArray(), c, first, writer);
- }
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and write the result to the specified stream.
- * String#removeAllOccurrencesOn(char, StringBuffer)
- */
- public static void removeAllOccurrencesOn(String string, char c, StringBuffer sb) {
- int first = string.indexOf(c);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllOccurrencesOn_(string.toCharArray(), c, first, sb);
- }
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and write the result to the specified stream.
- * String#removeAllOccurrencesOn(char, StringBuilder)
- */
- public static void removeAllOccurrencesOn(String string, char c, StringBuilder sb) {
- int first = string.indexOf(c);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllOccurrencesOn_(string.toCharArray(), c, first, sb);
- }
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and return the result.
- * String#removeAllOccurrences(char)
- */
- public static char[] removeAllOccurrences(char[] string, char c) {
- int first = CollectionTools.indexOf(string, c);
- return (first == -1) ? string : removeAllOccurrences_(string, c, first);
- }
-
- /*
- * The index of the first matching character is passed in.
- */
- private static char[] removeAllOccurrences_(char[] string, char c, int first) {
- StringBuilder sb = new StringBuilder(string.length);
- removeAllOccurrencesOn_(string, c, first, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and write the result to the
- * specified writer.
- * String#removeAllOccurrencesOn(char, Writer)
- */
- public static void removeAllOccurrencesOn(char[] string, char c, Writer writer) {
- int first = CollectionTools.indexOf(string, c);
- if (first == -1) {
- writeStringOn(string, writer);
- } else {
- removeAllOccurrencesOn_(string, c, first, writer);
- }
- }
-
- /*
- * The index of the first matching character is passed in.
- */
- private static void removeAllOccurrencesOn_(char[] string, char c, int first, Writer writer) {
- writeStringOn(string, 0, first, writer);
- int len = string.length;
- for (int i = first; i < len; i++) {
- char d = string[i];
- if (d != c) {
- writeCharOn(d, writer);
- }
- }
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and append the result to the
- * specified string buffer.
- * String#removeAllOccurrencesOn(char, StringBuffer)
- */
- public static void removeAllOccurrencesOn(char[] string, char c, StringBuffer sb) {
- int first = CollectionTools.indexOf(string, c);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllOccurrencesOn_(string, c, first, sb);
- }
- }
-
- /*
- * The index of the first matching character is passed in.
- */
- private static void removeAllOccurrencesOn_(char[] string, char c, int first, StringBuffer sb) {
- sb.append(string, 0, first);
- int len = string.length;
- for (int i = first; i < len; i++) {
- char d = string[i];
- if (d != c) {
- sb.append(d);
- }
- }
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and append the result to the
- * specified string builder.
- * String#removeAllOccurrencesOn(char, StringBuilder)
- */
- public static void removeAllOccurrencesOn(char[] string, char c, StringBuilder sb) {
- int first = CollectionTools.indexOf(string, c);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllOccurrencesOn_(string, c, first, sb);
- }
- }
-
- /*
- * The index of the first matching character is passed in.
- */
- private static void removeAllOccurrencesOn_(char[] string, char c, int first, StringBuilder sb) {
- sb.append(string, 0, first);
- int len = string.length;
- for (int i = first; i < len; i++) {
- char d = string[i];
- if (d != c) {
- sb.append(d);
- }
- }
- }
-
- /**
- * Remove all the spaces from the specified string and return the result.
- * String#removeAllSpaces()
- */
- public static String removeAllSpaces(String string) {
- return removeAllOccurrences(string, ' ');
- }
-
- /**
- * Remove all the spaces
- * from the specified string and write the result to the specified writer.
- * String#removeAllSpacesOn(Writer)
- */
- public static void removeAllSpacesOn(String string, Writer writer) {
- removeAllOccurrencesOn(string, ' ', writer);
- }
-
- /**
- * Remove all the spaces
- * from the specified string and write the result to the specified
- * string buffer.
- * String#removeAllSpacesOn(StringBuffer)
- */
- public static void removeAllSpacesOn(String string, StringBuffer sb) {
- removeAllOccurrencesOn(string, ' ', sb);
- }
-
- /**
- * Remove all the spaces
- * from the specified string and write the result to the specified
- * string builder.
- * String#removeAllSpacesOn(StringBuilder)
- */
- public static void removeAllSpacesOn(String string, StringBuilder sb) {
- removeAllOccurrencesOn(string, ' ', sb);
- }
-
- /**
- * Remove all the spaces from the specified string and return the result.
- * String#removeAllSpaces()
- */
- public static char[] removeAllSpaces(char[] string) {
- return removeAllOccurrences(string, ' ');
- }
-
- /**
- * Remove all the spaces
- * from the specified string and write the result to the
- * specified writer.
- * String#removeAllSpacesOn(Writer)
- */
- public static void removeAllSpacesOn(char[] string, Writer writer) {
- removeAllOccurrencesOn(string, ' ', writer);
- }
-
- /**
- * Remove all the spaces
- * from the specified string and append the result to the
- * specified string buffer.
- * String#removeAllSpacesOn(StringBuffer)
- */
- public static void removeAllSpacesOn(char[] string, StringBuffer sb) {
- removeAllOccurrencesOn(string, ' ', sb);
- }
-
- /**
- * Remove all the spaces
- * from the specified string and append the result to the
- * specified string builder.
- * String#removeAllSpacesOn(StringBuilder)
- */
- public static void removeAllSpacesOn(char[] string, StringBuilder sb) {
- removeAllOccurrencesOn(string, ' ', sb);
- }
-
- /**
- * Remove all the whitespace from the specified string and return the result.
- * String#removeAllWhitespace()
- */
- public static String removeAllWhitespace(String string) {
- char[] string2 = string.toCharArray();
- int first = indexOfWhitespace_(string2);
- return (first == -1) ? string : new String(removeAllWhitespace_(string2, first));
- }
-
- /**
- * Remove all the whitespace
- * from the specified string and append the result to the
- * specified writer.
- * String#removeAllWhitespaceOn(Writer)
- */
- public static void removeAllWhitespaceOn(String string, Writer writer) {
- char[] string2 = string.toCharArray();
- int first = indexOfWhitespace_(string2);
- if (first == -1) {
- writeStringOn(string, writer);
- } else {
- removeAllWhitespaceOn_(string2, first, writer);
- }
- }
-
- /**
- * Remove all the whitespace
- * from the specified string and append the result to the
- * specified string buffer.
- * String#removeAllWhitespaceOn(StringBuffer)
- */
- public static void removeAllWhitespaceOn(String string, StringBuffer sb) {
- char[] string2 = string.toCharArray();
- int first = indexOfWhitespace_(string2);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllWhitespaceOn_(string2, first, sb);
- }
- }
-
- /**
- * Remove all the whitespace
- * from the specified string and append the result to the
- * specified string builder.
- * String#removeAllWhitespaceOn(StringBuilder)
- */
- public static void removeAllWhitespaceOn(String string, StringBuilder sb) {
- char[] string2 = string.toCharArray();
- int first = indexOfWhitespace_(string2);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllWhitespaceOn_(string2, first, sb);
- }
- }
-
- /**
- * Remove all the whitespace from the specified string and return the result.
- * String#removeAllWhitespace()
- */
- public static char[] removeAllWhitespace(char[] string) {
- int first = indexOfWhitespace_(string);
- return (first == -1) ? string : removeAllWhitespace_(string, first);
- }
-
- private static int indexOfWhitespace_(char[] string) {
- int len = string.length;
- for (int i = 0; i < len; i++) {
- if (Character.isWhitespace(string[i])) {
- return i;
- }
- }
- return -1;
- }
-
- /*
- * The index of the first non-whitespace character is passed in.
- */
- private static char[] removeAllWhitespace_(char[] string, int first) {
- StringBuilder sb = new StringBuilder(string.length);
- removeAllWhitespaceOn_(string, first, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Remove all the whitespace
- * from the specified string and append the result to the
- * specified writer.
- * String#removeAllWhitespaceOn(Writer)
- */
- public static void removeAllWhitespaceOn(char[] string, Writer writer) {
- int first = indexOfWhitespace_(string);
- if (first == -1) {
- writeStringOn(string, writer);
- } else {
- removeAllWhitespaceOn_(string, first, writer);
- }
- }
-
- /*
- * The index of the first non-whitespace character is passed in.
- */
- private static void removeAllWhitespaceOn_(char[] string, int first, Writer writer) {
- writeStringOn(string, 0, first, writer);
- int len = string.length;
- for (int i = first; i < len; i++) {
- char c = string[i];
- if ( ! Character.isWhitespace(c)) {
- writeCharOn(c, writer);
- }
- }
- }
-
- /**
- * Remove all the whitespace
- * from the specified string and append the result to the
- * specified string buffer.
- * String#removeAllWhitespaceOn(StringBuffer)
- */
- public static void removeAllWhitespaceOn(char[] string, StringBuffer sb) {
- int first = indexOfWhitespace_(string);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllWhitespaceOn_(string, first, sb);
- }
- }
-
- /*
- * The index of the first non-whitespace character is passed in.
- */
- private static void removeAllWhitespaceOn_(char[] string, int first, StringBuffer sb) {
- sb.append(string, 0, first);
- int len = string.length;
- for (int i = first; i < len; i++) {
- char c = string[i];
- if ( ! Character.isWhitespace(c)) {
- sb.append(c);
- }
- }
- }
-
- /**
- * Remove all the whitespace
- * from the specified string and append the result to the
- * specified string builder.
- * String#removeAllWhitespaceOn(StringBuilder)
- */
- public static void removeAllWhitespaceOn(char[] string, StringBuilder sb) {
- int first = indexOfWhitespace_(string);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllWhitespaceOn_(string, first, sb);
- }
- }
-
- /*
- * The index of the first non-whitespace character is passed in.
- */
- private static void removeAllWhitespaceOn_(char[] string, int first, StringBuilder sb) {
- sb.append(string, 0, first);
- int len = string.length;
- for (int i = first; i < len; i++) {
- char c = string[i];
- if ( ! Character.isWhitespace(c)) {
- sb.append(c);
- }
- }
- }
-
-
- // ********** common prefix **********
-
- /**
- * Return the length of the common prefix shared by the specified strings.
- * String#commonPrefixLength(String)
- */
- public static int commonPrefixLength(String s1, String s2) {
- return commonPrefixLength(s1.toCharArray(), s2.toCharArray());
- }
-
- /**
- * Return the length of the common prefix shared by the specified strings.
- */
- public static int commonPrefixLength(char[] s1, char[] s2) {
- return commonPrefixLength_(s1, s2, Math.min(s1.length, s2.length));
- }
-
- /**
- * Return the length of the common prefix shared by the specified strings;
- * but limit the length to the specified maximum.
- * String#commonPrefixLength(String, int)
- */
- public static int commonPrefixLength(String s1, String s2, int max) {
- return commonPrefixLength(s1.toCharArray(), s2.toCharArray(), max);
- }
-
- /**
- * Return the length of the common prefix shared by the specified strings;
- * but limit the length to the specified maximum.
- */
- public static int commonPrefixLength(char[] s1, char[] s2, int max) {
- return commonPrefixLength_(s1, s2, Math.min(max, Math.min(s1.length, s2.length)));
- }
-
- /*
- * Return the length of the common prefix shared by the specified strings;
- * but limit the length to the specified maximum. Assume the specified
- * maximum is less than the lengths of the specified strings.
- */
- private static int commonPrefixLength_(char[] s1, char[] s2, int max) {
- for (int i = 0; i < max; i++) {
- if (s1[i] != s2[i]) {
- return i;
- }
- }
- return max; // all the characters up to 'max' are the same
- }
-
-
- // ********** capitalization **********
-
- /*
- * no zero-length check or lower case check
- */
- private static char[] capitalize_(char[] string) {
- string[0] = Character.toUpperCase(string[0]);
- return string;
- }
-
- /**
- * Modify and return the specified string with
- * its first letter capitalized.
- */
- public static char[] capitalize(char[] string) {
- if ((string.length == 0) || Character.isUpperCase(string[0])) {
- return string;
- }
- return capitalize_(string);
- }
-
- /**
- * Return the specified string with its first letter capitalized.
- * String#capitalize()
- */
- public static String capitalize(String string) {
- if ((string.length() == 0) || Character.isUpperCase(string.charAt(0))) {
- return string;
- }
- return new String(capitalize_(string.toCharArray()));
- }
-
- /*
- * no zero-length check or upper case check
- */
- private static void capitalizeOn_(char[] string, StringBuffer sb) {
- sb.append(Character.toUpperCase(string[0]));
- sb.append(string, 1, string.length - 1);
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter capitalized.
- */
- public static void capitalizeOn(char[] string, StringBuffer sb) {
- if (string.length == 0) {
- return;
- }
- if (Character.isUpperCase(string[0])) {
- sb.append(string);
- } else {
- capitalizeOn_(string, sb);
- }
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter capitalized.
- * String#capitalizeOn(StringBuffer)
- */
- public static void capitalizeOn(String string, StringBuffer sb) {
- if (string.length() == 0) {
- return;
- }
- if (Character.isUpperCase(string.charAt(0))) {
- sb.append(string);
- } else {
- capitalizeOn_(string.toCharArray(), sb);
- }
- }
-
- /*
- * no zero-length check or upper case check
- */
- private static void capitalizeOn_(char[] string, StringBuilder sb) {
- sb.append(Character.toUpperCase(string[0]));
- sb.append(string, 1, string.length - 1);
- }
-
- /**
- * Append the specified string to the specified string builder
- * with its first letter capitalized.
- */
- public static void capitalizeOn(char[] string, StringBuilder sb) {
- if (string.length == 0) {
- return;
- }
- if (Character.isUpperCase(string[0])) {
- sb.append(string);
- } else {
- capitalizeOn_(string, sb);
- }
- }
-
- /**
- * Append the specified string to the specified string builder
- * with its first letter capitalized.
- * String#capitalizeOn(StringBuffer)
- */
- public static void capitalizeOn(String string, StringBuilder sb) {
- if (string.length() == 0) {
- return;
- }
- if (Character.isUpperCase(string.charAt(0))) {
- sb.append(string);
- } else {
- capitalizeOn_(string.toCharArray(), sb);
- }
- }
-
- /*
- * no zero-length check or upper case check
- */
- private static void capitalizeOn_(char[] string, Writer writer) {
- writeCharOn(Character.toUpperCase(string[0]), writer);
- writeStringOn(string, 1, string.length - 1, writer);
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter capitalized.
- */
- public static void capitalizeOn(char[] string, Writer writer) {
- if (string.length == 0) {
- return;
- }
- if (Character.isUpperCase(string[0])) {
- writeStringOn(string, writer);
- } else {
- capitalizeOn_(string, writer);
- }
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter capitalized.
- * String#capitalizeOn(Writer)
- */
- public static void capitalizeOn(String string, Writer writer) {
- if (string.length() == 0) {
- return;
- }
- if (Character.isUpperCase(string.charAt(0))) {
- writeStringOn(string, writer);
- } else {
- capitalizeOn_(string.toCharArray(), writer);
- }
- }
-
- /*
- * no zero-length check or lower case check
- */
- private static char[] uncapitalize_(char[] string) {
- string[0] = Character.toLowerCase(string[0]);
- return string;
- }
-
- private static boolean stringNeedNotBeUncapitalized_(char[] string) {
- if (string.length == 0) {
- return true;
- }
- if (Character.isLowerCase(string[0])) {
- return true;
- }
- // if both the first and second characters are capitalized,
- // return the string unchanged
- if ((string.length > 1)
- && Character.isUpperCase(string[1])
- && Character.isUpperCase(string[0])){
- return true;
- }
- return false;
- }
-
- /**
- * Modify and return the specified string with its
- * first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- */
- public static char[] uncapitalize(char[] string) {
- if (stringNeedNotBeUncapitalized_(string)) {
- return string;
- }
- return uncapitalize_(string);
- }
-
- private static boolean stringNeedNotBeUncapitalized_(String string) {
- if (string.length() == 0) {
- return true;
- }
- if (Character.isLowerCase(string.charAt(0))) {
- return true;
- }
- // if both the first and second characters are capitalized,
- // return the string unchanged
- if ((string.length() > 1)
- && Character.isUpperCase(string.charAt(1))
- && Character.isUpperCase(string.charAt(0))){
- return true;
- }
- return false;
- }
-
- /**
- * Return the specified string with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- * String#uncapitalize()
- */
- public static String uncapitalize(String string) {
- if (stringNeedNotBeUncapitalized_(string)) {
- return string;
- }
- return new String(uncapitalize_(string.toCharArray()));
- }
-
- /*
- * no zero-length check or lower case check
- */
- private static void uncapitalizeOn_(char[] string, StringBuffer sb) {
- sb.append(Character.toLowerCase(string[0]));
- sb.append(string, 1, string.length - 1);
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- */
- public static void uncapitalizeOn(char[] string, StringBuffer sb) {
- if (stringNeedNotBeUncapitalized_(string)) {
- sb.append(string);
- } else {
- uncapitalizeOn_(string, sb);
- }
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- * String#uncapitalizeOn(StringBuffer)
- */
- public static void uncapitalizeOn(String string, StringBuffer sb) {
- if (stringNeedNotBeUncapitalized_(string)) {
- sb.append(string);
- } else {
- uncapitalizeOn_(string.toCharArray(), sb);
- }
- }
-
- /*
- * no zero-length check or lower case check
- */
- private static void uncapitalizeOn_(char[] string, StringBuilder sb) {
- sb.append(Character.toLowerCase(string[0]));
- sb.append(string, 1, string.length - 1);
- }
-
- /**
- * Append the specified string to the specified string builder
- * with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- */
- public static void uncapitalizeOn(char[] string, StringBuilder sb) {
- if (stringNeedNotBeUncapitalized_(string)) {
- sb.append(string);
- } else {
- uncapitalizeOn_(string, sb);
- }
- }
-
- /**
- * Append the specified string to the specified string builder
- * with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- * String#uncapitalizeOn(StringBuffer)
- */
- public static void uncapitalizeOn(String string, StringBuilder sb) {
- if (stringNeedNotBeUncapitalized_(string)) {
- sb.append(string);
- } else {
- uncapitalizeOn_(string.toCharArray(), sb);
- }
- }
-
- /*
- * no zero-length check or upper case check
- */
- private static void uncapitalizeOn_(char[] string, Writer writer) {
- writeCharOn(Character.toLowerCase(string[0]), writer);
- writeStringOn(string, 1, string.length - 1, writer);
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- */
- public static void uncapitalizeOn(char[] string, Writer writer) {
- if (stringNeedNotBeUncapitalized_(string)) {
- writeStringOn(string, writer);
- } else {
- uncapitalizeOn_(string, writer);
- }
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- * String#uncapitalizeOn(Writer)
- */
- public static void uncapitalizeOn(String string, Writer writer) {
- if (stringNeedNotBeUncapitalized_(string)) {
- writeStringOn(string, writer);
- } else {
- uncapitalizeOn_(string.toCharArray(), writer);
- }
- }
-
-
- // ********** #toString() helper methods **********
-
- /**
- * Build a "standard" #toString() result for the specified object
- * and additional information:
- * ClassName[00F3EE42] (add'l info)
- */
- public static String buildToStringFor(Object o, Object additionalInfo) {
- StringBuilder sb = new StringBuilder();
- buildSimpleToStringOn(o, sb);
- sb.append(" (");
- sb.append(additionalInfo);
- sb.append(')');
- return sb.toString();
- }
-
- /**
- * Build a "standard" simple #toString() result for the specified object:
- * ClassName[00F3EE42]
- */
- public static String buildToStringFor(Object o) {
- StringBuilder sb = new StringBuilder();
- buildSimpleToStringOn(o, sb);
- return sb.toString();
- }
-
- /**
- * Append a "standard" simple #toString() for the specified object to
- * the specified string buffer:
- * ClassName[00F3EE42]
- */
- public static void buildSimpleToStringOn(Object o, StringBuffer sb) {
- sb.append(ClassTools.toStringClassNameForObject(o));
- sb.append('[');
- // use System#identityHashCode(Object), since Object#hashCode() may be overridden
- sb.append(zeroPad(Integer.toHexString(System.identityHashCode(o)).toUpperCase(), 8));
- sb.append(']');
- }
-
- /**
- * Append a "standard" simple #toString() for the specified object to
- * the specified string builder:
- * ClassName[00F3EE42]
- */
- public static void buildSimpleToStringOn(Object o, StringBuilder sb) {
- sb.append(ClassTools.toStringClassNameForObject(o));
- sb.append('[');
- // use System#identityHashCode(Object), since Object#hashCode() may be overridden
- sb.append(zeroPad(Integer.toHexString(System.identityHashCode(o)).toUpperCase(), 8));
- sb.append(']');
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether the specified string is null, empty, or contains
- * only whitespace characters.
- */
- public static boolean stringIsEmpty(String string) {
- if ((string == null) || (string.length() == 0)) {
- return true;
- }
- return stringIsEmpty_(string.toCharArray());
- }
-
- /**
- * Return whether the specified string is null, empty, or contains
- * only whitespace characters.
- */
- public static boolean stringIsEmpty(char[] string) {
- if ((string == null) || (string.length == 0)) {
- return true;
- }
- return stringIsEmpty_(string);
- }
-
- private static boolean stringIsEmpty_(char[] s) {
- for (int i = s.length; i-- > 0; ) {
- if ( ! Character.isWhitespace(s[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified strings are equal, ignoring case.
- * Check for nulls.
- */
- public static boolean stringsAreEqualIgnoreCase(String s1, String s2) {
- if ((s1 == null) && (s2 == null)) {
- return true; // both are null
- }
- if ((s1 == null) || (s2 == null)) {
- return false; // one is null but the other is not
- }
- return s1.equalsIgnoreCase(s2);
- }
-
- /**
- * Return whether the specified strings are equal, ignoring case.
- * Check for nulls.
- */
- public static boolean stringsAreEqualIgnoreCase(char[] s1, char[] s2) {
- if ((s1 == null) && (s2 == null)) {
- return true; // both are null
- }
- if ((s1 == null) || (s2 == null)) {
- return false; // one is null but the other is not
- }
- if (s1.length != s2.length) {
- return false;
- }
- for (int i = s1.length; i-- > 0; ) {
- if ( ! charactersAreEqualIgnoreCase(s1[i], s2[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified string starts with the specified prefix,
- * ignoring case.
- */
- public static boolean stringStartsWithIgnoreCase(char[] string, char[] prefix) {
- if (string.length < prefix.length) {
- return false;
- }
- for (int i = prefix.length; i-- > 0; ) {
- if ( ! charactersAreEqualIgnoreCase(string[i], prefix[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified string starts with the specified prefix,
- * ignoring case.
- */
- public static boolean stringStartsWithIgnoreCase(String string, String prefix) {
- return string.regionMatches(true, 0, prefix, 0, prefix.length());
- }
-
- /**
- * Return whether the specified characters are are equal, ignoring case.
- * @see java.lang.String#regionMatches(boolean, int, String, int, int)
- */
- public static boolean charactersAreEqualIgnoreCase(char c1, char c2) {
- // something about the Georgian alphabet requires us to check lower case also
- return (c1 == c2)
- || (Character.toUpperCase(c1) == Character.toUpperCase(c2))
- || (Character.toLowerCase(c1) == Character.toLowerCase(c2));
- }
-
- // ********** conversions **********
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static String convertCamelCaseToAllCaps(String camelCaseString) {
- int len = camelCaseString.length();
- if (len == 0) {
- return camelCaseString;
- }
- return new String(convertCamelCaseToAllCaps_(camelCaseString.toCharArray(), len));
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static char[] convertCamelCaseToAllCaps(char[] camelCaseString) {
- int len = camelCaseString.length;
- if (len == 0) {
- return camelCaseString;
- }
- return convertCamelCaseToAllCaps_(camelCaseString, len);
- }
-
- private static char[] convertCamelCaseToAllCaps_(char[] camelCaseString, int len) {
- StringBuilder sb = new StringBuilder(len * 2);
- convertCamelCaseToAllCapsOn_(camelCaseString, len, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static void convertCamelCaseToAllCapsOn(String camelCaseString, StringBuffer sb) {
- int len = camelCaseString.length();
- if (len != 0) {
- convertCamelCaseToAllCapsOn_(camelCaseString.toCharArray(), len, sb);
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static void convertCamelCaseToAllCapsOn(char[] camelCaseString, StringBuffer sb) {
- int len = camelCaseString.length;
- if (len != 0) {
- convertCamelCaseToAllCapsOn_(camelCaseString, len, sb);
- }
- }
-
- private static void convertCamelCaseToAllCapsOn_(char[] camelCaseString, int len, StringBuffer sb) {
- char prev = 0; // assume 0 is not a valid char
- char c = 0;
- char next = camelCaseString[0];
- for (int i = 1; i <= len; i++) { // NB: start at 1 and end at len!
- c = next;
- next = ((i == len) ? 0 : camelCaseString[i]);
- if (camelCaseWordBreak_(prev, c, next)) {
- sb.append('_');
- }
- sb.append(Character.toUpperCase(c));
- prev = c;
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static void convertCamelCaseToAllCapsOn(String camelCaseString, StringBuilder sb) {
- int len = camelCaseString.length();
- if (len != 0) {
- convertCamelCaseToAllCapsOn_(camelCaseString.toCharArray(), len, sb);
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static void convertCamelCaseToAllCapsOn(char[] camelCaseString, StringBuilder sb) {
- int len = camelCaseString.length;
- if (len != 0) {
- convertCamelCaseToAllCapsOn_(camelCaseString, len, sb);
- }
- }
-
- private static void convertCamelCaseToAllCapsOn_(char[] camelCaseString, int len, StringBuilder sb) {
- char prev = 0; // assume 0 is not a valid char
- char c = 0;
- char next = camelCaseString[0];
- for (int i = 1; i <= len; i++) { // NB: start at 1 and end at len!
- c = next;
- next = ((i == len) ? 0 : camelCaseString[i]);
- if (camelCaseWordBreak_(prev, c, next)) {
- sb.append('_');
- }
- sb.append(Character.toUpperCase(c));
- prev = c;
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static void convertCamelCaseToAllCapsOn(String camelCaseString, Writer writer) {
- int len = camelCaseString.length();
- if (len != 0) {
- convertCamelCaseToAllCapsOn_(camelCaseString.toCharArray(), len, writer);
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static void convertCamelCaseToAllCapsOn(char[] camelCaseString, Writer writer) {
- int len = camelCaseString.length;
- if (len != 0) {
- convertCamelCaseToAllCapsOn_(camelCaseString, len, writer);
- }
- }
-
- private static void convertCamelCaseToAllCapsOn_(char[] camelCaseString, int len, Writer writer) {
- char prev = 0; // assume 0 is not a valid char
- char c = 0;
- char next = camelCaseString[0];
- for (int i = 1; i <= len; i++) { // NB: start at 1 and end at len!
- c = next;
- next = ((i == len) ? 0 : camelCaseString[i]);
- if (camelCaseWordBreak_(prev, c, next)) {
- writeCharOn('_', writer);
- }
- writeCharOn(Character.toUpperCase(c), writer);
- prev = c;
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static String convertCamelCaseToAllCaps(String camelCaseString, int maxLength) {
- int len = camelCaseString.length();
- if ((len == 0) || (maxLength == 0)) {
- return camelCaseString;
- }
- return new String(convertCamelCaseToAllCaps_(camelCaseString.toCharArray(), maxLength, len));
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static char[] convertCamelCaseToAllCaps(char[] camelCaseString, int maxLength) {
- int len = camelCaseString.length;
- if ((len == 0) || (maxLength == 0)) {
- return camelCaseString;
- }
- return convertCamelCaseToAllCaps_(camelCaseString, maxLength, len);
- }
-
- private static char[] convertCamelCaseToAllCaps_(char[] camelCaseString, int maxLength, int len) {
- StringBuilder sb = new StringBuilder(maxLength);
- convertCamelCaseToAllCapsOn_(camelCaseString, maxLength, len, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static void convertCamelCaseToAllCapsOn(String camelCaseString, int maxLength, StringBuffer sb) {
- int len = camelCaseString.length();
- if ((len != 0) && (maxLength != 0)) {
- convertCamelCaseToAllCapsOn_(camelCaseString.toCharArray(), maxLength, len, sb);
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static void convertCamelCaseToAllCapsOn(char[] camelCaseString, int maxLength, StringBuffer sb) {
- int len = camelCaseString.length;
- if ((len != 0) && (maxLength != 0)) {
- convertCamelCaseToAllCapsOn_(camelCaseString, maxLength, len, sb);
- }
- }
-
- private static void convertCamelCaseToAllCapsOn_(char[] camelCaseString, int maxLength, int len, StringBuffer sb) {
- char prev = 0; // assume 0 is not a valid char
- char c = 0;
- char next = camelCaseString[0];
- for (int i = 1; i <= len; i++) { // NB: start at 1 and end at len!
- c = next;
- next = ((i == len) ? 0 : camelCaseString[i]);
- if (camelCaseWordBreak_(prev, c, next)) {
- sb.append('_');
- if (sb.length() == maxLength) {
- return;
- }
- }
- sb.append(Character.toUpperCase(c));
- if (sb.length() == maxLength) {
- return;
- }
- prev = c;
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static void convertCamelCaseToAllCapsOn(String camelCaseString, int maxLength, StringBuilder sb) {
- int len = camelCaseString.length();
- if ((len != 0) && (maxLength != 0)) {
- convertCamelCaseToAllCapsOn_(camelCaseString.toCharArray(), maxLength, len, sb);
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static void convertCamelCaseToAllCapsOn(char[] camelCaseString, int maxLength, StringBuilder sb) {
- int len = camelCaseString.length;
- if ((len != 0) && (maxLength != 0)) {
- convertCamelCaseToAllCapsOn_(camelCaseString, maxLength, len, sb);
- }
- }
-
- private static void convertCamelCaseToAllCapsOn_(char[] camelCaseString, int maxLength, int len, StringBuilder sb) {
- char prev = 0; // assume 0 is not a valid char
- char c = 0;
- char next = camelCaseString[0];
- for (int i = 1; i <= len; i++) { // NB: start at 1 and end at len!
- c = next;
- next = ((i == len) ? 0 : camelCaseString[i]);
- if (camelCaseWordBreak_(prev, c, next)) {
- sb.append('_');
- if (sb.length() == maxLength) {
- return;
- }
- }
- sb.append(Character.toUpperCase(c));
- if (sb.length() == maxLength) {
- return;
- }
- prev = c;
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static void convertCamelCaseToAllCapsOn(String camelCaseString, int maxLength, Writer writer) {
- int len = camelCaseString.length();
- if ((len != 0) && (maxLength != 0)) {
- convertCamelCaseToAllCapsOn_(camelCaseString.toCharArray(), maxLength, len, writer);
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static void convertCamelCaseToAllCapsOn(char[] camelCaseString, int maxLength, Writer writer) {
- int len = camelCaseString.length;
- if ((len != 0) && (maxLength != 0)) {
- convertCamelCaseToAllCapsOn_(camelCaseString, maxLength, len, writer);
- }
- }
-
- private static void convertCamelCaseToAllCapsOn_(char[] camelCaseString, int maxLength, int len, Writer writer) {
- char prev = 0; // assume 0 is not a valid char
- char c = 0;
- char next = camelCaseString[0];
- int writerLength = 0;
- for (int i = 1; i <= len; i++) { // NB: start at 1 and end at len!
- c = next;
- next = ((i == len) ? 0 : camelCaseString[i]);
- if (camelCaseWordBreak_(prev, c, next)) {
- writeCharOn('_', writer);
- if (++writerLength == maxLength) {
- return;
- }
- }
- writeCharOn(Character.toUpperCase(c), writer);
- if (++writerLength == maxLength) {
- return;
- }
- prev = c;
- }
- }
-
- /*
- * Return whether the specified series of characters occur at
- * a "camel case" work break:
- * "*aa" -> false
- * "*AA" -> false
- * "*Aa" -> false
- * "AaA" -> false
- * "AAA" -> false
- * "aa*" -> false
- * "AaA" -> false
- * "aAa" -> true
- * "AA*" -> false
- * "AAa" -> true
- * where '*' == any char
- */
- private static boolean camelCaseWordBreak_(char prev, char c, char next) {
- if (prev == 0) { // start of string
- return false;
- }
- if (Character.isLowerCase(c)) {
- return false;
- }
- if (Character.isLowerCase(prev)) {
- return true;
- }
- if (next == 0) { // end of string
- return false;
- }
- return Character.isLowerCase(next);
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "LargeProject"
- * Capitalize the first letter.
- */
- public static String convertUnderscoresToCamelCase(String underscoreString) {
- return convertUnderscoresToCamelCase(underscoreString, true);
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "LargeProject"
- * Capitalize the first letter.
- */
- public static char[] convertUnderscoresToCamelCase(char[] underscoreString) {
- return convertUnderscoresToCamelCase(underscoreString, true);
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static String convertUnderscoresToCamelCase(String underscoreString, boolean capitalizeFirstLetter) {
- int len = underscoreString.length();
- if (len == 0) {
- return underscoreString;
- }
- return new String(convertUnderscoresToCamelCase_(underscoreString.toCharArray(), capitalizeFirstLetter, len));
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static char[] convertUnderscoresToCamelCase(char[] underscoreString, boolean capitalizeFirstLetter) {
- int len = underscoreString.length;
- if (len == 0) {
- return underscoreString;
- }
- return convertUnderscoresToCamelCase_(underscoreString, capitalizeFirstLetter, len);
- }
-
- private static char[] convertUnderscoresToCamelCase_(char[] underscoreString, boolean capitalizeFirstLetter, int len) {
- StringBuilder sb = new StringBuilder(len);
- convertUnderscoresToCamelCaseOn_(underscoreString, capitalizeFirstLetter, len, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static void convertUnderscoresToCamelCaseOn(String underscoreString, boolean capitalizeFirstLetter, StringBuffer sb) {
- int len = underscoreString.length();
- if (len != 0) {
- convertUnderscoresToCamelCaseOn_(underscoreString.toCharArray(), capitalizeFirstLetter, len, sb);
- }
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static void convertUnderscoresToCamelCaseOn(char[] underscoreString, boolean capitalizeFirstLetter, StringBuffer sb) {
- int len = underscoreString.length;
- if (len != 0) {
- convertUnderscoresToCamelCaseOn_(underscoreString, capitalizeFirstLetter, len, sb);
- }
- }
-
- private static void convertUnderscoresToCamelCaseOn_(char[] underscoreString, boolean capitalizeFirstLetter, int len, StringBuffer sb) {
- char prev = 0;
- char c = 0;
- boolean first = true;
- for (int i = 0; i < len; i++) {
- prev = c;
- c = underscoreString[i];
- if (c == '_') {
- continue;
- }
- if (first) {
- first = false;
- if (capitalizeFirstLetter) {
- sb.append(Character.toUpperCase(c));
- } else {
- sb.append(Character.toLowerCase(c));
- }
- } else {
- if (prev == '_') {
- sb.append(Character.toUpperCase(c));
- } else {
- sb.append(Character.toLowerCase(c));
- }
- }
- }
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static void convertUnderscoresToCamelCaseOn(String underscoreString, boolean capitalizeFirstLetter, StringBuilder sb) {
- int len = underscoreString.length();
- if (len != 0) {
- convertUnderscoresToCamelCaseOn_(underscoreString.toCharArray(), capitalizeFirstLetter, len, sb);
- }
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static void convertUnderscoresToCamelCaseOn(char[] underscoreString, boolean capitalizeFirstLetter, StringBuilder sb) {
- int len = underscoreString.length;
- if (len != 0) {
- convertUnderscoresToCamelCaseOn_(underscoreString, capitalizeFirstLetter, len, sb);
- }
- }
-
- private static void convertUnderscoresToCamelCaseOn_(char[] underscoreString, boolean capitalizeFirstLetter, int len, StringBuilder sb) {
- char prev = 0;
- char c = 0;
- boolean first = true;
- for (int i = 0; i < len; i++) {
- prev = c;
- c = underscoreString[i];
- if (c == '_') {
- continue;
- }
- if (first) {
- first = false;
- if (capitalizeFirstLetter) {
- sb.append(Character.toUpperCase(c));
- } else {
- sb.append(Character.toLowerCase(c));
- }
- } else {
- if (prev == '_') {
- sb.append(Character.toUpperCase(c));
- } else {
- sb.append(Character.toLowerCase(c));
- }
- }
- }
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static void convertUnderscoresToCamelCaseOn(String underscoreString, boolean capitalizeFirstLetter, Writer writer) {
- int len = underscoreString.length();
- if (len != 0) {
- convertUnderscoresToCamelCaseOn_(underscoreString.toCharArray(), capitalizeFirstLetter, len, writer);
- }
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static void convertUnderscoresToCamelCaseOn(char[] underscoreString, boolean capitalizeFirstLetter, Writer writer) {
- int len = underscoreString.length;
- if (len != 0) {
- convertUnderscoresToCamelCaseOn_(underscoreString, capitalizeFirstLetter, len, writer);
- }
- }
-
- private static void convertUnderscoresToCamelCaseOn_(char[] underscoreString, boolean capitalizeFirstLetter, int len, Writer writer) {
- char prev = 0;
- char c = 0;
- boolean first = true;
- for (int i = 0; i < len; i++) {
- prev = c;
- c = underscoreString[i];
- if (c == '_') {
- continue;
- }
- if (first) {
- first = false;
- if (capitalizeFirstLetter) {
- writeCharOn(Character.toUpperCase(c), writer);
- } else {
- writeCharOn(Character.toLowerCase(c), writer);
- }
- } else {
- if (prev == '_') {
- writeCharOn(Character.toUpperCase(c), writer);
- } else {
- writeCharOn(Character.toLowerCase(c), writer);
- }
- }
- }
- }
-
-
- // ********** convenience **********
-
- public static char[] convertToCharArray(StringBuffer sb) {
- int len = sb.length();
- char[] result = new char[len];
- sb.getChars(0, len, result, 0);
- return result;
- }
-
- public static char[] convertToCharArray(StringBuilder sb) {
- int len = sb.length();
- char[] result = new char[len];
- sb.getChars(0, len, result, 0);
- return result;
- }
-
- private static void writeStringOn(char[] string, Writer writer) {
- try {
- writer.write(string);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private static void writeStringOn(char[] string, int off, int len, Writer writer) {
- try {
- writer.write(string, off, len);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private static void writeStringOn(String string, Writer writer) {
- try {
- writer.write(string);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private static void writeCharOn(char c, Writer writer) {
- try {
- writer.write(c);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
-
- // ********** constructor **********
-
- /*
- * Suppress default constructor, ensuring non-instantiability.
- */
- private StringTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBoolean.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBoolean.java
deleted file mode 100644
index 92b6bc1f96..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBoolean.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-
-import org.eclipse.jpt.utility.Command;
-
-/**
- * This class provides synchronized access to a boolean value.
- * It also provides protocol for suspending a thread until the
- * boolean value is set to true or false, with optional time-outs.
- */
-public class SynchronizedBoolean
- implements Cloneable, Serializable
-{
- /** Backing boolean. */
- private boolean value;
-
- /** Object to synchronize on. */
- private final Object mutex;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Create a synchronized boolean with the specified initial value
- * and mutex.
- */
- public SynchronizedBoolean(boolean value, Object mutex) {
- super();
- this.value = value;
- this.mutex = mutex;
- }
-
- /**
- * Create a synchronized boolean with the specified initial value.
- */
- public SynchronizedBoolean(boolean value) {
- super();
- this.value = value;
- this.mutex = this;
- }
-
- /**
- * Create a synchronized boolean with an initial value of false
- * and specified mutex.
- */
- public SynchronizedBoolean(Object mutex) {
- this(false, mutex);
- }
-
- /**
- * Create a synchronized boolean with an initial value of false.
- */
- public SynchronizedBoolean() {
- this(false);
- }
-
-
- // ********** accessors **********
-
- /**
- * Return the current boolean value.
- */
- public boolean value() {
- synchronized (this.mutex) {
- return this.value;
- }
- }
-
- /**
- * Return whether the current boolean value is true.
- */
- public boolean isTrue() {
- synchronized (this.mutex) {
- return this.value;
- }
- }
-
- /**
- * Return whether the current boolean value is false.
- */
- public boolean isFalse() {
- synchronized (this.mutex) {
- return ! this.value;
- }
- }
-
- /**
- * Set the boolean value. If the value changes, all waiting
- * threads are notified.
- */
- public void setValue(boolean value) {
- synchronized (this.mutex) {
- if (this.value != value) {
- this.value = value;
- this.mutex.notifyAll();
- }
- }
- }
-
- /**
- * Set the boolean value to true. If the value changes, all waiting
- * threads are notified.
- */
- public void setTrue() {
- synchronized (this.mutex) {
- this.setValue(true);
- }
- }
-
- /**
- * Set the boolean value to false. If the value changes, all waiting
- * threads are notified.
- */
- public void setFalse() {
- synchronized (this.mutex) {
- this.setValue(false);
- }
- }
-
- /**
- * Return the object this object locks on while performing
- * its operations.
- */
- public Object mutex() {
- return this.mutex;
- }
-
-
- // ********** indefinite waits **********
-
- /**
- * Suspend the current thread until the boolean value changes
- * to the specified value. If the boolean value is already the
- * specified value, return immediately.
- */
- public void waitUntilValueIs(boolean v) throws InterruptedException {
- synchronized (this.mutex) {
- while (this.value != v) {
- this.mutex.wait();
- }
- }
- }
-
- /**
- * Suspend the current thread until the boolean value changes to true.
- * If the boolean value is already true, return immediately.
- */
- public void waitUntilTrue() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIs(true);
- }
- }
-
- /**
- * Suspend the current thread until the boolean value changes to false.
- * If the boolean value is already false, return immediately.
- */
- public void waitUntilFalse() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIs(false);
- }
- }
-
- /**
- * Suspend the current thread until the boolean value changes to
- * NOT the specified value, then change it back to the specified
- * value and continue executing. If the boolean value is already
- * NOT the specified value, set the value to the specified value
- * immediately.
- */
- public void waitToSetValue(boolean v) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIs( ! v);
- this.setValue(v);
- }
- }
-
- /**
- * Suspend the current thread until the boolean value changes to false,
- * then change it back to true and continue executing. If the boolean
- * value is already false, set the value to true immediately.
- */
- public void waitToSetTrue() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitToSetValue(true);
- }
- }
-
- /**
- * Suspend the current thread until the boolean value changes to true,
- * then change it back to false and continue executing. If the boolean
- * value is already true, set the value to false immediately.
- */
- public void waitToSetFalse() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitToSetValue(false);
- }
- }
-
-
- // ********** timed waits **********
-
- /**
- * Suspend the current thread until the boolean value changes
- * to the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
- * If the boolean value is already the specified value, return true
- * immediately.
- */
- public boolean waitUntilValueIs(boolean v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- if (timeout == 0L) {
- this.waitUntilValueIs(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value != v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value == v);
- }
- }
-
- /**
- * Suspend the current thread until the boolean value changes
- * to true or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
- * If the boolean value is already true, return true immediately.
- */
- public boolean waitUntilTrue(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilValueIs(true, timeout);
- }
- }
-
- /**
- * Suspend the current thread until the boolean value changes
- * to false or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
- * If the boolean value is already true, return true immediately.
- */
- public boolean waitUntilFalse(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilValueIs(false, timeout);
- }
- }
-
- /**
- * Suspend the current thread until the boolean value changes to NOT the
- * specified value, then change it back to the specified value and continue
- * executing. If the boolean value does not change to false before the
- * time-out, simply continue executing without changing the value.
- * The time-out is specified in milliseconds. Return true if the value was
- * set to the specified value; return false if a time-out occurred.
- * If the boolean value is already NOT the specified value, set the value
- * to the specified value immediately and return true.
- */
- public boolean waitToSetValue(boolean v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilValueIs( ! v, timeout);
- if (success) {
- this.setValue(v);
- }
- return success;
- }
- }
-
- /**
- * Suspend the current thread until the boolean value changes to false,
- * then change it back to true and continue executing. If the boolean
- * value does not change to false before the time-out, simply continue
- * executing without changing the value. The time-out is specified in
- * milliseconds. Return true if the value was set to true; return false
- * if a time-out occurred. If the boolean value is already false, set the
- * value to true immediately and return true.
- */
- public boolean waitToSetTrue(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitToSetValue(true, timeout);
- }
- }
-
- /**
- * Suspend the current thread until the boolean value changes to true,
- * then change it back to false and continue executing. If the boolean
- * value does not change to true before the time-out, simply continue
- * executing without changing the value. The time-out is specified in
- * milliseconds. Return true if the value was set to false; return false
- * if a time-out occurred. If the boolean value is already true, set the
- * value to false immediately and return true.
- */
- public boolean waitToSetFalse(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitToSetValue(false, timeout);
- }
- }
-
-
- // ********** synchronized behavior **********
-
- /**
- * If the current thread is not interrupted, execute the specified command
- * with the mutex locked. This is useful for initializing the value in another
- * thread.
- */
- public void execute(Command command) throws InterruptedException {
- if (Thread.interrupted()) {
- throw new InterruptedException();
- }
- synchronized (this.mutex) {
- command.execute();
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public Object clone() {
- try {
- synchronized (this.mutex) {
- return super.clone();
- }
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public boolean equals(Object o) {
- if (o instanceof SynchronizedBoolean) {
- return this.value() == ((SynchronizedBoolean) o).value();
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return this.value() ? 1 : 0;
- }
-
- @Override
- public String toString() {
- return String.valueOf(this.value());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedObject.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedObject.java
deleted file mode 100644
index bfb09c3c62..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedObject.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-
-import org.eclipse.jpt.utility.Command;
-
-/**
- * This class provides synchronized access to an object of type T.
- * It also provides protocol for suspending a thread until the
- * value is set to null or a non-null value, with optional time-outs.
- */
-public class SynchronizedObject<T>
- implements Cloneable, Serializable
-{
- /** Backing value. */
- private T value;
-
- /** Object to synchronize on. */
- private final Object mutex;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Create a synchronized object with the specified initial value
- * and mutex.
- */
- public SynchronizedObject(T value, Object mutex) {
- super();
- this.value = value;
- this.mutex = mutex;
- }
-
- /**
- * Create a synchronized object with the specified initial value.
- */
- public SynchronizedObject(T value) {
- super();
- this.value = value;
- this.mutex = this;
- }
-
- /**
- * Create a synchronized object with an initial value of null.
- */
- public SynchronizedObject() {
- this(null);
- }
-
-
- // ********** accessors **********
-
- /**
- * Return the current value.
- */
- public T value() {
- synchronized (this.mutex) {
- return this.value;
- }
- }
-
- /**
- * Return whether the current value is null.
- */
- public boolean isNull() {
- synchronized (this.mutex) {
- return this.value == null;
- }
- }
-
- /**
- * Return whether the current value is not null.
- */
- public boolean isNotNull() {
- synchronized (this.mutex) {
- return this.value != null;
- }
- }
-
- /**
- * Set the value. If the value changes, all waiting
- * threads are notified.
- */
- public void setValue(T value) {
- synchronized (this.mutex) {
- if (this.value != value) {
- this.value = value;
- this.mutex.notifyAll();
- }
- }
- }
-
- /**
- * Set the value to null. If the value changes, all waiting
- * threads are notified.
- */
- public void setNull() {
- synchronized (this.mutex) {
- this.setValue(null);
- }
- }
-
- /**
- * Return the object this object locks on while performing
- * its operations.
- */
- public Object mutex() {
- return this.mutex;
- }
-
-
- // ********** indefinite waits **********
-
- /**
- * Suspend the current thread until the value changes
- * to the specified value. If the value is already the
- * specified value, return immediately.
- */
- public void waitUntilValueIs(T v) throws InterruptedException {
- synchronized (this.mutex) {
- while (this.value != v) {
- this.mutex.wait();
- }
- }
- }
-
- /**
- * Suspend the current thread until the value changes
- * to something other than the specified value. If the
- * value is already NOT the specified value, return immediately.
- */
- public void waitUntilValueIsNot(T v) throws InterruptedException {
- synchronized (this.mutex) {
- while (this.value == v) {
- this.mutex.wait();
- }
- }
- }
-
- /**
- * Suspend the current thread until the value changes to null.
- * If the value is already null, return immediately.
- */
- public void waitUntilNull() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIs(null);
- }
- }
-
- /**
- * Suspend the current thread until the value changes
- * to something other than null.
- * If the value is already NOT null, return immediately.
- */
- public void waitUntilNotNull() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIsNot(null);
- }
- }
-
- /**
- * Suspend the current thread until the value changes to
- * something other than the specified value, then change
- * it back to the specified value and continue executing.
- * If the value is already NOT the specified value, set
- * the value immediately.
- */
- public void waitToSetValue(T v) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIsNot(v);
- this.setValue(v);
- }
- }
-
- /**
- * Suspend the current thread until the value changes to
- * something other than null, then change it back to null
- * and continue executing. If the value is already NOT null,
- * set the value to null immediately.
- */
- public void waitToSetNull() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilNotNull();
- this.setValue(null);
- }
- }
-
-
- // ********** timed waits **********
-
- /**
- * Suspend the current thread until the value changes
- * to the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
- * If the value is already the specified value, return true immediately.
- */
- public boolean waitUntilValueIs(T v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- if (timeout == 0L) {
- this.waitUntilValueIs(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value != v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value == v);
- }
- }
-
- /**
- * Suspend the current thread until the value changes to something
- * other than the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was removed; return false if a time-out occurred.
- * If the value is already NOT the specified value, return true immediately.
- */
- public boolean waitUntilValueIsNot(T v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- if (timeout == 0L) {
- this.waitUntilValueIsNot(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value == v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value != v);
- }
- }
-
- /**
- * Suspend the current thread until the value changes
- * to null or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
- * If the value is already null, return true immediately.
- */
- public boolean waitUntilNull(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilValueIs(null, timeout);
- }
- }
-
- /**
- * Suspend the current thread until the value changes
- * to something other than null or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
- * If the value is already NOT null, return true immediately.
- */
- public boolean waitUntilNotNull(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilValueIsNot(null, timeout);
- }
- }
-
- /**
- * Suspend the current thread until the value changes to
- * something other than the specified value, then change
- * it back to the specified value and continue executing.
- * If the value does not change to something other than the
- * specified before the time-out, simply continue executing
- * without changing the value.
- * The time-out is specified in milliseconds. Return true if the value was
- * set to true; return false if a time-out occurred.
- * If the value is already something other than the specified value, set
- * the value immediately and return true.
- */
- public boolean waitToSetValue(T v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilValueIsNot(v, timeout);
- if (success) {
- this.setValue(v);
- }
- return success;
- }
- }
-
- /**
- * Suspend the current thread until the value changes to something
- * other than null, then change it back to null and continue executing.
- * If the value does not change to something other than null before
- * the time-out, simply continue executing without changing the value.
- * The time-out is specified in milliseconds. Return true if the value was
- * set to false; return false if a time-out occurred.
- * If the value is already something other than null, set
- * the value to null immediately and return true.
- */
- public boolean waitToSetNull(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilNotNull(timeout);
- if (success) {
- this.setValue(null);
- }
- return success;
- }
- }
-
-
- // ********** synchronized behavior **********
-
- /**
- * If current thread is not interrupted, execute the specified command
- * with the mutex locked. This is useful for initializing the value in another
- * thread.
- */
- public void execute(Command command) throws InterruptedException {
- if (Thread.interrupted()) {
- throw new InterruptedException();
- }
- synchronized (this.mutex) {
- command.execute();
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public SynchronizedObject<T> clone() {
- try {
- synchronized (this.mutex) {
- @SuppressWarnings("unchecked")
- SynchronizedObject<T> clone = (SynchronizedObject<T>) super.clone();
- return clone;
- }
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- if ( ! (obj instanceof SynchronizedObject)) {
- return false;
- }
- Object v1 = this.value();
- Object v2 = ((SynchronizedObject<?>) obj).value();
- return (v1 == null) ?
- (v2 == null) : v1.equals(v2);
- }
-
- @Override
- public int hashCode() {
- Object v = this.value();
- return (v == null) ? 0 : v.hashCode();
- }
-
- @Override
- public String toString() {
- return String.valueOf(this.value());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedStack.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedStack.java
deleted file mode 100644
index c6382bbd4a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedStack.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.Serializable;
-import java.util.EmptyStackException;
-
-import org.eclipse.jpt.utility.Command;
-
-/**
- * Thread-safe implementation of the Stack interface.
- * This also provides protocol for suspending a thread until the
- * stack is empty or not empty, with optional time-outs.
- */
-public class SynchronizedStack<E>
- implements Stack<E>, Serializable
-{
- /** Backing stack. */
- private Stack<E> stack;
-
- /** Object to synchronize on. */
- private final Object mutex;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a synchronized stack that wraps the
- * specified stack and locks on the specified mutex.
- */
- public SynchronizedStack(Stack<E> stack, Object mutex) {
- super();
- this.stack = stack;
- this.mutex = mutex;
- }
-
- /**
- * Construct a synchronized stack that wraps the
- * specified stack and locks on itself.
- */
- public SynchronizedStack(Stack<E> stack) {
- super();
- this.stack = stack;
- this.mutex = this;
- }
-
- /**
- * Construct a synchronized stack that locks on the specified mutex.
- */
- public SynchronizedStack(Object mutex) {
- this(new SimpleStack<E>(), mutex);
- }
-
- /**
- * Construct a synchronized stack that locks on itself.
- */
- public SynchronizedStack() {
- this(new SimpleStack<E>());
- }
-
-
- // ********** Stack implementation **********
-
- public void push(E o) {
- synchronized (this.mutex) {
- this.stack.push(o);
- this.mutex.notifyAll();
- }
- }
-
- public E pop() {
- synchronized (this.mutex) {
- E o = this.stack.pop();
- this.mutex.notifyAll();
- return o;
- }
- }
-
- public E peek() {
- synchronized (this.mutex) {
- return this.stack.peek();
- }
- }
-
- public boolean isEmpty() {
- synchronized (this.mutex) {
- return this.stack.isEmpty();
- }
- }
-
-
- // ********** indefinite waits **********
-
- /**
- * Suspend the current thread until the stack's empty status changes
- * to the specified value.
- */
- public void waitUntilEmptyIs(boolean empty) throws InterruptedException {
- synchronized (this.mutex) {
- while (this.isEmpty() != empty) {
- this.mutex.wait();
- }
- }
- }
-
- /**
- * Suspend the current thread until the stack is empty.
- */
- public void waitUntilEmpty() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilEmptyIs(true);
- }
- }
-
- /**
- * Suspend the current thread until the stack has something on it.
- */
- public void waitUntilNotEmpty() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilEmptyIs(false);
- }
- }
-
- /**
- * Suspend the current thread until the stack is empty,
- * then "push" the specified item on to the top of the stack
- * and continue executing.
- */
- public void waitToPush(E o) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilEmpty();
- this.push(o);
- }
- }
-
- /**
- * Suspend the current thread until the stack has something on it,
- * then "pop" an item from the top of the stack and return it.
- */
- public Object waitToPop() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilNotEmpty();
- return this.pop();
- }
- }
-
-
- // ********** timed waits **********
-
- /**
- * Suspend the current thread until the stack's empty status changes
- * to the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
- */
- public boolean waitUntilEmptyIs(boolean empty, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- if (timeout == 0L) {
- this.waitUntilEmptyIs(empty); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.isEmpty() != empty) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.isEmpty() == empty);
- }
- }
-
- /**
- * Suspend the current thread until the stack is empty
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if
- * the stack is empty; return false if a time-out occurred.
- */
- public boolean waitUntilEmpty(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilEmptyIs(true, timeout);
- }
- }
-
- /**
- * Suspend the current thread until the stack has something on it.
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if
- * the stack has something on it; return false if a time-out occurred.
- */
- public boolean waitUntilNotEmpty(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilEmptyIs(false, timeout);
- }
- }
-
- /**
- * Suspend the current thread until the stack is empty,
- * then "push" the specified item on to the top of the stack
- * and continue executing. If the stack is not emptied out
- * before the time-out, simply continue executing without
- * "pushing" the item.
- * The time-out is specified in milliseconds. Return true if the
- * item was pushed; return false if a time-out occurred.
- */
- public boolean waitToPush(E o, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilEmpty(timeout);
- if (success) {
- this.push(o);
- }
- return success;
- }
- }
-
- /**
- * Suspend the current thread until the stack has something on it,
- * then "pop" an item from the top of the stack and return it.
- * If the stack is empty and nothing is "pushed" on to it before the
- * time-out, throw an empty stack exception.
- * The time-out is specified in milliseconds.
- */
- public Object waitToPop(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilNotEmpty(timeout);
- if (success) {
- return this.pop();
- }
- throw new EmptyStackException();
- }
- }
-
-
- // ********** synchronized behavior **********
-
- /**
- * If the current thread is not interrupted, execute the specified command
- * with the mutex locked. This is useful for initializing the stack in another
- * thread.
- */
- public void execute(Command command) throws InterruptedException {
- if (Thread.interrupted()) {
- throw new InterruptedException();
- }
- synchronized (this.mutex) {
- command.execute();
- }
- }
-
-
- // ********** additional public protocol **********
-
- /**
- * Return the object this object locks on while performing
- * its operations.
- */
- public Object mutex() {
- return this.mutex;
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- synchronized (this.mutex) {
- return this.stack.toString();
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Transformer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Transformer.java
deleted file mode 100644
index 75e4cc0839..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Transformer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-/**
- * Used by various "pluggable" classes to transform objects.
- * Transform an object of type T1 to an object of type T2.
- */
-public interface Transformer<T1, T2> {
-
- /**
- * Return the transformed object.
- * The semantics of "transform" is determined by the
- * contract between the client and the server.
- */
- T2 transform(T1 o);
-
-
- final class Null<S1, S2> implements Transformer<S1, S2> {
- @SuppressWarnings("unchecked")
- public static final Transformer INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R1, R2> Transformer<R1, R2> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // simply return the object, unchanged
- @SuppressWarnings("unchecked")
- public S2 transform(S1 o) {
- return (S2) o;
- }
- @Override
- public String toString() {
- return "Transformer.Null";
- }
- }
-
- final class Disabled<S1, S2> implements Transformer<S1, S2> {
- @SuppressWarnings("unchecked")
- public static final Transformer INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R1, R2> Transformer<R1, R2> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public S2 transform(S1 o) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return "Transformer.Disabled";
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/XMLStringEncoder.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/XMLStringEncoder.java
deleted file mode 100644
index fcc359de00..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/XMLStringEncoder.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-
-/**
- * This encoder will replace any of a specified set of characters with an XML
- * "character reference": '/' => "&#x2f;"
- */
-public final class XMLStringEncoder {
-
- /** The set of characters to be converted into XML character references. */
- private final char[] chars;
-
- /** Cache the value of the highest character in the set above. */
- private final char maxChar;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Construct an encoder that converts the specified set of characters
- * into XML character references.
- */
- public XMLStringEncoder(char[] chars) {
- super();
- if (chars == null) {
- throw new NullPointerException();
- }
- // the ampersand must be included since it is the escape character
- if (CollectionTools.contains(chars, '&')) {
- this.chars = chars;
- } else {
- this.chars = CollectionTools.add(chars, '&');
- }
- this.maxChar = this.calculateMaxInvalidFileNameChar();
- }
-
- /**
- * Calculate the maximum value of the set of characters to be converted
- * into XML character references. This will be used to short-circuit the
- * search for a character in the set.
- * @see #charIsToBeEncoded(char)
- */
- private char calculateMaxInvalidFileNameChar() {
- char[] localChars = this.chars;
- char max = 0;
- for (int i = localChars.length; i-- > 0; ) {
- char c = localChars[i];
- if (max < c) {
- max = c;
- }
- }
- return max;
- }
-
-
- // ********** API **********
-
- /**
- * Return the specified string with any characters in the set
- * replaced with XML character references.
- */
- public String encode(String s) {
- int len = s.length();
- // allow for a few encoded characters
- StringBuilder sb = new StringBuilder(len + 20);
- for (int i = 0; i < len; i++) {
- this.appendCharacterTo(s.charAt(i), sb);
- }
- return sb.toString();
- }
-
- /**
- * Return the specified string with any XML character references
- * replaced by the characters themselves.
- */
- public String decode(String s) {
- StringBuilder sb = new StringBuilder(s.length());
- StringBuilder temp = new StringBuilder(); // performance tweak
- this.decodeTo(new StringReader(s), sb, temp);
- return sb.toString();
- }
-
-
- // ********** internal methods **********
-
- /**
- * Append the specified character to the string buffer,
- * converting it to an XML character reference if necessary.
- */
- private void appendCharacterTo(char c, StringBuilder sb) {
- if (this.charIsToBeEncoded(c)) {
- this.appendCharacterReferenceTo(c, sb);
- } else {
- sb.append(c);
- }
- }
-
- /**
- * Return whether the specified character is one of the characters
- * to be converted to XML character references.
- */
- private boolean charIsToBeEncoded(char c) {
- return (c <= this.maxChar) && CollectionTools.contains(this.chars, c);
- }
-
- /**
- * Append the specified character's XML character reference to the
- * specified string buffer (e.g. '/' => "&#x2f;").
- */
- private void appendCharacterReferenceTo(char c, StringBuilder sb) {
- sb.append("&#x");
- sb.append(Integer.toString(c, 16));
- sb.append(';');
- }
-
- private void decodeTo(Reader reader, StringBuilder sb, StringBuilder temp) {
- try {
- this.decodeTo_(reader, sb, temp);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private void decodeTo_(Reader reader, StringBuilder sb, StringBuilder temp) throws IOException {
- int c = reader.read();
- while (c != -1) {
- if (c == '&') {
- this.decodeCharacterReferenceTo(reader, sb, temp);
- } else {
- sb.append((char) c);
- }
- c = reader.read();
- }
- reader.close();
- }
-
- private void decodeCharacterReferenceTo(Reader reader, StringBuilder sb, StringBuilder temp) throws IOException {
- int c = reader.read();
- this.checkChar(c, '#');
- c = reader.read();
- this.checkChar(c, 'x');
-
- temp.setLength(0); // re-use temp
- c = reader.read();
- while (c != ';') {
- this.checkEndOfStream(c);
- temp.append((char) c);
- c = reader.read();
- }
- String charValue = temp.toString();
- if (charValue.length() == 0) {
- throw new IllegalStateException("missing numeric string");
- }
- sb.append((char) Integer.parseInt(charValue, 16));
- }
-
- private void checkChar(int c, int expected) {
- this.checkEndOfStream(c);
- if (c != expected) {
- throw new IllegalStateException("expected '" + (char) expected + "', but encountered '" + (char) c + "'");
- }
- }
-
- private void checkEndOfStream(int c) {
- if (c == -1) {
- throw new IllegalStateException("unexpected end of string");
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayIterator.java
deleted file mode 100644
index 2874af48ad..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayIterator.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * An <code>ArrayIterator</code> provides an <code>Iterator</code>
- * for an array of objects of type E.
- */
-public class ArrayIterator<E>
- implements Iterator<E>
-{
- final E[] array; // private-protected
- int nextIndex; // private-protected
- private final int maxIndex;
-
- /**
- * Construct an iterator for the specified array.
- */
- public ArrayIterator(E... array) {
- this(array, 0, array.length);
- }
-
- /**
- * Construct an iterator for the specified array,
- * starting at the specified start index and continuing for
- * the specified length.
- */
- public ArrayIterator(E[] array, int start, int length) {
- if ((start < 0) || (start > array.length)) {
- throw new IllegalArgumentException("start: " + start);
- }
- if ((length < 0) || (length > array.length - start)) {
- throw new IllegalArgumentException("length: " + length);
- }
- this.array = array;
- this.nextIndex = start;
- this.maxIndex = start + length;
- }
-
- public boolean hasNext() {
- return this.nextIndex < this.maxIndex;
- }
-
- public E next() {
- if (this.hasNext()) {
- return this.array[this.nextIndex++];
- }
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, CollectionTools.list(this.array));
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayListIterator.java
deleted file mode 100644
index 5b70ed4721..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayListIterator.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-/**
- * An <code>ArrayListIterator</code> provides a <code>ListIterator</code>
- * for an array of objects.
- *
- * The name might be a bit confusing:
- * This is a <code>ListIterator</code> for an <code>Array</code>;
- * <em>not</em> an <code>Iterator</code> for an <code>ArrayList</code>.
- */
-public class ArrayListIterator<E>
- extends ArrayIterator<E>
- implements ListIterator<E>
-{
- private final int minIndex;
-
- /**
- * Construct a list iterator for the specified array.
- */
- public ArrayListIterator(E... array) {
- this(array, 0, array.length);
- }
-
- /**
- * Construct a list iterator for the specified array,
- * starting at the specified start index and continuing for
- * the specified length.
- */
- public ArrayListIterator(E[] array, int start, int length) {
- super(array, start, length);
- this.minIndex = start;
- }
-
- public int nextIndex() {
- return this.nextIndex;
- }
-
- public int previousIndex() {
- return this.nextIndex - 1;
- }
-
- public boolean hasPrevious() {
- return this.nextIndex > this.minIndex;
- }
-
- public E previous() {
- if (this.hasPrevious()) {
- return this.array[--this.nextIndex];
- }
- throw new NoSuchElementException();
- }
-
- public void add(E e) {
- throw new UnsupportedOperationException();
- }
-
- public void set(E e) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return super.toString();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ChainIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ChainIterator.java
deleted file mode 100644
index ea5076e854..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ChainIterator.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>ChainIterator</code> provides a pluggable <code>Iterator</code>
- * that loops over a chain of arbitrarily linked objects. The chain
- * should be null-terminated (i.e. a call to the <code>nextLink(Object)</code>
- * method should return <code>null</code> when it is passed the last
- * link of the chain).
- * To use, supply a starting link and supply a <code>Linker</code> or
- * subclass <code>ChainIterator</code> and override the
- * <code>nextLink(Object)</code> method.
- * The starting link will be the first object returned by the iterator.
- * If the starting link is <code>null</code>, the iterator will be empty.
- * Note that the iterator does not support <code>null</code> elements.
- */
-public class ChainIterator<E>
- implements Iterator<E>
-{
- private E nextLink;
- private final Linker<E> linker;
-
-
- /**
- * Construct an iterator with the specified starting link
- * and a disabled linker.
- * Use this constructor if you want to override the
- * <code>nextLink(Object)</code> method instead of building
- * a <code>Linker</code>.
- */
- public ChainIterator(E startLink) {
- this(startLink, Linker.Disabled.<E>instance());
- }
-
- /**
- * Construct an iterator with the specified starting link
- * and linker.
- */
- public ChainIterator(E startLink, Linker<E> linker) {
- super();
- this.nextLink = startLink;
- this.linker = linker;
- }
-
- public boolean hasNext() {
- return this.nextLink != null;
- }
-
- public E next() {
- if (this.nextLink == null) {
- throw new NoSuchElementException();
- }
- E result = this.nextLink;
- this.nextLink = this.nextLink(this.nextLink);
- return result;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Return the next link in the chain.
- */
- protected E nextLink(E currentLink) {
- return this.linker.nextLink(currentLink);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.nextLink);
- }
-
-
- //********** inner classes **********
-
- /**
- * Used by <code>ChainIterator</code> to link
- * the elements in the chain.
- */
- public interface Linker<T> {
-
- /**
- * Return the next link in the chain.
- */
- T nextLink(T currentLink);
-
-
- final class Null<S> implements Linker<S> {
- @SuppressWarnings("unchecked")
- public static final Linker INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R> Linker<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // simply return null, indicating the chain is ended
- public S nextLink(S currentLink) {
- return null;
- }
- @Override
- public String toString() {
- return "ChainIterator.Linker.Null";
- }
- }
-
- final class Disabled<S> implements Linker<S> {
- @SuppressWarnings("unchecked")
- public static final Linker INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> Linker<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public S nextLink(S currentLink) {
- throw new UnsupportedOperationException(); // ChainIterator.nextLink(Object) was not implemented
- }
- @Override
- public String toString() {
- return "ChainIterator.Linker.Disabled";
- }
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneIterator.java
deleted file mode 100644
index cf823a5e2d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneIterator.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Collection;
-import java.util.Iterator;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>CloneIterator</code> iterates over a copy of a collection,
- * allowing for concurrent access to the original collection.
- * <p>
- * The original collection passed to the <code>CloneIterator</code>'s
- * constructor should be synchronized; otherwise you run the risk of
- * a corrupted collection.
- * <p>
- * By default, a <code>CloneIterator</code> does not support the
- * <code>#remove()</code> operation; this is because it does not have
- * access to the original collection. But if the <code>CloneIterator</code>
- * is supplied with an <code>Mutator</code> it will delegate the
- * <code>#remove()</code> operation to the <code>Mutator</code>.
- * Alternatively, a subclass can override the <code>#remove(Object)</code>
- * method.
- */
-public class CloneIterator<E>
- implements Iterator<E>
-{
- private final Iterator<Object> nestedIterator;
- private E current;
- private final Mutator<E> mutator;
- private boolean removeAllowed;
-
-
- // ********** constructors **********
-
- /**
- * Construct an iterator on a copy of the specified collection.
- * The <code>#remove()</code> method will not be supported,
- * unless a subclass overrides the <code>#remove(Object)</code>.
- */
- public CloneIterator(Collection<? extends E> c) {
- this(c, Mutator.ReadOnly.<E>instance());
- }
-
- /**
- * Construct an iterator on a copy of the specified collection.
- * Use the specified mutator to remove objects from the
- * original collection.
- */
- public CloneIterator(Collection<? extends E> c, Mutator<E> mutator) {
- super();
- this.nestedIterator = new ArrayIterator<Object>(c.toArray());
- this.current = null;
- this.mutator = mutator;
- this.removeAllowed = false;
- }
-
-
- // ********** Iterator implementation **********
-
- public boolean hasNext() {
- return this.nestedIterator.hasNext();
- }
-
- public E next() {
- this.current = this.nestedNext();
- this.removeAllowed = true;
- return this.current;
- }
-
- public void remove() {
- if ( ! this.removeAllowed) {
- throw new IllegalStateException();
- }
- this.remove(this.current);
- this.removeAllowed = false;
- }
-
-
- // ********** internal methods **********
-
- /**
- * The collection passed in during construction held Es,
- * so this cast is not a problem. We need this cast because
- * all the elements of the original collection were copied into
- * an object array (Object[]).
- */
- @SuppressWarnings("unchecked")
- protected E nestedNext() {
- return (E) this.nestedIterator.next();
- }
-
- /**
- * Remove the specified element from the original collection.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building an <code>Mutator</code>.
- */
- protected void remove(E e) {
- this.mutator.remove(e);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-
- //********** member interface **********
-
- /**
- * Used by <code>CloneIterator</code> to remove
- * elements from the original collection; since the iterator
- * does not have direct access to the original collection.
- */
- public interface Mutator<T> {
-
- /**
- * Remove the specified object from the original collection.
- */
- void remove(T current);
-
-
- final class ReadOnly<S> implements Mutator<S> {
- @SuppressWarnings("unchecked")
- public static final Mutator INSTANCE = new ReadOnly();
- @SuppressWarnings("unchecked")
- public static <R> Mutator<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private ReadOnly() {
- super();
- }
- // remove is not supported
- public void remove(Object current) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return "CloneIterator.Mutator.ReadOnly";
- }
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneListIterator.java
deleted file mode 100644
index bbad3409e2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneListIterator.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>CloneListIterator</code> iterates over a copy of a list,
- * allowing for concurrent access to the original list.
- * <p>
- * The original list passed to the <code>CloneListIterator</code>'s
- * constructor should be synchronized; otherwise you run the risk of
- * a corrupted list.
- * <p>
- * By default, a <code>CloneListIterator</code> does not support the
- * modification operations; this is because it does not have
- * access to the original list. But if the <code>CloneListIterator</code>
- * is supplied with a <code>Mutator</code> it will delegate the
- * modification operations to the <code>Mutator</code>.
- * Alternatively, a subclass can override the modification methods.
- */
-public class CloneListIterator<E>
- implements ListIterator<E>
-{
- private final ListIterator<Object> nestedListIterator;
- private int cursor;
- private String state;
- private final Mutator<E> mutator;
-
- private static final String UNKNOWN = "unknown";
- private static final String PREVIOUS = "previous";
- private static final String NEXT = "next";
-
-
- // ********** constructors **********
-
- /**
- * Construct a list iterator on a copy of the specified list.
- * The modification methods will not be supported,
- * unless a subclass overrides them.
- */
- public CloneListIterator(List<? extends E> list) {
- this(list, Mutator.ReadOnly.<E>instance());
- }
-
- /**
- * Construct a list iterator on a copy of the specified list.
- * Use the specified list mutator to modify the original list.
- */
- public CloneListIterator(List<? extends E> list, Mutator<E> mutator) {
- super();
- // build a copy of the list and keep it in synch with original (if the mutator allows changes)
- // that way the nested list iterator will maintain some of our state
- this.nestedListIterator = CollectionTools.list(list.toArray()).listIterator();
- this.mutator = mutator;
- this.cursor = 0;
- this.state = UNKNOWN;
- }
-
-
- // ********** ListIterator implementation **********
-
- public boolean hasNext() {
- return this.nestedListIterator.hasNext();
- }
-
- public E next() {
- // allow the nested iterator to throw an exception before we modify the index
- E next = this.nestedNext();
- this.cursor++;
- this.state = NEXT;
- return next;
- }
-
- public void remove() {
- // allow the nested iterator to throw an exception before we modify the original list
- this.nestedListIterator.remove();
- if (this.state == PREVIOUS) {
- this.remove(this.cursor);
- } else {
- this.cursor--;
- this.remove(this.cursor);
- }
- }
-
- public int nextIndex() {
- return this.nestedListIterator.nextIndex();
- }
-
- public int previousIndex() {
- return this.nestedListIterator.previousIndex();
- }
-
- public boolean hasPrevious() {
- return this.nestedListIterator.hasPrevious();
- }
-
- public E previous() {
- // allow the nested iterator to throw an exception before we modify the index
- E previous = this.nestedPrevious();
- this.cursor--;
- this.state = PREVIOUS;
- return previous;
- }
-
- public void add(E o) {
- // allow the nested iterator to throw an exception before we modify the original list
- this.nestedListIterator.add(o);
- this.add(this.cursor, o);
- this.cursor++;
- }
-
- public void set(E o) {
- // allow the nested iterator to throw an exception before we modify the original list
- this.nestedListIterator.set(o);
- if (this.state == PREVIOUS) {
- this.set(this.cursor, o);
- } else {
- this.set(this.cursor - 1, o);
- }
- }
-
-
- // ********** internal methods **********
-
- /**
- * The list passed in during construction held Es,
- * so this cast is not a problem. We need this cast because
- * all the elements of the original collection were copied into
- * an object array (Object[]).
- */
- @SuppressWarnings("unchecked")
- protected E nestedNext() {
- return (E) this.nestedListIterator.next();
- }
-
- /**
- * The list passed in during construction held Es,
- * so this cast is not a problem. We need this cast because
- * all the elements of the original collection were copied into
- * an object array (Object[]).
- */
- @SuppressWarnings("unchecked")
- protected E nestedPrevious() {
- return (E) this.nestedListIterator.previous();
- }
-
- /**
- * Add the specified element to the original list.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a <code>Mutator</code>.
- */
- protected void add(int index, E o) {
- this.mutator.add(index, o);
- }
-
- /**
- * Remove the specified element from the original list.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a <code>Mutator</code>.
- */
- protected void remove(int index) {
- this.mutator.remove(index);
- }
-
- /**
- * Set the specified element in the original list.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a <code>Mutator</code>.
- */
- protected void set(int index, E o) {
- this.mutator.set(index, o);
- }
-
-
- // ********** overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-
- //********** member interface **********
-
- /**
- * Used by <code>CloneListIterator</code> to remove
- * elements from the original list; since the list iterator
- * does not have direct access to the original list.
- */
- public interface Mutator<T> {
-
- /**
- * Add the specified object to the original list.
- */
- void add(int index, T o);
-
- /**
- * Remove the specified object from the original list.
- */
- void remove(int index);
-
- /**
- * Set the specified object in the original list.
- */
- void set(int index, T o);
-
-
- final class ReadOnly<S> implements Mutator<S> {
- @SuppressWarnings("unchecked")
- public static final Mutator INSTANCE = new ReadOnly();
- @SuppressWarnings("unchecked")
- public static <R> Mutator<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private ReadOnly() {
- super();
- }
- // add is not supported
- public void add(int index, Object o) {
- throw new UnsupportedOperationException();
- }
- // remove is not supported
- public void remove(int index) {
- throw new UnsupportedOperationException();
- }
- // set is not supported
- public void set(int index, Object o) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return "CloneListIterator.Mutator.ReadOnly";
- }
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeIterator.java
deleted file mode 100644
index 083f535b4a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeIterator.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>CompositeIterator</code> wraps a collection
- * of <code>Iterator</code>s and makes them appear to be a single
- * <code>Iterator</code>.
- */
-public class CompositeIterator<E>
- implements Iterator<E>
-{
- private final Iterator<? extends Iterator<? extends E>> iterators;
- private Iterator<? extends E> currentIterator;
- private Iterator<? extends E> lastIteratorToReturnNext;
-
-
- // ********** constructors **********
-
- /**
- * Construct an iterator with the specified collection of iterators.
- */
- public CompositeIterator(Collection<? extends Iterator<? extends E>> iterators) {
- this(iterators.iterator());
- }
-
- /**
- * Construct an iterator with the specified collection of iterators.
- */
- public CompositeIterator(Iterator<? extends Iterator<? extends E>> iterators) {
- super();
- this.iterators = iterators;
- }
-
- /**
- * Construct an iterator with the specified object prepended
- * to the specified iterator.
- */
- @SuppressWarnings("unchecked")
- public CompositeIterator(E object, Iterator<? extends E> iterator) {
- this(new SingleElementIterator<E>(object), iterator);
- }
-
- /**
- * Construct an iterator with the specified object appended
- * to the specified iterator.
- */
- @SuppressWarnings("unchecked")
- public CompositeIterator(Iterator<? extends E> iterator, E object) {
- this(iterator, new SingleElementIterator<E>(object));
- }
-
- /**
- * Construct an iterator with the specified iterators.
- */
- public CompositeIterator(Iterator<? extends E>... iterators) {
- this(new ArrayIterator<Iterator<? extends E>>(iterators));
- }
-
-
- // ********** Iterator implementation **********
-
- public boolean hasNext() {
- try {
- this.loadCurrentIterator();
- } catch (NoSuchElementException ex) {
- // this occurs if there are no iterators at all
- return false;
- }
- return this.currentIterator.hasNext();
- }
-
- public E next() {
- this.loadCurrentIterator();
- E result = this.currentIterator.next();
-
- // the statement above will throw a NoSuchElementException
- // if the current iterator is at the end of the line;
- // so if we get here, we can set 'lastIteratorToReturnNext'
- this.lastIteratorToReturnNext = this.currentIterator;
-
- return result;
- }
-
- public void remove() {
- if (this.lastIteratorToReturnNext == null) {
- // CompositeIterator#next() has never been called
- throw new IllegalStateException();
- }
- this.lastIteratorToReturnNext.remove();
- }
-
- /**
- * Load currentIterator with the first iterator that <code>hasNext()</code>
- * or the final iterator if all the elements have already been retrieved.
- */
- private void loadCurrentIterator() {
- if (this.currentIterator == null) {
- this.currentIterator = this.iterators.next();
- }
- while (( ! this.currentIterator.hasNext()) && this.iterators.hasNext()) {
- this.currentIterator = this.iterators.next();
- }
- }
-
-
- // ********** overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterators);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeListIterator.java
deleted file mode 100644
index c2037f053d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeListIterator.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>CompositeListIterator</code> wraps a list
- * of <code>ListIterator</code>s and makes them appear to be a single
- * <code>ListIterator</code>.
- */
-public class CompositeListIterator<E>
- implements ListIterator<E>
-{
- private final ListIterator<? extends ListIterator<E>> iterators;
- private ListIterator<E> nextIterator;
- private int nextIndex;
- /**
- * true if "next" was last returned; false if "previous" was last returned;
- * this determines the effect of remove(Object) on nextIndex
- */
- private boolean nextReturned;
- private ListIterator<E> lastIteratorToReturnElement;
-
-
- /**
- * Construct a list iterator with the specified list of list iterators.
- */
- public CompositeListIterator(List<? extends ListIterator<E>> iterators) {
- this(iterators.listIterator());
- }
-
- /**
- * Construct a list iterator with the specified list of list iterators.
- */
- public CompositeListIterator(ListIterator<? extends ListIterator<E>> iterators) {
- super();
- this.iterators = iterators;
- this.nextIndex = 0;
- this.nextReturned = false;
- }
-
- /**
- * Construct a list iterator with the specified object prepended
- * to the specified iterator.
- */
- @SuppressWarnings("unchecked")
- public CompositeListIterator(E object, ListIterator<E> iterator) {
- this(new SingleElementListIterator<E>(object), iterator);
- }
-
- /**
- * Construct a list iterator with the specified object appended
- * to the specified iterator.
- */
- @SuppressWarnings("unchecked")
- public CompositeListIterator(ListIterator<E> iterator, E object) {
- this(iterator, new SingleElementListIterator<E>(object));
- }
-
- /**
- * Construct a list iterator with the specified list iterators.
- */
- public CompositeListIterator(ListIterator<E>... iterators) {
- this(new ArrayListIterator<ListIterator<E>>(iterators));
- }
-
- public void add(E o) {
- this.checkNextIterator();
- this.nextIterator.add(o);
- this.nextIndex++;
- }
-
- public boolean hasNext() {
- try {
- this.loadNextIterator();
- } catch (NoSuchElementException ex) {
- // this occurs if there are no iterators at all
- return false;
- }
- return this.nextIterator.hasNext();
- }
-
- public boolean hasPrevious() {
- try {
- this.loadPreviousIterator();
- } catch (NoSuchElementException ex) {
- // this occurs if there are no iterators at all
- return false;
- }
- return this.nextIterator.hasPrevious();
- }
-
- public E next() {
- this.loadNextIterator();
- E result = this.nextIterator.next();
-
- // the statement above will throw a NoSuchElementException
- // if the current iterator is at the end of the line;
- // so if we get here, we can set the 'lastIteratorToReturnElement'
- this.lastIteratorToReturnElement = this.nextIterator;
- this.nextIndex++;
- this.nextReturned = true;
-
- return result;
- }
-
- public int nextIndex() {
- return this.nextIndex;
- }
-
- public E previous() {
- this.loadPreviousIterator();
- E result = this.nextIterator.previous();
-
- // the statement above will throw a NoSuchElementException
- // if the current iterator is at the end of the line;
- // so if we get here, we can set the 'lastIteratorToReturnElement'
- this.lastIteratorToReturnElement = this.nextIterator;
- this.nextIndex--;
- this.nextReturned = false;
-
- return result;
- }
-
- public int previousIndex() {
- return this.nextIndex - 1;
- }
-
- public void remove() {
- if (this.lastIteratorToReturnElement == null) {
- throw new IllegalStateException();
- }
- this.lastIteratorToReturnElement.remove();
- if (this.nextReturned) {
- // decrement the index because the "next" element has moved forward in the list
- this.nextIndex--;
- }
- }
-
- public void set(E e) {
- if (this.lastIteratorToReturnElement == null) {
- throw new IllegalStateException();
- }
- this.lastIteratorToReturnElement.set(e);
- }
-
- /**
- * Load 'nextIterator' with the first iterator that <code>hasNext()</code>
- * or the final iterator if all the elements have already been retrieved.
- */
- private void loadNextIterator() {
- this.checkNextIterator();
- while (( ! this.nextIterator.hasNext()) && this.iterators.hasNext()) {
- this.nextIterator = this.iterators.next();
- }
- }
-
- /**
- * Load 'nextIterator' with the first iterator that <code>hasPrevious()</code>
- * or the first iterator if all the elements have already been retrieved.
- */
- private void loadPreviousIterator() {
- this.checkNextIterator();
- while (( ! this.nextIterator.hasPrevious()) && this.iterators.hasPrevious()) {
- this.nextIterator = this.iterators.previous();
- }
- }
-
- /**
- * If 'nextIterator' is null, load it with the first iterator.
- */
- private void checkNextIterator() {
- if (this.nextIterator == null) {
- this.nextIterator = this.iterators.next();
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterators);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyEnumeration.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyEnumeration.java
deleted file mode 100644
index 1e7721a892..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyEnumeration.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>NullEnumeration</code> is just that.
- */
-public final class EmptyEnumeration<E>
- implements Enumeration<E>
-{
-
- // singleton
- @SuppressWarnings("unchecked")
- private static final EmptyEnumeration INSTANCE = new EmptyEnumeration();
-
- /**
- * Return the singleton.
- */
- @SuppressWarnings("unchecked")
- public static <T> Enumeration<T> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private EmptyEnumeration() {
- super();
- }
-
- public boolean hasMoreElements() {
- return false;
- }
-
- public E nextElement() {
- throw new NoSuchElementException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyIterator.java
deleted file mode 100644
index af8a394119..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyIterator.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * An <code>EmptyIterator</code> is just that.
- */
-public final class EmptyIterator<E>
- implements Iterator<E>
-{
-
- // singleton
- @SuppressWarnings("unchecked")
- private static final EmptyIterator INSTANCE = new EmptyIterator();
-
- /**
- * Return the singleton.
- */
- @SuppressWarnings("unchecked")
- public static <T> Iterator<T> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private EmptyIterator() {
- super();
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public E next() {
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyListIterator.java
deleted file mode 100644
index 5d6df99a2b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyListIterator.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * An <code>EmptyListIterator</code> is just that.
- */
-public final class EmptyListIterator<E>
- implements ListIterator<E>
-{
-
- // singleton
- @SuppressWarnings("unchecked")
- private static final EmptyListIterator INSTANCE = new EmptyListIterator();
-
- /**
- * Return the singleton.
- */
- @SuppressWarnings("unchecked")
- public static <T> ListIterator<T> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private EmptyListIterator() {
- super();
- }
-
- public void add(E e) {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public boolean hasPrevious() {
- return false;
- }
-
- public E next() {
- throw new NoSuchElementException();
- }
-
- public int nextIndex() {
- return 0;
- }
-
- public E previous() {
- throw new NoSuchElementException();
- }
-
- public int previousIndex() {
- return -1;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public void set(E e) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EnumerationIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EnumerationIterator.java
deleted file mode 100644
index a75710c4ef..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EnumerationIterator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * An <code>EnumerationIterator</code> wraps an
- * <code>Enumeration</code> so that it can be treated like an
- * <code>Iterator</code>.
- */
-public class EnumerationIterator<E>
- implements Iterator<E>
-{
- private final Enumeration<? extends E> enumeration;
-
- /**
- * Construct an iterator that wraps the specified enumeration.
- */
- public EnumerationIterator(Enumeration<? extends E> enumeration) {
- this.enumeration = enumeration;
- }
-
- public boolean hasNext() {
- return this.enumeration.hasMoreElements();
- }
-
- public E next() {
- return this.enumeration.nextElement();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.enumeration);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/FilteringIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/FilteringIterator.java
deleted file mode 100644
index dd8230bf26..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/FilteringIterator.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>FilteringIterator</code> wraps another <code>Iterator</code>
- * and uses a <code>Filter</code> to determine which elements in the
- * nested iterator are to be returned by calls to <code>next()</code>.
- * <p>
- * As an alternative to building a <code>Filter</code>, a subclass
- * of <code>FilteringIterator</code> can override the
- * <code>accept(Object)</code> method.
- * <p>
- * One, possibly undesirable, side-effect of using this iterator is that
- * the nested iterator's <code>next()</code> method will be invoked
- * <em>before</em> the filtered iterator's <code>next()</code>
- * method is invoked. This is because the "next" element must be
- * checked for whether it is to be accepted before the filtered iterator
- * can determine whether it has a "next" element (i.e. that the
- * <code>hasNext()</code> method should return <code>true</code>).
- * This also prevents a filtered iterator from supporting the optional
- * <code>remove()</code> method.
- */
-public class FilteringIterator<E1, E2>
- implements Iterator<E2>
-{
- private final Iterator<? extends E1> nestedIterator;
- private final Filter<E1> filter;
- private E2 next;
- private boolean done;
-
-
- /**
- * Construct an iterator with the specified nested
- * iterator and a disabled filter.
- * Use this constructor if you want to override the
- * <code>accept(Object)</code> method instead of building
- * a <code>Filter</code>.
- */
- public FilteringIterator(Iterator<? extends E1> nestedIterator) {
- this(nestedIterator, Filter.Disabled.<E1>instance());
- }
-
- /**
- * Construct an iterator with the specified nested
- * iterator and filter.
- */
- public FilteringIterator(Iterator<? extends E1> nestedIterator, Filter<E1> filter) {
- super();
- this.nestedIterator = nestedIterator;
- this.filter = filter;
- this.loadNext();
- }
-
- public boolean hasNext() {
- return ! this.done;
- }
-
- public E2 next() {
- if (this.done) {
- throw new NoSuchElementException();
- }
- E2 result = this.next;
- this.loadNext();
- return result;
- }
-
- /**
- * Because we need to pre-load the next element
- * to be returned, we cannot support the <code>remove()</code>
- * method.
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Load next with the next valid entry from the nested
- * iterator. If there are none, next is set to <code>END</code>.
- */
- private void loadNext() {
- this.done = true;
- while (this.nestedIterator.hasNext() && (this.done)) {
- E1 temp = this.nestedIterator.next();
- if (this.accept(temp)) {
- // assume that if the object was accepted it is of type E
- this.next = this.cast(temp);
- this.done = false;
- } else {
- this.next = null;
- this.done = true;
- }
- }
- }
-
- /**
- * We have to assume the filter will only "accept" objects that can
- * be cast to E2.
- */
- @SuppressWarnings("unchecked")
- private E2 cast(E1 o) {
- return (E2) o;
- }
-
- /**
- * Return whether the <code>FilteringIterator</code>
- * should return the specified next element from a call to the
- * <code>next()</code> method.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a <code>Filter</code>.
- */
- protected boolean accept(E1 o) {
- return this.filter.accept(o);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.nestedIterator);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GenericIteratorWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GenericIteratorWrapper.java
deleted file mode 100644
index 246ead8b91..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GenericIteratorWrapper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * Wrap an iterator on elements of any sub-type of E, converting it into an
- * iterator on elements of type E. This shouldn't be a problem since there
- * is no way to add elements to the iterator.
- */
-public class GenericIteratorWrapper<E>
- implements Iterator<E>
-{
- private final Iterator<? extends E> iterator;
-
- public GenericIteratorWrapper(Iterator<? extends E> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public boolean hasNext() {
- return this.iterator.hasNext();
- }
-
- public E next() {
- return this.iterator.next();
- }
-
- public void remove() {
- this.iterator.remove();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterator);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GraphIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GraphIterator.java
deleted file mode 100644
index c199e6ec4c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GraphIterator.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>GraphIterator</code> is similar to a <code>TreeIterator</code>
- * except that it cannot be assumed that all nodes assume a strict tree
- * structure. For instance, in a tree, a node cannot be a descendent of
- * itself, but a graph may have a cyclical structure.
- *
- * A <code>GraphIterator</code> simplifies the traversal of a
- * graph of objects, where the objects' protocol(s) provides
- * a method for getting the next collection of nodes in the graph,
- * (or *neighbors*), but does not provide a method for getting *all*
- * of the nodes in the graph.
- * (e.g. a neighbor can return his neighbors, and those neighbors
- * can return their neighbors, which might also include the original
- * neighbor, but you only want to visit the original neighbor once.)
- * <p>
- * If a neighbor has already been visited (determined by using
- * <code>equals(Object)</code>), that neighbor is not visited again,
- * nor are the neighbors of that object.
- * <p>
- * It is up to the user of this class to ensure a *complete* graph.
- * <p>
- * To use, supply:<ul>
- * <li> either the initial node of the graph or an Iterator over an
- * initial collection of graph nodes
- * <li> a <code>MisterRogers</code> that tells who the neighbors are
- * of each node
- * (alternatively, subclass <code>GraphIterator</code>
- * and override the <code>neighbors(Object)</code> method)
- * </ul>
- * <p>
- * <code>remove()</code> is not supported. This method, if
- * desired, must be implemented by the user of this class.
- */
-public class GraphIterator<E>
- implements Iterator<E>
-{
- private final Collection<Iterator<? extends E>> iterators;
- private final Set<E> visitedNeighbors;
- private final MisterRogers<E> misterRogers;
-
- private Iterator<? extends E> currentIterator;
-
- private E nextNeighbor;
- private boolean done;
-
-
- /**
- * Construct an iterator with the specified collection of roots
- * and a disabled mister rogers.
- * Use this constructor if you want to override the
- * <code>children(Object)</code> method instead of building
- * a <code>MisterRogers</code>.
- */
- public GraphIterator(E... roots) {
- this(new ArrayIterator<E>(roots));
- }
-
- /**
- * Construct an iterator with the specified collection of roots
- * and a disabled mister rogers.
- * Use this constructor if you want to override the
- * <code>children(Object)</code> method instead of building
- * a <code>MisterRogers</code>.
- */
- public GraphIterator(Iterator<? extends E> roots) {
- this(roots, MisterRogers.Disabled.<E>instance());
- }
-
- /**
- * Construct an iterator with the specified root
- * and a disabled mister rogers.
- * Use this constructor if you want to override the
- * <code>children(Object)</code> method instead of building
- * a <code>MisterRogers</code>.
- */
- public GraphIterator(E root) {
- this(root, MisterRogers.Disabled.<E>instance());
- }
-
- /**
- * Construct an iterator with the specified root
- * and mister rogers.
- */
- public GraphIterator(E root, MisterRogers<E> misterRogers) {
- this(new SingleElementIterator<E>(root), misterRogers);
- }
-
- /**
- * Construct an iterator with the specified roots
- * and mister rogers.
- */
- public GraphIterator(Iterator<? extends E> roots, MisterRogers<E> misterRogers) {
- super();
- this.currentIterator = roots;
- // use a LinkedList since we will be pulling off the front and adding to the end
- this.iterators = new LinkedList<Iterator<? extends E>>();
- this.misterRogers = misterRogers;
- this.visitedNeighbors = new HashSet<E>();
- this.loadNextNeighbor();
- }
-
- /**
- * Load next neighbor with the next entry from the current iterator.
- * If the current iterator has none, load the next iterator.
- * If there are no more, the 'done' flag is set.
- */
- private void loadNextNeighbor() {
- if (this.currentIterator == EmptyIterator.instance()) {
- this.done = true;
- }
- else if (this.currentIterator.hasNext()) {
- E nextPossibleNeighbor = this.currentIterator.next();
- if (this.visitedNeighbors.contains(nextPossibleNeighbor)) {
- this.loadNextNeighbor(); // recurse
- } else {
- this.nextNeighbor = nextPossibleNeighbor;
- this.visitedNeighbors.add(nextPossibleNeighbor);
- this.iterators.add(this.neighbors(nextPossibleNeighbor));
- }
- }
- else {
- for (Iterator<? extends Iterator<? extends E>> stream = this.iterators.iterator(); ! this.currentIterator.hasNext() && stream.hasNext(); ) {
- this.currentIterator = stream.next();
- stream.remove();
- }
- if ( ! this.currentIterator.hasNext()) {
- this.currentIterator = EmptyIterator.instance();
- }
- this.loadNextNeighbor(); // recurse
- }
- }
-
- public boolean hasNext() {
- return ! this.done;
- }
-
- public E next() {
- if (this.done) {
- throw new NoSuchElementException();
- }
- E next = this.nextNeighbor;
- this.loadNextNeighbor();
- return next;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Return the immediate neighbors of the specified object.
- */
- protected Iterator<? extends E> neighbors(E next) {
- return this.misterRogers.neighbors(next);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.currentIterator);
- }
-
-
- //********** inner classes **********
-
- /**
- * Used by <code>GraphIterator</code> to retrieve
- * the immediate neighbors of a node in the graph.
- * "These are the people in your neighborhood..."
- */
- public interface MisterRogers<T> {
-
- /**
- * Return the immediate neighbors of the specified object.
- */
- Iterator<? extends T> neighbors(T next);
-
-
- final class Null<S> implements MisterRogers<S> {
- @SuppressWarnings("unchecked")
- public static final MisterRogers INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R> MisterRogers<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // return no neighbors
- public Iterator<S> neighbors(S next) {
- return EmptyIterator.instance();
- }
- @Override
- public String toString() {
- return "GraphIterator.MisterRogers.Null";
- }
- }
-
- /** The mister rogers used when the #neighbors(Object) method is overridden. */
- final class Disabled<S> implements MisterRogers<S> {
- @SuppressWarnings("unchecked")
- public static final MisterRogers INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> MisterRogers<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public Iterator<S> neighbors(S next) {
- throw new UnsupportedOperationException(); // GraphIterator.neighbors(Object) was not implemented
- }
- @Override
- public String toString() {
- return "GraphIterator.MisterRogers.Disabled";
- }
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/IteratorEnumeration.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/IteratorEnumeration.java
deleted file mode 100644
index 55a4f08b70..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/IteratorEnumeration.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * An <code>IteratorEnumeration</code> wraps an
- * <code>Iterator</code> so that it can be treated like an
- * <code>Enumeration</code>.
- */
-public class IteratorEnumeration<E>
- implements Enumeration<E>
-{
- private final Iterator<? extends E> iterator;
-
- /**
- * Construct an enumeration that wraps the specified iterator.
- */
- public IteratorEnumeration(Iterator<? extends E> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public boolean hasMoreElements() {
- return this.iterator.hasNext();
- }
-
- public E nextElement() {
- return this.iterator.next();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterator);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/PeekableIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/PeekableIterator.java
deleted file mode 100644
index 316aedcf63..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/PeekableIterator.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>PeekableIterator</code> wraps another <code>Iterator</code>
- * and allows a <code>peek()</code> at the next element to be
- * returned by <code>next()</code>.
- * <p>
- * One, possibly undesirable, side-effect of using this iterator is that
- * the nested iterator's <code>next()</code> method will be invoked
- * <em>before</em> the peekable iterator's <code>next()</code>
- * method is invoked. This is because the "next" element must be
- * pre-loaded for the <code>peek()</code> method.
- * This also prevents a peekable iterator from supporting the optional
- * <code>remove()</code> method.
- */
-
-public class PeekableIterator<E>
- implements Iterator<E>
-{
- private final Iterator<? extends E> nestedIterator;
- private E next;
- private boolean done;
-
-
- /**
- * Construct a peekable iterator that wraps the specified nested
- * iterator.
- */
- public PeekableIterator(Iterator<? extends E> nestedIterator) {
- super();
- this.nestedIterator = nestedIterator;
- this.done = false;
- this.loadNext();
- }
-
- public boolean hasNext() {
- return ! this.done;
- }
-
- public E next() {
- if (this.done) {
- throw new NoSuchElementException();
- }
- E result = this.next;
- this.loadNext();
- return result;
- }
-
- /**
- * Return the element that will be returned by the next call to the
- * <code>next()</code> method, without advancing past it.
- */
- public E peek() {
- if (this.done) {
- throw new NoSuchElementException();
- }
- return this.next;
- }
-
- /**
- * Because we need to pre-load the next element
- * to be returned, we cannot support the <code>remove()</code>
- * method.
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Load next with the next entry from the nested
- * iterator. If there are none, next is set to <code>END</code>.
- */
- private void loadNext() {
- if (this.nestedIterator.hasNext()) {
- this.next = this.nestedIterator.next();
- } else {
- this.next = null;
- this.done = true;
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.nestedIterator);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyCompositeListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyCompositeListIterator.java
deleted file mode 100644
index d13d36e25b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyCompositeListIterator.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>ReadOnlyCompositeListIterator</code> wraps a list
- * of <code>ListIterator</code>s and makes them appear to be a single
- * read-only <code>ListIterator</code>. A read-only composite list
- * iterator is more flexible than a normal composite when it comes to the element types of
- * the nested iterators.
- */
-public class ReadOnlyCompositeListIterator<E>
- implements ListIterator<E>
-{
- private final ListIterator<? extends ListIterator<? extends E>> iterators;
- private ListIterator<? extends E> nextIterator;
- private int nextIndex;
-
-
- /**
- * Construct a read-only list iterator with the specified list of
- * list iterators.
- */
- public ReadOnlyCompositeListIterator(List<? extends ListIterator<? extends E>> iterators) {
- this(iterators.listIterator());
- }
-
- /**
- * Construct a read-only list iterator with the specified list of
- * list iterators.
- */
- public ReadOnlyCompositeListIterator(ListIterator<? extends ListIterator<? extends E>> iterators) {
- super();
- this.iterators = iterators;
- this.nextIndex = 0;
- }
-
- /**
- * Construct a read-only list iterator with the specified object prepended
- * to the specified iterator.
- */
- @SuppressWarnings("unchecked")
- public ReadOnlyCompositeListIterator(E object, ListIterator<? extends E> iterator) {
- this(new SingleElementListIterator<E>(object), iterator);
- }
-
- /**
- * Construct a read-only list iterator with the specified object appended
- * to the specified iterator.
- */
- @SuppressWarnings("unchecked")
- public ReadOnlyCompositeListIterator(ListIterator<? extends E> iterator, E object) {
- this(iterator, new SingleElementListIterator<E>(object));
- }
-
- /**
- * Construct a read-only list iterator with the specified list iterators.
- */
- public ReadOnlyCompositeListIterator(ListIterator<? extends E>... iterators) {
- this(new ArrayListIterator<ListIterator<? extends E>>(iterators));
- }
-
- public boolean hasNext() {
- try {
- this.loadNextIterator();
- } catch (NoSuchElementException ex) {
- // this occurs if there are no iterators at all
- return false;
- }
- return this.nextIterator.hasNext();
- }
-
- public boolean hasPrevious() {
- try {
- this.loadPreviousIterator();
- } catch (NoSuchElementException ex) {
- // this occurs if there are no iterators at all
- return false;
- }
- return this.nextIterator.hasPrevious();
- }
-
- public E next() {
- this.loadNextIterator();
- E result = this.nextIterator.next();
-
- // the statement above will throw a NoSuchElementException
- // if the current iterator is at the end of the line;
- // so if we get here, we can increment 'nextIndex'
- this.nextIndex++;
-
- return result;
- }
-
- public int nextIndex() {
- return this.nextIndex;
- }
-
- public E previous() {
- this.loadPreviousIterator();
- E result = this.nextIterator.previous();
-
- // the statement above will throw a NoSuchElementException
- // if the current iterator is at the end of the line;
- // so if we get here, we can decrement 'nextIndex'
- this.nextIndex--;
-
- return result;
- }
-
- public int previousIndex() {
- return this.nextIndex - 1;
- }
-
- public void add(E o) {
- // the list iterator is read-only
- throw new UnsupportedOperationException();
- }
-
- public void remove() {
- // the list iterator is read-only
- throw new UnsupportedOperationException();
- }
-
- public void set(E e) {
- // the list iterator is read-only
- throw new UnsupportedOperationException();
- }
-
- /**
- * Load nextIterator with the first iterator that <code>hasNext()</code>
- * or the final iterator if all the elements have already been retrieved.
- */
- private void loadNextIterator() {
- this.checkNextIterator();
- while (( ! this.nextIterator.hasNext()) && this.iterators.hasNext()) {
- this.nextIterator = this.iterators.next();
- }
- }
-
- /**
- * Load nextIterator with the first iterator that <code>hasPrevious()</code>
- * or the first iterator if all the elements have already been retrieved.
- */
- private void loadPreviousIterator() {
- this.checkNextIterator();
- while (( ! this.nextIterator.hasPrevious()) && this.iterators.hasPrevious()) {
- this.nextIterator = this.iterators.previous();
- }
- }
-
- /**
- * If 'nextIterator' is null, load it with the first iterator.
- */
- private void checkNextIterator() {
- if (this.nextIterator == null) {
- this.nextIterator = this.iterators.next();
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterators);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyIterator.java
deleted file mode 100644
index df0a51333d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyIterator.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Collection;
-import java.util.Iterator;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>ReadOnlyIterator</code> wraps another <code>Iterator</code>
- * and removes support for #remove().
- */
-public class ReadOnlyIterator<E>
- implements Iterator<E>
-{
- private final Iterator<? extends E> nestedIterator;
-
- /**
- * Construct an iterator on the specified collection that
- * disallows removes.
- */
- public ReadOnlyIterator(Collection<? extends E> c) {
- this(c.iterator());
- }
-
- /**
- * Construct an iterator with the specified nested iterator
- * and disallow removes.
- */
- public ReadOnlyIterator(Iterator<? extends E> nestedIterator) {
- super();
- this.nestedIterator = nestedIterator;
- }
-
- public boolean hasNext() {
- // delegate to the nested iterator
- return this.nestedIterator.hasNext();
- }
-
- public E next() {
- // delegate to the nested iterator
- return this.nestedIterator.next();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.nestedIterator);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyListIterator.java
deleted file mode 100644
index c3b2591f44..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyListIterator.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>ReadOnlyListIterator</code> wraps another
- * <code>ListIterator</code> and removes support for:
- * #remove()
- * #set(Object)
- * #add(Object)
- */
-public class ReadOnlyListIterator<E>
- implements ListIterator<E>
-{
- private final ListIterator<? extends E> nestedListIterator;
-
-
- /**
- * Construct an iterator on the specified list that
- * disallows removes, sets, and adds.
- */
- public ReadOnlyListIterator(List<? extends E> list) {
- this(list.listIterator());
- }
-
- /**
- * Construct an iterator on the specified list iterator that
- * disallows removes, sets, and adds.
- */
- public ReadOnlyListIterator(ListIterator<? extends E> nestedListIterator) {
- super();
- this.nestedListIterator = nestedListIterator;
- }
-
- public boolean hasNext() {
- // delegate to the nested iterator
- return this.nestedListIterator.hasNext();
- }
-
- public E next() {
- // delegate to the nested iterator
- return this.nestedListIterator.next();
- }
-
- public boolean hasPrevious() {
- // delegate to the nested iterator
- return this.nestedListIterator.hasPrevious();
- }
-
- public E previous() {
- // delegate to the nested iterator
- return this.nestedListIterator.previous();
- }
-
- public int nextIndex() {
- // delegate to the nested iterator
- return this.nestedListIterator.nextIndex();
- }
-
- public int previousIndex() {
- // delegate to the nested iterator
- return this.nestedListIterator.previousIndex();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public void set(E o) {
- throw new UnsupportedOperationException();
- }
-
- public void add(E o) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.nestedListIterator);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ResultSetIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ResultSetIterator.java
deleted file mode 100644
index a8da8442ab..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ResultSetIterator.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>ResultSetIterator</code> wraps a <code>ResultSet</code>
- * and transforms its rows for client consumption. Subclasses can override
- * <code>#buildNext(ResultSet)</code> to build the expected object from
- * the current row of the result set.
- * <p>
- * To use, supply:<ul>
- * <li> a <code>ResultSet</code>
- * <li> an <code>Adapter</code> that converts a row in the <code>ResultSet</code>
- * into the desired object
- * (alternatively, subclass <code>ResultSetIterator</code>
- * and override the <code>buildNext(ResultSet)</code> method)
- * </ul>
- * <p>
- */
-public class ResultSetIterator<E>
- implements Iterator<E>
-{
- private final ResultSet resultSet;
- private final Adapter<E> adapter;
- private E next;
- private boolean done;
-
-
- /**
- * Construct an iterator on the specified result set that returns
- * the objects produced by the specified adapter.
- */
- public ResultSetIterator(ResultSet resultSet, Adapter<E> adapter) {
- super();
- this.resultSet = resultSet;
- this.adapter = adapter;
- this.done = false;
- this.next = this.buildNext();
- }
-
- /**
- * Construct an iterator on the specified result set that returns
- * the first object in each row of the result set.
- */
- public ResultSetIterator(ResultSet resultSet) {
- this(resultSet, Adapter.Default.<E>instance());
- }
-
- /**
- * Build the next object for the iterator to return.
- * Close the result set when we reach the end.
- */
- private E buildNext() {
- try {
- if (this.resultSet.next()) {
- return this.buildNext(this.resultSet);
- }
- this.resultSet.close();
- this.done = true;
- return null;
- } catch (SQLException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * By default, return the first object in the current row
- * of the result set. Any <code>SQLException</code>s will
- * be caught and wrapped in a <code>RuntimeException</code>.
- */
- protected E buildNext(ResultSet rs) throws SQLException {
- return this.adapter.buildNext(rs);
- }
-
- public boolean hasNext() {
- return ! this.done;
- }
-
- public E next() {
- if (this.done) {
- throw new NoSuchElementException();
- }
- E temp = this.next;
- this.next = this.buildNext();
- return temp;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.resultSet);
- }
-
-
- // ********** interface **********
-
- /**
- * Used by <code>ResultSetIterator</code> to convert a
- * <code>ResultSet</code>'s current row into the next object
- * to be returned by the <code>Iterator</code>.
- */
- public interface Adapter<T> {
-
- /**
- * Return an object corresponding to the result set's
- * "current" row. Any <code>SQLException</code>s will
- * be caught and wrapped in a <code>RuntimeException</code>.
- * @see java.sql.ResultSet
- */
- T buildNext(ResultSet rs) throws SQLException;
-
-
- final class Default<S> implements Adapter<S> {
- @SuppressWarnings("unchecked")
- public static final Adapter INSTANCE = new Default();
- @SuppressWarnings("unchecked")
- public static <R> Adapter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- // return the first object in the current row of the result set
- @SuppressWarnings("unchecked")
- public S buildNext(ResultSet rs) throws SQLException {
- // result set columns are indexed starting with 1
- return (S) rs.getObject(1);
- }
- @Override
- public String toString() {
- return "ResultSetIterator.Adapter.Default";
- }
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementIterator.java
deleted file mode 100644
index 75fd9d80fd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementIterator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>SingleElementIterator</code> holds a single element
- * and returns it with the first call to <code>next()</code>, at
- * which point it will return <code>false</code> to any subsequent
- * call to <code>hasNext()</code>.
- * <p>
- * A <code>SingleElementIterator</code> is equivalent to the
- * <code>Iterator</code> returned by:
- * <code>java.util.Collections.singleton(element).iterator()</code>
- */
-public class SingleElementIterator<E>
- implements Iterator<E>
-{
- private final E element;
- private boolean done;
-
-
- /**
- * Construct an iterator that returns only the specified element.
- */
- public SingleElementIterator(E element) {
- super();
- this.element = element;
- this.done = false;
- }
-
- public boolean hasNext() {
- return ! this.done;
- }
-
- public E next() {
- if (this.done) {
- throw new NoSuchElementException();
- }
- this.done = true;
- return this.element;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.element);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementListIterator.java
deleted file mode 100644
index 799cb72aef..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementListIterator.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>SingleElementListIterator</code> holds a single element
- * and returns it with the first call to <code>next()</code>, at
- * which point it will return <code>false</code> to any subsequent
- * call to <code>hasNext()</code>. Likewise, it will return <code>false</code>
- * to a call to <code>hasPrevious()</code> until a call to <code>next()</code>,
- * at which point a call to <code>previous()</code> will return the
- * single element.
- * <p>
- * A <code>SingleElementListIterator</code> is equivalent to the
- * <code>Iterator</code> returned by:
- * <code>java.util.Collections.singletonList(element).listIterator()</code>
- */
-public class SingleElementListIterator<E>
- implements ListIterator<E>
-{
- private final E element;
- private boolean hasNext;
-
-
- /**
- * Construct a list iterator that returns only the specified element.
- */
- public SingleElementListIterator(E element) {
- super();
- this.element = element;
- this.hasNext = true;
- }
-
- public boolean hasNext() {
- return this.hasNext;
- }
-
- public E next() {
- if (this.hasNext) {
- this.hasNext = false;
- return this.element;
- }
- throw new NoSuchElementException();
- }
-
- public int nextIndex() {
- return this.hasNext ? 0 : 1;
- }
-
- public boolean hasPrevious() {
- return ! this.hasNext;
- }
-
- public E previous() {
- if (this.hasNext) {
- throw new NoSuchElementException();
- }
- this.hasNext = true;
- return this.element;
- }
-
- public int previousIndex() {
- return this.hasNext ? -1 : 0;
- }
-
- public void add(E e) {
- throw new UnsupportedOperationException();
- }
-
- public void set(E e) {
- throw new UnsupportedOperationException();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.element);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationIterator.java
deleted file mode 100644
index b970d28841..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationIterator.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Iterator;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.Transformer;
-
-
-/**
- * A <code>TransformationIterator</code> wraps another <code>Iterator</code>
- * and transforms its results for client consumption. To use, supply a
- * <code>Transformer</code> or subclass <code>TransformationIterator</code>
- * and override the <code>transform(Object)</code> method.
- * Objects of type E1 are transformed into objects of type E2;
- * i.e. the iterator returns objects of type E2.
- */
-public class TransformationIterator<E1, E2>
- implements Iterator<E2>
-{
- private final Iterator<? extends E1> nestedIterator;
- private final Transformer<E1, ? extends E2> transformer;
-
-
- /**
- * Construct an iterator with the specified nested iterator
- * and a disabled transformer.
- * Use this constructor if you want to override the
- * <code>transform(Object)</code> method instead of building
- * a <code>Transformer</code>.
- */
- public TransformationIterator(Iterator<? extends E1> nestedIterator) {
- this(nestedIterator, Transformer.Disabled.<E1, E2>instance());
- }
-
- /**
- * Construct an iterator with the specified nested iterator
- * and transformer.
- */
- public TransformationIterator(Iterator<? extends E1> nestedIterator, Transformer<E1, ? extends E2> transformer) {
- super();
- this.nestedIterator = nestedIterator;
- this.transformer = transformer;
- }
-
- public boolean hasNext() {
- // delegate to the nested iterator
- return this.nestedIterator.hasNext();
- }
-
- public E2 next() {
- // transform the object returned by the nested iterator before returning it
- return this.transform(this.nestedIterator.next());
- }
-
- public void remove() {
- // delegate to the nested iterator
- this.nestedIterator.remove();
- }
-
- /**
- * Transform the specified object and return the result.
- */
- protected E2 transform(E1 next) {
- return this.transformer.transform(next);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.nestedIterator);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationListIterator.java
deleted file mode 100644
index 087fc11046..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationListIterator.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.Transformer;
-
-/**
- * A <code>TransformationListIterator</code> wraps another <code>ListIterator</code>
- * and transforms its results for client consumption. To use, supply a
- * <code>Transformer</code> or subclass <code>TransformationIterator</code>
- * and override the <code>transform(Object)</code> method.
- *
- * The methods <code>set(Object)</code> and <code>add(Object)</code>
- * are left unsupported in this class.
- */
-public class TransformationListIterator<E1, E2>
- implements ListIterator<E2>
-{
- private final ListIterator<? extends E1> nestedIterator;
- private final Transformer<E1, ? extends E2> transformer;
-
-
- /**
- * Construct an iterator with the specified nested iterator
- * and a disabled transformer.
- * Use this constructor if you want to override the
- * <code>transform(Object)</code> method instead of building
- * a <code>Transformer</code>.
- */
- public TransformationListIterator(ListIterator<? extends E1> nestedIterator) {
- this(nestedIterator, Transformer.Disabled.<E1, E2>instance());
- }
-
- /**
- * Construct an iterator with the specified nested iterator
- * and transformer.
- */
- public TransformationListIterator(ListIterator<? extends E1> nestedIterator, Transformer<E1, ? extends E2> transformer) {
- super();
- this.nestedIterator = nestedIterator;
- this.transformer = transformer;
- }
-
- public boolean hasNext() {
- // delegate to the nested iterator
- return this.nestedIterator.hasNext();
- }
-
- public E2 next() {
- // transform the object returned by the nested iterator before returning it
- return this.transform(this.nestedIterator.next());
- }
-
- public int nextIndex() {
- // delegate to the nested iterator
- return this.nestedIterator.nextIndex();
- }
-
- public boolean hasPrevious() {
- // delegate to the nested iterator
- return this.nestedIterator.hasPrevious();
- }
-
- public E2 previous() {
- // transform the object returned by the nested iterator before returning it
- return this.transform(this.nestedIterator.previous());
- }
-
- public int previousIndex() {
- // delegate to the nested iterator
- return this.nestedIterator.previousIndex();
- }
-
- public void add(E2 o) {
- throw new UnsupportedOperationException();
- }
-
- public void set(E2 o) {
- throw new UnsupportedOperationException();
- }
-
- public void remove() {
- // delegate to the nested iterator
- this.nestedIterator.remove();
- }
-
- /**
- * Transform the specified object and return the result.
- */
- protected E2 transform(E1 next) {
- return this.transformer.transform(next);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.nestedIterator);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TreeIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TreeIterator.java
deleted file mode 100644
index 3d05090b1c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TreeIterator.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.iterators;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * A <code>TreeIterator</code> simplifies the traversal of a
- * tree of objects, where the objects' protocol(s) provides
- * a method for getting the immediate children of the given
- * node but does not provide a method for getting all the
- * descendants (children, grandchildren, etc.) of the given node.
- * <p>
- * To use, supply:<ul>
- * <li> either the root element of the tree or, if the tree has
- * multiple roots, an <code>Iterator</code> over the set of roots
- * <li> a <code>Midwife</code> that delivers the children
- * of each child
- * (alternatively, subclass <code>TreeIterator</code>
- * and override the <code>children(Object)</code> method)
- * </ul>
- * <p>
- */
-public class TreeIterator<E>
- implements Iterator<E>
-{
- private final Collection<Iterator<? extends E>> iterators;
- private final Midwife<E> midwife;
- private Iterator<? extends E> currentIterator;
-
-
- /**
- * Construct an iterator with the specified collection of roots
- * and a disabled midwife.
- * Use this constructor if you want to override the
- * <code>children(Object)</code> method instead of building
- * a <code>Midwife</code>.
- */
- public TreeIterator(Iterator<? extends E> roots) {
- this(roots, Midwife.Disabled.<E>instance());
- }
-
- /**
- * Construct an iterator with the specified root
- * and a disabled midwife.
- * Use this constructor if you want to override the
- * <code>children(Object)</code> method instead of building
- * a <code>Midwife</code>.
- */
- public TreeIterator(E root) {
- this(root, Midwife.Disabled.<E>instance());
- }
-
- /**
- * Construct an iterator with the specified root
- * and midwife.
- */
- public TreeIterator(E root, Midwife<E> midwife) {
- this(new SingleElementIterator<E>(root), midwife);
- }
-
- /**
- * Construct an iterator with the specified roots
- * and midwife.
- */
- public TreeIterator(Iterator<? extends E> roots, Midwife<E> midwife) {
- super();
- this.currentIterator = roots;
- // use a LinkedList since we will be pulling off the front and adding to the end
- this.iterators = new LinkedList<Iterator<? extends E>>();
- this.midwife = midwife;
- }
-
- public boolean hasNext() {
- if (this.currentIterator.hasNext()) {
- return true;
- }
- for (Iterator<? extends E> iterator : this.iterators) {
- if (iterator.hasNext()) {
- return true;
- }
- }
- return false;
- }
-
- public E next() {
- if (this.currentIterator.hasNext()) {
- return this.nextInternal();
- }
- for (Iterator<Iterator<? extends E>> stream = this.iterators.iterator(); stream.hasNext(); ) {
- this.currentIterator = stream.next();
- if (this.currentIterator.hasNext()) {
- break;
- }
- stream.remove();
- }
- return this.nextInternal();
- }
-
- /**
- * Fetch the children of the next node before returning it.
- */
- private E nextInternal() {
- E next = this.currentIterator.next();
- this.iterators.add(this.children(next));
- return next;
- }
-
- public void remove() {
- this.currentIterator.remove();
- }
-
- /**
- * Return the immediate children of the specified object.
- */
- protected Iterator<? extends E> children(E next) {
- return this.midwife.children(next);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.currentIterator);
- }
-
-
- //********** inner classes **********
-
- /**
- * Used by <code>TreeIterator</code> to retrieve
- * the immediate children of a node in the tree.
- */
- public interface Midwife<T> {
-
- /**
- * Return the immediate children of the specified object.
- */
- Iterator<? extends T> children(T o);
-
-
- final class Null<S> implements Midwife<S> {
- @SuppressWarnings("unchecked")
- public static final Midwife INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R> Midwife<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // return no neighbors
- public Iterator<S> children(S next) {
- return EmptyIterator.instance();
- }
- @Override
- public String toString() {
- return "TreeIterator.Midwife.Null";
- }
- }
-
- /** The midwife used when the #children(Object) method is overridden. */
- final class Disabled<S> implements Midwife<S> {
- @SuppressWarnings("unchecked")
- public static final Midwife INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> Midwife<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public Iterator<S> children(S next) {
- throw new UnsupportedOperationException(); // TreeIterator.children(Object) was not implemented
- }
- @Override
- public String toString() {
- return "TreeIterator.Midwife.Disabled";
- }
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/AbstractModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/AbstractModel.java
deleted file mode 100644
index 5aa4d9a886..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/AbstractModel.java
+++ /dev/null
@@ -1,1002 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
-
-/**
- * Convenience implementation of Model protocol.
- */
-public abstract class AbstractModel implements Model, Serializable {
- /**
- * Delegate state/property/collection/list/tree change support to this
- * helper object. The change support object is "lazy-initialized".
- */
- private ChangeSupport changeSupport;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Default constructor.
- * This will call #initialize() on the newly-created instance.
- */
- protected AbstractModel() {
- super();
- this.initialize();
- }
-
- protected void initialize() {
- // do nothing by default
- }
-
- /**
- * This accessor will build the change support when required.
- */
- protected synchronized ChangeSupport getChangeSupport() {
- if (this.changeSupport == null) {
- this.changeSupport = this.buildChangeSupport();
- }
- return this.changeSupport;
- }
-
- /**
- * Allow subclasses to tweak the change support used.
- */
- protected ChangeSupport buildChangeSupport() {
- return new ChangeSupport(this);
- }
-
-
- // ********** state change support **********
-
- public synchronized void addStateChangeListener(StateChangeListener listener) {
- this.getChangeSupport().addStateChangeListener(listener);
- }
-
- public synchronized void removeStateChangeListener(StateChangeListener listener) {
- this.getChangeSupport().removeStateChangeListener(listener);
- }
-
- protected final void fireStateChanged() {
- this.getChangeSupport().fireStateChanged();
- }
-
- protected final void fireStateChanged(StateChangeEvent event) {
- this.getChangeSupport().fireStateChanged(event);
- }
-
-
- // ********** property change support **********
-
- public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
- this.getChangeSupport().addPropertyChangeListener(listener);
- }
-
- public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- this.getChangeSupport().addPropertyChangeListener(propertyName, listener);
- }
-
- public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
- this.getChangeSupport().removePropertyChangeListener(listener);
- }
-
- public synchronized void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- this.getChangeSupport().removePropertyChangeListener(propertyName, listener);
- }
-
- protected final void firePropertyChanged(String propertyName, Object oldValue, Object newValue) {
- this.getChangeSupport().firePropertyChanged(propertyName, oldValue, newValue);
- }
-
- protected final void firePropertyChanged(String propertyName, int oldValue, int newValue) {
- this.getChangeSupport().firePropertyChanged(propertyName, oldValue, newValue);
- }
-
- protected final void firePropertyChanged(String propertyName, boolean oldValue, boolean newValue) {
- this.getChangeSupport().firePropertyChanged(propertyName, oldValue, newValue);
- }
-
- protected final void firePropertyChanged(String propertyName, Object newValue) {
- this.getChangeSupport().firePropertyChanged(propertyName, null, newValue);
- }
-
- protected final void firePropertyChanged(PropertyChangeEvent event) {
- this.getChangeSupport().firePropertyChanged(event);
- }
-
-
- // ********** collection change support **********
-
- public synchronized void addCollectionChangeListener(CollectionChangeListener listener) {
- this.getChangeSupport().addCollectionChangeListener(listener);
- }
-
- public synchronized void addCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- this.getChangeSupport().addCollectionChangeListener(collectionName, listener);
- }
-
- public synchronized void removeCollectionChangeListener(CollectionChangeListener listener) {
- this.getChangeSupport().removeCollectionChangeListener(listener);
- }
-
- public synchronized void removeCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- this.getChangeSupport().removeCollectionChangeListener(collectionName, listener);
- }
-
- protected final void fireItemAdded(String collectionName, Object addedItem) {
- this.getChangeSupport().fireItemAdded(collectionName, addedItem);
- }
-
- protected final void fireItemsAdded(String collectionName, Collection<?> addedItems) {
- this.getChangeSupport().fireItemsAdded(collectionName, addedItems);
- }
-
- protected final void fireItemsAdded(CollectionChangeEvent event) {
- this.getChangeSupport().fireItemsAdded(event);
- }
-
- protected final void fireItemRemoved(String collectionName, Object removedItem) {
- this.getChangeSupport().fireItemRemoved(collectionName, removedItem);
- }
-
- protected final void fireItemsRemoved(String collectionName, Collection<?> removedItems) {
- this.getChangeSupport().fireItemsRemoved(collectionName, removedItems);
- }
-
- protected final void fireItemsRemoved(CollectionChangeEvent event) {
- this.getChangeSupport().fireItemsRemoved(event);
- }
-
- protected final void fireCollectionCleared(String collectionName) {
- this.getChangeSupport().fireCollectionCleared(collectionName);
- }
-
- protected final void fireCollectionCleared(CollectionChangeEvent event) {
- this.getChangeSupport().fireCollectionCleared(event);
- }
-
- protected final void fireCollectionChanged(String collectionName) {
- this.getChangeSupport().fireCollectionChanged(collectionName);
- }
-
- protected final void fireCollectionChanged(CollectionChangeEvent event) {
- this.getChangeSupport().fireCollectionChanged(event);
- }
-
- /**
- * Convenience method.
- * Add the specified item to the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see java.util.Collection#add(Object)
- */
- protected <E> boolean addItemToCollection(E item, Collection<E> collection, String collectionName) {
- if (collection.add(item)) {
- this.fireItemAdded(collectionName, item);
- return true;
- }
- return false;
- }
-
- /**
- * Convenience method.
- * Add the specified items to the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether collection changed.
- * @see java.util.Collection#addAll(java.util.Collection)
- */
- protected <E> boolean addItemsToCollection(E[] items, Collection<E> collection, String collectionName) {
- return this.addItemsToCollection(new ArrayIterator<E>(items), collection, collectionName);
- }
-
- /**
- * Convenience method.
- * Add the specified items to the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether collection changed.
- * @see java.util.Collection#addAll(java.util.Collection)
- */
- protected <E> boolean addItemsToCollection(Iterable<? extends E> items, Collection<E> collection, String collectionName) {
- return this.addItemsToCollection(items.iterator(), collection, collectionName);
- }
-
- /**
- * Convenience method.
- * Add the specified items to the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether collection changed.
- * @see java.util.Collection#addAll(java.util.Collection)
- */
- protected <E> boolean addItemsToCollection(Iterator<? extends E> items, Collection<E> collection, String collectionName) {
- Collection<E> addedItems = null;
- while (items.hasNext()) {
- E item = items.next();
- if (collection.add(item)) {
- if (addedItems == null) {
- addedItems = new ArrayList<E>();
- }
- addedItems.add(item);
- }
- }
- if (addedItems != null) {
- this.fireItemsAdded(collectionName, addedItems);
- return true;
- }
- return false;
- }
-
- /**
- * Convenience method.
- * Remove the specified item from the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see java.util.Collection#remove(Object)
- */
- protected boolean removeItemFromCollection(Object item, Collection<?> collection, String collectionName) {
- if (collection.remove(item)) {
- this.fireItemRemoved(collectionName, item);
- return true;
- }
- return false;
- }
-
- /**
- * Convenience method.
- * Remove the specified items from the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see java.util.Collection#removeAll(java.util.Collection)
- */
- protected boolean removeItemsFromCollection(Object[] items, Collection<?> collection, String collectionName) {
- return this.removeItemsFromCollection(new ArrayIterator<Object>(items), collection, collectionName);
- }
-
- /**
- * Convenience method.
- * Remove the specified items from the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see java.util.Collection#removeAll(java.util.Collection)
- */
- protected boolean removeItemsFromCollection(Iterable<?> items, Collection<?> collection, String collectionName) {
- return this.removeItemsFromCollection(items.iterator(), collection, collectionName);
- }
-
- /**
- * Convenience method.
- * Remove the specified items from the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see java.util.Collection#removeAll(java.util.Collection)
- */
- protected boolean removeItemsFromCollection(Iterator<?> items, Collection<?> collection, String collectionName) {
- Collection<?> items2 = CollectionTools.collection(items);
- items2.retainAll(collection);
- boolean changed = collection.removeAll(items2);
-
- if ( ! items2.isEmpty()) {
- this.fireItemsRemoved(collectionName, items2);
- }
- return changed;
- }
-
- /**
- * Convenience method.
- * Retain the specified items in the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see java.util.Collection#retainAll(java.util.Collection)
- */
- protected boolean retainItemsInCollection(Object[] items, Collection<?> collection, String collectionName) {
- return this.retainItemsInCollection(new ArrayIterator<Object>(items), collection, collectionName);
- }
-
- /**
- * Convenience method.
- * Retain the specified items in the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see java.util.Collection#retainAll(java.util.Collection)
- */
- protected boolean retainItemsInCollection(Iterable<?> items, Collection<?> collection, String collectionName) {
- return this.retainItemsInCollection(items.iterator(), collection, collectionName);
- }
-
- /**
- * Convenience method.
- * Retain the specified items in the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see java.util.Collection#retainAll(java.util.Collection)
- */
- protected boolean retainItemsInCollection(Iterator<?> items, Collection<?> collection, String collectionName) {
- Collection<?> items2 = CollectionTools.collection(items);
- Collection<?> removedItems = CollectionTools.collection(collection);
- removedItems.removeAll(items2);
- boolean changed = collection.retainAll(items2);
-
- if ( ! removedItems.isEmpty()) {
- this.fireItemsRemoved(collectionName, removedItems);
- }
- return changed;
- }
-
- /**
- * Convenience method.
- * Clear the entire collection
- * and fire the appropriate event if necessary.
- * Return whether the list changed.
- * @see java.util.Collection#clear()
- */
- protected boolean clearCollection(Collection<?> collection, String collectionName) {
- if (collection.isEmpty()) {
- return false;
- }
- collection.clear();
- this.fireCollectionCleared(collectionName);
- return true;
- }
-
- /**
- * Convenience method.
- * Synchronize the collection with the specified new collection,
- * making a minimum number of removes and adds.
- * Return whether the collection changed.
- */
- protected <E> boolean synchronizeCollection(Collection<E> newCollection, Collection<E> collection, String collectionName) {
- if (newCollection.isEmpty()) {
- return this.clearCollection(collection, collectionName);
- }
-
- if (collection.isEmpty()) {
- return this.addItemsToCollection(newCollection, collection, collectionName);
- }
-
- boolean changed = false;
- Collection<E> removeItems = new HashBag<E>(collection);
- removeItems.removeAll(newCollection);
- changed |= this.removeItemsFromCollection(removeItems, collection, collectionName);
-
- Collection<E> addItems = new HashBag<E>(newCollection);
- addItems.removeAll(collection);
- changed |= this.addItemsToCollection(addItems, collection, collectionName);
-
- return changed;
- }
-
- /**
- * Convenience method.
- * Synchronize the collection with the specified new collection,
- * making a minimum number of removes and adds.
- * Return whether the collection changed.
- */
- protected <E> boolean synchronizeCollection(Iterator<E> newItems, Collection<E> collection, String collectionName) {
- return this.synchronizeCollection(CollectionTools.collection(newItems), collection, collectionName);
- }
-
-
- // ********** list change support **********
-
- public synchronized void addListChangeListener(ListChangeListener listener) {
- this.getChangeSupport().addListChangeListener(listener);
- }
-
- public synchronized void addListChangeListener(String listName, ListChangeListener listener) {
- this.getChangeSupport().addListChangeListener(listName, listener);
- }
-
- public synchronized void removeListChangeListener(ListChangeListener listener) {
- this.getChangeSupport().removeListChangeListener(listener);
- }
-
- public synchronized void removeListChangeListener(String listName, ListChangeListener listener) {
- this.getChangeSupport().removeListChangeListener(listName, listener);
- }
-
- protected final void fireItemAdded(String listName, int index, Object addedItem) {
- this.getChangeSupport().fireItemAdded(listName, index, addedItem);
- }
-
- protected final void fireItemsAdded(String listName, int index, List<?> addedItems) {
- this.getChangeSupport().fireItemsAdded(listName, index, addedItems);
- }
-
- protected final void fireItemsAdded(ListChangeEvent event) {
- this.getChangeSupport().fireItemsAdded(event);
- }
-
- protected final void fireItemRemoved(String listName, int index, Object removedItem) {
- this.getChangeSupport().fireItemRemoved(listName, index, removedItem);
- }
-
- protected final void fireItemsRemoved(String listName, int index, List<?> removedItems) {
- this.getChangeSupport().fireItemsRemoved(listName, index, removedItems);
- }
-
- protected final void fireItemsRemoved(ListChangeEvent event) {
- this.getChangeSupport().fireItemsRemoved(event);
- }
-
- protected final void fireItemReplaced(String listName, int index, Object newItem, Object replacedItem) {
- this.getChangeSupport().fireItemReplaced(listName, index, newItem, replacedItem);
- }
-
- protected final <E> void fireItemsReplaced(String listName, int index, List<? extends E> newItems, List<E> replacedItems) {
- this.getChangeSupport().fireItemsReplaced(listName, index, newItems, replacedItems);
- }
-
- protected final void fireItemsReplaced(ListChangeEvent event) {
- this.getChangeSupport().fireItemsReplaced(event);
- }
-
- protected final void fireItemMoved(String listName, int targetIndex, int sourceIndex) {
- this.getChangeSupport().fireItemMoved(listName, targetIndex, sourceIndex);
- }
-
- protected final <E> void fireItemsMoved(String listName, int targetIndex, int sourceIndex, int length) {
- this.getChangeSupport().fireItemsMoved(listName, targetIndex, sourceIndex, length);
- }
-
- protected final void fireItemsMoved(ListChangeEvent event) {
- this.getChangeSupport().fireItemsMoved(event);
- }
-
- protected final void fireListCleared(String listName) {
- this.getChangeSupport().fireListCleared(listName);
- }
-
- protected final void fireListCleared(ListChangeEvent event) {
- this.getChangeSupport().fireListCleared(event);
- }
-
- protected final void fireListChanged(String listName) {
- this.getChangeSupport().fireListChanged(listName);
- }
-
- protected final void fireListChanged(ListChangeEvent event) {
- this.getChangeSupport().fireListChanged(event);
- }
-
- /**
- * Convenience method.
- * Add the specified item to the specified bound list
- * and fire the appropriate event if necessary.
- * @see java.util.List#add(int, Object)
- */
- protected <E> void addItemToList(int index, E item, List<E> list, String listName) {
- list.add(index, item);
- this.fireItemAdded(listName, index, item);
- }
-
- /**
- * Convenience method.
- * Add the specified item to the end of the specified bound list
- * and fire the appropriate event if necessary.
- * Return whether list changed.
- * @see java.util.List#add(Object)
- */
- protected <E> boolean addItemToList(E item, List<E> list, String listName) {
- if (list.add(item)) {
- this.fireItemAdded(listName, list.size() - 1, item);
- return true;
- }
- return false;
- }
-
- /**
- * Convenience method.
- * Add the specified items to the specified bound list
- * and fire the appropriate event if necessary.
- * @see java.util.List#addAll(int, java.util.Collection)
- */
- protected <E> boolean addItemsToList(int index, E[] items, List<E> list, String listName) {
- return this.addItemsToList(index, new ArrayIterator<E>(items), list, listName);
- }
-
- /**
- * Convenience method.
- * Add the specified items to the specified bound list
- * and fire the appropriate event if necessary.
- * @see java.util.List#addAll(int, java.util.Collection)
- */
- protected <E> boolean addItemsToList(int index, Iterable<? extends E> items, List<E> list, String listName) {
- return this.addItemsToList(index, items.iterator(), list, listName);
- }
-
- /**
- * Convenience method.
- * Add the specified items to the specified bound list
- * and fire the appropriate event if necessary.
- * @see java.util.List#addAll(int, java.util.Collection)
- */
- protected <E> boolean addItemsToList(int index, Iterator<? extends E> items, List<E> list, String listName) {
- List<E> items2 = CollectionTools.list(items);
- if (list.addAll(index, items2)) {
- this.fireItemsAdded(listName, index, items2);
- return true;
- }
- return false;
- }
-
- /**
- * Convenience method.
- * Add the specified items to the end of to the specified bound list
- * and fire the appropriate event if necessary.
- * @see java.util.List#addAll(java.util.Collection)
- */
- protected <E> boolean addItemsToList(E[] items, List<E> list, String listName) {
- return this.addItemsToList(new ArrayIterator<E>(items), list, listName);
- }
-
- /**
- * Convenience method.
- * Add the specified items to the end of to the specified bound list
- * and fire the appropriate event if necessary.
- * @see java.util.List#addAll(java.util.Collection)
- */
- protected <E> boolean addItemsToList(Iterable<? extends E> items, List<E> list, String listName) {
- return this.addItemsToList(items.iterator(), list, listName);
- }
-
- /**
- * Convenience method.
- * Add the specified items to the end of to the specified bound list
- * and fire the appropriate event if necessary.
- * @see java.util.List#addAll(java.util.Collection)
- */
- protected <E> boolean addItemsToList(Iterator<? extends E> items, List<E> list, String listName) {
- List<E> items2 = CollectionTools.list(items);
- int index = list.size();
- if (list.addAll(items2)) {
- this.fireItemsAdded(listName, index, items2);
- return true;
- }
- return false; // empty list of items added
- }
-
- /**
- * Convenience method.
- * Remove the specified item from the specified bound list
- * and fire the appropriate event if necessary.
- * Return the removed item.
- * @see java.util.List#remove(int)
- */
- protected <E> E removeItemFromList(int index, List<E> list, String listName) {
- E item = list.remove(index);
- this.fireItemRemoved(listName, index, item);
- return item;
- }
-
- /**
- * Convenience method.
- * Remove the specified item from the specified bound list
- * and fire the appropriate event if necessary.
- * Return the removed item.
- * @see java.util.List#remove(Object)
- */
- protected boolean removeItemFromList(Object item, List<?> list, String listName) {
- int index = list.indexOf(item);
- if (index == -1) {
- return false;
- }
- list.remove(index);
- this.fireItemRemoved(listName, index, item);
- return true;
- }
-
- /**
- * Convenience method.
- * Remove the specified items from the specified bound list
- * and fire the appropriate event if necessary.
- * Return the removed items.
- * @see java.util.List#remove(int)
- */
- protected <E> List<E> removeItemsFromList(int index, int length, List<E> list, String listName) {
- List<E> subList = list.subList(index, index + length);
- List<E> removedItems = new ArrayList<E>(subList);
- subList.clear();
- this.fireItemsRemoved(listName, index, removedItems);
- return removedItems;
- }
-
- /**
- * Convenience method.
- * Remove the specified items from the specified bound list
- * and fire the appropriate event if necessary.
- * Return the removed items.
- * @see java.util.List#removeAll(java.util.Collection)
- */
- protected boolean removeItemsFromList(Object[] items, List<?> list, String listName) {
- return this.removeItemsFromList(new ArrayIterator<Object>(items), list, listName);
- }
-
- /**
- * Convenience method.
- * Remove the specified items from the specified bound list
- * and fire the appropriate event if necessary.
- * Return the removed items.
- * @see java.util.List#removeAll(java.util.Collection)
- */
- protected boolean removeItemsFromList(Iterable<?> items, List<?> list, String listName) {
- return this.removeItemsFromList(items.iterator(), list, listName);
- }
-
- /**
- * Convenience method.
- * Remove the specified items from the specified bound list
- * and fire the appropriate event if necessary.
- * Return the removed items.
- * @see java.util.List#removeAll(java.util.Collection)
- */
- protected boolean removeItemsFromList(Iterator<?> items, List<?> list, String listName) {
- boolean changed = false;
- while (items.hasNext()) {
- changed |= this.removeItemFromList(items.next(), list, listName);
- }
- return changed;
- }
-
- /**
- * Convenience method.
- * Retain the specified items in the specified bound list
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see java.util.List#retainAll(java.util.Collection)
- */
- protected boolean retainItemsInList(Object[] items, List<?> list, String listName) {
- return this.retainItemsInList(new ArrayIterator<Object>(items), list, listName);
- }
-
- /**
- * Convenience method.
- * Retain the specified items in the specified bound list
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see java.util.List#retainAll(java.util.Collection)
- */
- protected boolean retainItemsInList(Iterable<?> items, List<?> list, String listName) {
- return this.retainItemsInList(items.iterator(), list, listName);
- }
-
- /**
- * Convenience method.
- * Retain the specified items in the specified bound list
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see java.util.List#retainAll(java.util.Collection)
- */
- protected boolean retainItemsInList(Iterator<?> items, List<?> list, String listName) {
- Collection<?> items2 = CollectionTools.collection(items);
- Collection<?> removedItems = CollectionTools.collection(list);
- removedItems.removeAll(items2);
- return this.removeItemsFromList(removedItems, list, listName);
- }
-
- /**
- * Convenience method.
- * Set the specified item in the specified bound list
- * and fire the appropriate event if necessary.
- * Return the replaced item.
- * @see java.util.List#set(int, Object)
- */
- protected <E> E setItemInList(int index, E item, List<E> list, String listName) {
- E replacedItem = list.set(index, item);
- this.fireItemReplaced(listName, index, item, replacedItem);
- return replacedItem;
- }
-
- /**
- * Convenience method.
- * Replace the specified item in the specified bound list
- * and fire the appropriate event if necessary.
- * Return the replaced item.
- * @see java.util.List#set(int, Object)
- */
- protected <E> E replaceItemInList(E oldItem, E newItem, List<E> list, String listName) {
- return this.setItemInList(list.indexOf(oldItem), newItem, list, listName);
- }
-
- /**
- * Convenience method.
- * Set the specified items in the specified bound list
- * and fire the appropriate event if necessary.
- * Return the replaced items.
- * @see java.util.List#set(int, Object)
- */
- protected <E> List<E> setItemsInList(int index, E[] items, List<E> list, String listName) {
- return this.setItemsInList(index, Arrays.asList(items), list, listName);
- }
-
- /**
- * Convenience method.
- * Set the specified items in the specified bound list
- * and fire the appropriate event if necessary.
- * Return the replaced items.
- * @see java.util.List#set(int, Object)
- */
- protected <E> List<E> setItemsInList(int index, List<? extends E> items, List<E> list, String listName) {
- List<E> subList = list.subList(index, index + items.size());
- List<E> replacedItems = new ArrayList<E>(subList);
- for (int i = 0; i < items.size(); i++) {
- subList.set(i, items.get(i));
- }
- this.fireItemsReplaced(listName, index, items, replacedItems);
- return replacedItems;
- }
-
- /**
- * Convenience method.
- * Move items in the specified list from the specified source index to the
- * specified target index for the specified length.
- */
- protected <E> void moveItemsInList(int targetIndex, int sourceIndex, int length, List<E> list, String listName) {
- CollectionTools.move(list, targetIndex, sourceIndex, length);
- this.fireItemsMoved(listName, targetIndex, sourceIndex, length);
- }
-
- /**
- * Convenience method.
- * Move an item in the specified list from the specified source index to the
- * specified target index.
- */
- protected <E> void moveItemInList(int targetIndex, int sourceIndex, List<E> list, String listName) {
- CollectionTools.move(list, targetIndex, sourceIndex);
- this.fireItemMoved(listName, targetIndex, sourceIndex);
- }
-
- /**
- * Convenience method.
- * Clear the entire list
- * and fire the appropriate event if necessary.
- * Return whether the list changed.
- * @see java.util.List#clear()
- */
- protected boolean clearList(List<?> list, String listName) {
- if (list.isEmpty()) {
- return false;
- }
- list.clear();
- this.fireListCleared(listName);
- return true;
- }
-
-
- // ********** tree change support **********
-
- public synchronized void addTreeChangeListener(TreeChangeListener listener) {
- this.getChangeSupport().addTreeChangeListener(listener);
- }
-
- public synchronized void addTreeChangeListener(String treeName, TreeChangeListener listener) {
- this.getChangeSupport().addTreeChangeListener(treeName, listener);
- }
-
- public synchronized void removeTreeChangeListener(TreeChangeListener listener) {
- this.getChangeSupport().removeTreeChangeListener(listener);
- }
-
- public synchronized void removeTreeChangeListener(String treeName, TreeChangeListener listener) {
- this.getChangeSupport().removeTreeChangeListener(treeName, listener);
- }
-
- protected final void fireNodeAdded(String treeName, Object[] path) {
- this.getChangeSupport().fireNodeAdded(treeName, path);
- }
-
- protected final void fireNodeAdded(TreeChangeEvent event) {
- this.getChangeSupport().fireNodeAdded(event);
- }
-
- protected final void fireNodeRemoved(String treeName, Object[] path) {
- this.getChangeSupport().fireNodeRemoved(treeName, path);
- }
-
- protected final void fireNodeRemoved(TreeChangeEvent event) {
- this.getChangeSupport().fireNodeRemoved(event);
- }
-
- protected final void fireTreeCleared(String treeName) {
- this.getChangeSupport().fireTreeCleared(treeName);
- }
-
- protected final void fireTreeCleared(TreeChangeEvent event) {
- this.getChangeSupport().fireTreeCleared(event);
- }
-
- protected final void fireTreeChanged(String treeName) {
- this.getChangeSupport().fireTreeChanged(treeName);
- }
-
- protected final void fireTreeChanged(String treeName, Object[] path) {
- this.getChangeSupport().fireTreeChanged(treeName, path);
- }
-
- protected final void fireTreeChanged(TreeChangeEvent event) {
- this.getChangeSupport().fireTreeChanged(event);
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether there are any state change listeners.
- */
- public boolean hasAnyStateChangeListeners() {
- return this.getChangeSupport().hasAnyStateChangeListeners();
- }
-
- /**
- * Return whether there are no state change listeners.
- */
- public boolean hasNoStateChangeListeners() {
- return ! this.hasAnyStateChangeListeners();
- }
-
- /**
- * Return whether there are any property change listeners for a specific property.
- */
- public boolean hasAnyPropertyChangeListeners(String propertyName) {
- return this.getChangeSupport().hasAnyPropertyChangeListeners(propertyName);
- }
-
- /**
- * Return whether there are any property change listeners for a specific property.
- */
- public boolean hasNoPropertyChangeListeners(String propertyName) {
- return ! this.hasAnyPropertyChangeListeners(propertyName);
- }
-
- /**
- * Return whether there are any collection change listeners for a specific collection.
- */
- public boolean hasAnyCollectionChangeListeners(String collectionName) {
- return this.getChangeSupport().hasAnyCollectionChangeListeners(collectionName);
- }
-
- /**
- * Return whether there are any collection change listeners for a specific collection.
- */
- public boolean hasNoCollectionChangeListeners(String collectionName) {
- return ! this.hasAnyCollectionChangeListeners(collectionName);
- }
-
- /**
- * Return whether there are any list change listeners for a specific list.
- */
- public boolean hasAnyListChangeListeners(String listName) {
- return this.getChangeSupport().hasAnyListChangeListeners(listName);
- }
-
- /**
- * Return whether there are any list change listeners for a specific list.
- */
- public boolean hasNoListChangeListeners(String listName) {
- return ! this.hasAnyListChangeListeners(listName);
- }
-
- /**
- * Return whether there are any tree change listeners for a specific tree.
- */
- public boolean hasAnyTreeChangeListeners(String treeName) {
- return this.getChangeSupport().hasAnyTreeChangeListeners(treeName);
- }
-
- /**
- * Return whether there are any tree change listeners for a specific tree.
- */
- public boolean hasNoTreeChangeListeners(String treeName) {
- return ! this.hasAnyTreeChangeListeners(treeName);
- }
-
-
- // ********** convenience methods **********
-
- /**
- * Return whether the values are equal, with the appropriate null checks.
- * Convenience method for checking whether an attribute value has changed.
- *
- * DO NOT use this to determine whether to fire a change notification,
- * ChangeSupport already does that.
- */
- protected final boolean valuesAreEqual(Object value1, Object value2) {
- return this.getChangeSupport().valuesAreEqual(value1, value2);
- }
- protected final boolean attributeValueHasNotChanged(Object oldValue, Object newValue) {
- return this.valuesAreEqual(oldValue, newValue);
- }
-
-
- /**
- * Return whether the values are different, with the appropriate null checks.
- * Convenience method for checking whether an attribute value has changed.
- *
- * DO NOT use this to determine whether to fire a change notification,
- * ChangeSupport already does that.
- *
- * For example, after firing the change notification, you can use this method
- * to decide if some other, related, piece of state needs to be synchronized
- * with the state that just changed.
- */
- protected final boolean valuesAreDifferent(Object value1, Object value2) {
- return this.getChangeSupport().valuesAreDifferent(value1, value2);
- }
- protected final boolean attributeValueHasChanged(Object oldValue, Object newValue) {
- return this.valuesAreDifferent(oldValue, newValue);
- }
-
-
- // ********** Object overrides **********
-
- /**
- * Although cloning models is usually not a Good Idea,
- * we should at least support it properly.
- */
- @Override
- protected AbstractModel clone() throws CloneNotSupportedException {
- AbstractModel clone = (AbstractModel) super.clone();
- clone.postClone();
- return clone;
- }
-
- /**
- * Perform any post-clone processing necessary to
- * successfully disconnect the clone from the original.
- * When this method is called on the clone, the clone
- * is a "shallow" copy of the original (i.e. the clone
- * shares all its instance variables with the original).
- */
- protected void postClone() {
- // clear out change support - models do not share listeners
- this.changeSupport = null;
- // when you override this method, don't forget to include:
- // super.postClone();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- StringTools.buildSimpleToStringOn(this, sb);
- sb.append(" (");
- this.toString(sb);
- sb.append(')');
- return sb.toString();
- }
-
- /**
- * make this public so one model can call a nested model's
- * #toString(StringBuilder)
- */
- public void toString(StringBuilder sb) {
- // subclasses should override this to do something a bit more helpful
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/CallbackChangeSupport.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/CallbackChangeSupport.java
deleted file mode 100644
index 076f17fe1a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/CallbackChangeSupport.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model;
-
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * This change support class will notify the source when one of the source's
- * aspects has changed.
- */
-public class CallbackChangeSupport extends ChangeSupport {
- private static final long serialVersionUID = 1L;
-
- public CallbackChangeSupport(Source source) {
- super(source);
- }
-
- protected Source source() {
- return (Source) this.source;
- }
-
- @Override
- protected ChangeSupport buildChildChangeSupport() {
- return new Child(this.source());
- }
-
- @Override
- protected void sourceChanged(String aspectName) {
- super.sourceChanged(aspectName);
- this.source().aspectChanged(aspectName);
- }
-
-
- // ********** child chang support **********
-
- /**
- * The aspect-specific change support class does not need to
- * notify the source node of changes (the parent will take care of that);
- * nor does it need to build "grandchildren" change support objects.
- */
- protected static class Child extends ChangeSupport {
- private static final long serialVersionUID = 1L;
-
- public Child(Source source) {
- super(source);
- }
-
- protected Source source() {
- return (Source) this.source;
- }
-
- @Override
- protected ChangeSupport buildChildChangeSupport() {
- // there are no grandchildren
- throw new UnsupportedOperationException();
- }
-
- }
-
-
- // ********** source interface **********
-
- /**
- * The callback change support source must implement this interface so it
- * can be notified of any aspect changes.
- */
- public interface Source extends Model {
-
- /**
- * The specified aspect changed.
- */
- void aspectChanged(String aspectName);
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java
deleted file mode 100644
index 88748ae149..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java
+++ /dev/null
@@ -1,2363 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.reflect.Array;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
-
-/**
- * Support object that can be used by implementors of the Model interface.
- * It provides for state, property, collection, list, and tree change notifications to
- * listeners.
- *
- * NB: There is lots of copy-n-paste code in this class. Nearly all of this duplication
- * is an effort to prevent the unnecessary creation of new objects (typically event
- * objects). Since many events are fired when there are no listeners, we postpone
- * the creation of event objects until we know we have interested listeners.
- * Most methods have the "non-duplicated" version of the method body commented
- * out at the top of the current method body.
- * The hope was that this class would prove to be fairly static and the duplicated
- * code would not prove onerous; but that has not proven to be
- * the case, as we have added support for "state" changes, "dirty" notification,
- * and custom "notifiers", with more to come, I'm sure.... ~bjv
- *
- * NB2: This class will check to see if, during the firing of events, a listener
- * on the original, cloned, list of listeners has been removed from the master
- * list of listeners *before* it is notified. If the listener has been removed
- * "concurrently" it will *not* be notified. (See the code that uses the
- * 'stillListening' local boolean flag.)
- *
- * NB3: Any listener that is added during the firing of events will *not* be
- * also notified.
- *
- * NB4: This class is serializable, but it will only write out listeners that
- * are also serializable while silently leaving behind listeners that are not.
- *
- * TODO fire a state change event with *every* change?
- * TODO use objects (IDs?) instead of strings to identify aspects?
- */
-public class ChangeSupport
- implements Serializable
-{
-
- /** The object to be provided as the "source" for any generated events. */
- protected final Model source;
-
- /** Associate a listener class to a collection of "generic" listeners for that class. */
- transient private GenericListenerList[] genericListeners = EMPTY_GENERIC_LISTENERS;
- private static final GenericListenerList[] EMPTY_GENERIC_LISTENERS = new GenericListenerList[0];
-
- /** Associate aspect names to child change support objects. */
- private AspectChild[] aspectChildren = EMPTY_ASPECT_CHILDREN;
- private static final AspectChild[] EMPTY_ASPECT_CHILDREN = new AspectChild[0];
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructor **********
-
- /**
- * Construct support for the specified source of change events.
- * The source cannot be null.
- */
- public ChangeSupport(Model source) {
- super();
- if (source == null) {
- throw new NullPointerException();
- }
- this.source = source;
- }
-
-
- // ********** internal behavior **********
-
- /**
- * Add a "generic" listener that listens to all events appropriate to that
- * listener, regardless of the aspect name associated with that event.
- * The listener cannot be null.
- */
- protected <T extends ChangeListener> void addListener(Class<T> listenerClass, T listener) {
- if (listener == null) {
- throw new NullPointerException(); // better sooner than later
- }
- synchronized (this) {
- GenericListenerList gll = this.genericListenerList(listenerClass);
- if (gll == null) {
- this.addGenericListenerList(listenerClass, listener);
- } else {
- gll.addListener(listener);
- }
- }
- }
-
- /**
- * Return the "generic" listener list for the specified listener class.
- * Return null if the list is not present.
- */
- protected GenericListenerList genericListenerList(Class<? extends ChangeListener> listenerClass) {
- for (GenericListenerList gll : this.genericListeners) {
- if (gll.listenerClass == listenerClass) {
- return gll;
- }
- }
- return null;
- }
-
- /**
- * Add the "generic" listener list for the specified listener class.
- * Return the newly-built generic listener list.
- */
- protected <T extends ChangeListener> GenericListenerList addGenericListenerList(Class<T> listenerClass, T listener) {
- GenericListenerList gll = new GenericListenerList(listenerClass, listener);
- this.genericListeners = CollectionTools.add(this.genericListeners, gll);
- return gll;
- }
-
- /**
- * Adds a listener that listens to all events appropriate to that listener,
- * and only to those events carrying the aspect name specified.
- * The aspect name cannot be null and the listener cannot be null.
- */
- protected <T extends ChangeListener> void addListener(String aspectName, Class<T> listenerClass, T listener) {
- if ((aspectName == null) || (listener == null)) {
- throw new NullPointerException(); // better sooner than later
- }
- synchronized (this) {
- ChangeSupport child = this.child(aspectName);
- if (child == null) {
- child = this.addChild(aspectName);
- }
- child.addListener(listenerClass, listener);
- }
- }
-
- /**
- * Return the child change support for the specified aspect name.
- * Return null if the aspect name is null or the child is not present.
- */
- protected ChangeSupport child(String aspectName) {
- // put in a null check to simplify calling code
- if (aspectName == null) {
- return null;
- }
- for (AspectChild aspectChild : this.aspectChildren) {
- if (aspectChild.aspectName == aspectName) {
- return aspectChild.child;
- }
- }
- return null;
- }
-
- /**
- * Add the child change support for the specified aspect name.
- * Return the newly-built child change support.
- */
- protected ChangeSupport addChild(String aspectName) {
- ChangeSupport child = this.buildChildChangeSupport();
- this.aspectChildren = CollectionTools.add(this.aspectChildren, new AspectChild(aspectName, child));
- return child;
- }
-
- /**
- * Build and return a child change support to hold aspect-specific listeners.
- */
- protected ChangeSupport buildChildChangeSupport() {
- return new ChangeSupport(this.source);
- }
-
- /**
- * Removes a "generic" listener that has been registered for all events
- * appropriate to that listener.
- */
- protected <T extends ChangeListener> void removeListener(Class<T> listenerClass, T listener) {
- synchronized (this) {
- GenericListenerList gll = this.genericListenerList(listenerClass);
- if (gll == null) {
- throw new IllegalArgumentException("listener not registered");
- }
- if ( ! gll.removeListener(listener)) { // leave the GLL, even if it is empty?
- throw new IllegalArgumentException("listener not registered");
- }
- }
- }
-
- /**
- * Removes a listener that has been registered for appropriate
- * events carrying the specified aspect name.
- */
- protected <T extends ChangeListener> void removeListener(String aspectName, Class<T> listenerClass, T listener) {
- synchronized (this) {
- ChangeSupport child = this.child(aspectName);
- if (child == null) {
- throw new IllegalArgumentException("listener not registered");
- }
- child.removeListener(listenerClass, listener); // leave the child, even if it is empty?
- }
- }
-
-
- // ********** internal queries **********
-
- /**
- * Return the "generic" listeners for the specified listener class.
- * Return null if there are no listeners.
- */
- protected ChangeListener[] listeners(Class<? extends ChangeListener> listenerClass) {
- GenericListenerList gll = this.genericListenerList(listenerClass);
- return (gll == null) ? null : gll.listeners;
- }
-
- /**
- * Return whether there are any "generic" listeners for the specified
- * listener class.
- */
- protected synchronized <T extends ChangeListener> boolean hasAnyListeners(Class<T> listenerClass) {
- GenericListenerList gll = this.genericListenerList(listenerClass);
- return (gll != null) && gll.hasListeners();
- }
-
- /**
- * Return whether there are no "generic" listeners for the specified
- * listener class.
- */
- protected <T extends ChangeListener> boolean hasNoListeners(Class<T> listenerClass) {
- return ! this.hasAnyListeners(listenerClass);
- }
-
- /**
- * Return whether there are any listeners for the specified
- * listener class and aspect name.
- */
- protected synchronized boolean hasAnyListeners(Class<? extends ChangeListener> listenerClass, String aspectName) {
- if (this.hasAnyListeners(listenerClass)) {
- return true; // there's a "generic" listener
- }
- ChangeSupport child = this.child(aspectName);
- return (child != null) &&
- child.hasAnyListeners(listenerClass);
- }
-
- /**
- * Return whether there are no "generic" listeners for the specified
- * listener class and aspect name.
- */
- protected <T extends ChangeListener> boolean hasNoListeners(Class<T> listenerClass, String aspectName) {
- return ! this.hasAnyListeners(listenerClass, aspectName);
- }
-
-
- // ********** behavior **********
-
- /**
- * The specified aspect of the source has changed;
- * override this method to perform things like setting a
- * dirty flag or validating the source's state.
- * The aspect ID will be null if a "state change" occurred.
- */
- protected void sourceChanged(String aspectName) {
- // the default is to do nothing
- }
-
-
- // ********** state change support **********
-
- protected static final Class<StateChangeListener> STATE_CHANGE_LISTENER_CLASS = StateChangeListener.class;
-
- /**
- * Add a state change listener.
- */
- public void addStateChangeListener(StateChangeListener listener) {
- this.addListener(STATE_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Remove a state change listener.
- */
- public void removeStateChangeListener(StateChangeListener listener) {
- this.removeListener(STATE_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Return whether there are any state change listeners.
- */
- public boolean hasAnyStateChangeListeners() {
- return this.hasAnyListeners(STATE_CHANGE_LISTENER_CLASS);
- }
-
- private StateChangeListener[] stateChangeListeners() {
- return (StateChangeListener[]) this.listeners(STATE_CHANGE_LISTENER_CLASS);
- }
-
- /**
- * Fire the specified state change event to any registered listeners.
- */
- public void fireStateChanged(StateChangeEvent event) {
-
- StateChangeListener[] targets = null;
-
- synchronized (this) {
- StateChangeListener[] stateChangeListeners = this.stateChangeListeners();
- if (stateChangeListeners != null) {
- targets = stateChangeListeners.clone();
- }
- }
-
- if (targets != null) {
- for (StateChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.stateChangeListeners(), target);
- }
- if (stillListening) {
- target.stateChanged(event);
- }
- }
- }
-
- this.sourceChanged(null);
- }
-
- /**
- * Report a generic state change event to any registered state change
- * listeners.
- */
- public void fireStateChanged() {
-// this.fireStateChange(new StateChangeEvent(this.source));
-
- StateChangeListener[] targets = null;
-
- synchronized (this) {
- StateChangeListener[] stateChangeListeners = this.stateChangeListeners();
- if (stateChangeListeners != null) {
- targets = stateChangeListeners.clone();
- }
- }
-
- if (targets != null) {
- StateChangeEvent event = null;
- for (StateChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.stateChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new StateChangeEvent(this.source);
- }
- target.stateChanged(event);
- }
- }
- }
-
- this.sourceChanged(null);
- }
-
-
- // ********** property change support **********
-
- protected static final Class<PropertyChangeListener> PROPERTY_CHANGE_LISTENER_CLASS = PropertyChangeListener.class;
-
- /**
- * Return whether the values are equal, with the appropriate null checks.
- * Convenience method for checking whether an attribute value has changed.
- */
- public boolean valuesAreEqual(Object value1, Object value2) {
- if ((value1 == null) && (value2 == null)) {
- return true; // both are null
- }
- if ((value1 == null) || (value2 == null)) {
- return false; // one is null but the other is not
- }
- return value1.equals(value2);
- }
-
- /**
- * Return whether the values are different, with the appropriate null checks.
- * Convenience method for checking whether an attribute value has changed.
- */
- public boolean valuesAreDifferent(Object value1, Object value2) {
- return ! this.valuesAreEqual(value1, value2);
- }
-
- /**
- * Add a property change listener that is registered for all properties.
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- this.addListener(PROPERTY_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Add a property change listener for the specified property. The listener
- * will be notified only for changes to the specified property.
- */
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- this.addListener(propertyName, PROPERTY_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Remove a property change listener that was registered for all properties.
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- this.removeListener(PROPERTY_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Remove a property change listener that was registered for a specific property.
- */
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- this.removeListener(propertyName, PROPERTY_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Return whether there are any property change listeners that will
- * be notified when the specified property has changed.
- */
- public boolean hasAnyPropertyChangeListeners(String propertyName) {
- return this.hasAnyListeners(PROPERTY_CHANGE_LISTENER_CLASS, propertyName);
- }
-
- /**
- * Return whether there are any property change listeners that will
- * be notified when any property has changed.
- */
- public boolean hasAnyPropertyChangeListeners() {
- return this.hasAnyListeners(PROPERTY_CHANGE_LISTENER_CLASS);
- }
-
- private PropertyChangeListener[] propertyChangeListeners() {
- return (PropertyChangeListener[]) this.listeners(PROPERTY_CHANGE_LISTENER_CLASS);
- }
-
- /**
- * Fire the specified property change event to any registered listeners.
- * No event is fired if the given event's old and new values are the same;
- * this includes when both values are null. Use a state change event
- * for general purpose notification of changes.
- */
- public void firePropertyChanged(PropertyChangeEvent event) {
- if (this.valuesAreEqual(event.getOldValue(), event.getNewValue())) {
- return;
- }
-
- String propertyName = event.getPropertyName();
-
- PropertyChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- PropertyChangeListener[] propertyChangeListeners = this.propertyChangeListeners();
- if (propertyChangeListeners != null) {
- targets = propertyChangeListeners.clone();
- }
- child = this.child(propertyName);
- }
-
- if (targets != null) {
- for (PropertyChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.propertyChangeListeners(), target);
- }
- if (stillListening) {
- target.propertyChanged(event);
- }
- }
- }
- if (child != null) {
- child.firePropertyChanged(event);
- }
-
- this.sourceChanged(propertyName);
- }
-
- /**
- * Report a bound property update to any registered property change listeners.
- * No event is fired if the given old and new values are the same;
- * this includes when both values are null. Use a state change event
- * for general purpose notification of changes.
- */
- public void firePropertyChanged(String propertyName, Object oldValue, Object newValue) {
-// this.firePropertyChanged(new PropertyChangeEvent(this.source, propertyName, oldValue, newValue));
- if (this.valuesAreEqual(oldValue, newValue)) {
- return;
- }
-
- PropertyChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- PropertyChangeListener[] propertyChangeListeners = this.propertyChangeListeners();
- if (propertyChangeListeners != null) {
- targets = propertyChangeListeners.clone();
- }
- child = this.child(propertyName);
- }
-
- PropertyChangeEvent event = null;
-
- if (targets != null) {
- for (PropertyChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.propertyChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new PropertyChangeEvent(this.source, propertyName, oldValue, newValue);
- }
- target.propertyChanged(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.firePropertyChanged(propertyName, oldValue, newValue);
- } else {
- child.firePropertyChanged(event);
- }
- }
-
- this.sourceChanged(propertyName);
- }
-
- /**
- * Report an int bound property update to any registered listeners.
- * No event is fired if old and new are equal.
- * <p>
- * This is merely a convenience wrapper around the more general
- * firePropertyChange method that takes Object values.
- */
- public void firePropertyChanged(String propertyName, int oldValue, int newValue) {
-// this.firePropertyChanged(propertyName, new Integer(oldValue), new Integer(newValue));
- if (oldValue == newValue) {
- return;
- }
-
- PropertyChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- PropertyChangeListener[] propertyChangeListeners = this.propertyChangeListeners();
- if (propertyChangeListeners != null) {
- targets = propertyChangeListeners.clone();
- }
- child = this.child(propertyName);
- }
-
- PropertyChangeEvent event = null;
-
- if (targets != null) {
- for (PropertyChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.propertyChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new PropertyChangeEvent(this.source, propertyName, new Integer(oldValue), new Integer(newValue));
- }
- target.propertyChanged(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.firePropertyChanged(propertyName, oldValue, newValue);
- } else {
- child.firePropertyChanged(event);
- }
- }
-
- this.sourceChanged(propertyName);
- }
-
- /**
- * Report a boolean bound property update to any registered listeners.
- * No event is fired if old and new are equal.
- * <p>
- * This is merely a convenience wrapper around the more general
- * firePropertyChange method that takes Object values.
- */
- public void firePropertyChanged(String propertyName, boolean oldValue, boolean newValue) {
-// this.firePropertyChanged(propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
- if (oldValue == newValue) {
- return;
- }
-
- PropertyChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- PropertyChangeListener[] propertyChangeListeners = this.propertyChangeListeners();
- if (propertyChangeListeners != null) {
- targets = propertyChangeListeners.clone();
- }
- child = this.child(propertyName);
- }
-
- PropertyChangeEvent event = null;
-
- if (targets != null) {
- for (PropertyChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.propertyChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new PropertyChangeEvent(this.source, propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
- }
- target.propertyChanged(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.firePropertyChanged(propertyName, oldValue, newValue);
- } else {
- child.firePropertyChanged(event);
- }
- }
-
- this.sourceChanged(propertyName);
- }
-
-
- // ********** collection change support **********
-
- protected static final Class<CollectionChangeListener> COLLECTION_CHANGE_LISTENER_CLASS = CollectionChangeListener.class;
-
- /**
- * Add a collection change listener that is registered for all collections.
- */
- public void addCollectionChangeListener(CollectionChangeListener listener) {
- this.addListener(COLLECTION_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Add a collection change listener for the specified collection. The listener
- * will be notified only for changes to the specified collection.
- */
- public void addCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- this.addListener(collectionName, COLLECTION_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Remove a collection change listener that was registered for all collections.
- */
- public void removeCollectionChangeListener(CollectionChangeListener listener) {
- this.removeListener(COLLECTION_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Remove a collection change listener that was registered for a specific collection.
- */
- public void removeCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- this.removeListener(collectionName, COLLECTION_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Return whether there are any collection change listeners that will
- * be notified when the specified collection has changed.
- */
- public boolean hasAnyCollectionChangeListeners(String collectionName) {
- return this.hasAnyListeners(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- }
-
- /**
- * Return whether there are any collection change listeners that will
- * be notified when any collection has changed.
- */
- public boolean hasAnyCollectionChangeListeners() {
- return this.hasAnyListeners(COLLECTION_CHANGE_LISTENER_CLASS);
- }
-
- private CollectionChangeListener[] collectionChangeListeners() {
- return (CollectionChangeListener[]) this.listeners(COLLECTION_CHANGE_LISTENER_CLASS);
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireItemsAdded(CollectionChangeEvent event) {
- if (event.itemsSize() == 0) {
- return;
- }
-
- String collectionName = event.getCollectionName();
-
- CollectionChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- CollectionChangeListener[] collectionChangeListeners = this.collectionChangeListeners();
- if (collectionChangeListeners != null) {
- targets = collectionChangeListeners.clone();
- }
- child = this.child(collectionName);
- }
-
- if (targets != null) {
- for (CollectionChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.collectionChangeListeners(), target);
- }
- if (stillListening) {
- target.itemsAdded(event);
- }
- }
- }
- if (child != null) {
- child.fireItemsAdded(event);
- }
-
- this.sourceChanged(collectionName);
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireItemsAdded(String collectionName, Collection<?> addedItems) {
-// this.fireItemsAdded(new CollectionChangeEvent(this.source, collectionName, addedItems));
- if (addedItems.size() == 0) {
- return;
- }
-
- CollectionChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- CollectionChangeListener[] collectionChangeListeners = this.collectionChangeListeners();
- if (collectionChangeListeners != null) {
- targets = collectionChangeListeners.clone();
- }
- child = this.child(collectionName);
- }
-
- CollectionChangeEvent event = null;
-
- if (targets != null) {
- for (CollectionChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.collectionChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new CollectionChangeEvent(this.source, collectionName, addedItems);
- }
- target.itemsAdded(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireItemsAdded(collectionName, addedItems);
- } else {
- child.fireItemsAdded(event);
- }
- }
-
- this.sourceChanged(collectionName);
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireItemAdded(String collectionName, Object addedItem) {
-// this.fireItemsAdded(collectionName, Collections.singleton(addedItem));
-
- CollectionChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- CollectionChangeListener[] collectionChangeListeners = this.collectionChangeListeners();
- if (collectionChangeListeners != null) {
- targets = collectionChangeListeners.clone();
- }
- child = this.child(collectionName);
- }
-
- CollectionChangeEvent event = null;
-
- if (targets != null) {
- for (CollectionChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.collectionChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new CollectionChangeEvent(this.source, collectionName, Collections.singleton(addedItem));
- }
- target.itemsAdded(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireItemAdded(collectionName, addedItem);
- } else {
- child.fireItemsAdded(event);
- }
- }
-
- this.sourceChanged(collectionName);
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireItemsRemoved(CollectionChangeEvent event) {
- if (event.itemsSize() == 0) {
- return;
- }
-
- String collectionName = event.getCollectionName();
-
- CollectionChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- CollectionChangeListener[] collectionChangeListeners = this.collectionChangeListeners();
- if (collectionChangeListeners != null) {
- targets = collectionChangeListeners.clone();
- }
- child = this.child(collectionName);
- }
-
- if (targets != null) {
- for (CollectionChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.collectionChangeListeners(), target);
- }
- if (stillListening) {
- target.itemsRemoved(event);
- }
- }
- }
- if (child != null) {
- child.fireItemsRemoved(event);
- }
-
- this.sourceChanged(collectionName);
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireItemsRemoved(String collectionName, Collection<?> removedItems) {
-// this.fireItemsRemoved(new CollectionChangeEvent(this.source, collectionName, removedItems));
- if (removedItems.size() == 0) {
- return;
- }
-
- CollectionChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- CollectionChangeListener[] collectionChangeListeners = this.collectionChangeListeners();
- if (collectionChangeListeners != null) {
- targets = collectionChangeListeners.clone();
- }
- child = this.child(collectionName);
- }
-
- CollectionChangeEvent event = null;
-
- if (targets != null) {
- for (CollectionChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.collectionChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new CollectionChangeEvent(this.source, collectionName, removedItems);
- }
- target.itemsRemoved(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireItemsRemoved(collectionName, removedItems);
- } else {
- child.fireItemsRemoved(event);
- }
- }
-
- this.sourceChanged(collectionName);
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireItemRemoved(String collectionName, Object removedItem) {
-// this.fireItemsRemoved(collectionName, Collections.singleton(removedItem));
-
- CollectionChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- CollectionChangeListener[] collectionChangeListeners = this.collectionChangeListeners();
- if (collectionChangeListeners != null) {
- targets = collectionChangeListeners.clone();
- }
- child = this.child(collectionName);
- }
-
- CollectionChangeEvent event = null;
-
- if (targets != null) {
- for (CollectionChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.collectionChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new CollectionChangeEvent(this.source, collectionName, Collections.singleton(removedItem));
- }
- target.itemsRemoved(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireItemRemoved(collectionName, removedItem);
- } else {
- child.fireItemsRemoved(event);
- }
- }
-
- this.sourceChanged(collectionName);
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireCollectionCleared(CollectionChangeEvent event) {
- String collectionName = event.getCollectionName();
-
- CollectionChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- CollectionChangeListener[] collectionChangeListeners = this.collectionChangeListeners();
- if (collectionChangeListeners != null) {
- targets = collectionChangeListeners.clone();
- }
- child = this.child(collectionName);
- }
-
- if (targets != null) {
- for (CollectionChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.collectionChangeListeners(), target);
- }
- if (stillListening) {
- target.collectionCleared(event);
- }
- }
- }
- if (child != null) {
- child.fireCollectionCleared(event);
- }
-
- this.sourceChanged(collectionName);
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireCollectionCleared(String collectionName) {
-// this.fireCollectionCleared(new CollectionChangeEvent(this.source, collectionName));
-
- CollectionChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- CollectionChangeListener[] collectionChangeListeners = this.collectionChangeListeners();
- if (collectionChangeListeners != null) {
- targets = collectionChangeListeners.clone();
- }
- child = this.child(collectionName);
- }
-
- CollectionChangeEvent event = null;
-
- if (targets != null) {
- for (CollectionChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.collectionChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new CollectionChangeEvent(this.source, collectionName);
- }
- target.collectionCleared(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireCollectionCleared(collectionName);
- } else {
- child.fireCollectionCleared(event);
- }
- }
-
- this.sourceChanged(collectionName);
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireCollectionChanged(CollectionChangeEvent event) {
- String collectionName = event.getCollectionName();
-
- CollectionChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- CollectionChangeListener[] collectionChangeListeners = this.collectionChangeListeners();
- if (collectionChangeListeners != null) {
- targets = collectionChangeListeners.clone();
- }
- child = this.child(collectionName);
- }
-
- if (targets != null) {
- for (CollectionChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.collectionChangeListeners(), target);
- }
- if (stillListening) {
- target.collectionChanged(event);
- }
- }
- }
- if (child != null) {
- child.fireCollectionChanged(event);
- }
-
- this.sourceChanged(collectionName);
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireCollectionChanged(String collectionName) {
-// this.fireCollectionChanged(new CollectionChangeEvent(this.source, collectionName));
-
- CollectionChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- CollectionChangeListener[] collectionChangeListeners = this.collectionChangeListeners();
- if (collectionChangeListeners != null) {
- targets = collectionChangeListeners.clone();
- }
- child = this.child(collectionName);
- }
-
- CollectionChangeEvent event = null;
-
- if (targets != null) {
- for (CollectionChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.collectionChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new CollectionChangeEvent(this.source, collectionName);
- }
- target.collectionChanged(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireCollectionChanged(collectionName);
- } else {
- child.fireCollectionChanged(event);
- }
- }
-
- this.sourceChanged(collectionName);
- }
-
-
- // ********** list change support **********
-
- protected static final Class<ListChangeListener> LIST_CHANGE_LISTENER_CLASS = ListChangeListener.class;
-
- /**
- * Add a list change listener that is registered for all lists.
- */
- public void addListChangeListener(ListChangeListener listener) {
- this.addListener(LIST_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Add a list change listener for the specified list. The listener
- * will be notified only for changes to the specified list.
- */
- public void addListChangeListener(String listName, ListChangeListener listener) {
- this.addListener(listName, LIST_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Remove a list change listener that was registered for all lists.
- */
- public void removeListChangeListener(ListChangeListener listener) {
- this.removeListener(LIST_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Remove a list change listener that was registered for a specific list.
- */
- public void removeListChangeListener(String listName, ListChangeListener listener) {
- this.removeListener(listName, LIST_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Return whether there are any list change listeners that will
- * be notified when the specified list has changed.
- */
- public boolean hasAnyListChangeListeners(String listName) {
- return this.hasAnyListeners(LIST_CHANGE_LISTENER_CLASS, listName);
- }
-
- /**
- * Return whether there are any list change listeners that will
- * be notified when any list has changed.
- */
- public boolean hasAnyListChangeListeners() {
- return this.hasAnyListeners(LIST_CHANGE_LISTENER_CLASS);
- }
-
- private ListChangeListener[] listChangeListeners() {
- return (ListChangeListener[]) this.listeners(LIST_CHANGE_LISTENER_CLASS);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemsAdded(ListChangeEvent event) {
- if (event.itemsSize() == 0) {
- return;
- }
-
- String listName = event.getListName();
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- target.itemsAdded(event);
- }
- }
- }
- if (child != null) {
- child.fireItemsAdded(event);
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemsAdded(String listName, int index, List<?> addedItems) {
-// this.fireItemsAdded(new ListChangeEvent(this.source, listName, index, addedItems));
- if (addedItems.size() == 0) {
- return;
- }
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- ListChangeEvent event = null;
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new ListChangeEvent(this.source, listName, index, addedItems);
- }
- target.itemsAdded(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireItemsAdded(listName, index, addedItems);
- } else {
- child.fireItemsAdded(event);
- }
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemAdded(String listName, int index, Object addedItem) {
-// this.fireItemsAdded(listName, index, Collections.singletonList(addedItem));
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- ListChangeEvent event = null;
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new ListChangeEvent(this.source, listName, index, Collections.singletonList(addedItem));
- }
- target.itemsAdded(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireItemAdded(listName, index, addedItem);
- } else {
- child.fireItemsAdded(event);
- }
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemsRemoved(ListChangeEvent event) {
- if (event.itemsSize() == 0) {
- return;
- }
-
- String listName = event.getListName();
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- target.itemsRemoved(event);
- }
- }
- }
- if (child != null) {
- child.fireItemsRemoved(event);
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemsRemoved(String listName, int index, List<?> removedItems) {
-// this.fireItemsRemoved(new ListChangeEvent(this.source, listName, index, removedItems));
- if (removedItems.size() == 0) {
- return;
- }
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- ListChangeEvent event = null;
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new ListChangeEvent(this.source, listName, index, removedItems);
- }
- target.itemsRemoved(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireItemsRemoved(listName, index, removedItems);
- } else {
- child.fireItemsRemoved(event);
- }
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemRemoved(String listName, int index, Object removedItem) {
-// this.fireItemsRemoved(listName, index, Collections.singletonList(removedItem));
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- ListChangeEvent event = null;
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new ListChangeEvent(this.source, listName, index, Collections.singletonList(removedItem));
- }
- target.itemsRemoved(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireItemRemoved(listName, index, removedItem);
- } else {
- child.fireItemsRemoved(event);
- }
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemsReplaced(ListChangeEvent event) {
- if (event.itemsSize() == 0) {
- return;
- }
-
- String listName = event.getListName();
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- target.itemsReplaced(event);
- }
- }
- }
- if (child != null) {
- child.fireItemsReplaced(event);
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemsReplaced(String listName, int index, List<?> newItems, List<?> replacedItems) {
-// this.fireItemsReplaced(new ListChangeEvent(this.source, listName, index, newItems, replacedItems));
- if (newItems.size() == 0) {
- return;
- }
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- ListChangeEvent event = null;
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new ListChangeEvent(this.source, listName, index, newItems, replacedItems);
- }
- target.itemsReplaced(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireItemsReplaced(listName, index, newItems, replacedItems);
- } else {
- child.fireItemsReplaced(event);
- }
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemReplaced(String listName, int index, Object newItem, Object replacedItem) {
-// this.fireItemsReplaced(listName, index, Collections.singletonList(newItem), Collections.singletonList(replacedItem));
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- ListChangeEvent event = null;
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new ListChangeEvent(this.source, listName, index, Collections.singletonList(newItem), Collections.singletonList(replacedItem));
- }
- target.itemsReplaced(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireItemReplaced(listName, index, newItem, replacedItem);
- } else {
- child.fireItemsReplaced(event);
- }
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemsMoved(ListChangeEvent event) {
- if (event.getTargetIndex() == event.getSourceIndex()) {
- return;
- }
-
- String listName = event.getListName();
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- target.itemsMoved(event);
- }
- }
- }
- if (child != null) {
- child.fireItemsMoved(event);
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemsMoved(String listName, int targetIndex, int sourceIndex, int length) {
-// this.fireItemsMoved(new ListChangeEvent(this.source, listName, targetIndex, sourceIndex, length));
- if (targetIndex == sourceIndex) {
- return;
- }
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- ListChangeEvent event = null;
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new ListChangeEvent(this.source, listName, targetIndex, sourceIndex, length);
- }
- target.itemsMoved(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireItemsMoved(listName, targetIndex, sourceIndex, length);
- } else {
- child.fireItemsMoved(event);
- }
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemMoved(String listName, int targetIndex, int sourceIndex) {
- this.fireItemsMoved(listName, targetIndex, sourceIndex, 1);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireListCleared(ListChangeEvent event) {
- String listName = event.getListName();
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- target.listCleared(event);
- }
- }
- }
- if (child != null) {
- child.fireListCleared(event);
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireListCleared(String listName) {
-// this.fireListCleared(new ListChangeEvent(this.source, listName));
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- ListChangeEvent event = null;
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new ListChangeEvent(this.source, listName);
- }
- target.listCleared(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireListCleared(listName);
- } else {
- child.fireListCleared(event);
- }
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireListChanged(ListChangeEvent event) {
- String listName = event.getListName();
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- target.listChanged(event);
- }
- }
- }
- if (child != null) {
- child.fireListChanged(event);
- }
-
- this.sourceChanged(listName);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireListChanged(String listName) {
-// this.fireListChanged(new ListChangeEvent(this.source, listName));
-
- ListChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- ListChangeListener[] listChangeListeners = this.listChangeListeners();
- if (listChangeListeners != null) {
- targets = listChangeListeners.clone();
- }
- child = this.child(listName);
- }
-
- ListChangeEvent event = null;
-
- if (targets != null) {
- for (ListChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.listChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new ListChangeEvent(this.source, listName);
- }
- target.listChanged(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireListChanged(listName);
- } else {
- child.fireListChanged(event);
- }
- }
-
- this.sourceChanged(listName);
- }
-
-
- // ********** tree change support **********
-
- protected static final Class<TreeChangeListener> TREE_CHANGE_LISTENER_CLASS = TreeChangeListener.class;
- private static final Object[] EMPTY_TREE_PATH = new Object[0];
-
- /**
- * Add a tree change listener that is registered for all trees.
- */
- public void addTreeChangeListener(TreeChangeListener listener) {
- this.addListener(TREE_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Add a tree change listener for the specified tree. The listener
- * will be notified only for changes to the specified tree.
- */
- public void addTreeChangeListener(String treeName, TreeChangeListener listener) {
- this.addListener(treeName, TREE_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Remove a tree change listener that was registered for all tree.
- */
- public void removeTreeChangeListener(TreeChangeListener listener) {
- this.removeListener(TREE_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Remove a tree change listener that was registered for a specific tree.
- */
- public void removeTreeChangeListener(String treeName, TreeChangeListener listener) {
- this.removeListener(treeName, TREE_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Return whether there are any tree change listeners that will
- * be notified when the specified tree has changed.
- */
- public boolean hasAnyTreeChangeListeners(String treeName) {
- return this.hasAnyListeners(TREE_CHANGE_LISTENER_CLASS, treeName);
- }
-
- /**
- * Return whether there are any tree change listeners that will
- * be notified when any tree has changed.
- */
- public boolean hasAnyTreeChangeListeners() {
- return this.hasAnyListeners(TREE_CHANGE_LISTENER_CLASS);
- }
-
- private TreeChangeListener[] treeChangeListeners() {
- return (TreeChangeListener[]) this.listeners(TREE_CHANGE_LISTENER_CLASS);
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireNodeAdded(TreeChangeEvent event) {
- String treeName = event.getTreeName();
-
- TreeChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- TreeChangeListener[] treeChangeListeners = this.treeChangeListeners();
- if (treeChangeListeners != null) {
- targets = treeChangeListeners.clone();
- }
- child = this.child(treeName);
- }
-
- if (targets != null) {
- for (TreeChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.treeChangeListeners(), target);
- }
- if (stillListening) {
- target.nodeAdded(event);
- }
- }
- }
- if (child != null) {
- child.fireNodeAdded(event);
- }
-
- this.sourceChanged(treeName);
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireNodeAdded(String treeName, Object[] path) {
-// this.fireNodeAdded(new TreeChangeEvent(this.source, treeName, path));
-
- TreeChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- TreeChangeListener[] treeChangeListeners = this.treeChangeListeners();
- if (treeChangeListeners != null) {
- targets = treeChangeListeners.clone();
- }
- child = this.child(treeName);
- }
-
- TreeChangeEvent event = null;
-
- if (targets != null) {
- for (TreeChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.treeChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new TreeChangeEvent(this.source, treeName, path);
- }
- target.nodeAdded(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireNodeAdded(treeName, path);
- } else {
- child.fireNodeAdded(event);
- }
- }
-
- this.sourceChanged(treeName);
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireNodeRemoved(TreeChangeEvent event) {
- String treeName = event.getTreeName();
-
- TreeChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- TreeChangeListener[] treeChangeListeners = this.treeChangeListeners();
- if (treeChangeListeners != null) {
- targets = treeChangeListeners.clone();
- }
- child = this.child(treeName);
- }
-
- if (targets != null) {
- for (TreeChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.treeChangeListeners(), target);
- }
- if (stillListening) {
- target.nodeRemoved(event);
- }
- }
- }
- if (child != null) {
- child.fireNodeRemoved(event);
- }
-
- this.sourceChanged(treeName);
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireNodeRemoved(String treeName, Object[] path) {
-// this.fireNodeRemoved(new TreeChangeEvent(this.source, treeName, path));
-
- TreeChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- TreeChangeListener[] treeChangeListeners = this.treeChangeListeners();
- if (treeChangeListeners != null) {
- targets = treeChangeListeners.clone();
- }
- child = this.child(treeName);
- }
-
- TreeChangeEvent event = null;
-
- if (targets != null) {
- for (TreeChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.treeChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new TreeChangeEvent(this.source, treeName, path);
- }
- target.nodeRemoved(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireNodeRemoved(treeName, path);
- } else {
- child.fireNodeRemoved(event);
- }
- }
-
- this.sourceChanged(treeName);
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireTreeCleared(TreeChangeEvent event) {
- String treeName = event.getTreeName();
-
- TreeChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- TreeChangeListener[] treeChangeListeners = this.treeChangeListeners();
- if (treeChangeListeners != null) {
- targets = treeChangeListeners.clone();
- }
- child = this.child(treeName);
- }
-
- if (targets != null) {
- for (TreeChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.treeChangeListeners(), target);
- }
- if (stillListening) {
- target.treeCleared(event);
- }
- }
- }
- if (child != null) {
- child.fireTreeCleared(event);
- }
-
- this.sourceChanged(treeName);
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireTreeCleared(String treeName, Object[] path) {
-// this.fireTreeCleared(new TreeChangeEvent(this.source, treeName, path));
-
- TreeChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- TreeChangeListener[] treeChangeListeners = this.treeChangeListeners();
- if (treeChangeListeners != null) {
- targets = treeChangeListeners.clone();
- }
- child = this.child(treeName);
- }
-
- TreeChangeEvent event = null;
-
- if (targets != null) {
- for (TreeChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.treeChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new TreeChangeEvent(this.source, treeName, path);
- }
- target.treeCleared(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireTreeCleared(treeName, path);
- } else {
- child.fireTreeCleared(event);
- }
- }
-
- this.sourceChanged(treeName);
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireTreeCleared(String treeName) {
- this.fireTreeCleared(treeName, EMPTY_TREE_PATH);
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireTreeChanged(TreeChangeEvent event) {
- String treeName = event.getTreeName();
-
- TreeChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- TreeChangeListener[] treeChangeListeners = this.treeChangeListeners();
- if (treeChangeListeners != null) {
- targets = treeChangeListeners.clone();
- }
- child = this.child(treeName);
- }
-
- if (targets != null) {
- for (TreeChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.treeChangeListeners(), target);
- }
- if (stillListening) {
- target.treeChanged(event);
- }
- }
- }
- if (child != null) {
- child.fireTreeChanged(event);
- }
-
- this.sourceChanged(treeName);
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireTreeChanged(String treeName, Object[] path) {
-// this.fireTreeChanged(new TreeChangeEvent(this.source, treeName, path));
-
- TreeChangeListener[] targets = null;
- ChangeSupport child = null;
-
- synchronized (this) {
- TreeChangeListener[] treeChangeListeners = this.treeChangeListeners();
- if (treeChangeListeners != null) {
- targets = treeChangeListeners.clone();
- }
- child = this.child(treeName);
- }
-
- TreeChangeEvent event = null;
-
- if (targets != null) {
- for (TreeChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.treeChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new TreeChangeEvent(this.source, treeName, path);
- }
- target.treeChanged(event);
- }
- }
- }
- if (child != null) {
- if (event == null) {
- child.fireTreeChanged(treeName, path);
- } else {
- child.fireTreeChanged(event);
- }
- }
-
- this.sourceChanged(treeName);
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireTreeChanged(String treeName) {
- this.fireTreeChanged(treeName, EMPTY_TREE_PATH);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.source);
- }
-
-
- // ********** serialization **********
-
- private synchronized void writeObject(ObjectOutputStream s) throws IOException {
- // write out the source, children, and any hidden stuff
- s.defaultWriteObject();
-
- // only write out Serializable listeners
- int len1 = this.genericListeners.length;
- for (int i = 0; i < len1; i++) {
- this.writeObject(s, this.genericListeners[i]);
- }
- s.writeObject(null);
- }
-
- private void writeObject(ObjectOutputStream s, GenericListenerList gll) throws IOException {
- boolean first = true;
- int len = gll.listeners.length;
- for (int i = 0; i < len; i++) {
- ChangeListener listener = gll.listeners[i];
- if (listener instanceof Serializable) {
- if (first) {
- first = false;
- s.writeObject(gll.listenerClass);
- }
- s.writeObject(listener);
- }
- }
- if ( ! first) {
- s.writeObject(null);
- }
- }
-
- private synchronized void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
- // read in the source, children, and any hidden stuff
- s.defaultReadObject();
-
- // read in generic listener lists
- this.genericListeners = EMPTY_GENERIC_LISTENERS;
- Object o;
- while (null != (o = s.readObject())) {
- @SuppressWarnings("unchecked")
- Class<? extends ChangeListener> listenerClass = (Class<? extends ChangeListener>) o;
- GenericListenerList gll = null;
- while (null != (o = s.readObject())) {
- if (gll == null) {
- gll = this.addGenericListenerListInternal(listenerClass, (ChangeListener) o);
- } else {
- gll.addListener((ChangeListener) o);
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- private <T extends ChangeListener> GenericListenerList addGenericListenerListInternal(Class<T> listenerClass, ChangeListener listener) {
- return this.addGenericListenerList(listenerClass, (T) listener);
- }
-
-
- // ********** member classes **********
-
- /**
- * Pair a listener class with its "generic" listeners.
- */
- private static class GenericListenerList {
- final Class<? extends ChangeListener> listenerClass;
- ChangeListener[] listeners;
-
- <T extends ChangeListener> GenericListenerList(Class<T> listenerClass, T listener) {
- super();
- this.listenerClass = listenerClass;
- this.listeners = (ChangeListener[]) Array.newInstance(listenerClass, 1);
- this.listeners[0] = listener;
- }
-
- void addListener(ChangeListener listener) {
- this.listeners = CollectionTools.add(this.listeners, listener);
- }
-
- boolean removeListener(ChangeListener listener) {
- int len = this.listeners.length;
- if (len == 0) {
- return false;
- }
- try {
- this.listeners = CollectionTools.remove(this.listeners, listener);
- } catch (ArrayIndexOutOfBoundsException ex) {
- return false; // listener not in the list
- }
- return (this.listeners.length + 1) == len;
- }
-
- boolean hasListeners() {
- return this.listeners.length > 0;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, ClassTools.shortNameFor(this.listenerClass));
- }
-
- }
-
- /**
- * Pair an aspect name with the change support holding its associated
- * listeners.
- */
- private static class AspectChild implements Serializable {
- final String aspectName;
- final ChangeSupport child;
- private static final long serialVersionUID = 1L;
-
- AspectChild(String aspectName, ChangeSupport child) {
- super();
- this.aspectName = aspectName;
- this.child = child;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.aspectName);
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/SingleAspectChangeSupport.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/SingleAspectChangeSupport.java
deleted file mode 100644
index f63e523c6c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/SingleAspectChangeSupport.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
-
-/**
- * This change support class changes the behavior of the standard
- * ChangeSupport in several ways:
- * - All events fired by the source must specify the single aspect.
- * - Listeners are required to be either "generic" listeners or
- * listeners of the single aspect.
- */
-public class SingleAspectChangeSupport
- extends ChangeSupport
-{
- protected final Class<? extends ChangeListener> listenerClass;
- protected final String aspectName;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructor **********
-
- public SingleAspectChangeSupport(Model source, Class<? extends ChangeListener> listenerClass, String aspectName) {
- super(source);
- this.listenerClass = listenerClass;
- this.aspectName = aspectName;
- }
-
-
- // ********** internal behavior **********
-
- private UnsupportedOperationException unsupportedOperationException() {
- return new UnsupportedOperationException("This Model supports only changes for the listener type \"" + this.listenerClass.getName()
- + "\" and the aspect \"" + this.aspectName + "\"");
- }
-
- private void check(Class<? extends ChangeListener> lClass, String aName) {
- if (lClass != this.listenerClass) {
- throw new IllegalArgumentException("This Model supports only changes for the listener type \"" + this.listenerClass.getName() + "\" : \"" + lClass.getName() + "\"");
- }
- if (aName != this.aspectName) {
- throw new IllegalArgumentException("This Model supports only changes for the aspect \"" + this.aspectName + "\" : \"" + aName + "\"");
- }
- }
-
- @Override
- protected <T extends ChangeListener> void addListener(String aName, Class<T> lClass, T listener) {
- this.check(lClass, aName);
- super.addListener(aName, lClass, listener);
- }
-
- @Override
- protected <T extends ChangeListener> void removeListener(String aName, Class<T> lClass, T listener) {
- this.check(lClass, aName);
- super.removeListener(aName, lClass, listener);
- }
-
-
- // ********** internal queries **********
-
- @Override
- protected boolean hasAnyListeners(Class<? extends ChangeListener> lClass, String aName) {
- this.check(lClass, aName);
- return super.hasAnyListeners(lClass, aName);
- }
-
-
- // ********** state change support **********
-
- @Override
- public void fireStateChanged(StateChangeEvent event) {
- throw this.unsupportedOperationException();
- }
-
- @Override
- public void fireStateChanged() {
- throw this.unsupportedOperationException();
- }
-
-
- // ********** property change support **********
-
- @Override
- public void firePropertyChanged(PropertyChangeEvent event) {
- this.check(PROPERTY_CHANGE_LISTENER_CLASS, event.getPropertyName());
- super.firePropertyChanged(event);
- }
-
- @Override
- public void firePropertyChanged(String propertyName, Object oldValue, Object newValue) {
- this.check(PROPERTY_CHANGE_LISTENER_CLASS, propertyName);
- super.firePropertyChanged(propertyName, oldValue, newValue);
- }
-
- @Override
- public void firePropertyChanged(String propertyName, int oldValue, int newValue) {
- this.check(PROPERTY_CHANGE_LISTENER_CLASS, propertyName);
- super.firePropertyChanged(propertyName, oldValue, newValue);
- }
-
- @Override
- public void firePropertyChanged(String propertyName, boolean oldValue, boolean newValue) {
- this.check(PROPERTY_CHANGE_LISTENER_CLASS, propertyName);
- super.firePropertyChanged(propertyName, oldValue, newValue);
- }
-
-
- // ********** collection change support **********
-
- @Override
- public void fireItemsAdded(CollectionChangeEvent event) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, event.getCollectionName());
- super.fireItemsAdded(event);
- }
-
- @Override
- public void fireItemsAdded(String collectionName, Collection<?> addedItems) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- super.fireItemsAdded(collectionName, addedItems);
- }
-
- @Override
- public void fireItemAdded(String collectionName, Object addedItem) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- super.fireItemAdded(collectionName, addedItem);
- }
-
- @Override
- public void fireItemsRemoved(CollectionChangeEvent event) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, event.getCollectionName());
- super.fireItemsRemoved(event);
- }
-
- @Override
- public void fireItemsRemoved(String collectionName, Collection<?> removedItems) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- super.fireItemsRemoved(collectionName, removedItems);
- }
-
- @Override
- public void fireItemRemoved(String collectionName, Object removedItem) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- super.fireItemRemoved(collectionName, removedItem);
- }
-
- @Override
- public void fireCollectionCleared(CollectionChangeEvent event) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, event.getCollectionName());
- super.fireCollectionCleared(event);
- }
-
- @Override
- public void fireCollectionCleared(String collectionName) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- super.fireCollectionCleared(collectionName);
- }
-
- @Override
- public void fireCollectionChanged(CollectionChangeEvent event) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, event.getCollectionName());
- super.fireCollectionChanged(event);
- }
-
- @Override
- public void fireCollectionChanged(String collectionName) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- super.fireCollectionChanged(collectionName);
- }
-
-
- // ********** list change support **********
-
- @Override
- public void fireItemsAdded(ListChangeEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- super.fireItemsAdded(event);
- }
-
- @Override
- public void fireItemsAdded(String listName, int index, List<?> addedItems) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireItemsAdded(listName, index, addedItems);
- }
-
- @Override
- public void fireItemAdded(String listName, int index, Object addedItem) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireItemAdded(listName, index, addedItem);
- }
-
- @Override
- public void fireItemsRemoved(ListChangeEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- super.fireItemsRemoved(event);
- }
-
- @Override
- public void fireItemsRemoved(String listName, int index, List<?> removedItems) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireItemsRemoved(listName, index, removedItems);
- }
-
- @Override
- public void fireItemRemoved(String listName, int index, Object removedItem) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireItemRemoved(listName, index, removedItem);
- }
-
- @Override
- public void fireItemsReplaced(ListChangeEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- super.fireItemsReplaced(event);
- }
-
- @Override
- public void fireItemsReplaced(String listName, int index, List<?> newItems, List<?> replacedItems) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireItemsReplaced(listName, index, newItems, replacedItems);
- }
-
- @Override
- public void fireItemReplaced(String listName, int index, Object newItem, Object replacedItem) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireItemReplaced(listName, index, newItem, replacedItem);
- }
-
- @Override
- public void fireItemsMoved(ListChangeEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- super.fireItemsMoved(event);
- }
-
- @Override
- public void fireItemsMoved(String listName, int targetIndex, int sourceIndex, int length) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireItemsMoved(listName, targetIndex, sourceIndex, length);
- }
-
- @Override
- public void fireListCleared(ListChangeEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- super.fireListCleared(event);
- }
-
- @Override
- public void fireListCleared(String listName) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireListCleared(listName);
- }
-
- @Override
- public void fireListChanged(ListChangeEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- super.fireListChanged(event);
- }
-
- @Override
- public void fireListChanged(String listName) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireListChanged(listName);
- }
-
-
- // ********** tree change support **********
-
- @Override
- public void fireNodeAdded(TreeChangeEvent event) {
- this.check(TREE_CHANGE_LISTENER_CLASS, event.getTreeName());
- super.fireNodeAdded(event);
- }
-
- @Override
- public void fireNodeAdded(String treeName, Object[] path) {
- this.check(TREE_CHANGE_LISTENER_CLASS, treeName);
- super.fireNodeAdded(treeName, path);
- }
-
- @Override
- public void fireNodeRemoved(TreeChangeEvent event) {
- this.check(TREE_CHANGE_LISTENER_CLASS, event.getTreeName());
- super.fireNodeRemoved(event);
- }
-
- @Override
- public void fireNodeRemoved(String treeName, Object[] path) {
- this.check(TREE_CHANGE_LISTENER_CLASS, treeName);
- super.fireNodeRemoved(treeName, path);
- }
-
- @Override
- public void fireTreeCleared(TreeChangeEvent event) {
- this.check(TREE_CHANGE_LISTENER_CLASS, event.getTreeName());
- super.fireTreeCleared(event);
- }
-
- @Override
- public void fireTreeCleared(String treeName, Object[] path) {
- this.check(TREE_CHANGE_LISTENER_CLASS, treeName);
- super.fireTreeCleared(treeName, path);
- }
-
- @Override
- public void fireTreeChanged(TreeChangeEvent event) {
- this.check(TREE_CHANGE_LISTENER_CLASS, event.getTreeName());
- super.fireTreeChanged(event);
- }
-
- @Override
- public void fireTreeChanged(String treeName, Object[] path) {
- this.check(TREE_CHANGE_LISTENER_CLASS, treeName);
- super.fireTreeChanged(treeName, path);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTCollectionChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTCollectionChangeListenerWrapper.java
deleted file mode 100644
index 297654ded7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTCollectionChangeListenerWrapper.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.listener.awt;
-
-import java.awt.EventQueue;
-
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-
-/**
- * Wrap another collection change listener and forward events to it on the AWT
- * event queue.
- */
-public class AWTCollectionChangeListenerWrapper
- implements CollectionChangeListener
-{
- private final CollectionChangeListener listener;
-
- public AWTCollectionChangeListenerWrapper(CollectionChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void itemsAdded(CollectionChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.itemsAdded_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsAddedRunnable(event));
- }
- }
-
- public void itemsRemoved(CollectionChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.itemsRemoved_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsRemovedRunnable(event));
- }
- }
-
- public void collectionCleared(CollectionChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.collectionCleared_(event);
- } else {
- this.executeOnEventQueue(this.buildCollectionClearedRunnable(event));
- }
- }
-
- public void collectionChanged(CollectionChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.collectionChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildCollectionChangedRunnable(event));
- }
- }
-
- private Runnable buildItemsAddedRunnable(final CollectionChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTCollectionChangeListenerWrapper.this.itemsAdded_(event);
- }
- @Override
- public String toString() {
- return "items added";
- }
- };
- }
-
- private Runnable buildItemsRemovedRunnable(final CollectionChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTCollectionChangeListenerWrapper.this.itemsRemoved_(event);
- }
- @Override
- public String toString() {
- return "items removed";
- }
- };
- }
-
- private Runnable buildCollectionClearedRunnable(final CollectionChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTCollectionChangeListenerWrapper.this.collectionCleared_(event);
- }
- @Override
- public String toString() {
- return "collection cleared";
- }
- };
- }
-
- private Runnable buildCollectionChangedRunnable(final CollectionChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTCollectionChangeListenerWrapper.this.collectionChanged_(event);
- }
- @Override
- public String toString() {
- return "collection changed";
- }
- };
- }
-
- /**
- * EventQueue#invokeLater(Runnable) seems to work OK;
- * but using #invokeAndWait(Runnable) can sometimes make things
- * more predictable when debugging, at the risk of deadlocks.
- */
- private void executeOnEventQueue(Runnable r) {
- EventQueue.invokeLater(r);
-// try {
-// EventQueue.invokeAndWait(r);
-// } catch (InterruptedException ex) {
-// throw new RuntimeException(ex);
-// } catch (java.lang.reflect.InvocationTargetException ex) {
-// throw new RuntimeException(ex);
-// }
- }
-
- void itemsAdded_(CollectionChangeEvent event) {
- this.listener.itemsAdded(event);
- }
-
- void itemsRemoved_(CollectionChangeEvent event) {
- this.listener.itemsRemoved(event);
- }
-
- void collectionCleared_(CollectionChangeEvent event) {
- this.listener.collectionCleared(event);
- }
-
- void collectionChanged_(CollectionChangeEvent event) {
- this.listener.collectionChanged(event);
- }
-
- @Override
- public String toString() {
- return "AWT(" + this.listener.toString() + ")";
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTListChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTListChangeListenerWrapper.java
deleted file mode 100644
index 8c63c63664..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTListChangeListenerWrapper.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.listener.awt;
-
-import java.awt.EventQueue;
-
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-
-/**
- * Wrap another list change listener and forward events to it on the AWT
- * event queue.
- */
-public class AWTListChangeListenerWrapper
- implements ListChangeListener
-{
- private final ListChangeListener listener;
-
- public AWTListChangeListenerWrapper(ListChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void itemsAdded(ListChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.itemsAdded_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsAddedRunnable(event));
- }
- }
-
- public void itemsRemoved(ListChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.itemsRemoved_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsRemovedRunnable(event));
- }
- }
-
- public void itemsMoved(ListChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.itemsMoved_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsMovedRunnable(event));
- }
- }
-
- public void itemsReplaced(ListChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.itemsReplaced_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsReplacedRunnable(event));
- }
- }
-
- public void listCleared(ListChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.listCleared_(event);
- } else {
- this.executeOnEventQueue(this.buildListClearedRunnable(event));
- }
- }
-
- public void listChanged(ListChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.listChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildListChangedRunnable(event));
- }
- }
-
- private Runnable buildItemsAddedRunnable(final ListChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTListChangeListenerWrapper.this.itemsAdded_(event);
- }
- @Override
- public String toString() {
- return "items added";
- }
- };
- }
-
- private Runnable buildItemsRemovedRunnable(final ListChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTListChangeListenerWrapper.this.itemsRemoved_(event);
- }
- @Override
- public String toString() {
- return "items removed";
- }
- };
- }
-
- private Runnable buildItemsMovedRunnable(final ListChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTListChangeListenerWrapper.this.itemsMoved_(event);
- }
- @Override
- public String toString() {
- return "items moved";
- }
- };
- }
-
- private Runnable buildItemsReplacedRunnable(final ListChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTListChangeListenerWrapper.this.itemsReplaced_(event);
- }
- @Override
- public String toString() {
- return "items replaced";
- }
- };
- }
-
- private Runnable buildListClearedRunnable(final ListChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTListChangeListenerWrapper.this.listCleared_(event);
- }
- @Override
- public String toString() {
- return "list cleared";
- }
- };
- }
-
- private Runnable buildListChangedRunnable(final ListChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTListChangeListenerWrapper.this.listChanged_(event);
- }
- @Override
- public String toString() {
- return "list changed";
- }
- };
- }
-
- /**
- * EventQueue#invokeLater(Runnable) seems to work OK;
- * but using #invokeAndWait(Runnable) can sometimes make things
- * more predictable when debugging, at the risk of deadlocks.
- */
- private void executeOnEventQueue(Runnable r) {
- EventQueue.invokeLater(r);
-// try {
-// EventQueue.invokeAndWait(r);
-// } catch (InterruptedException ex) {
-// throw new RuntimeException(ex);
-// } catch (java.lang.reflect.InvocationTargetException ex) {
-// throw new RuntimeException(ex);
-// }
- }
-
- void itemsAdded_(ListChangeEvent event) {
- this.listener.itemsAdded(event);
- }
-
- void itemsRemoved_(ListChangeEvent event) {
- this.listener.itemsRemoved(event);
- }
-
- void itemsMoved_(ListChangeEvent event) {
- this.listener.itemsMoved(event);
- }
-
- void itemsReplaced_(ListChangeEvent event) {
- this.listener.itemsReplaced(event);
- }
-
- void listCleared_(ListChangeEvent event) {
- this.listener.listCleared(event);
- }
-
- void listChanged_(ListChangeEvent event) {
- this.listener.listChanged(event);
- }
-
- @Override
- public String toString() {
- return "AWT(" + this.listener.toString() + ")";
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTPropertyChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTPropertyChangeListenerWrapper.java
deleted file mode 100644
index 171ac87ad2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTPropertyChangeListenerWrapper.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.listener.awt;
-
-import java.awt.EventQueue;
-
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-
-/**
- * Wrap another property change listener and forward events to it on the AWT
- * event queue.
- */
-public class AWTPropertyChangeListenerWrapper
- implements PropertyChangeListener
-{
- private final PropertyChangeListener listener;
-
-
- public AWTPropertyChangeListenerWrapper(PropertyChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void propertyChanged(PropertyChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.propertyChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildRunnable(event));
- }
- }
-
- private Runnable buildRunnable(final PropertyChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTPropertyChangeListenerWrapper.this.propertyChanged_(event);
- }
- };
- }
-
- /**
- * EventQueue#invokeLater(Runnable) seems to work OK;
- * but using #invokeAndWait(Runnable) can sometimes make things
- * more predictable when debugging, at the risk of deadlocks.
- */
- private void executeOnEventQueue(Runnable r) {
- EventQueue.invokeLater(r);
-// try {
-// EventQueue.invokeAndWait(r);
-// } catch (InterruptedException ex) {
-// throw new RuntimeException(ex);
-// } catch (java.lang.reflect.InvocationTargetException ex) {
-// throw new RuntimeException(ex);
-// }
- }
-
- void propertyChanged_(PropertyChangeEvent event) {
- this.listener.propertyChanged(event);
- }
-
- @Override
- public String toString() {
- return "AWT(" + this.listener.toString() + ")";
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTStateChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTStateChangeListenerWrapper.java
deleted file mode 100644
index bb042ae023..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTStateChangeListenerWrapper.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.listener.awt;
-
-import java.awt.EventQueue;
-
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-
-/**
- * Wrap another state change listener and forward events to it on the AWT
- * event queue.
- */
-public class AWTStateChangeListenerWrapper
- implements StateChangeListener
-{
- private final StateChangeListener listener;
-
- public AWTStateChangeListenerWrapper(StateChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void stateChanged(StateChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.stateChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildRunnable(event));
- }
- }
-
- private Runnable buildRunnable(final StateChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTStateChangeListenerWrapper.this.stateChanged_(event);
- }
- };
- }
-
- /**
- * EventQueue#invokeLater(Runnable) seems to work OK;
- * but using #invokeAndWait(Runnable) can sometimes make things
- * more predictable when debugging, at the risk of deadlocks.
- */
- private void executeOnEventQueue(Runnable r) {
- EventQueue.invokeLater(r);
-// try {
-// EventQueue.invokeAndWait(r);
-// } catch (InterruptedException ex) {
-// throw new RuntimeException(ex);
-// } catch (java.lang.reflect.InvocationTargetException ex) {
-// throw new RuntimeException(ex);
-// }
- }
-
- void stateChanged_(StateChangeEvent event) {
- this.listener.stateChanged(event);
- }
-
- @Override
- public String toString() {
- return "AWT(" + this.listener.toString() + ")";
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTTreeChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTTreeChangeListenerWrapper.java
deleted file mode 100644
index 0186d5d065..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTTreeChangeListenerWrapper.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.listener.awt;
-
-import java.awt.EventQueue;
-
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
-
-/**
- * Wrap another tree change listener and forward events to it on the AWT
- * event queue.
- */
-public class AWTTreeChangeListenerWrapper
- implements TreeChangeListener
-{
- private final TreeChangeListener listener;
-
- public AWTTreeChangeListenerWrapper(TreeChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void nodeAdded(TreeChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.nodeAdded_(event);
- } else {
- this.executeOnEventQueue(this.buildNodeAddedRunnable(event));
- }
- }
-
- public void nodeRemoved(TreeChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.nodeRemoved_(event);
- } else {
- this.executeOnEventQueue(this.buildNodeRemovedRunnable(event));
- }
- }
-
- public void treeCleared(TreeChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.treeCleared_(event);
- } else {
- this.executeOnEventQueue(this.buildTreeClearedRunnable(event));
- }
- }
-
- public void treeChanged(TreeChangeEvent event) {
- if (EventQueue.isDispatchThread()) {
- this.treeChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildTreeChangedRunnable(event));
- }
- }
-
- private Runnable buildNodeAddedRunnable(final TreeChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTTreeChangeListenerWrapper.this.nodeAdded_(event);
- }
- @Override
- public String toString() {
- return "node added";
- }
- };
- }
-
- private Runnable buildNodeRemovedRunnable(final TreeChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTTreeChangeListenerWrapper.this.nodeRemoved_(event);
- }
- @Override
- public String toString() {
- return "node removed";
- }
- };
- }
-
- private Runnable buildTreeClearedRunnable(final TreeChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTTreeChangeListenerWrapper.this.treeCleared_(event);
- }
- @Override
- public String toString() {
- return "tree cleared";
- }
- };
- }
-
- private Runnable buildTreeChangedRunnable(final TreeChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTTreeChangeListenerWrapper.this.treeChanged_(event);
- }
- @Override
- public String toString() {
- return "tree changed";
- }
- };
- }
-
- /**
- * EventQueue#invokeLater(Runnable) seems to work OK;
- * but using #invokeAndWait(Runnable) can sometimes make things
- * more predictable when debugging, at the risk of deadlocks.
- */
- private void executeOnEventQueue(Runnable r) {
- EventQueue.invokeLater(r);
-// try {
-// EventQueue.invokeAndWait(r);
-// } catch (InterruptedException ex) {
-// throw new RuntimeException(ex);
-// } catch (java.lang.reflect.InvocationTargetException ex) {
-// throw new RuntimeException(ex);
-// }
- }
-
- void nodeAdded_(TreeChangeEvent event) {
- this.listener.nodeAdded(event);
- }
-
- void nodeRemoved_(TreeChangeEvent event) {
- this.listener.nodeRemoved(event);
- }
-
- void treeCleared_(TreeChangeEvent event) {
- this.listener.treeCleared(event);
- }
-
- void treeChanged_(TreeChangeEvent event) {
- this.listener.treeChanged(event);
- }
-
- @Override
- public String toString() {
- return "AWT(" + this.listener.toString() + ")";
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AbstractTreeNodeValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AbstractTreeNodeValueModel.java
deleted file mode 100644
index b06c83a3ac..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AbstractTreeNodeValueModel.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ChainIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.TreeNodeValueModel;
-
-/**
- * Subclasses need only implement the following methods:
- *
- * #value()
- * return the user-determined "value" of the node,
- * i.e. the object "wrapped" by the node
- *
- * #setValue(Object)
- * set the user-determined "value" of the node,
- * i.e. the object "wrapped" by the node;
- * typically only overridden for nodes with "primitive" values
- *
- * #parent()
- * return the parent of the node, which should be another
- * TreeNodeValueModel
- *
- * #childrenModel()
- * return a ListValueModel for the node's children
- *
- * #engageValue() and #disengageValue()
- * override these methods to listen to the node's value if
- * it can change in a way that should be reflected in the tree
- */
-public abstract class AbstractTreeNodeValueModel<T>
- extends AbstractModel
- implements TreeNodeValueModel<T>
-{
-
-
- // ********** constructors **********
-
- /**
- * Default constructor.
- */
- protected AbstractTreeNodeValueModel() {
- super();
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- // this model fires *both* "value property change" and "state change" events...
-// return new SingleAspectChangeSupport(this, PropertyChangeListener.class, PropertyValueModel.VALUE);
- return super.buildChangeSupport();
- }
-
-
- // ********** extend AbstractModel implementation **********
-
- /**
- * Clients should be adding both "state change" and "value property change"
- * listeners.
- */
- @Override
- public void addStateChangeListener(StateChangeListener listener) {
- if (this.hasNoStateChangeListeners()) {
- this.engageValue();
- }
- super.addStateChangeListener(listener);
- }
-
- /**
- * Begin listening to the node's value's state. If the state of the node changes
- * in a way that should be reflected in the tree, fire a "state change" event.
- */
- protected abstract void engageValue();
-
- /**
- * @see #addStateChangeListener(StateChangeListener)
- */
- @Override
- public void removeStateChangeListener(StateChangeListener listener) {
- super.removeStateChangeListener(listener);
- if (this.hasNoStateChangeListeners()) {
- this.disengageValue();
- }
- }
-
- /**
- * Stop listening to the node's value.
- * @see #engageValue()
- */
- protected abstract void disengageValue();
-
-
- // ********** WritablePropertyValueModel implementation **********
-
- public void setValue(T value) {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** TreeNodeValueModel implementation **********
-
- @SuppressWarnings("unchecked")
- public TreeNodeValueModel<T>[] path() {
- List<TreeNodeValueModel<T>> path = CollectionTools.reverseList(this.backPath());
- return path.toArray(new TreeNodeValueModel[path.size()]);
- }
-
- /**
- * Return an iterator that climbs up the node's path,
- * starting with, and including, the node
- * and up to, and including, the root node.
- */
- protected Iterator<TreeNodeValueModel<T>> backPath() {
- return new ChainIterator<TreeNodeValueModel<T>>(this) {
- @Override
- protected TreeNodeValueModel<T> nextLink(TreeNodeValueModel<T> currentLink) {
- return currentLink.parent();
- }
- };
- }
-
- public TreeNodeValueModel<T> child(int index) {
- return this.childrenModel().get(index);
- }
-
- public int childrenSize() {
- return this.childrenModel().size();
- }
-
- public int indexOfChild(TreeNodeValueModel<T> child) {
- ListValueModel<TreeNodeValueModel<T>> children = this.childrenModel();
- int size = children.size();
- for (int i = 0; i < size; i++) {
- if (children.get(i) == child) {
- return i;
- }
- }
- return -1;
- }
-
- public boolean isLeaf() {
- return this.childrenModel().size() == 0;
- }
-
-
- // ********** standard methods **********
-
- /**
- * We implement #equals(Object) so that TreePaths containing these nodes
- * will resolve properly when the nodes contain the same values. This is
- * necessary because nodes are dropped and rebuilt willy-nilly when dealing
- * with a sorted list of children; and this allows us to save and restore
- * a tree's expanded paths. The nodes in the expanded paths that are
- * saved before any modification (e.g. renaming a node) will be different
- * from the nodes in the tree's paths after the modification, if the modification
- * results in a possible change in the node sort order. ~bjv
- */
- @Override
- public boolean equals(Object o) {
- if (o == null) {
- return false;
- }
- if (o.getClass() != this.getClass()) {
- return false;
- }
- @SuppressWarnings("unchecked")
- AbstractTreeNodeValueModel<T> other = (AbstractTreeNodeValueModel<T>) o;
- return this.getValue().equals(other.getValue());
- }
-
- @Override
- public int hashCode() {
- return this.getValue().hashCode();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getValue());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AspectAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AspectAdapter.java
deleted file mode 100644
index f7d33d56e3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AspectAdapter.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * This abstract extension of AbstractModel provides a base for adding
- * change listeners (PropertyChange, CollectionChange, ListChange, TreeChange)
- * to a subject and converting the subject's change notifications into a single
- * set of change notifications for a common aspect (e.g. VALUE).
- *
- * The adapter will only listen to the subject (and subject holder) when the
- * adapter itself actually has listeners. This will allow the adapter to be
- * garbage collected when appropriate
- */
-public abstract class AspectAdapter<S>
- extends AbstractModel
-{
- /**
- * The subject that holds the aspect and fires
- * change notification when the aspect changes.
- * We need to hold on to this directly so we can
- * disengage it when it changes.
- */
- protected S subject;
-
- /**
- * A value model that holds the subject
- * that holds the aspect and provides change notification.
- * This is useful when there are a number of AspectAdapters
- * that have the same subject and that subject can change.
- * All the AspectAdapters should share the same subject holder.
- * For now, this is can only be set upon construction and is
- * immutable.
- */
- protected final PropertyValueModel<? extends S> subjectHolder;
-
- /** A listener that keeps us in synch with the subjectHolder. */
- protected final PropertyChangeListener subjectChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an AspectAdapter for the specified subject.
- */
- protected AspectAdapter(S subject) {
- this(new StaticPropertyValueModel<S>(subject));
- }
-
- /**
- * Construct an AspectAdapter for the specified subject holder.
- * The subject holder cannot be null.
- */
- protected AspectAdapter(PropertyValueModel<? extends S> subjectHolder) {
- super();
- if (subjectHolder == null) {
- throw new NullPointerException();
- }
- this.subjectHolder = subjectHolder;
- this.subjectChangeListener = this.buildSubjectChangeListener();
- // the subject is null when we are not listening to it
- // this will typically result in our value being null
- this.subject = null;
- }
-
-
- // ********** initialization **********
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new LocalChangeSupport(this, this.getListenerClass(), this.getListenerAspectName());
- }
-
- /**
- * The subject holder's value has changed, keep our subject in synch.
- */
- protected PropertyChangeListener buildSubjectChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- AspectAdapter.this.subjectChanged();
- }
- @Override
- public String toString() {
- return "subject change listener";
- }
- };
- }
-
-
- // ********** behavior **********
-
- /**
- * The subject has changed. Notify listeners that the value has changed.
- */
- protected synchronized void subjectChanged() {
- Object oldValue = this.getValue();
- boolean hasListeners = this.hasListeners();
- if (hasListeners) {
- this.disengageSubject();
- }
- this.subject = this.subjectHolder.getValue();
- if (hasListeners) {
- this.engageSubject();
- this.fireAspectChange(oldValue, this.getValue());
- }
- }
-
- /**
- * Return the aspect's current value.
- */
- protected abstract Object getValue();
-
- /**
- * Return the class of listener that is interested in the aspect adapter's
- * changes.
- */
- protected abstract Class<? extends ChangeListener> getListenerClass();
-
- /**
- * Return the name of the aspect adapter's aspect (e.g. VALUE).
- * This is the name of the aspect adapter's single aspect, not the
- * name of the subject's aspect the aspect adapter is adapting.
- */
- protected abstract String getListenerAspectName();
-
- /**
- * Return whether there are any listeners for the aspect.
- */
- protected abstract boolean hasListeners();
-
- /**
- * Return whether there are no listeners for the aspect.
- */
- protected boolean hasNoListeners() {
- return ! this.hasListeners();
- }
-
- /**
- * The aspect has changed, notify listeners appropriately.
- */
- protected abstract void fireAspectChange(Object oldValue, Object newValue);
-
- protected void engageSubject() {
- // check for nothing to listen to
- if (this.subject != null) {
- this.engageSubject_();
- }
- }
-
- /**
- * The subject is not null - add our listener.
- */
- protected abstract void engageSubject_();
-
- protected void disengageSubject() {
- // check for nothing to listen to
- if (this.subject != null) {
- this.disengageSubject_();
- }
- }
-
- /**
- * The subject is not null - remove our listener.
- */
- protected abstract void disengageSubject_();
-
- protected void engageSubjectHolder() {
- this.subjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.subjectChangeListener);
- // synch our subject *after* we start listening to the subject holder,
- // since its value might change when a listener is added
- this.subject = this.subjectHolder.getValue();
- }
-
- protected void disengageSubjectHolder() {
- this.subjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.subjectChangeListener);
- // clear out the subject when we are not listening to its holder
- this.subject = null;
- }
-
- protected void engageModels() {
- this.engageSubjectHolder();
- this.engageSubject();
- }
-
- protected void disengageModels() {
- this.disengageSubject();
- this.disengageSubjectHolder();
- }
-
-
- // ********** local change support **********
-
- /**
- * Extend change support to start listening to the aspect adapter's
- * models (the subject holder and the subject itself) when the first
- * relevant listener is added.
- * Conversely, stop listening to the aspect adapter's models when the
- * last relevant listener is removed.
- * A relevant listener is a listener of the relevant type.
- */
- protected class LocalChangeSupport extends SingleAspectChangeSupport {
- private static final long serialVersionUID = 1L;
-
- public LocalChangeSupport(AspectAdapter<S> source, Class<? extends ChangeListener> listenerClass, String aspectName) {
- super(source, listenerClass, aspectName);
- }
-
- protected boolean listenerIsRelevant(Class<? extends ChangeListener> lClass) {
- return lClass == this.listenerClass;
- }
-
- protected boolean hasNoRelevantListeners(Class<? extends ChangeListener> lClass) {
- return this.listenerIsRelevant(lClass)
- && this.hasNoListeners(lClass);
- }
-
- protected boolean listenerIsRelevant(Class<? extends ChangeListener> lClass, String listenerAspectName) {
- return this.listenerIsRelevant(lClass)
- && (listenerAspectName == AspectAdapter.this.getListenerAspectName());
- }
-
- protected boolean hasNoRelevantListeners(Class<? extends ChangeListener> lClass, String listenerAspectName) {
- return this.listenerIsRelevant(lClass, listenerAspectName)
- && this.hasNoListeners(lClass, listenerAspectName);
- }
-
-
- // ********** overrides **********
-
- @Override
- protected <T extends ChangeListener> void addListener(Class<T> lClass, T listener) {
- if (this.hasNoRelevantListeners(lClass)) {
- AspectAdapter.this.engageModels();
- }
- super.addListener(lClass, listener);
- }
-
- @Override
- protected <T extends ChangeListener> void addListener(String listenerAspectName, Class<T> lClass, T listener) {
- if (this.hasNoRelevantListeners(lClass, listenerAspectName)) {
- AspectAdapter.this.engageModels();
- }
- super.addListener(listenerAspectName, lClass, listener);
- }
-
- @Override
- protected <T extends ChangeListener> void removeListener(Class<T> lClass, T listener) {
- super.removeListener(lClass, listener);
- if (this.hasNoRelevantListeners(lClass)) {
- AspectAdapter.this.disengageModels();
- }
- }
-
- @Override
- protected <T extends ChangeListener> void removeListener(String listenerAspectName, Class<T> lClass, T listener) {
- super.removeListener(listenerAspectName, lClass, listener);
- if (this.hasNoRelevantListeners(lClass, listenerAspectName)) {
- AspectAdapter.this.disengageModels();
- }
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AspectPropertyValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AspectPropertyValueModelAdapter.java
deleted file mode 100644
index 75853757ad..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AspectPropertyValueModelAdapter.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * a value model, "lazily" listen to it, and convert
- * its change notifications into property value model change
- * notifications.
- *
- * Subclasses must override:
- * - #buildValue()
- * to return the current property value, as derived from the
- * current model value
- *
- */
-public abstract class AspectPropertyValueModelAdapter<T>
- extends AbstractModel
- implements PropertyValueModel<T>
-{
- /**
- * Cache the current value so we can pass an "old value" when
- * we fire a property change event.
- * We need this because the value may be calculated and we may
- * not able to derive the "old value" from the collection
- * change event fired by the collection value model.
- */
- protected T value;
-
-
- // ********** constructor/initialization **********
-
- protected AspectPropertyValueModelAdapter() {
- super();
- // our value is null when we are not listening to the collection holder
- this.value = null;
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, PropertyChangeListener.class, VALUE);
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- /**
- * Return the cached value.
- */
- public T getValue() {
- return this.value;
- }
-
-
- // ********** extend change support **********
-
- /**
- * Extend to start listening to the wrapped collection if necessary.
- */
- @Override
- public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addPropertyChangeListener(listener);
- }
-
- /**
- * Extend to start listening to the wrapped collection if necessary.
- */
- @Override
- public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- if (propertyName == VALUE && this.hasNoListeners()) {
- this.engageModel();
- }
- super.addPropertyChangeListener(propertyName, listener);
- }
-
- /**
- * Extend to stop listening to the wrapped collection if necessary.
- */
- @Override
- public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
- super.removePropertyChangeListener(listener);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Extend to stop listening to the wrapped collection if necessary.
- */
- @Override
- public synchronized void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- super.removePropertyChangeListener(propertyName, listener);
- if (propertyName == VALUE && this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether there are any listeners for the aspect.
- */
- protected boolean hasListeners() {
- return this.hasAnyPropertyChangeListeners(VALUE);
- }
-
- /**
- * Return whether there are any listeners for the aspect.
- */
- protected boolean hasNoListeners() {
- return ! this.hasListeners();
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the model and build the value.
- */
- protected void engageModel() {
- this.engageModel_();
- // synch our value *after* we start listening to the collection,
- // since the collection's value might change when a listener is added
- this.value = this.buildValue();
- }
-
- /**
- * Start listening to the model.
- */
- protected abstract void engageModel_();
-
- /**
- * Build and return the current value, as derived from the
- * current state of the wrapped model.
- */
- protected abstract T buildValue();
-
- /**
- * Stop listening to the model and clear the value.
- */
- protected void disengageModel() {
- this.disengageModel_();
- // clear out our value when we are not listening to the collection
- this.value = null;
- }
-
- /**
- * Stop listening to the model.
- */
- protected abstract void disengageModel_();
-
- /**
- * The wrapped model changed in some fashion.
- * Recalculate the value and notify any listeners.
- */
- protected void propertyChanged() {
- Object old = this.value;
- this.value = this.buildValue();
- this.firePropertyChanged(VALUE, old, this.value);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/BufferedWritablePropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/BufferedWritablePropertyValueModel.java
deleted file mode 100644
index 8781be4afd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/BufferedWritablePropertyValueModel.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * A BufferedPropertyValueModel is used to hold a temporary copy of the value
- * in another property value model (the "wrapped" value holder). The application
- * can modify this temporary copy, ad nauseam; but the temporary copy is only
- * passed through to the "wrapped" value holder when the trigger "accepts" the
- * buffered value. Alternatively, the application can "reset" the buffered value
- * to the original, "wrapped" value.
- *
- * The trigger is another value model that holds a Boolean and the application
- * changes the trigger's value to true on "accept", false on "reset". Typically,
- * in a dialog:
- * - pressing the OK button will trigger an "accept" and close the dialog
- * - pressing the Cancel button will simply close the dialog,
- * dropping the "buffered" values into the bit bucket
- * - pressing the Apply button will trigger an "accept" and leave the dialog open
- * - pressing the Restore button will trigger a "reset" and leave the dialog open
- *
- * A number of buffered property value models can wrap another set of
- * property aspect adapters that adapt the various aspects of a single
- * domain model. All the bufferd property value models can be hooked to the
- * same trigger, and that trigger is controlled by the application, typically
- * via the OK button in a dialog.
- *
- * @see PropertyAspectAdapter
- */
-public class BufferedWritablePropertyValueModel<T>
- extends PropertyValueModelWrapper<T>
- implements WritablePropertyValueModel<T>
-{
-
- /**
- * We cache the value here until it is accepted and passed
- * through to the wrapped value holder.
- */
- protected T bufferedValue;
-
- /**
- * This is set to true when we are "accepting" the buffered value
- * and passing it through to the wrapped value holder. This allows
- * us to ignore the property change event fired by the wrapped
- * value holder.
- * (We can't stop listening to the wrapped value holder, because
- * if we are the only listener that could "deactivate" the wrapped
- * value holder.)
- */
- protected boolean accepting;
-
- /**
- * This is the trigger that indicates whether the buffered value
- * should be accepted or reset.
- */
- protected final PropertyValueModel<Boolean> triggerHolder;
-
- /** This listens to the trigger holder. */
- protected final PropertyChangeListener triggerChangeListener;
-
- /**
- * This flag indicates whether our buffered value has been assigned
- * a value and is possibly out of synch with the wrapped value.
- */
- protected boolean buffering;
-
-
- // ********** constructors **********
-
- /**
- * Construct a buffered property value model with the specified wrapped
- * property value model and trigger holder.
- */
- public BufferedWritablePropertyValueModel(WritablePropertyValueModel<T> valueHolder, PropertyValueModel<Boolean> triggerHolder) {
- super(valueHolder);
- if (triggerHolder == null) {
- throw new NullPointerException();
- }
- this.triggerHolder = triggerHolder;
- this.bufferedValue = null;
- this.buffering = false;
- this.accepting = false;
- this.triggerChangeListener = this.buildTriggerChangeListener();
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildTriggerChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- BufferedWritablePropertyValueModel.this.triggerChanged(event);
- }
- @Override
- public String toString() {
- return "trigger change listener";
- }
- };
- }
-
-
- // ********** ValueModel implementation **********
-
- /**
- * If we are currently "buffering" a value, return that;
- * otherwise, return the wrapped value.
- */
- public T getValue() {
- return this.buffering ? this.bufferedValue : this.valueHolder.getValue();
- }
-
- /**
- * Assign the new value to our "buffered" value.
- * It will be forwarded to the wrapped value holder
- * when the trigger is "accepted".
- */
- public void setValue(T value) {
- Object old = this.getValue();
- this.bufferedValue = value;
- this.buffering = true;
- this.firePropertyChanged(VALUE, old, this.bufferedValue);
- }
-
-
- // ********** PropertyValueModelWrapper extensions **********
-
- /**
- * extend to engage the trigger holder also
- */
- @Override
- protected void engageValueHolder() {
- super.engageValueHolder();
- this.triggerHolder.addPropertyChangeListener(VALUE, this.triggerChangeListener);
- }
-
- /**
- * extend to disengage the trigger holder also
- */
- @Override
- protected void disengageValueHolder() {
- this.triggerHolder.removePropertyChangeListener(VALUE, this.triggerChangeListener);
- super.disengageValueHolder();
- }
-
-
- // ********** behavior **********
-
- /**
- * If we do not yet have a "buffered" value, simply propagate the
- * change notification with the buffered model as the source.
- * If we do have a "buffered" value, do nothing.
- */
- @Override
- protected void valueChanged(PropertyChangeEvent event) {
- if (this.accepting) {
- // if we are currently "accepting" the value, ignore change notifications,
- // since we caused them and our own listeners are already aware of the change
- return;
- }
- if (this.buffering) {
- this.handleChangeConflict(event);
- } else {
- this.firePropertyChanged(event.cloneWithSource(this));
- }
- }
-
- /**
- * By default, if we have a "buffered" value and the "wrapped" value changes,
- * we simply ignore the new "wrapped" value and simply overlay it with the
- * "buffered" value if it is "accepted". ("Last One In Wins" concurrency model)
- * Subclasses can override this method to change that behavior with a
- * different concurrency model. For example, you could drop the "buffered" value
- * and replace it with the new "wrapped" value, or you could throw an
- * exception.
- */
- protected void handleChangeConflict(PropertyChangeEvent event) {
- // the default is to do nothing
- }
-
- /**
- * The trigger changed:
- * If it is now true, "accept" the buffered value and forward
- * it to the wrapped value holder.
- * If it is now false, "reset" the buffered value to its original value.
- */
- protected void triggerChanged(PropertyChangeEvent event) {
- if ( ! this.buffering) {
- // if nothing has been "buffered", we don't need to do anything:
- // nothing needs to be passed through; nothing needs to be reset;
- return;
- }
- if (((Boolean) event.getNewValue()).booleanValue()) {
- // set the accepting flag so we ignore any events
- // fired by the wrapped value holder
- this.accepting = true;
- this.valueHolder().setValue(this.bufferedValue);
- this.bufferedValue = null;
- this.buffering = false;
- // clear the flag once the "accept" is complete
- this.accepting = false;
- } else {
- // notify our listeners that our value has been reset
- Object old = this.bufferedValue;
- this.bufferedValue = null;
- this.buffering = false;
- this.firePropertyChanged(VALUE, old, this.valueHolder.getValue());
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getValue());
- }
-
-
- // ********** convenience methods **********
-
- /**
- * Return whether the buffered model is currently "buffering"
- * a value.
- */
- public boolean isBuffering() {
- return this.buffering;
- }
-
- /**
- * Our constructor accepts only a WritablePropertyValueModel<T>.
- */
- @SuppressWarnings("unchecked")
- protected WritablePropertyValueModel<T> valueHolder() {
- return (WritablePropertyValueModel<T>) this.valueHolder;
- }
-
-
- // ********** inner class **********
-
- /**
- * Trigger is a special property value model that only maintains its
- * value (of true or false) during the change notification caused by
- * the #setValue(Object) method. In other words, a Trigger object
- * only has a valid value
- */
- public static class Trigger extends SimplePropertyValueModel<Boolean> {
-
-
- // ********** constructor **********
-
- /**
- * Construct a trigger with a null value.
- */
- public Trigger() {
- super();
- }
-
-
- // ********** ValueModel implementation **********
-
- /**
- * Extend so that this method can only be invoked during
- * change notification triggered by #setValue(Object).
- */
- @Override
- public Boolean getValue() {
- if (this.value == null) {
- throw new IllegalStateException("The method Trigger.value() may only be called during change notification.");
- }
- return this.value;
- }
-
- /**
- * Extend to reset the value to null once all the
- * listeners have been notified.
- */
- @Override
- public void setValue(Boolean value) {
- super.setValue(value);
- this.value = null;
- }
-
-
- // ********** convenience methods **********
-
- /**
- * Set the trigger's value:
- * - true indicates "accept"
- * - false indicates "reset"
- */
- public void setValue(boolean value) {
- this.setValue(Boolean.valueOf(value));
- }
-
- /**
- * Return the trigger's value:
- * - true indicates "accept"
- * - false indicates "reset"
- */
- public boolean booleanValue() {
- return this.getValue().booleanValue();
- }
-
- /**
- * Accept the trigger (i.e. set its value to true).
- */
- public void accept() {
- this.setValue(true);
- }
-
- /**
- * Return whether the trigger has been accepted
- * (i.e. its value was changed to true).
- */
- public boolean isAccepted() {
- return this.booleanValue();
- }
-
- /**
- * Reset the trigger (i.e. set its value to false).
- */
- public void reset() {
- this.setValue(false);
- }
-
- /**
- * Return whether the trigger has been reset
- * (i.e. its value was changed to false).
- */
- public boolean isReset() {
- return ! this.booleanValue();
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java
deleted file mode 100644
index 725c275d31..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * This extension of AspectAdapter provides CollectionChange support.
- * This allows us to convert a set of one or more collections into
- * a single collection, VALUES.
- *
- * The typical subclass will override the following methods:
- * #iterator_()
- * at the very minimum, override this method to return an iterator on the
- * subject's collection aspect; it does not need to be overridden if
- * #iterator() is overridden and its behavior changed
- * #size_()
- * override this method to improve performance; it does not need to be overridden if
- * #size() is overridden and its behavior changed
- * #iterator()
- * override this method only if returning an empty iterator when the
- * subject is null is unacceptable
- * #size()
- * override this method only if returning a zero when the
- * subject is null is unacceptable
- */
-public abstract class CollectionAspectAdapter<S extends Model, E>
- extends AspectAdapter<S>
- implements CollectionValueModel<E>
-{
- /**
- * The name of the subject's collections that we use for the value.
- */
- protected final String[] collectionNames;
- protected static final String[] EMPTY_COLLECTION_NAMES = new String[0];
-
- /** A listener that listens to the subject's collection aspect. */
- protected final CollectionChangeListener collectionChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a CollectionAspectAdapter for the specified subject
- * and collection.
- */
- protected CollectionAspectAdapter(String collectionName, S subject) {
- this(new String[] {collectionName}, subject);
- }
-
- /**
- * Construct a CollectionAspectAdapter for the specified subject
- * and collections.
- */
- protected CollectionAspectAdapter(String[] collectionNames, S subject) {
- this(new StaticPropertyValueModel<S>(subject), collectionNames);
- }
-
- /**
- * Construct a CollectionAspectAdapter for the specified subject holder
- * and collections.
- */
- protected CollectionAspectAdapter(PropertyValueModel<? extends S> subjectHolder, String... collectionNames) {
- super(subjectHolder);
- this.collectionNames = collectionNames;
- this.collectionChangeListener = this.buildCollectionChangeListener();
- }
-
- /**
- * Construct a CollectionAspectAdapter for the specified subject holder
- * and collections.
- */
- protected CollectionAspectAdapter(PropertyValueModel<? extends S> subjectHolder, Collection<String> collectionNames) {
- this(subjectHolder, collectionNames.toArray(new String[collectionNames.size()]));
- }
-
- /**
- * Construct a CollectionAspectAdapter for an "unchanging" collection in
- * the specified subject. This is useful for a collection aspect that does not
- * change for a particular subject; but the subject will change, resulting in
- * a new collection.
- */
- protected CollectionAspectAdapter(PropertyValueModel<? extends S> subjectHolder) {
- this(subjectHolder, EMPTY_COLLECTION_NAMES);
- }
-
-
- // ********** initialization **********
-
- /**
- * The subject's collection aspect has changed, notify the listeners.
- */
- protected CollectionChangeListener buildCollectionChangeListener() {
- // transform the subject's collection change events into VALUE collection change events
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent event) {
- CollectionAspectAdapter.this.itemsAdded(event);
- }
- public void itemsRemoved(CollectionChangeEvent event) {
- CollectionAspectAdapter.this.itemsRemoved(event);
- }
- public void collectionCleared(CollectionChangeEvent event) {
- CollectionAspectAdapter.this.collectionCleared(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- CollectionAspectAdapter.this.collectionChanged(event);
- }
- @Override
- public String toString() {
- return "collection change listener: " + Arrays.asList(CollectionAspectAdapter.this.collectionNames);
- }
- };
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- /**
- * Return the elements of the subject's collection aspect.
- */
- public Iterator<E> iterator() {
- return (this.subject == null) ? EmptyIterator.<E>instance() : this.iterator_();
- }
-
- /**
- * Return the elements of the subject's collection aspect.
- * At this point we can be sure that the subject is not null.
- * @see #iterator()
- */
- protected Iterator<E> iterator_() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Return the size of the subject's collection aspect.
- */
- public int size() {
- return (this.subject == null) ? 0 : this.size_();
- }
-
- /**
- * Return the size of the subject's collection aspect.
- * At this point we can be sure that the subject is not null.
- * @see #size()
- */
- protected int size_() {
- return CollectionTools.size(this.iterator());
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected Object getValue() {
- return this.iterator();
- }
-
- @Override
- protected Class<? extends ChangeListener> getListenerClass() {
- return CollectionChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return VALUES;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyCollectionChangeListeners(VALUES);
- }
-
- @Override
- protected void fireAspectChange(Object oldValue, Object newValue) {
- this.fireCollectionChanged(VALUES);
- }
-
- @Override
- protected void engageSubject_() {
- for (String collectionName : this.collectionNames) {
- ((Model) this.subject).addCollectionChangeListener(collectionName, this.collectionChangeListener);
- }
- }
-
- @Override
- protected void disengageSubject_() {
- for (String collectionName : this.collectionNames) {
- ((Model) this.subject).removeCollectionChangeListener(collectionName, this.collectionChangeListener);
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- for (int i = 0; i < this.collectionNames.length; i++) {
- if (i != 0) {
- sb.append(", ");
- }
- sb.append(this.collectionNames[i]);
- }
- }
-
-
- // ********** behavior **********
-
- protected void itemsAdded(CollectionChangeEvent event) {
- this.fireItemsAdded(event.cloneWithSource(this, VALUES));
- }
-
- protected void itemsRemoved(CollectionChangeEvent event) {
- this.fireItemsRemoved(event.cloneWithSource(this, VALUES));
- }
-
- protected void collectionCleared(CollectionChangeEvent event) {
- this.fireCollectionCleared(VALUES); // nothing from original event to forward
- }
-
- protected void collectionChanged(CollectionChangeEvent event) {
- this.fireCollectionChanged(VALUES); // nothing from original event to forward
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java
deleted file mode 100644
index 32ac311a6e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * An adapter that allows us to make a CollectionValueModel behave like
- * a read-only ListValueModel, sorta.
- *
- * To maintain a reasonably consistent appearance to client code, we
- * keep an internal list somewhat in synch with the wrapped collection.
- *
- * NB: Since we only listen to the wrapped collection when we have
- * listeners ourselves and we can only stay in synch with the wrapped
- * collection while we are listening to it, results to various methods
- * (e.g. #size(), getItem(int)) will be unpredictable whenever
- * we do not have any listeners. This should not be too painful since,
- * most likely, client objects will also be listeners.
- */
-public class CollectionListValueModelAdapter<E>
- extends AbstractModel
- implements ListValueModel<E>
-{
- /** The wrapped collection value model. */
- protected final CollectionValueModel<? extends E> collectionHolder;
-
- /** A listener that forwards any events fired by the collection holder. */
- protected final CollectionChangeListener collectionChangeListener;
-
- /**
- * Our internal list, which holds the same elements as
- * the wrapped collection, but keeps them in order.
- */
- // we declare this an ArrayList so we can use #clone() and #ensureCapacity(int)
- protected final ArrayList<E> list;
-
-
- // ********** constructors **********
-
- /**
- * Wrap the specified CollectionValueModel.
- */
- public CollectionListValueModelAdapter(CollectionValueModel<? extends E> collectionHolder) {
- super();
- if (collectionHolder == null) {
- throw new NullPointerException();
- }
- this.collectionHolder = collectionHolder;
- this.collectionChangeListener = this.buildCollectionChangeListener();
- this.list = new ArrayList<E>();
- // postpone building the list and listening to the underlying collection
- // until we have listeners ourselves...
- }
-
-
- // ********** initialization **********
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, ListChangeListener.class, LIST_VALUES);
- }
-
- /**
- * The wrapped collection has changed, forward an equivalent
- * list change event to our listeners.
- */
- protected CollectionChangeListener buildCollectionChangeListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent event) {
- CollectionListValueModelAdapter.this.itemsAdded(event);
- }
- public void itemsRemoved(CollectionChangeEvent event) {
- CollectionListValueModelAdapter.this.itemsRemoved(event);
- }
- public void collectionCleared(CollectionChangeEvent event) {
- CollectionListValueModelAdapter.this.collectionCleared(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- CollectionListValueModelAdapter.this.collectionChanged(event);
- }
- @Override
- public String toString() {
- return "collection change listener";
- }
- };
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E> listIterator() {
- return new ReadOnlyListIterator<E>(this.list);
- }
-
- public E get(int index) {
- return this.list.get(index);
- }
-
- public int size() {
- return this.list.size();
- }
-
- public Object[] toArray() {
- return this.list.toArray();
- }
-
-
- // ********** extend change support **********
-
- /**
- * Override to start listening to the collection holder if necessary.
- */
- @Override
- public void addListChangeListener(ListChangeListener listener) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addListChangeListener(listener);
- }
-
- /**
- * Override to start listening to the collection holder if necessary.
- */
- @Override
- public void addListChangeListener(String listName, ListChangeListener listener) {
- if (listName == LIST_VALUES && this.hasNoListeners()) {
- this.engageModel();
- }
- super.addListChangeListener(listName, listener);
- }
-
- /**
- * Override to stop listening to the collection holder if appropriate.
- */
- @Override
- public void removeListChangeListener(ListChangeListener listener) {
- super.removeListChangeListener(listener);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Override to stop listening to the collection holder if appropriate.
- */
- @Override
- public void removeListChangeListener(String listName, ListChangeListener listener) {
- super.removeListChangeListener(listName, listener);
- if (listName == LIST_VALUES && this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** queries **********
-
- protected boolean hasListeners() {
- return this.hasAnyListChangeListeners(LIST_VALUES);
- }
-
- protected boolean hasNoListeners() {
- return ! this.hasListeners();
- }
-
- /**
- * Return the index of the specified item, using object
- * identity instead of equality.
- */
- protected int lastIdentityIndexOf(Object o) {
- return this.lastIdentityIndexOf(o, this.list.size());
- }
-
- /**
- * Return the last index of the specified item, starting just before the
- * the specified endpoint, and using object identity instead of equality.
- */
- protected int lastIdentityIndexOf(Object o, int end) {
- for (int i = end; i-- > 0; ) {
- if (this.list.get(i) == o) {
- return i;
- }
- }
- return -1;
- }
-
-
- // ********** behavior **********
-
- protected void buildList() {
- Iterator<? extends E> stream = this.collectionHolder.iterator();
- // if the new collection is empty, do nothing
- if (stream.hasNext()) {
- this.list.ensureCapacity(this.collectionHolder.size());
- while (stream.hasNext()) {
- this.list.add(stream.next());
- }
- this.postBuildList();
- }
- }
-
- /**
- * Allow subclasses to manipulate the internal list before
- * sending out change notification.
- */
- protected void postBuildList() {
- // the default is to do nothing...
- }
-
- protected void engageModel() {
- this.collectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.collectionChangeListener);
- // synch our list *after* we start listening to the collection holder,
- // since its value might change when a listener is added
- this.buildList();
- }
-
- protected void disengageModel() {
- this.collectionHolder.removeCollectionChangeListener(CollectionValueModel.VALUES, this.collectionChangeListener);
- // clear out the list when we are not listening to the collection holder
- this.list.clear();
- }
-
- protected void itemsAdded(CollectionChangeEvent e) {
- this.addItemsToList(this.indexToAddItems(), CollectionTools.list(this.items(e)), this.list, LIST_VALUES);
- }
-
- protected int indexToAddItems() {
- return this.list.size();
- }
-
- @SuppressWarnings("unchecked")
- protected Iterator<E> items(CollectionChangeEvent e) {
- return (Iterator<E>) e.items();
- }
-
- protected void itemsRemoved(CollectionChangeEvent e) {
- // we have to remove the items individually,
- // since they are probably not in sequence
- for (Iterator<E> stream = this.items(e); stream.hasNext(); ) {
- this.removeItemFromList(this.lastIdentityIndexOf(stream.next()), this.list, LIST_VALUES);
- }
- }
-
- protected void collectionCleared(CollectionChangeEvent e) {
- this.clearList(this.list, LIST_VALUES);
- }
-
- /**
- * synchronize our internal list with the wrapped collection
- * and fire the appropriate events
- */
- protected void collectionChanged(CollectionChangeEvent e) {
- // put in empty check so we don't fire events unnecessarily
- if ( ! this.list.isEmpty()) {
- @SuppressWarnings("unchecked")
- ArrayList<E> removedItems = (ArrayList<E>) this.list.clone();
- this.list.clear();
- this.fireItemsRemoved(LIST_VALUES, 0, removedItems);
- }
-
- this.buildList();
- // put in empty check so we don't fire events unnecessarily
- if ( ! this.list.isEmpty()) {
- this.fireItemsAdded(LIST_VALUES, 0, this.list);
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.collectionHolder);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionPropertyValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionPropertyValueModelAdapter.java
deleted file mode 100644
index a28ff711db..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionPropertyValueModelAdapter.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * a collection value model, "lazily" listen to it, and convert
- * its change notifications into property value model change
- * notifications.
- *
- * Subclasses must override:
- * - #buildValue()
- * to return the current property value, as derived from the
- * current collection value
- *
- * Subclasses might want to override:
- * - #itemsAdded(CollectionChangeEvent event)
- * - #itemsRemoved(CollectionChangeEvent event)
- * - #collectionCleared(CollectionChangeEvent event)
- * - #collectionChanged(CollectionChangeEvent event)
- * to improve performance (by not recalculating the value, if possible)
- */
-public abstract class CollectionPropertyValueModelAdapter<T>
- extends AspectPropertyValueModelAdapter<T>
-{
- /** The wrapped collection value model. */
- protected final CollectionValueModel<?> collectionHolder;
-
- /** A listener that allows us to synch with changes to the wrapped collection holder. */
- protected final CollectionChangeListener collectionChangeListener;
-
-
- // ********** constructor/initialization **********
-
- /**
- * Construct a property value model with the specified wrapped
- * collection value model.
- */
- protected CollectionPropertyValueModelAdapter(CollectionValueModel<?> collectionHolder) {
- super();
- this.collectionHolder = collectionHolder;
- this.collectionChangeListener = this.buildCollectionChangeListener();
- }
-
- protected CollectionChangeListener buildCollectionChangeListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent event) {
- CollectionPropertyValueModelAdapter.this.itemsAdded(event);
- }
- public void itemsRemoved(CollectionChangeEvent event) {
- CollectionPropertyValueModelAdapter.this.itemsRemoved(event);
- }
- public void collectionCleared(CollectionChangeEvent event) {
- CollectionPropertyValueModelAdapter.this.collectionCleared(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- CollectionPropertyValueModelAdapter.this.collectionChanged(event);
- }
- @Override
- public String toString() {
- return "collection change listener";
- }
- };
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the collection holder.
- */
- @Override
- protected void engageModel_() {
- this.collectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.collectionChangeListener);
- }
-
- /**
- * Stop listening to the collection holder.
- */
- @Override
- protected void disengageModel_() {
- this.collectionHolder.removeCollectionChangeListener(CollectionValueModel.VALUES, this.collectionChangeListener);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.collectionHolder);
- }
-
-
- // ********** collection change support **********
-
- /**
- * Items were added to the wrapped collection holder;
- * propagate the change notification appropriately.
- */
- protected void itemsAdded(CollectionChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * Items were removed from the wrapped collection holder;
- * propagate the change notification appropriately.
- */
- protected void itemsRemoved(CollectionChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * The wrapped collection holder was cleared;
- * propagate the change notification appropriately.
- */
- protected void collectionCleared(CollectionChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * The value of the wrapped collection holder has changed;
- * propagate the change notification appropriately.
- */
- protected void collectionChanged(CollectionChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java
deleted file mode 100644
index f4bd305c89..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * another collection value model, "lazily" listen to it, and propagate
- * its change notifications.
- */
-public abstract class CollectionValueModelWrapper<E>
- extends AbstractModel
-{
-
- /** The wrapped collection value model. */
- protected final CollectionValueModel<? extends E> collectionHolder;
-
- /** A listener that allows us to synch with changes to the wrapped collection holder. */
- protected final CollectionChangeListener collectionChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a collection value model with the specified wrapped
- * collection value model.
- */
- protected CollectionValueModelWrapper(CollectionValueModel<? extends E> collectionHolder) {
- super();
- this.collectionHolder = collectionHolder;
- this.collectionChangeListener = this.buildCollectionChangeListener();
- }
-
-
- // ********** initialization **********
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, CollectionChangeListener.class, CollectionValueModel.VALUES);
- }
-
- protected CollectionChangeListener buildCollectionChangeListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent event) {
- CollectionValueModelWrapper.this.itemsAdded(event);
- }
- public void itemsRemoved(CollectionChangeEvent event) {
- CollectionValueModelWrapper.this.itemsRemoved(event);
- }
- public void collectionCleared(CollectionChangeEvent event) {
- CollectionValueModelWrapper.this.collectionCleared(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- CollectionValueModelWrapper.this.collectionChanged(event);
- }
- @Override
- public String toString() {
- return "collection change listener";
- }
- };
- }
-
-
- // ********** extend change support **********
-
- /**
- * Extend to start listening to the nested model if necessary.
- */
- @Override
- public synchronized void addCollectionChangeListener(CollectionChangeListener listener) {
- if (this.hasNoCollectionChangeListeners(CollectionValueModel.VALUES)) {
- this.engageModel();
- }
- super.addCollectionChangeListener(listener);
- }
-
- /**
- * Extend to start listening to the nested model if necessary.
- */
- @Override
- public synchronized void addCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- if (collectionName == CollectionValueModel.VALUES && this.hasNoCollectionChangeListeners(CollectionValueModel.VALUES)) {
- this.engageModel();
- }
- super.addCollectionChangeListener(collectionName, listener);
- }
-
- /**
- * Extend to stop listening to the nested model if necessary.
- */
- @Override
- public synchronized void removeCollectionChangeListener(CollectionChangeListener listener) {
- super.removeCollectionChangeListener(listener);
- if (this.hasNoCollectionChangeListeners(CollectionValueModel.VALUES)) {
- this.disengageModel();
- }
- }
-
- /**
- * Extend to stop listening to the nested model if necessary.
- */
- @Override
- public synchronized void removeCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- super.removeCollectionChangeListener(collectionName, listener);
- if (collectionName == CollectionValueModel.VALUES && this.hasNoCollectionChangeListeners(CollectionValueModel.VALUES)) {
- this.disengageModel();
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the collection holder.
- */
- protected void engageModel() {
- this.collectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.collectionChangeListener);
- }
-
- /**
- * Stop listening to the collection holder.
- */
- protected void disengageModel() {
- this.collectionHolder.removeCollectionChangeListener(CollectionValueModel.VALUES, this.collectionChangeListener);
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterator<E> items(CollectionChangeEvent event) {
- return (Iterator<E>) event.items();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.collectionHolder);
- }
-
-
- // ********** collection change support **********
-
- /**
- * Items were added to the wrapped collection holder;
- * propagate the change notification appropriately.
- */
- protected abstract void itemsAdded(CollectionChangeEvent event);
-
- /**
- * Items were removed from the wrapped collection holder;
- * propagate the change notification appropriately.
- */
- protected abstract void itemsRemoved(CollectionChangeEvent event);
-
- /**
- * The wrapped collection holder was cleared;
- * propagate the change notification appropriately.
- */
- protected abstract void collectionCleared(CollectionChangeEvent event);
-
- /**
- * The value of the wrapped collection holder has changed;
- * propagate the change notification appropriately.
- */
- protected abstract void collectionChanged(CollectionChangeEvent event);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java
deleted file mode 100644
index 2fd65eebb1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java
+++ /dev/null
@@ -1,407 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.NullList;
-import org.eclipse.jpt.utility.internal.Transformer;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * A <code>CompositeCollectionValueModel</code> wraps another
- * <code>CollectionValueModel</code> and uses a <code>Transformer</code>
- * to convert each item in the wrapped collection to yet another
- * <code>CollectionValueModel</code>. This composite collection contains
- * the combined items from all these component collections.
- *
- * NB: The wrapped collection must be an "identity set" that does not
- * contain the same item twice or this class will throw an exception.
- *
- * Terminology:
- * - sources - the items in the wrapped collection value model; these
- * are converted into component CVMs by the transformer
- * - component CVMs - the component collection value models that are combined
- * by this composite collection value model
- * - items - the items held by the component CVMs
- */
-public class CompositeCollectionValueModel<E1, E2>
- extends CollectionValueModelWrapper<E1>
- implements CollectionValueModel<E2>
-{
- /**
- * This is the (optional) user-supplied object that transforms
- * the items in the wrapped collection to collection value models.
- */
- private final Transformer<E1, CollectionValueModel<E2>> transformer;
-
- /**
- * Cache of the component collection value models that
- * were generated by the transformer; keyed by the item
- * in the wrapped collection that was passed to the transformer.
- */
- private final IdentityHashMap<E1, CollectionValueModel<E2>> componentCVMs;
-
- /**
- * Cache of the collections corresponding to the component
- * collection value models above; keyed by the component
- * collection value models.
- * Use ArrayLists so we can use ArrayList-specific methods
- * (e.g. #clone() and #ensureCapacity()).
- */
- private final IdentityHashMap<CollectionValueModel<E2>, ArrayList<E2>> collections;
-
- /** Listener that listens to all the component collection value models. */
- private final CollectionChangeListener componentCVMListener;
-
- /** Cache the size of the composite collection. */
- private int size;
-
-
- // ********** constructors **********
-
- /**
- * Construct a collection value model with the specified wrapped
- * collection value model. Use this constructor if
- * - the wrapped collection value model already contains other
- * collection value models or
- * - you want to override the <code>transform(E1)</code> method
- * instead of building a <code>Transformer</code>
- */
- public CompositeCollectionValueModel(CollectionValueModel<? extends E1> collectionHolder) {
- this(collectionHolder, Transformer.Null.<E1, CollectionValueModel<E2>>instance());
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * collection value model and transformer.
- */
- public CompositeCollectionValueModel(CollectionValueModel<? extends E1> collectionHolder, Transformer<E1, CollectionValueModel<E2>> transformer) {
- super(collectionHolder);
- this.transformer = transformer;
- this.componentCVMs = new IdentityHashMap<E1, CollectionValueModel<E2>>();
- this.collections = new IdentityHashMap<CollectionValueModel<E2>, ArrayList<E2>>();
- this.componentCVMListener = this.buildComponentListener();
- this.size = 0;
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * list value model. Use this constructor if
- * - the wrapped list value model already contains collection
- * value models or
- * - you want to override the <code>transform(E1)</code> method
- * instead of building a <code>Transformer</code>
- */
- public CompositeCollectionValueModel(ListValueModel<? extends E1> listHolder) {
- this(new ListCollectionValueModelAdapter<E1>(listHolder));
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * list value model and transformer.
- */
- public CompositeCollectionValueModel(ListValueModel<? extends E1> listHolder, Transformer<E1, CollectionValueModel<E2>> transformer) {
- this(new ListCollectionValueModelAdapter<E1>(listHolder), transformer);
- }
-
- /**
- * Construct a collection value model with the specified, unchanging, wrapped
- * collection. Use this constructor if
- * - the wrapped collection already contains collection
- * value models or
- * - you want to override the <code>transform(E1)</code> method
- * instead of building a <code>Transformer</code>
- */
- public CompositeCollectionValueModel(Collection<? extends E1> collection) {
- this(new StaticCollectionValueModel<E1>(collection));
- }
-
- /**
- * Construct a collection value model with the specified, unchanging, wrapped
- * collection and transformer.
- */
- public CompositeCollectionValueModel(Collection<? extends E1> collection, Transformer<E1, CollectionValueModel<E2>> transformer) {
- this(new StaticCollectionValueModel<E1>(collection), transformer);
- }
-
-
- // ********** initialization **********
-
- protected CollectionChangeListener buildComponentListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent event) {
- CompositeCollectionValueModel.this.componentItemsAdded(event);
- }
- public void itemsRemoved(CollectionChangeEvent event) {
- CompositeCollectionValueModel.this.componentItemsRemoved(event);
- }
- public void collectionCleared(CollectionChangeEvent event) {
- CompositeCollectionValueModel.this.componentCollectionCleared(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- CompositeCollectionValueModel.this.componentCollectionChanged(event);
- }
- @Override
- public String toString() {
- return "component listener";
- }
- };
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public Iterator<E2> iterator() {
- return new CompositeIterator<E2>(this.buildCollectionsIterators());
- }
-
- protected Iterator<Iterator<E2>> buildCollectionsIterators() {
- return new TransformationIterator<ArrayList<E2>, Iterator<E2>>(this.collections.values().iterator()) {
- @Override
- protected Iterator<E2> transform(ArrayList<E2> next) {
- return next.iterator();
- }
- };
- }
-
- public int size() {
- return this.size;
- }
-
-
- // ********** CollectionValueModelWrapper overrides/implementation **********
-
- @Override
- protected void engageModel() {
- super.engageModel();
- // synch our cache *after* we start listening to the wrapped collection,
- // since its value might change when a listener is added
- this.addAllComponentSources();
- }
-
- /**
- * Transform all the sources to collection value models
- * and add their items to our cache, with no event notification.
- */
- protected void addAllComponentSources() {
- for (E1 source : this.collectionHolder) {
- this.addComponentSource(source, NullList.<E2>instance());
- }
- }
-
- @Override
- protected void disengageModel() {
- super.disengageModel();
- // stop listening to the components...
- for (CollectionValueModel<E2> componentCVM : this.componentCVMs.values()) {
- componentCVM.removeCollectionChangeListener(VALUES, this.componentCVMListener);
- }
- // ...and clear the cache
- this.componentCVMs.clear();
- this.collections.clear();
- this.size = 0;
- }
-
- /**
- * Some component sources were added;
- * add their corresponding items to our cache.
- */
- @Override
- protected void itemsAdded(CollectionChangeEvent event) {
- ArrayList<E2> addedItems = new ArrayList<E2>();
- for (Iterator<E1> stream = this.items(event); stream.hasNext(); ) {
- this.addComponentSource(stream.next(), addedItems);
- }
- this.fireItemsAdded(VALUES, addedItems);
- }
-
- /**
- * Transform the specified source to a collection value model
- * and add its items to our cache and the "collecting parameter".
- */
- protected void addComponentSource(E1 source, List<E2> addedItems) {
- CollectionValueModel<E2> componentCVM = this.transform(source);
- if (this.componentCVMs.put(source, componentCVM) != null) {
- throw new IllegalStateException("duplicate component: " + source);
- }
- componentCVM.addCollectionChangeListener(VALUES, this.componentCVMListener);
- ArrayList<E2> componentCollection = new ArrayList<E2>(componentCVM.size());
- if (this.collections.put(componentCVM, componentCollection) != null) {
- throw new IllegalStateException("duplicate collection: " + source);
- }
- this.addComponentItems(componentCVM, componentCollection);
- addedItems.addAll(componentCollection);
- }
-
- /**
- * Add the items in the specified component CVM to the specified component
- * collection.
- */
- protected void addComponentItems(CollectionValueModel<E2> componentCVM, ArrayList<E2> componentCollection) {
- int itemsSize = componentCVM.size();
- this.size += itemsSize;
- componentCollection.ensureCapacity(componentCollection.size() + itemsSize);
- CollectionTools.addAll(componentCollection, componentCVM);
- }
-
- /**
- * Some component sources were removed;
- * remove their corresponding items from our cache.
- */
- @Override
- protected void itemsRemoved(CollectionChangeEvent event) {
- ArrayList<E2> removedItems = new ArrayList<E2>();
- for (Iterator<E1> stream = this.items(event); stream.hasNext(); ) {
- this.removeComponentSource(stream.next(), removedItems);
- }
- this.fireItemsRemoved(VALUES, removedItems);
- }
-
- /**
- * Remove the items corresponding to the specified source
- * from our cache.
- */
- protected void removeComponentSource(E1 source, List<E2> removedItems) {
- CollectionValueModel<E2> componentCVM = this.componentCVMs.remove(source);
- if (componentCVM == null) {
- throw new IllegalStateException("missing component: " + source);
- }
- componentCVM.removeCollectionChangeListener(VALUES, this.componentCVMListener);
- ArrayList<E2> componentCollection = this.collections.remove(componentCVM);
- if (componentCollection == null) {
- throw new IllegalStateException("missing collection: " + source);
- }
- removedItems.addAll(componentCollection);
- this.removeComponentItems(componentCollection);
- }
-
- /**
- * Update our size and collection cache.
- */
- protected void removeComponentItems(ArrayList<E2> componentCollection) {
- this.size -= componentCollection.size();
- componentCollection.clear();
- }
-
- /**
- * The component sources cleared;
- * clear our cache.
- */
- @Override
- protected void collectionCleared(CollectionChangeEvent event) {
- this.removeAllComponentSources();
- this.fireCollectionCleared(VALUES);
- }
-
- protected void removeAllComponentSources() {
- // copy the keys so we don't eat our own tail
- ArrayList<E1> copy = new ArrayList<E1>(this.componentCVMs.keySet());
- for (E1 source : copy) {
- this.removeComponentSource(source, NullList.<E2>instance());
- }
- }
-
- /**
- * The component sources changed;
- * rebuild our cache.
- */
- @Override
- protected void collectionChanged(CollectionChangeEvent event) {
- this.removeAllComponentSources();
- this.addAllComponentSources();
- this.fireCollectionChanged(VALUES);
- }
-
-
- // ********** internal methods **********
-
- /**
- * Transform the specified object into a collection value model.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a <code>Transformer</code>.
- */
- protected CollectionValueModel<E2> transform(E1 value) {
- return this.transformer.transform(value);
- }
-
- /**
- * One of the component collections had items added;
- * synchronize our caches.
- */
- protected void componentItemsAdded(CollectionChangeEvent event) {
- int itemsSize = event.itemsSize();
- this.size += itemsSize;
-
- ArrayList<E2> componentCollection = this.collections.get(this.componentCVM(event));
- componentCollection.ensureCapacity(componentCollection.size() + itemsSize);
-
- this.addItemsToCollection(this.componentItems(event), componentCollection, VALUES);
- }
-
- /**
- * One of the component collections had items removed;
- * synchronize our caches.
- */
- protected void componentItemsRemoved(CollectionChangeEvent event) {
- this.size -= event.itemsSize();
- ArrayList<E2> componentCollection = this.collections.get(this.componentCVM(event));
- this.removeItemsFromCollection(this.componentItems(event), componentCollection, VALUES);
- }
-
- /**
- * One of the component collections was cleared;
- * synchronize our caches by clearing out the appropriate
- * collection.
- */
- protected void componentCollectionCleared(CollectionChangeEvent event) {
- ArrayList<E2> componentCollection = this.collections.get(this.componentCVM(event));
- ArrayList<E2> removedItems = new ArrayList<E2>(componentCollection);
- this.removeComponentItems(componentCollection);
- this.fireItemsRemoved(VALUES, removedItems);
- }
-
- /**
- * One of the component collections changed;
- * synchronize our caches by clearing out the appropriate
- * collection and then rebuilding it.
- */
- protected void componentCollectionChanged(CollectionChangeEvent event) {
- CollectionValueModel<E2> componentCVM = this.componentCVM(event);
- ArrayList<E2> componentCollection = this.collections.get(componentCVM);
- this.removeComponentItems(componentCollection);
- this.addComponentItems(componentCVM, componentCollection);
- this.fireCollectionChanged(VALUES);
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterator<E2> componentItems(CollectionChangeEvent event) {
- return (Iterator<E2>) event.items();
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected CollectionValueModel<E2> componentCVM(CollectionChangeEvent event) {
- return (CollectionValueModel<E2>) event.getSource();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeListValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeListValueModel.java
deleted file mode 100644
index dcc84c447d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeListValueModel.java
+++ /dev/null
@@ -1,575 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.Transformer;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyCompositeListIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationListIterator;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * A <code>CompositeListValueModel</code> wraps another
- * <code>ListValueModel</code> and uses a <code>Transformer</code>
- * to convert each item in the wrapped list to yet another
- * <code>ListValueModel</code>. This composite list contains
- * the combined items from all these component lists.
- *
- * Terminology:
- * - sources - the items in the wrapped list value model; these
- * are converted into component LVMs by the transformer
- * - componentLVMs - the component list value models that are combined
- * by this composite list value model
- * - items - the items held by the component LVMs
- */
-public class CompositeListValueModel<E1, E2>
- extends ListValueModelWrapper<E1>
- implements ListValueModel<E2>
-{
- /**
- * This is the (optional) user-supplied object that transforms
- * the items in the wrapped list to list value models.
- */
- private final Transformer<E1, ListValueModel<E2>> transformer;
-
- /**
- * Cache of the sources, component LVMs, lists.
- */
- private final ArrayList<Info> infoList;
- protected class Info {
- // the object passed to the transformer
- final E1 source;
- // the list value model generated by the transformer
- final ListValueModel<E2> componentLVM;
- // cache of the items held by the component LVM
- final ArrayList<E2> items;
- // the component LVM's beginning index within the composite LVM
- int begin;
- Info(E1 source, ListValueModel<E2> componentLVM, ArrayList<E2> items, int begin) {
- super();
- this.source = source;
- this.componentLVM = componentLVM;
- this.items = items;
- this.begin = begin;
- }
- }
-
- /** Listener that listens to all the component list value models. */
- private final ListChangeListener componentLVMListener;
-
- /** Cache the size of the composite list. */
- private int size;
-
-
- // ********** constructors **********
-
- /**
- * Construct a list value model with the specified wrapped
- * list value model. Use this constructor if
- * - the wrapped list value model already contains other
- * list value models or
- * - you want to override the <code>transform(E1)</code> method
- * instead of building a <code>Transformer</code>
- */
- public CompositeListValueModel(ListValueModel<? extends E1> listHolder) {
- this(listHolder, Transformer.Null.<E1, ListValueModel<E2>>instance());
- }
-
- /**
- * Construct a list value model with the specified wrapped
- * list value model and transformer.
- */
- public CompositeListValueModel(ListValueModel<? extends E1> listHolder, Transformer<E1, ListValueModel<E2>> transformer) {
- super(listHolder);
- this.transformer = transformer;
- this.infoList = new ArrayList<Info>();
- this.componentLVMListener = this.buildComponentLVMListener();
- this.size = 0;
- }
-
- /**
- * Construct a list value model with the specified, unchanging, wrapped
- * list. Use this constructor if
- * - the wrapped list already contains list value models or
- * - you want to override the <code>transform(E1)</code> method
- * instead of building a <code>Transformer</code>
- */
- public CompositeListValueModel(List<? extends E1> list) {
- this(new StaticListValueModel<E1>(list));
- }
-
- /**
- * Construct a list value model with the specified, unchanging, wrapped
- * list and transformer.
- */
- public CompositeListValueModel(List<? extends E1> list, Transformer<E1, ListValueModel<E2>> transformer) {
- this(new StaticListValueModel<E1>(list), transformer);
- }
-
-
- // ********** initialization **********
-
- protected ListChangeListener buildComponentLVMListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent event) {
- CompositeListValueModel.this.componentItemsAdded(event);
- }
- public void itemsRemoved(ListChangeEvent event) {
- CompositeListValueModel.this.componentItemsRemoved(event);
- }
- public void itemsReplaced(ListChangeEvent event) {
- CompositeListValueModel.this.componentItemsReplaced(event);
- }
- public void itemsMoved(ListChangeEvent event) {
- CompositeListValueModel.this.componentItemsMoved(event);
- }
- public void listCleared(ListChangeEvent event) {
- CompositeListValueModel.this.componentListCleared(event);
- }
- public void listChanged(ListChangeEvent event) {
- CompositeListValueModel.this.componentListChanged(event);
- }
- @Override
- public String toString() {
- return "component LVM listener";
- }
- };
- }
-
-
- // ********** ListValueModel implementation **********
-
- public E2 get(int index) {
- if ((index < 0) || (index >= this.size)) {
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + this.size);
- }
- // move backwards through the info list
- for (int i = this.infoList.size(); i-- > 0; ) {
- Info info = this.infoList.get(i);
- if (index >= info.begin) {
- return info.items.get(index - info.begin);
- }
- }
- throw new IllegalStateException(); // something is wack
- }
-
- public Iterator<E2> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E2> listIterator() {
- return new ReadOnlyCompositeListIterator<E2>(this.buildListsIterators());
- }
-
- protected ListIterator<ListIterator<E2>> buildListsIterators() {
- return new TransformationListIterator<Info, ListIterator<E2>>(this.infoList.listIterator()) {
- @Override
- protected ListIterator<E2> transform(Info info) {
- return info.items.listIterator();
- }
- };
- }
-
- public int size() {
- return this.size;
- }
-
- public Object[] toArray() {
- return CollectionTools.array(this.listIterator(), this.size);
- }
-
-
- // ********** ListValueModelWrapper overrides/implementation **********
-
- @Override
- protected void engageModel() {
- super.engageModel();
- // synch our cache *after* we start listening to the wrapped list,
- // since its value might change when a listener is added
- this.addComponentSources(0, this.listHolder.listIterator(), this.listHolder.size());
- }
-
- @Override
- protected void disengageModel() {
- super.disengageModel();
- // stop listening to the component LVMs...
- for (Info info : this.infoList) {
- info.componentLVM.removeListChangeListener(LIST_VALUES, this.componentLVMListener);
- }
- // ...and clear the cache
- this.infoList.clear();
- this.size = 0;
- }
-
- /**
- * Some component sources were added; update our cache.
- */
- @Override
- protected void itemsAdded(ListChangeEvent event) {
- this.addComponentSources(event.getIndex(), this.items(event), event.itemsSize(), true); // true = fire event
- }
-
- /**
- * Do not fire an event.
- */
- protected void addComponentSources(int addedSourcesIndex, ListIterator<? extends E1> addedSources, int addedSourcesSize) {
- this.addComponentSources(addedSourcesIndex, addedSources, addedSourcesSize, false); // false = do not fire event
- }
-
- /**
- * Add infos corresponding to the specified sources to our cache.
- * Fire the appropriate event if requested.
- */
- protected void addComponentSources(int addedSourcesIndex, ListIterator<? extends E1> addedSources, int addedSourcesSize, boolean fireEvent) {
- ArrayList<Info> newInfoList = new ArrayList<Info>(addedSourcesSize);
- // the 'items' are either tacked on to the end or
- // at the 'begin' index of the first 'info' that is being pushed back
- int newItemsIndex = (addedSourcesIndex == this.infoList.size()) ? this.size : this.infoList.get(addedSourcesIndex).begin;
-
- int begin = newItemsIndex;
- while (addedSources.hasNext()) {
- E1 source = addedSources.next();
- ListValueModel<E2> componentLVM = this.transform(source);
- componentLVM.addListChangeListener(LIST_VALUES, this.componentLVMListener);
- ArrayList<E2> items = new ArrayList<E2>(componentLVM.size());
- CollectionTools.addAll(items, componentLVM.listIterator());
- newInfoList.add(new Info(source, componentLVM, items, begin));
- begin += items.size();
- }
- this.infoList.addAll(addedSourcesIndex, newInfoList);
- int newItemsSize = begin - newItemsIndex;
- this.size += newItemsSize;
-
- // bump the 'begin' index for all the infos that were pushed back by the insert
- int movedInfosIndex = addedSourcesIndex + addedSourcesSize;
- for (int i = movedInfosIndex; i < this.infoList.size(); i++) {
- this.infoList.get(i).begin += newItemsSize;
- }
-
- if (fireEvent) {
- ArrayList<E2> newItems = new ArrayList<E2>(newItemsSize);
- for (int i = addedSourcesIndex; i < movedInfosIndex; i++) {
- newItems.addAll(this.infoList.get(i).items);
- }
- this.fireItemsAdded(LIST_VALUES, newItemsIndex, newItems);
- }
- }
-
- /**
- * Some component sources were removed; update our cache.
- */
- @Override
- protected void itemsRemoved(ListChangeEvent event) {
- this.removeComponentSources(event.getIndex(), event.itemsSize(), true); // true = fire event
- }
-
- /**
- * Do not fire an event.
- */
- protected void removeComponentSources(int removedSourcesIndex, int removedSourcesSize) {
- this.removeComponentSources(removedSourcesIndex, removedSourcesSize, false); // false = do not fire event
- }
-
- /**
- * Remove the infos corresponding to the specified sources from our cache.
- */
- protected void removeComponentSources(int removedSourcesIndex, int removedSourcesSize, boolean fireEvent) {
- int removedItemsIndex = this.infoList.get(removedSourcesIndex).begin;
- int movedSourcesIndex = removedSourcesIndex + removedSourcesSize;
- int movedItemsIndex = (movedSourcesIndex == this.infoList.size()) ? this.size : this.infoList.get(movedSourcesIndex).begin;
- int removedItemsSize = movedItemsIndex - removedItemsIndex;
- this.size -= removedItemsSize;
-
- List<Info> subList = this.infoList.subList(removedSourcesIndex, removedSourcesIndex + removedSourcesSize);
- ArrayList<Info> removedInfoList = new ArrayList<Info>(subList); // make a copy
- subList.clear();
-
- // decrement the 'begin' index for all the infos that were moved forward by the deletes
- for (int i = removedSourcesIndex; i < this.infoList.size(); i++) {
- this.infoList.get(i).begin -= removedItemsSize;
- }
-
- for (Info removedInfo : removedInfoList) {
- removedInfo.componentLVM.removeListChangeListener(LIST_VALUES, this.componentLVMListener);
- }
-
- if (fireEvent) {
- ArrayList<E2> removedItems = new ArrayList<E2>(removedItemsSize);
- for (Info removedInfo : removedInfoList) {
- removedItems.addAll(removedInfo.items);
- }
- this.fireItemsRemoved(LIST_VALUES, removedItemsIndex, removedItems);
- }
- }
-
- /**
- * Some component sources were replaced; update our cache.
- */
- @Override
- protected void itemsReplaced(ListChangeEvent event) {
- this.replaceComponentSources(event.getIndex(), this.items(event), event.itemsSize(), true); // true = fire event
- }
-
- /**
- * Replaced component sources will not (typically) map to a set of replaced
- * items, so we remove and add the corresponding lists of items, resulting in
- * two events.
- */
- protected void replaceComponentSources(int replacedSourcesIndex, ListIterator<? extends E1> newSources, int replacedSourcesSize, boolean fireEvent) {
- this.removeComponentSources(replacedSourcesIndex, replacedSourcesSize, fireEvent);
- this.addComponentSources(replacedSourcesIndex, newSources, replacedSourcesSize, fireEvent);
- }
-
- /**
- * Some component sources were moved; update our cache.
- */
- @Override
- protected void itemsMoved(ListChangeEvent event) {
- this.moveComponentSources(event.getTargetIndex(), event.getSourceIndex(), event.getMoveLength(), true); // true = fire event
- }
-
- protected void moveComponentSources(int targetSourcesIndex, int sourceSourcesIndex, int movedSourcesLength, boolean fireEvent) {
- int sourceItemsIndex = this.infoList.get(sourceSourcesIndex).begin;
-
- int nextSourceSourceIndex = sourceSourcesIndex + movedSourcesLength;
- int nextSourceItemIndex = (nextSourceSourceIndex == this.infoList.size()) ? this.size : this.infoList.get(nextSourceSourceIndex).begin;
- int moveItemsLength = nextSourceItemIndex - sourceItemsIndex;
-
- int targetItemsIndex = -1;
- if (sourceSourcesIndex > targetSourcesIndex) {
- // move from high to low index
- targetItemsIndex = this.infoList.get(targetSourcesIndex).begin;
- } else {
- // move from low to high index (higher items move down during move)
- int nextTargetSourceIndex = targetSourcesIndex + movedSourcesLength;
- targetItemsIndex = (nextTargetSourceIndex == this.infoList.size()) ? this.size : this.infoList.get(nextTargetSourceIndex).begin;
- targetItemsIndex = targetItemsIndex - moveItemsLength;
- }
-
- CollectionTools.move(this.infoList, targetSourcesIndex, sourceSourcesIndex, movedSourcesLength);
-
- // update the 'begin' indexes of all the affected 'infos'
- int min = Math.min(targetSourcesIndex, sourceSourcesIndex);
- int max = Math.max(targetSourcesIndex, sourceSourcesIndex) + movedSourcesLength;
- int begin = Math.min(targetItemsIndex, sourceItemsIndex);
- for (int i = min; i < max; i++) {
- Info info = this.infoList.get(i);
- info.begin = begin;
- begin += info.componentLVM.size();
- }
-
- if (fireEvent) {
- this.fireItemsMoved(LIST_VALUES, targetItemsIndex, sourceItemsIndex, moveItemsLength);
- }
- }
-
- /**
- * The component sources were cleared; clear our cache.
- */
- @Override
- protected void listCleared(ListChangeEvent event) {
- this.removeComponentSources(0, this.infoList.size());
- this.fireListCleared(LIST_VALUES);
- }
-
- /**
- * The component sources changed; rebuild our cache.
- */
- @Override
- protected void listChanged(ListChangeEvent event) {
- this.removeComponentSources(0, this.infoList.size());
- this.addComponentSources(0, this.listHolder.listIterator(), this.listHolder.size());
- this.fireListChanged(LIST_VALUES);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(CollectionTools.list(this.listIterator(), this.size));
- }
-
-
- // ********** internal methods **********
-
- /**
- * Transform the specified object into a list value model.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a <code>Transformer</code>.
- */
- protected ListValueModel<E2> transform(E1 value) {
- return this.transformer.transform(value);
- }
-
- /**
- * Return the index of the specified component LVM.
- */
- protected int indexOf(ListValueModel<E2> componentLVM) {
- for (int i = 0; i < this.infoList.size(); i++) {
- if (this.infoList.get(i).componentLVM == componentLVM) {
- return i;
- }
- }
- throw new IllegalArgumentException("invalid component LVM: " + componentLVM);
- }
-
- /**
- * Return the index of the specified event's component LVM.
- */
- protected int indexFor(ListChangeEvent event) {
- return this.indexOf(this.componentLVM(event));
- }
-
- /**
- * Items were added to one of the component lists;
- * synchronize our cache.
- */
- protected void componentItemsAdded(ListChangeEvent event) {
- // update the affected 'begin' indices
- int componentLVMIndex = this.indexFor(event);
- int newItemsSize = event.itemsSize();
- for (int i = componentLVMIndex + 1; i < this.infoList.size(); i++) {
- this.infoList.get(i).begin += newItemsSize;
- }
- this.size += newItemsSize;
-
- // synchronize the cached list
- Info info = this.infoList.get(componentLVMIndex);
- CollectionTools.addAll(info.items, event.getIndex(), this.componentItems(event), event.itemsSize());
-
- // translate the event
- this.fireItemsAdded(event.cloneWithSource(this, LIST_VALUES, info.begin));
- }
-
- /**
- * Items were removed from one of the component lists;
- * synchronize our cache.
- */
- protected void componentItemsRemoved(ListChangeEvent event) {
- // update the affected 'begin' indices
- int componentLVMIndex = this.indexFor(event);
- int removedItemsSize = event.itemsSize();
- for (int i = componentLVMIndex + 1; i < this.infoList.size(); i++) {
- this.infoList.get(i).begin -= removedItemsSize;
- }
- this.size -= removedItemsSize;
-
- // synchronize the cached list
- Info info = this.infoList.get(componentLVMIndex);
- int itemIndex = event.getIndex();
- info.items.subList(itemIndex, itemIndex + event.itemsSize()).clear();
-
- // translate the event
- this.fireItemsRemoved(event.cloneWithSource(this, LIST_VALUES, info.begin));
- }
-
- /**
- * Items were replaced in one of the component lists;
- * synchronize our cache.
- */
- protected void componentItemsReplaced(ListChangeEvent event) {
- // no changes to the 'begin' indices or size
-
- // synchronize the cached list
- int componentLVMIndex = this.indexFor(event);
- Info info = this.infoList.get(componentLVMIndex);
- int i = event.getIndex();
- for (Iterator<E2> stream = this.componentItems(event); stream.hasNext(); ) {
- info.items.set(i++, stream.next());
- }
-
- // translate the event
- this.fireItemsReplaced(event.cloneWithSource(this, LIST_VALUES, info.begin));
- }
-
- /**
- * Items were moved in one of the component lists;
- * synchronize our cache.
- */
- protected void componentItemsMoved(ListChangeEvent event) {
- // no changes to the 'begin' indices or size
-
- // synchronize the cached list
- int componentLVMIndex = this.indexFor(event);
- Info info = this.infoList.get(componentLVMIndex);
- CollectionTools.move(info.items, event.getTargetIndex(), event.getSourceIndex(), event.getMoveLength());
-
- // translate the event
- this.fireItemsMoved(event.cloneWithSource(this, LIST_VALUES, info.begin));
- }
-
- /**
- * One of the component lists was cleared;
- * synchronize our cache.
- */
- protected void componentListCleared(ListChangeEvent event) {
- int componentLVMIndex = this.indexFor(event);
- this.clearComponentList(componentLVMIndex, this.infoList.get(componentLVMIndex));
- }
-
- protected void clearComponentList(int componentLVMIndex, Info info) {
- // update the affected 'begin' indices
- int removedItemsSize = info.items.size();
- for (int i = componentLVMIndex + 1; i < this.infoList.size(); i++) {
- this.infoList.get(i).begin -= removedItemsSize;
- }
- this.size -= removedItemsSize;
-
- // synchronize the cached list
- ArrayList<E2> items = new ArrayList<E2>(info.items);
- info.items.clear();
-
- // translate the event
- this.fireItemsRemoved(LIST_VALUES, info.begin, items);
- }
-
- /**
- * One of the component lists changed;
- * synchronize our cache by clearing out the appropriate
- * list and rebuilding it.
- */
- protected void componentListChanged(ListChangeEvent event) {
- int componentLVMIndex = this.indexFor(event);
- Info info = this.infoList.get(componentLVMIndex);
- this.clearComponentList(componentLVMIndex, info);
-
- // update the affected 'begin' indices
- int newItemsSize = info.componentLVM.size();
- for (int i = componentLVMIndex + 1; i < this.infoList.size(); i++) {
- this.infoList.get(i).begin += newItemsSize;
- }
- this.size += newItemsSize;
-
- // synchronize the cached list
- CollectionTools.addAll(info.items, info.componentLVM.listIterator(), newItemsSize);
-
- // translate the event
- this.fireItemsAdded(LIST_VALUES, info.begin, info.items);
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected ListIterator<E2> componentItems(ListChangeEvent event) {
- return (ListIterator<E2>) event.items();
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected ListValueModel<E2> componentLVM(ListChangeEvent event) {
- return (ListValueModel<E2>) event.getSource();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java
deleted file mode 100644
index 84bd413e02..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyCompositeListIterator;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * This wrapper extends a ListValueModel (or CollectionValueModel)
- * with fixed collections of items on either end.
- * <p>
- * NB: Be careful using or wrapping this list value model, since the
- * "extended" items may be unexpected by the client code or wrapper.
- */
-public class ExtendedListValueModelWrapper<E>
- extends ListValueModelWrapper<E>
- implements ListValueModel<E>
-{
- /** the items "prepended" to the wrapped list */
- protected List<E> prefix;
-
- /** the items "appended" to the wrapped list */
- protected List<E> suffix;
-
-
- // ********** lots o' constructors **********
-
- /**
- * Extend the specified list with a prefix and suffix.
- */
- public ExtendedListValueModelWrapper(List<? extends E> prefix, ListValueModel<? extends E> listHolder, List<? extends E> suffix) {
- super(listHolder);
- this.prefix = new ArrayList<E>(prefix);
- this.suffix = new ArrayList<E>(suffix);
- }
-
- /**
- * Extend the specified list with a prefix and suffix.
- */
- public ExtendedListValueModelWrapper(E prefix, ListValueModel<? extends E> listHolder, E suffix) {
- super(listHolder);
- this.prefix = Collections.singletonList(prefix);
- this.suffix = Collections.singletonList(suffix);
- }
-
- /**
- * Extend the specified list with a prefix.
- */
- public ExtendedListValueModelWrapper(List<? extends E> prefix, ListValueModel<? extends E> listHolder) {
- super(listHolder);
- this.prefix = new ArrayList<E>(prefix);
- this.suffix = Collections.emptyList();
- }
-
- /**
- * Extend the specified list with a prefix.
- */
- public ExtendedListValueModelWrapper(E prefix, ListValueModel<? extends E> listHolder) {
- super(listHolder);
- this.prefix = Collections.singletonList(prefix);
- this.suffix = Collections.emptyList();
- }
-
- /**
- * Extend the specified list with a suffix.
- */
- public ExtendedListValueModelWrapper(ListValueModel<? extends E> listHolder, List<? extends E> suffix) {
- super(listHolder);
- this.prefix = Collections.emptyList();
- this.suffix = new ArrayList<E>(suffix);
- }
-
- /**
- * Extend the specified list with a suffix.
- */
- public ExtendedListValueModelWrapper(ListValueModel<? extends E> listHolder, E suffix) {
- super(listHolder);
- this.prefix = Collections.emptyList();
- this.suffix = Collections.singletonList(suffix);
- }
-
- /**
- * Extend the specified list with a prefix containing a single null item.
- */
- public ExtendedListValueModelWrapper(ListValueModel<? extends E> listHolder) {
- super(listHolder);
- this.prefix = Collections.singletonList(null);
- this.suffix = Collections.emptyList();
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E> listIterator() {
- return new ReadOnlyListIterator<E>(this.listIterator_());
- }
-
- @SuppressWarnings("unchecked")
- protected ListIterator<E> listIterator_() {
- return new ReadOnlyCompositeListIterator<E>(
- this.prefix.listIterator(),
- this.listHolder.listIterator(),
- this.suffix.listIterator()
- );
- }
-
- public E get(int index) {
- int prefixSize = this.prefix.size();
- if (index < prefixSize) {
- return this.prefix.get(index);
- } else if (index >= prefixSize + this.listHolder.size()) {
- return this.suffix.get(index - (prefixSize + this.listHolder.size()));
- } else {
- return this.listHolder.get(index - prefixSize);
- }
- }
-
- public int size() {
- return this.prefix.size() + this.listHolder.size() + this.suffix.size();
- }
-
- public Object[] toArray() {
- ArrayList<E> list = new ArrayList<E>(this.size());
- list.addAll(this.prefix);
- CollectionTools.addAll(list, this.listHolder.iterator());
- list.addAll(this.suffix);
- return list.toArray();
- }
-
-
- // ********** ListValueModelWrapper implementation/overrides **********
-
- @Override
- protected void itemsAdded(ListChangeEvent event) {
- this.fireItemsAdded(event.cloneWithSource(this, LIST_VALUES, this.prefix.size()));
- }
-
- @Override
- protected void itemsRemoved(ListChangeEvent event) {
- this.fireItemsRemoved(event.cloneWithSource(this, LIST_VALUES, this.prefix.size()));
- }
-
- @Override
- protected void itemsReplaced(ListChangeEvent event) {
- this.fireItemsReplaced(event.cloneWithSource(this, LIST_VALUES, this.prefix.size()));
- }
-
- @Override
- protected void itemsMoved(ListChangeEvent event) {
- this.fireItemsMoved(event.cloneWithSource(this, LIST_VALUES, this.prefix.size()));
- }
-
- @Override
- protected void listCleared(ListChangeEvent event) {
- this.fireListChanged(LIST_VALUES); // not "cleared"
- }
-
- @Override
- protected void listChanged(ListChangeEvent event) {
- this.fireListChanged(LIST_VALUES);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.prefix);
- sb.append(" ");
- super.toString(sb);
- sb.append(" ");
- sb.append(this.suffix);
- }
-
-
- // ********** miscellaneous **********
-
- public void setPrefix(List<E> prefix) {
- this.prefix = prefix;
- this.fireListChanged(LIST_VALUES);
- }
-
- public void setSuffix(List<E> suffix) {
- this.suffix = suffix;
- this.fireListChanged(LIST_VALUES);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java
deleted file mode 100644
index 4cf2e2bc6b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * A <code>FilteringCollectionValueModel</code> wraps another
- * <code>CollectionValueModel</code> and uses a <code>Filter</code>
- * to determine which items in the collection are returned by calls
- * to <code>#iterator()</code>.
- * <p>
- * The filter can be changed at any time; allowing the same
- * adapter to be used with different filter criteria (e.g. when the user
- * wants to view a list of .java files).
- * <p>
- * NB: If the objects in the "filtered" collection can change in such a way
- * that they should be removed from the "filtered" collection, you will
- * need to wrap the original collection in an ItemAspectListValueModelAdapter.
- * For example, if the filter only "accepts" items whose names begin
- * with "X" and the names of the items can change, you will need to
- * wrap the original list of unfiltered items with an
- * ItemPropertyListValueModelAdapter that listens for changes to each
- * item's name and fires the appropriate event whenever an item's name
- * changes. The event will cause this wrapper to re-filter the changed
- * item and add or remove it from the "filtered" collection as appropriate.
- */
-public class FilteringCollectionValueModel<E>
- extends CollectionValueModelWrapper<E>
- implements CollectionValueModel<E>
-{
- /** This filters the items in the nested collection. */
- private Filter<E> filter;
-
- /** Cache the items that were accepted by the filter */
- private final Collection<E> filteredItems;
-
-
- // ********** constructors **********
-
- /**
- * Construct a collection value model with the specified wrapped
- * collection value model and a filter that simply accepts every object.
- */
- public FilteringCollectionValueModel(CollectionValueModel<? extends E> collectionHolder) {
- this(collectionHolder, Filter.Null.<E>instance());
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * collection value model and filter.
- */
- public FilteringCollectionValueModel(CollectionValueModel<? extends E> collectionHolder, Filter<E> filter) {
- super(collectionHolder);
- this.filter = filter;
- this.filteredItems = new ArrayList<E>();
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * list value model and a filter that simply accepts every object.
- */
- public FilteringCollectionValueModel(ListValueModel<E> listHolder) {
- this(new ListCollectionValueModelAdapter<E>(listHolder));
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * list value model and filter.
- */
- public FilteringCollectionValueModel(ListValueModel<E> listHolder, Filter<E> filter) {
- this(new ListCollectionValueModelAdapter<E>(listHolder), filter);
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public Iterator<E> iterator() {
- return new ReadOnlyIterator<E>(this.filteredItems);
- }
-
- public int size() {
- return this.filteredItems.size();
- }
-
-
- // ********** CollectionValueModelWrapper overrides/implementation **********
-
- @Override
- protected void engageModel() {
- super.engageModel();
- // synch our cache *after* we start listening to the nested collection,
- // since its value might change when a listener is added
- CollectionTools.addAll(this.filteredItems, this.filter(this.collectionHolder.iterator()));
- }
-
- @Override
- protected void disengageModel() {
- super.disengageModel();
- // clear out the cache when we are not listening to the nested collection
- this.filteredItems.clear();
- }
-
- @Override
- protected void itemsAdded(CollectionChangeEvent event) {
- // filter the values before propagating the change event
- this.addItemsToCollection(this.filter(this.items(event)), this.filteredItems, VALUES);
- }
-
- @Override
- protected void itemsRemoved(CollectionChangeEvent event) {
- // do *not* filter the values, because they may no longer be
- // "accepted" and that might be why they were removed in the first place;
- // anyway, any extraneous items are harmless
- this.removeItemsFromCollection(event.items(), this.filteredItems, VALUES);
- }
-
- @Override
- protected void collectionCleared(CollectionChangeEvent event) {
- this.clearCollection(this.filteredItems, VALUES);
- }
-
- @Override
- protected void collectionChanged(CollectionChangeEvent event) {
- this.rebuildFilteredItems();
- }
-
-
- // ********** miscellaneous **********
-
- /**
- * Change the filter and rebuild the collection.
- */
- public void setFilter(Filter<E> filter) {
- this.filter = filter;
- this.rebuildFilteredItems();
- }
-
- /**
- * Return an iterator that filters the specified iterator.
- */
- protected Iterator<E> filter(Iterator<? extends E> items) {
- return new FilteringIterator<E, E>(items, this.filter);
- }
-
- /**
- * Synchronize our cache with the wrapped collection.
- */
- protected void rebuildFilteredItems() {
- this.filteredItems.clear();
- CollectionTools.addAll(this.filteredItems, this.filter(this.collectionHolder.iterator()));
- this.fireCollectionChanged(VALUES);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringPropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringPropertyValueModel.java
deleted file mode 100644
index a56cc34c80..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringPropertyValueModel.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * A <code>FilteringPropertyValueModel</code> wraps another
- * <code>PropertyValueModel</code> and uses a <code>Filter</code>
- * to determine when the wrapped value is to be returned by calls
- * to <code>value()</code>.
- * <p>
- * As an alternative to building a <code>Filter</code>, a subclass
- * of <code>FilteringPropertyValueModel</code> can override the
- * <code>accept(Object)</code> method.
- * <p>
- * One, possibly undesirable, side-effect of using this value model is that
- * it must return *something* as the value. The default behavior is
- * to return <code>null</code> whenever the wrapped value is not "accepted",
- * which can be configured and/or overridden.
- */
-public class FilteringPropertyValueModel<T>
- extends PropertyValueModelWrapper<T>
- implements PropertyValueModel<T>
-{
- protected final Filter<T> filter;
- protected final T defaultValue;
-
-
- // ********** constructors **********
-
- /**
- * Construct a property value model with the specified nested
- * property value model and a disabled filter.
- * Use this constructor if you want to override the
- * <code>accept(Object)</code>
- * method instead of building a <code>Filter</code>.
- * The default value will be <code>null</code>.
- */
- public FilteringPropertyValueModel(PropertyValueModel<? extends T> valueHolder) {
- this(valueHolder, Filter.Disabled.<T>instance(), null);
- }
-
- /**
- * Construct a property value model with the specified nested
- * property value model, specified default value, and a disabled filter.
- * Use this constructor if you want to override the
- * <code>accept(Object)</code>
- * method instead of building a <code>Filter</code>
- * <em>and</em> you need to specify
- * a default value other than <code>null</code>.
- */
- public FilteringPropertyValueModel(PropertyValueModel<? extends T> valueHolder, T defaultValue) {
- this(valueHolder, Filter.Disabled.<T>instance(), defaultValue);
- }
-
- /**
- * Construct an property value model with the specified nested
- * property value model and filter.
- * The default value will be <code>null</code>.
- */
- public FilteringPropertyValueModel(PropertyValueModel<? extends T> valueHolder, Filter<T> filter) {
- this(valueHolder, filter, null);
- }
-
- /**
- * Construct an property value model with the specified nested
- * property value model, filter, and default value.
- */
- public FilteringPropertyValueModel(PropertyValueModel<? extends T> valueHolder, Filter<T> filter, T defaultValue) {
- super(valueHolder);
- this.filter = filter;
- this.defaultValue = defaultValue;
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- public T getValue() {
- return this.filterValue(this.valueHolder.getValue());
- }
-
-
- // ********** PropertyValueModelWrapper implementation **********
-
- @Override
- protected void valueChanged(PropertyChangeEvent event) {
- // filter the values before propagating the change event
- @SuppressWarnings("unchecked")
- Object oldValue = this.filterValue((T) event.getOldValue());
- @SuppressWarnings("unchecked")
- Object newValue = this.filterValue((T) event.getNewValue());
- this.firePropertyChanged(VALUE, oldValue, newValue);
- }
-
-
- // ********** queries **********
-
- /**
- * If the specified value is "accepted" simply return it,
- * otherwise return the default value.
- */
- protected T filterValue(T value) {
- return this.accept(value) ? value : this.defaultValue();
- }
-
- /**
- * Return whether the <code>FilteringPropertyValueModel</code> should
- * return the specified value from a call to the
- * <code>value()</code> method; the value came
- * from the nested property value model
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a <code>Filter</code>.
- */
- protected boolean accept(T value) {
- return this.filter.accept(value);
- }
-
- /**
- * Return the object that should be returned if
- * the nested value was rejected by the filter.
- * The default is <code>null</code>.
- */
- protected T defaultValue() {
- return this.defaultValue;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringWritablePropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringWritablePropertyValueModel.java
deleted file mode 100644
index d7e20f4cb3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringWritablePropertyValueModel.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.BidiFilter;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * A <code>FilteringWritablePropertyValueModel</code> wraps another
- * <code>WritabelPropertyValueModel</code> and uses a <code>BidiFilter</code>
- * to determine when the wrapped value is to be returned by calls
- * to <code>value()</code> and modified by calls to
- * <code>setValue(Object)</code>.
- * <p>
- * As an alternative to building a <code>BidiFilter</code>, a subclass
- * of <code>FilteringWritablePropertyValueModel</code> can override the
- * <code>accept(Object)</code> and <code>reverseAccept(Object)</code>
- * methods.
- * <p>
- * One, possibly undesirable, side-effect of using this value model is that
- * it must return *something* as the value. The default behavior is
- * to return <code>null</code> whenever the wrapped value is not "accepted",
- * which can be configured and/or overridden.
- * <p>
- * Similarly, if an incoming value is not "reverseAccepted", *nothing* will passed
- * through to the wrapped value holder, not even <code>null</code>.
- */
-public class FilteringWritablePropertyValueModel<T>
- extends FilteringPropertyValueModel<T>
- implements WritablePropertyValueModel<T>
-{
-
-
- // ********** constructors **********
-
- /**
- * Construct a property value model with the specified nested
- * property value model and a disabled filter.
- * Use this constructor if you want to override the
- * <code>accept(Object)</code> and <code>reverseAccept(Object)</code>
- * methods instead of building a <code>BidiFilter</code>.
- * The default value will be <code>null</code>.
- */
- public FilteringWritablePropertyValueModel(WritablePropertyValueModel<T> valueHolder) {
- this(valueHolder, BidiFilter.Disabled.<T>instance(), null);
- }
-
- /**
- * Construct a property value model with the specified nested
- * property value model, specified default value, and a disabled filter.
- * Use this constructor if you want to override the
- * <code>accept(Object)</code> and <code>reverseAccept(Object)</code>
- * methods instead of building a <code>BidiFilter</code>
- * <em>and</em> you need to specify
- * a default value other than <code>null</code>.
- */
- public FilteringWritablePropertyValueModel(WritablePropertyValueModel<T> valueHolder, T defaultValue) {
- this(valueHolder, BidiFilter.Disabled.<T>instance(), defaultValue);
- }
-
- /**
- * Construct an property value model with the specified nested
- * property value model and filter.
- * The default value will be <code>null</code>.
- */
- public FilteringWritablePropertyValueModel(WritablePropertyValueModel<T> valueHolder, BidiFilter<T> filter) {
- this(valueHolder, filter, null);
- }
-
- /**
- * Construct an property value model with the specified nested
- * property value model, filter, and default value.
- */
- public FilteringWritablePropertyValueModel(WritablePropertyValueModel<T> valueHolder, BidiFilter<T> filter, T defaultValue) {
- super(valueHolder, filter, defaultValue);
- }
-
-
- // ********** WritablePropertyValueModel implementation **********
-
- public void setValue(T value) {
- if (this.reverseAccept(value)) {
- this.valueHolder().setValue(value);
- }
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether the <code>FilteringWritablePropertyValueModel</code>
- * should pass through the specified value to the nested
- * writable property value model in a call to the
- * <code>setValue(Object)</code> method
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a <code>BidiFilter</code>.
- */
- protected boolean reverseAccept(T value) {
- return this.getFilter().reverseAccept(value);
- }
-
- /**
- * Our constructors accept only a WritablePropertyValueModel<T>.
- */
- @SuppressWarnings("unchecked")
- protected WritablePropertyValueModel<T> valueHolder() {
- return (WritablePropertyValueModel<T>) this.valueHolder;
- }
-
- /**
- * Our constructors accept only a bidirectional filter.
- */
- protected BidiFilter<T> getFilter() {
- return (BidiFilter<T>) this.filter;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemAspectListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemAspectListValueModelAdapter.java
deleted file mode 100644
index 3c86dbbc91..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemAspectListValueModelAdapter.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.EventObject;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.Counter;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Abstract list value model that provides behavior for wrapping a list value
- * model (or collection value model) and listening for changes to aspects of the
- * *items* held by the list (or collection). Changes to the actual list
- * (or collection) are also monitored.
- *
- * This is useful if you have a collection of items that can be modified by adding
- * or removing items or the items themselves might change in a fashion that
- * might change the collection's external appearance.
- *
- * Subclasses need to override two methods:
- *
- * #listenToItem(Model)
- * begin listening to the appropriate aspect of the specified item and call
- * #itemAspectChanged(Object) whenever the aspect changes
- *
- * #stopListeningToItem(Model)
- * stop listening to the appropriate aspect of the specified item
- */
-public abstract class ItemAspectListValueModelAdapter<E>
- extends ListValueModelWrapper<E>
- implements ListValueModel<E>
-{
-
- /**
- * Maintain a counter for each of the items in the
- * wrapped list holder we are listening to.
- */
- protected final IdentityHashMap<E, Counter> counters;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the list holder is required.
- */
- protected ItemAspectListValueModelAdapter(ListValueModel<? extends E> listHolder) {
- super(listHolder);
- this.counters = new IdentityHashMap<E, Counter>();
- }
-
- /**
- * Constructor - the collection holder is required.
- */
- protected ItemAspectListValueModelAdapter(CollectionValueModel<? extends E> collectionHolder) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder));
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E> listIterator() {
- return new ReadOnlyListIterator<E>(this.listHolder.listIterator());
- }
-
- public E get(int index) {
- return this.listHolder.get(index);
- }
-
- public int size() {
- return this.listHolder.size();
- }
-
- public Object[] toArray() {
- return this.listHolder.toArray();
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the list holder and the items in the list.
- */
- @Override
- protected void engageModel() {
- super.engageModel();
- this.engageAllItems();
- }
-
- protected void engageAllItems() {
- this.engageItems(this.listHolder.iterator());
- }
-
- protected void engageItems(Iterator<? extends E> stream) {
- while (stream.hasNext()) {
- this.engageItem(stream.next());
- }
- }
-
- protected void engageItem(E item) {
- // listen to an item only once
- Counter counter = this.counters.get(item);
- if (counter == null) {
- counter = new Counter();
- this.counters.put(item, counter);
- this.startListeningToItem((Model) item);
- }
- counter.increment();
- }
-
- /**
- * Start listening to the specified item.
- */
- protected abstract void startListeningToItem(Model item);
-
- /**
- * Stop listening to the list holder and the items in the list.
- */
- @Override
- protected void disengageModel() {
- this.disengageAllItems();
- super.disengageModel();
- }
-
- protected void disengageAllItems() {
- this.disengageItems(this.listHolder.iterator());
- }
-
- protected void disengageItems(Iterator<? extends E> stream) {
- while (stream.hasNext()) {
- this.disengageItem(stream.next());
- }
- }
-
- protected void disengageItem(E item) {
- // stop listening to an item only once
- Counter counter = this.counters.get(item);
- if (counter == null) {
- // something is wrong if this happens... ~bjv
- throw new IllegalStateException("missing counter: " + item);
- }
- if (counter.decrement() == 0) {
- this.counters.remove(item);
- this.stopListeningToItem((Model) item);
- }
- }
-
- /**
- * Stop listening to the specified item.
- */
- protected abstract void stopListeningToItem(Model item);
-
-
- // ********** list change support **********
-
- /**
- * Items were added to the wrapped list holder.
- * Forward the event and begin listening to the added items.
- */
- @Override
- protected void itemsAdded(ListChangeEvent event) {
- // re-fire event with the wrapper as the source
- this.fireItemsAdded(event.cloneWithSource(this, LIST_VALUES));
- this.engageItems(this.items(event));
- }
-
- /**
- * Items were removed from the wrapped list holder.
- * Stop listening to the removed items and forward the event.
- */
- @Override
- protected void itemsRemoved(ListChangeEvent event) {
- this.disengageItems(this.items(event));
- // re-fire event with the wrapper as the source
- this.fireItemsRemoved(event.cloneWithSource(this, LIST_VALUES));
- }
-
- /**
- * Items were replaced in the wrapped list holder.
- * Stop listening to the removed items, forward the event,
- * and begin listening to the added items.
- */
- @Override
- protected void itemsReplaced(ListChangeEvent event) {
- this.disengageItems(this.replacedItems(event));
- // re-fire event with the wrapper as the source
- this.fireItemsReplaced(event.cloneWithSource(this, LIST_VALUES));
- this.engageItems(this.items(event));
- }
-
- /**
- * Items were moved in the wrapped list holder.
- * No need to change any listeners; just forward the event.
- */
- @Override
- protected void itemsMoved(ListChangeEvent event) {
- // re-fire event with the wrapper as the source
- this.fireItemsMoved(event.cloneWithSource(this, LIST_VALUES));
- }
-
- /**
- * The wrapped list holder was cleared.
- * Stop listening to the removed items and forward the event.
- */
- @Override
- protected void listCleared(ListChangeEvent event) {
- // we should only need to disengage each item once...
- // make a copy to prevent a ConcurrentModificationException
- Collection<E> keys = new ArrayList<E>(this.counters.keySet());
- this.disengageItems(keys.iterator());
- this.counters.clear();
- // re-fire event with the wrapper as the source
- this.fireListCleared(LIST_VALUES);
- }
-
- /**
- * The wrapped list holder has changed in some dramatic fashion.
- * Reconfigure our listeners and forward the event.
- */
- @Override
- protected void listChanged(ListChangeEvent event) {
- // we should only need to disengage each item once...
- // make a copy to prevent a ConcurrentModificationException
- Collection<E> keys = new ArrayList<E>(this.counters.keySet());
- this.disengageItems(keys.iterator());
- this.counters.clear();
- // re-fire event with the wrapper as the source
- this.fireListChanged(LIST_VALUES);
- this.engageAllItems();
- }
-
-
- // ********** item change support **********
-
- /**
- * The specified item has a bound property that has changed.
- * Notify listeners of the change.
- */
- protected void itemAspectChanged(EventObject event) {
- Object item = event.getSource();
- int index = this.lastIdentityIndexOf(item);
- while (index != -1) {
- this.itemAspectChanged(index, item);
- index = this.lastIdentityIndexOf(item, index);
- }
- }
-
- /**
- * The specified item has a bound property that has changed.
- * Notify listeners of the change.
- */
- protected void itemAspectChanged(int index, Object item) {
- this.fireItemReplaced(LIST_VALUES, index, item, item); // hmmm...
- }
-
- /**
- * Return the last index of the specified item, using object
- * identity instead of equality.
- */
- protected int lastIdentityIndexOf(Object o) {
- return this.lastIdentityIndexOf(o, this.listHolder.size());
- }
-
- /**
- * Return the last index of the specified item, starting just before the
- * the specified endpoint, and using object identity instead of equality.
- */
- protected int lastIdentityIndexOf(Object o, int end) {
- for (int i = end; i-- > 0; ) {
- if (this.listHolder.get(i) == o) {
- return i;
- }
- }
- return -1;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemCollectionListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemCollectionListValueModelAdapter.java
deleted file mode 100644
index 6f46a74c32..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemCollectionListValueModelAdapter.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Extend ItemAspectListValueModelAdapter to listen to one or more collection
- * aspects of each item in the wrapped list model.
- */
-public class ItemCollectionListValueModelAdapter<E>
- extends ItemAspectListValueModelAdapter<E>
-{
-
- /** The names of the items' collections that we listen to. */
- protected final String[] collectionNames;
-
- /** Listener that listens to all the items in the list. */
- protected final CollectionChangeListener itemCollectionListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified item Collections.
- */
- public ItemCollectionListValueModelAdapter(ListValueModel<E> listHolder, String... collectionNames) {
- super(listHolder);
- this.collectionNames = collectionNames;
- this.itemCollectionListener = this.buildItemCollectionListener();
- }
-
- /**
- * Construct an adapter for the specified item Collections.
- */
- public ItemCollectionListValueModelAdapter(CollectionValueModel<E> collectionHolder, String... collectionNames) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder), collectionNames);
- }
-
-
- // ********** initialization **********
-
- /**
- * All we really care about is the fact that a Collection aspect has
- * changed. Do the same thing no matter which event occurs.
- */
- protected CollectionChangeListener buildItemCollectionListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent event) {
- ItemCollectionListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void itemsRemoved(CollectionChangeEvent event) {
- ItemCollectionListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void collectionCleared(CollectionChangeEvent event) {
- ItemCollectionListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- ItemCollectionListValueModelAdapter.this.itemAspectChanged(event);
- }
- @Override
- public String toString() {
- return "item collection listener: " + Arrays.asList(ItemCollectionListValueModelAdapter.this.collectionNames);
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void startListeningToItem(Model item) {
- for (String collectionName : this.collectionNames) {
- item.addCollectionChangeListener(collectionName, this.itemCollectionListener);
- }
- }
-
- @Override
- protected void stopListeningToItem(Model item) {
- for (String collectionName : this.collectionNames) {
- item.removeCollectionChangeListener(collectionName, this.itemCollectionListener);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemListListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemListListValueModelAdapter.java
deleted file mode 100644
index 9c3ac67ac5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemListListValueModelAdapter.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Extend ItemAspectListValueModelAdapter to listen to one or more list
- * aspects of each item in the wrapped list model.
- */
-public class ItemListListValueModelAdapter<E>
- extends ItemAspectListValueModelAdapter<E>
-{
-
- /** The names of the subject's lists that we listen to. */
- protected final String[] listNames;
-
- /** Listener that listens to all the items in the list. */
- protected final ListChangeListener itemListListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified item List aspects.
- */
- public ItemListListValueModelAdapter(ListValueModel<E> listHolder, String... listNames) {
- super(listHolder);
- this.listNames = listNames;
- this.itemListListener = this.buildItemListListener();
- }
-
- /**
- * Construct an adapter for the specified item List aspects.
- */
- public ItemListListValueModelAdapter(CollectionValueModel<E> collectionHolder, String... listNames) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder), listNames);
- }
-
-
- // ********** initialization **********
-
- /**
- * All we really care about is the fact that the List aspect has
- * changed. Do the same thing no matter which event occurs.
- */
- protected ListChangeListener buildItemListListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent event) {
- ItemListListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void itemsRemoved(ListChangeEvent event) {
- ItemListListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void itemsReplaced(ListChangeEvent event) {
- ItemListListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void itemsMoved(ListChangeEvent event) {
- ItemListListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void listCleared(ListChangeEvent event) {
- ItemListListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void listChanged(ListChangeEvent event) {
- ItemListListValueModelAdapter.this.itemAspectChanged(event);
- }
- @Override
- public String toString() {
- return "item list listener: " + Arrays.asList(ItemListListValueModelAdapter.this.listNames);
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void startListeningToItem(Model item) {
- for (String listName : this.listNames) {
- item.addListChangeListener(listName, this.itemListListener);
- }
- }
-
- @Override
- protected void stopListeningToItem(Model item) {
- for (String listName : this.listNames) {
- item.removeListChangeListener(listName, this.itemListListener);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemPropertyListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemPropertyListValueModelAdapter.java
deleted file mode 100644
index 3a00073252..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemPropertyListValueModelAdapter.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Extend ItemAspectListValueModelAdapter to listen to one or more
- * properties of each item in the wrapped list model.
- */
-public class ItemPropertyListValueModelAdapter<E>
- extends ItemAspectListValueModelAdapter<E>
-{
-
- /** The names of the items' properties that we listen to. */
- protected final String[] propertyNames;
-
- /** Listener that listens to all the items in the list. */
- protected final PropertyChangeListener itemPropertyListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified item properties.
- */
- public ItemPropertyListValueModelAdapter(ListValueModel<E> listHolder, String... propertyNames) {
- super(listHolder);
- this.propertyNames = propertyNames;
- this.itemPropertyListener = this.buildItemPropertyListener();
- }
-
- /**
- * Construct an adapter for the specified item properties.
- */
- public ItemPropertyListValueModelAdapter(CollectionValueModel<E> collectionHolder, String... propertyNames) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder), propertyNames);
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildItemPropertyListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- ItemPropertyListValueModelAdapter.this.itemAspectChanged(event);
- }
- @Override
- public String toString() {
- return "item property listener: " + Arrays.asList(ItemPropertyListValueModelAdapter.this.propertyNames);
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void startListeningToItem(Model item) {
- for (String propertyName : this.propertyNames) {
- item.addPropertyChangeListener(propertyName, this.itemPropertyListener);
- }
- }
-
- @Override
- protected void stopListeningToItem(Model item) {
- for (String propertyName : this.propertyNames) {
- item.removePropertyChangeListener(propertyName, this.itemPropertyListener);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemStateListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemStateListValueModelAdapter.java
deleted file mode 100644
index 46d7d863fb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemStateListValueModelAdapter.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Extend ItemAspectListValueModelAdapter to listen to the
- * "state" of each item in the wrapped list model.
- */
-public class ItemStateListValueModelAdapter<E>
- extends ItemAspectListValueModelAdapter<E>
-{
- /** Listener that listens to all the items in the list. */
- protected final StateChangeListener itemStateListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the item state.
- */
- public ItemStateListValueModelAdapter(ListValueModel<E> listHolder) {
- super(listHolder);
- this.itemStateListener = this.buildItemStateListener();
- }
-
- /**
- * Construct an adapter for the item state.
- */
- public ItemStateListValueModelAdapter(CollectionValueModel<E> collectionHolder) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder));
- }
-
-
- // ********** initialization **********
-
- protected StateChangeListener buildItemStateListener() {
- return new StateChangeListener() {
- public void stateChanged(StateChangeEvent event) {
- ItemStateListValueModelAdapter.this.itemAspectChanged(event);
- }
- @Override
- public String toString() {
- return "item state listener";
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void startListeningToItem(Model item) {
- item.addStateChangeListener(this.itemStateListener);
- }
-
- @Override
- protected void stopListeningToItem(Model item) {
- item.removeStateChangeListener(this.itemStateListener);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemTreeListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemTreeListValueModelAdapter.java
deleted file mode 100644
index 5fcc770398..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemTreeListValueModelAdapter.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Extend ItemAspectListValueModelAdapter to listen to one or more tree
- * aspects of each item in the wrapped list model.
- */
-public class ItemTreeListValueModelAdapter<E>
- extends ItemAspectListValueModelAdapter<E>
-{
-
- /** The names of the items' tree that we listen to. */
- protected final String[] treeNames;
-
- /** Listener that listens to all the items in the list. */
- protected final TreeChangeListener itemTreeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified item trees.
- */
- public ItemTreeListValueModelAdapter(ListValueModel<E> listHolder, String... treeNames) {
- super(listHolder);
- this.treeNames = treeNames;
- this.itemTreeListener = this.buildItemTreeListener();
- }
-
- /**
- * Construct an adapter for the specified item trees.
- */
- public ItemTreeListValueModelAdapter(CollectionValueModel<E> collectionHolder, String... treeNames) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder), treeNames);
- }
-
-
- // ********** initialization **********
-
- /**
- * All we really care about is the fact that a tree aspect has
- * changed. Do the same thing no matter which event occurs.
- */
- protected TreeChangeListener buildItemTreeListener() {
- return new TreeChangeListener() {
- public void nodeAdded(TreeChangeEvent event) {
- ItemTreeListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void nodeRemoved(TreeChangeEvent event) {
- ItemTreeListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void treeCleared(TreeChangeEvent event) {
- ItemTreeListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void treeChanged(TreeChangeEvent event) {
- ItemTreeListValueModelAdapter.this.itemAspectChanged(event);
- }
- @Override
- public String toString() {
- return "item tree listener: " + Arrays.asList(ItemTreeListValueModelAdapter.this.treeNames);
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void startListeningToItem(Model item) {
- for (String treeName : this.treeNames) {
- item.addTreeChangeListener(treeName, this.itemTreeListener);
- }
- }
-
- @Override
- protected void stopListeningToItem(Model item) {
- for (String treeName : this.treeNames) {
- item.removeTreeChangeListener(treeName, this.itemTreeListener);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListAspectAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListAspectAdapter.java
deleted file mode 100644
index be004fe730..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListAspectAdapter.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * This extension of AspectAdapter provides ListChange support.
- * This allows us to convert a set of one or more collections into
- * a single collection, LIST_VALUES.
- *
- * The typical subclass will override the following methods:
- * #listIterator_()
- * at the very minimum, override this method to return a list iterator
- * on the subject's list aspect; it does not need to be overridden if
- * #listIterator() is overridden and its behavior changed
- * #get(int)
- * override this method to improve performance
- * #size_()
- * override this method to improve performance; it does not need to be overridden if
- * #size() is overridden and its behavior changed
- * #listIterator()
- * override this method only if returning an empty list iterator when the
- * subject is null is unacceptable
- * #size()
- * override this method only if returning a zero when the
- * subject is null is unacceptable
- */
-public abstract class ListAspectAdapter<S extends Model, E>
- extends AspectAdapter<S>
- implements ListValueModel<E>
-{
- /**
- * The name of the subject's lists that we use for the value.
- */
- protected final String[] listNames;
- protected static final String[] EMPTY_LIST_NAMES = new String[0];
-
- /** A listener that listens to the subject's list aspect. */
- protected final ListChangeListener listChangeListener;
-
- private static final Object[] EMPTY_ARRAY = new Object[0];
-
-
- // ********** constructors **********
-
- /**
- * Construct a ListAspectAdapter for the specified subject
- * and list.
- */
- protected ListAspectAdapter(String listName, S subject) {
- this(new String[] {listName}, subject);
- }
-
- /**
- * Construct a ListAspectAdapter for the specified subject
- * and lists.
- */
- protected ListAspectAdapter(String[] listNames, S subject) {
- this(new StaticPropertyValueModel<S>(subject), listNames);
- }
-
- /**
- * Construct a ListAspectAdapter for the specified subject holder
- * and lists.
- */
- protected ListAspectAdapter(PropertyValueModel<? extends S> subjectHolder, String... listNames) {
- super(subjectHolder);
- this.listNames = listNames;
- this.listChangeListener = this.buildListChangeListener();
- }
-
- /**
- * Construct a ListAspectAdapter for the specified subject holder
- * and lists.
- */
- protected ListAspectAdapter(PropertyValueModel<? extends S> subjectHolder, Collection<String> listNames) {
- this(subjectHolder, listNames.toArray(new String[listNames.size()]));
- }
-
- /**
- * Construct a ListAspectAdapter for an "unchanging" list in
- * the specified subject. This is useful for a list aspect that does not
- * change for a particular subject; but the subject will change, resulting in
- * a new list.
- */
- protected ListAspectAdapter(PropertyValueModel<? extends S> subjectHolder) {
- this(subjectHolder, EMPTY_LIST_NAMES);
- }
-
-
- // ********** initialization **********
-
- /**
- * The subject's list aspect has changed, notify the listeners.
- */
- protected ListChangeListener buildListChangeListener() {
- // transform the subject's list change events into VALUE list change events
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent event) {
- ListAspectAdapter.this.itemsAdded(event);
- }
- public void itemsRemoved(ListChangeEvent event) {
- ListAspectAdapter.this.itemsRemoved(event);
- }
- public void itemsReplaced(ListChangeEvent event) {
- ListAspectAdapter.this.itemsReplaced(event);
- }
- public void itemsMoved(ListChangeEvent event) {
- ListAspectAdapter.this.itemsMoved(event);
- }
- public void listCleared(ListChangeEvent event) {
- ListAspectAdapter.this.listCleared(event);
- }
- public void listChanged(ListChangeEvent event) {
- ListAspectAdapter.this.listChanged(event);
- }
- @Override
- public String toString() {
- return "list change listener: " + Arrays.asList(ListAspectAdapter.this.listNames);
- }
- };
- }
-
-
- // ********** ListValueModel implementation **********
-
- /**
- * Return the elements of the subject's list aspect.
- */
- public Iterator<E> iterator() {
- return this.listIterator();
- }
-
- /**
- * Return the elements of the subject's list aspect.
- */
- public ListIterator<E> listIterator() {
- return (this.subject == null) ? EmptyListIterator.<E>instance() : this.listIterator_();
- }
-
- /**
- * Return the elements of the subject's list aspect.
- * At this point we can be sure that the subject is not null.
- * @see #listIterator()
- */
- protected ListIterator<E> listIterator_() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Return the element at the specified index of the subject's list aspect.
- */
- public E get(int index) {
- return CollectionTools.get(this.listIterator(), index);
- }
-
- /**
- * Return the size of the subject's list aspect.
- */
- public int size() {
- return this.subject == null ? 0 : this.size_();
- }
-
- /**
- * Return the size of the subject's list aspect.
- * At this point we can be sure that the subject is not null.
- * @see #size()
- */
- protected int size_() {
- return CollectionTools.size(this.listIterator());
- }
-
- /**
- * Return an array manifestation of the subject's list aspect.
- */
- public Object[] toArray() {
- return this.subject == null ? EMPTY_ARRAY : this.toArray_();
- }
-
- /**
- * Return an array manifestation of the subject's list aspect.
- * At this point we can be sure that the subject is not null.
- * @see #toArray()
- */
- protected Object[] toArray_() {
- return CollectionTools.array(this.listIterator(), this.size());
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected Object getValue() {
- return this.iterator();
- }
-
- @Override
- protected Class<? extends ChangeListener> getListenerClass() {
- return ListChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return LIST_VALUES;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyListChangeListeners(LIST_VALUES);
- }
-
- @Override
- protected void fireAspectChange(Object oldValue, Object newValue) {
- this.fireListChanged(LIST_VALUES);
- }
-
- @Override
- protected void engageSubject_() {
- for (String listName : this.listNames) {
- ((Model) this.subject).addListChangeListener(listName, this.listChangeListener);
- }
- }
-
- @Override
- protected void disengageSubject_() {
- for (String listName : this.listNames) {
- ((Model) this.subject).removeListChangeListener(listName, this.listChangeListener);
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- for (int i = 0; i < this.listNames.length; i++) {
- if (i != 0) {
- sb.append(", ");
- }
- sb.append(this.listNames[i]);
- }
- }
-
-
- // ********** behavior **********
-
- protected void itemsAdded(ListChangeEvent event) {
- this.fireItemsAdded(event.cloneWithSource(this, LIST_VALUES));
- }
-
- protected void itemsRemoved(ListChangeEvent event) {
- this.fireItemsRemoved(event.cloneWithSource(this, LIST_VALUES));
- }
-
- protected void itemsReplaced(ListChangeEvent event) {
- this.fireItemsReplaced(event.cloneWithSource(this, LIST_VALUES));
- }
-
- protected void itemsMoved(ListChangeEvent event) {
- this.fireItemsMoved(event.cloneWithSource(this, LIST_VALUES));
- }
-
- protected void listCleared(ListChangeEvent event) {
- this.fireListCleared(LIST_VALUES); // nothing from original event to forward
- }
-
- protected void listChanged(ListChangeEvent event) {
- this.fireListChanged(LIST_VALUES); // nothing from original event to forward
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java
deleted file mode 100644
index 30e73a7bfc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * An adapter that allows us to make a ListValueModel behave like
- * a read-only CollectionValueModel, sorta.
- *
- * We keep an internal collection somewhat in synch with the wrapped list.
- *
- * NB: Since we only listen to the wrapped list when we have
- * listeners ourselves and we can only stay in synch with the wrapped
- * list while we are listening to it, results to various methods
- * (e.g. #size(), value()) will be unpredictable whenever
- * we do not have any listeners. This should not be too painful since,
- * most likely, client objects will also be listeners.
- */
-public class ListCollectionValueModelAdapter<E>
- extends AbstractModel
- implements CollectionValueModel<E>
-{
- /** The wrapped list value model. */
- protected final ListValueModel<? extends E> listHolder;
-
- /** A listener that forwards any events fired by the list holder. */
- protected final ListChangeListener listChangeListener;
-
- /**
- * Our internal collection, which holds the same elements as
- * the wrapped list.
- */
- // we declare this an ArrayList so we can use #clone() and #ensureCapacity(int)
- protected final ArrayList<E> collection;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Wrap the specified ListValueModel.
- */
- public ListCollectionValueModelAdapter(ListValueModel<? extends E> listHolder) {
- super();
- if (listHolder == null) {
- throw new NullPointerException();
- }
- this.listHolder = listHolder;
- this.listChangeListener = this.buildListChangeListener();
- this.collection = new ArrayList<E>();
- // postpone building the collection and listening to the underlying list
- // until we have listeners ourselves...
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, CollectionChangeListener.class, VALUES);
- }
-
- /**
- * The wrapped list has changed, forward an equivalent
- * collection change event to our listeners.
- */
- protected ListChangeListener buildListChangeListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent event) {
- ListCollectionValueModelAdapter.this.itemsAdded(event);
- }
- public void itemsRemoved(ListChangeEvent event) {
- ListCollectionValueModelAdapter.this.itemsRemoved(event);
- }
- public void itemsReplaced(ListChangeEvent event) {
- ListCollectionValueModelAdapter.this.itemsReplaced(event);
- }
- public void itemsMoved(ListChangeEvent event) {
- ListCollectionValueModelAdapter.this.itemsMoved(event);
- }
- public void listCleared(ListChangeEvent event) {
- ListCollectionValueModelAdapter.this.listCleared(event);
- }
- public void listChanged(ListChangeEvent event) {
- ListCollectionValueModelAdapter.this.listChanged(event);
- }
- @Override
- public String toString() {
- return "list change listener";
- }
- };
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public Iterator<E> iterator() {
- // try to prevent backdoor modification of the list
- return new ReadOnlyIterator<E>(this.collection);
- }
-
- public int size() {
- return this.collection.size();
- }
-
-
- // ********** extend change support **********
-
- /**
- * Override to start listening to the list holder if necessary.
- */
- @Override
- public void addCollectionChangeListener(CollectionChangeListener listener) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addCollectionChangeListener(listener);
- }
-
- /**
- * Override to start listening to the list holder if necessary.
- */
- @Override
- public void addCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- if (collectionName == VALUES && this.hasNoListeners()) {
- this.engageModel();
- }
- super.addCollectionChangeListener(collectionName, listener);
- }
-
- /**
- * Override to stop listening to the list holder if appropriate.
- */
- @Override
- public void removeCollectionChangeListener(CollectionChangeListener listener) {
- super.removeCollectionChangeListener(listener);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Override to stop listening to the list holder if appropriate.
- */
- @Override
- public void removeCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- super.removeCollectionChangeListener(collectionName, listener);
- if (collectionName == VALUES && this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** queries **********
-
- protected boolean hasListeners() {
- return this.hasAnyCollectionChangeListeners(VALUES);
- }
-
- protected boolean hasNoListeners() {
- return ! this.hasListeners();
- }
-
- /**
- * Return the index of the specified item, using object
- * identity instead of equality.
- */
- protected int lastIdentityIndexOf(Object o) {
- return this.lastIdentityIndexOf(o, this.collection.size());
- }
-
- /**
- * Return the last index of the specified item, starting just before the
- * the specified endpoint, and using object identity instead of equality.
- */
- protected int lastIdentityIndexOf(Object o, int end) {
- for (int i = end; i-- > 0; ) {
- if (this.collection.get(i) == o) {
- return i;
- }
- }
- return -1;
- }
-
-
- // ********** behavior **********
-
- protected void buildCollection() {
- Iterator<? extends E> stream = this.listHolder.iterator();
- // if the new list is empty, do nothing
- if (stream.hasNext()) {
- this.collection.ensureCapacity(this.listHolder.size());
- while (stream.hasNext()) {
- this.collection.add(stream.next());
- }
- }
- }
-
- protected void engageModel() {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- // synch our collection *after* we start listening to the list holder,
- // since its value might change when a listener is added
- this.buildCollection();
- }
-
- protected void disengageModel() {
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- // clear out the collection when we are not listening to the list holder
- this.collection.clear();
- }
-
- // minimize suppressed warnings
- @SuppressWarnings("unchecked")
- protected ListIterator<E> items(ListChangeEvent event) {
- return (ListIterator<E>) event.items();
- }
-
- // minimize suppressed warnings
- @SuppressWarnings("unchecked")
- protected ListIterator<E> replacedItems(ListChangeEvent event) {
- return (ListIterator<E>) event.replacedItems();
- }
-
- protected void itemsAdded(ListChangeEvent event) {
- this.addItemsToCollection(this.items(event), this.collection, VALUES);
- }
-
- protected void removeInternalItems(Iterator<E> items) {
- // we have to remove the items individually,
- // since they are probably not in sequence
- while (items.hasNext()) {
- Object removedItem = items.next();
- int index = this.lastIdentityIndexOf(removedItem);
- this.collection.remove(index);
- this.fireItemRemoved(VALUES, removedItem);
- }
- }
-
- protected void itemsRemoved(ListChangeEvent event) {
- this.removeInternalItems(this.items(event));
- }
-
- protected void itemsReplaced(ListChangeEvent event) {
- this.removeInternalItems(this.replacedItems(event));
- this.addItemsToCollection(this.items(event), this.collection, VALUES);
- }
-
- protected void itemsMoved(ListChangeEvent event) {
- // do nothing? moving items in a list has no net effect on a collection...
- }
-
- protected void listCleared(ListChangeEvent event) {
- // put in empty check so we don't fire events unnecessarily
- if ( ! this.collection.isEmpty()) {
- this.collection.clear();
- this.fireCollectionCleared(VALUES);
- }
- }
-
- /**
- * synchronize our internal collection with the wrapped list
- * and fire the appropriate events
- */
- protected void listChanged(ListChangeEvent event) {
- // put in empty check so we don't fire events unnecessarily
- if ( ! this.collection.isEmpty()) {
- @SuppressWarnings("unchecked")
- ArrayList<E> removedItems = (ArrayList<E>) this.collection.clone();
- this.collection.clear();
- this.fireItemsRemoved(VALUES, removedItems);
- }
-
- this.buildCollection();
- // put in empty check so we don't fire events unnecessarily
- if ( ! this.collection.isEmpty()) {
- this.fireItemsAdded(VALUES, this.collection);
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.listHolder);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCurator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCurator.java
deleted file mode 100644
index 5420b78d84..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCurator.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * This extension of AspectAdapter provides ListChange support
- * by adapting a subject's state change events to a minimum set
- * of list change events.
- */
-public abstract class ListCurator<S extends Model, E>
- extends AspectAdapter<S>
- implements ListValueModel<E>
-{
- /** How the list looked before the last state change */
- private final ArrayList<E> record;
-
- /** A listener that listens for the subject's state to change */
- private final StateChangeListener stateChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a Curator for the specified subject.
- */
- protected ListCurator(S subject) {
- this(new StaticPropertyValueModel<S>(subject));
- }
-
- /**
- * Construct a curator for the specified subject holder.
- * The subject holder cannot be null.
- */
- protected ListCurator(PropertyValueModel<? extends S> subjectHolder) {
- super(subjectHolder);
- this.record = new ArrayList<E>();
- this.stateChangeListener = this.buildStateChangeListener();
- }
-
-
- // ********** initialization **********
-
- /**
- * The subject's state has changed, do inventory and report to listeners.
- */
- protected StateChangeListener buildStateChangeListener() {
- return new StateChangeListener() {
- public void stateChanged(StateChangeEvent event) {
- ListCurator.this.submitInventoryReport();
- }
- @Override
- public String toString() {
- return "state change listener";
- }
- };
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E> listIterator() {
- return new ReadOnlyListIterator<E>(this.record);
- }
-
- /**
- * Return the item at the specified index of the subject's list aspect.
- */
- public E get(int index) {
- return this.record.get(index);
- }
-
- /**
- * Return the size of the subject's list aspect.
- */
- public int size() {
- return this.record.size();
- }
-
- /**
- * Return an array manifestation of the subject's list aspect.
- */
- public Object[] toArray() {
- return this.record.toArray();
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected Object getValue() {
- return this.iterator();
- }
-
- @Override
- protected Class<? extends ChangeListener> getListenerClass() {
- return ListChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return LIST_VALUES;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyListChangeListeners(LIST_VALUES);
- }
-
- /**
- * The aspect has changed, notify listeners appropriately.
- */
- @Override
- protected void fireAspectChange(Object oldValue, Object newValue) {
- this.fireListChanged(LIST_VALUES);
- }
-
- /**
- * The subject is not null - add our listener.
- */
- @Override
- protected void engageSubject_() {
- ((Model) this.subject).addStateChangeListener(this.stateChangeListener);
- // synch our list *after* we start listening to the subject,
- // since its value might change when a listener is added
- CollectionTools.addAll(this.record, this.iteratorForRecord());
- }
-
- /**
- * The subject is not null - remove our listener.
- */
- @Override
- protected void disengageSubject_() {
- ((Model) this.subject).removeStateChangeListener(this.stateChangeListener);
- // clear out the list when we are not listening to the subject
- this.record.clear();
- }
-
-
- // ********** ListCurator protocol **********
-
- /**
- * This is intended to be different from #ListValueModel.iterator().
- * It is intended to be used only when the subject changes or the
- * subject's "state" changes (as signified by a state change event).
- */
- protected abstract Iterator<E> iteratorForRecord();
-
-
- // ********** behavior **********
-
- void submitInventoryReport() {
- List<E> newRecord = CollectionTools.list(this.iteratorForRecord());
- int recordIndex = 0;
-
- // add items from the new record
- for (E newItem : newRecord) {
- this.inventoryNewItem(recordIndex, newItem);
- recordIndex++;
- }
-
- // clean out items that are no longer in the new record
- for (recordIndex = 0; recordIndex < this.record.size(); ) {
- E item = this.record.get(recordIndex);
-
- if (newRecord.contains(item)) {
- recordIndex++;
- } else {
- this.removeItemFromInventory(recordIndex, item);
- }
- }
- }
-
- private void inventoryNewItem(int recordIndex, E newItem) {
- List<E> rec = new ArrayList<E>(this.record);
-
- if ((recordIndex < rec.size()) && rec.get(recordIndex).equals(newItem)) {
- return;
- }
- if (rec.contains(newItem)) {
- this.removeItemFromInventory(recordIndex, rec.get(recordIndex));
- this.inventoryNewItem(recordIndex, newItem);
- } else {
- this.addItemToInventory(recordIndex, newItem);
- }
- }
-
- private void addItemToInventory(int index, E item) {
- this.addItemToList(index, item, this.record, LIST_VALUES);
- }
-
- private void removeItemFromInventory(int index, E item) {
- this.removeItemFromList(index, this.record, LIST_VALUES);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListPropertyValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListPropertyValueModelAdapter.java
deleted file mode 100644
index 6c78b4fd62..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListPropertyValueModelAdapter.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * a list value model, "lazily" listen to it, and convert
- * its change notifications into property value model change
- * notifications.
- *
- * Subclasses must override:
- * - #buildValue()
- * to return the current property value, as derived from the
- * current list value
- *
- * Subclasses might want to override:
- * - #itemsAdded(ListChangeEvent event)
- * - #itemsRemoved(ListChangeEvent event)
- * - #itemsReplaced(ListChangeEvent event)
- * - #itemsMoved(ListChangeEvent event)
- * - #listCleared(ListChangeEvent event)
- * - #listChanged(ListChangeEvent event)
- * to improve performance (by not recalculating the value, if possible)
- */
-public abstract class ListPropertyValueModelAdapter<T>
- extends AspectPropertyValueModelAdapter<T>
-{
- /** The wrapped list value model. */
- protected final ListValueModel<?> listHolder;
-
- /** A listener that allows us to synch with changes to the wrapped list holder. */
- protected final ListChangeListener listChangeListener;
-
-
- // ********** constructor/initialization **********
-
- /**
- * Construct a property value model with the specified wrapped
- * list value model.
- */
- protected ListPropertyValueModelAdapter(ListValueModel<?> listHolder) {
- super();
- this.listHolder = listHolder;
- this.listChangeListener = this.buildListChangeListener();
- }
-
- protected ListChangeListener buildListChangeListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent event) {
- ListPropertyValueModelAdapter.this.itemsAdded(event);
- }
- public void itemsRemoved(ListChangeEvent event) {
- ListPropertyValueModelAdapter.this.itemsRemoved(event);
- }
- public void itemsReplaced(ListChangeEvent event) {
- ListPropertyValueModelAdapter.this.itemsReplaced(event);
- }
- public void itemsMoved(ListChangeEvent event) {
- ListPropertyValueModelAdapter.this.itemsMoved(event);
- }
- public void listCleared(ListChangeEvent event) {
- ListPropertyValueModelAdapter.this.listCleared(event);
- }
- public void listChanged(ListChangeEvent event) {
- ListPropertyValueModelAdapter.this.listChanged(event);
- }
- @Override
- public String toString() {
- return "list change listener";
- }
- };
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the list holder.
- */
- @Override
- protected void engageModel_() {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
- /**
- * Stop listening to the list holder.
- */
- @Override
- protected void disengageModel_() {
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.listHolder);
- }
-
-
- // ********** collection change support **********
-
- /**
- * Items were added to the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected void itemsAdded(ListChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * Items were removed from the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected void itemsRemoved(ListChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * Items were replaced in the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected void itemsReplaced(ListChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * Items were moved in the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected void itemsMoved(ListChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * The wrapped list holder was cleared;
- * propagate the change notification appropriately.
- */
- protected void listCleared(ListChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * The value of the wrapped list holder has changed;
- * propagate the change notification appropriately.
- */
- protected void listChanged(ListChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListValueModelWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListValueModelWrapper.java
deleted file mode 100644
index 3eb604dfd5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListValueModelWrapper.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * another list value model, "lazily" listen to it, and propagate
- * its change notifications.
- */
-public abstract class ListValueModelWrapper<E>
- extends AbstractModel
-{
-
- /** The wrapped list value model. */
- protected final ListValueModel<? extends E> listHolder;
-
- /** A listener that allows us to synch with changes to the wrapped list holder. */
- protected final ListChangeListener listChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a list value model with the specified wrapped
- * list value model.
- */
- protected ListValueModelWrapper(ListValueModel<? extends E> listHolder) {
- super();
- if (listHolder == null) {
- throw new NullPointerException();
- }
- this.listHolder = listHolder;
- this.listChangeListener = this.buildListChangeListener();
- }
-
-
- // ********** initialization **********
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, ListChangeListener.class, ListValueModel.LIST_VALUES);
- }
-
- protected ListChangeListener buildListChangeListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent event) {
- ListValueModelWrapper.this.itemsAdded(event);
- }
- public void itemsRemoved(ListChangeEvent event) {
- ListValueModelWrapper.this.itemsRemoved(event);
- }
- public void itemsReplaced(ListChangeEvent event) {
- ListValueModelWrapper.this.itemsReplaced(event);
- }
- public void itemsMoved(ListChangeEvent event) {
- ListValueModelWrapper.this.itemsMoved(event);
- }
- public void listCleared(ListChangeEvent event) {
- ListValueModelWrapper.this.listCleared(event);
- }
- public void listChanged(ListChangeEvent event) {
- ListValueModelWrapper.this.listChanged(event);
- }
- @Override
- public String toString() {
- return "list change listener";
- }
- };
- }
-
-
- // ********** extend change support **********
-
- /**
- * Extend to start listening to the nested model if necessary.
- */
- @Override
- public synchronized void addListChangeListener(ListChangeListener listener) {
- if (this.hasNoListChangeListeners(ListValueModel.LIST_VALUES)) {
- this.engageModel();
- }
- super.addListChangeListener(listener);
- }
-
- /**
- * Extend to start listening to the nested model if necessary.
- */
- @Override
- public synchronized void addListChangeListener(String listName, ListChangeListener listener) {
- if (listName == ListValueModel.LIST_VALUES && this.hasNoListChangeListeners(ListValueModel.LIST_VALUES)) {
- this.engageModel();
- }
- super.addListChangeListener(listName, listener);
- }
-
- /**
- * Extend to stop listening to the nested model if necessary.
- */
- @Override
- public synchronized void removeListChangeListener(ListChangeListener listener) {
- super.removeListChangeListener(listener);
- if (this.hasNoListChangeListeners(ListValueModel.LIST_VALUES)) {
- this.disengageModel();
- }
- }
-
- /**
- * Extend to stop listening to the nested model if necessary.
- */
- @Override
- public synchronized void removeListChangeListener(String listName, ListChangeListener listener) {
- super.removeListChangeListener(listName, listener);
- if (listName == ListValueModel.LIST_VALUES && this.hasNoListChangeListeners(ListValueModel.LIST_VALUES)) {
- this.disengageModel();
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the list holder.
- */
- protected void engageModel() {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
- /**
- * Stop listening to the list holder.
- */
- protected void disengageModel() {
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.listHolder);
- }
-
- // minimize suppressed warnings
- @SuppressWarnings("unchecked")
- protected ListIterator<E> items(ListChangeEvent event) {
- return (ListIterator<E>) event.items();
- }
-
- // minimize suppressed warnings
- @SuppressWarnings("unchecked")
- protected ListIterator<E> replacedItems(ListChangeEvent event) {
- return (ListIterator<E>) event.replacedItems();
- }
-
-
- // ********** list change support **********
-
- /**
- * Items were added to the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected abstract void itemsAdded(ListChangeEvent event);
-
- /**
- * Items were removed from the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected abstract void itemsRemoved(ListChangeEvent event);
-
- /**
- * Items were replaced in the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected abstract void itemsReplaced(ListChangeEvent event);
-
- /**
- * Items were moved in the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected abstract void itemsMoved(ListChangeEvent event);
-
- /**
- * The wrapped list holder was cleared;
- * propagate the change notification appropriately.
- */
- protected abstract void listCleared(ListChangeEvent event);
-
- /**
- * The value of the wrapped list holder has changed;
- * propagate the change notification appropriately.
- */
- protected abstract void listChanged(ListChangeEvent event);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java
deleted file mode 100644
index 910d90b53a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-
-/**
- * A read-only collection value model for when you
- * don't need to support a collection. In particular, this
- * is useful for the leaf nodes of a tree that never have
- * children.
- *
- * We don't use a singleton because we hold on to listeners.
- */
-public final class NullCollectionValueModel<E>
- extends AbstractModel
- implements CollectionValueModel<E>
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * Default constructor.
- */
- public NullCollectionValueModel() {
- super();
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public int size() {
- return 0;
- }
-
- public Iterator<E> iterator() {
- return EmptyIterator.instance();
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return ClassTools.shortClassNameForObject(this);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullListValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullListValueModel.java
deleted file mode 100644
index 3092ed6895..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullListValueModel.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * An empty list value model for when you don't
- * need to support a list.
- *
- * We don't use a singleton because we hold on to listeners.
- */
-public final class NullListValueModel<E>
- extends AbstractModel
- implements ListValueModel<E>
-{
- private static final Object[] EMPTY_ARRAY = new Object[0];
- private static final long serialVersionUID = 1L;
-
- /**
- * Default constructor.
- */
- public NullListValueModel() {
- super();
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return EmptyIterator.instance();
- }
-
- public ListIterator<E> listIterator() {
- return EmptyListIterator.instance();
- }
-
- public int size() {
- return 0;
- }
-
- public E get(int index) {
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: 0");
- }
-
- public Object[] toArray() {
- return EMPTY_ARRAY;
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return ClassTools.shortClassNameForObject(this);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullPropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullPropertyValueModel.java
deleted file mode 100644
index 12c9b670e8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullPropertyValueModel.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * A property value model for when you
- * don't need to support a value.
- *
- * We don't use a singleton because we hold on to listeners.
- */
-public class NullPropertyValueModel<T>
- extends AbstractModel
- implements PropertyValueModel<T>
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * Default constructor.
- */
- public NullPropertyValueModel() {
- super();
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- public T getValue() {
- return null;
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return ClassTools.shortClassNameForObject(this);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullTreeValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullTreeValueModel.java
deleted file mode 100644
index 4103536ebd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullTreeValueModel.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.value.TreeValueModel;
-
-/**
- * A tree value model for when you
- * don't need to support any nodes.
- *
- * We don't use a singleton because we hold on to listeners.
- */
-public class NullTreeValueModel<E>
- extends AbstractModel
- implements TreeValueModel<E>
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * Default constructor.
- */
- public NullTreeValueModel() {
- super();
- }
-
-
- // ********** TreeValueModel implementation **********
-
- public Iterator<E> nodes() {
- return EmptyIterator.instance();
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return ClassTools.shortClassNameForObject(this);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyAspectAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyAspectAdapter.java
deleted file mode 100644
index 81e93d8765..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyAspectAdapter.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * This AspectAdapter provides basic PropertyChange support.
- * This allows us to convert a set of one or more properties into
- * a single property, VALUE.
- *
- * The typical subclass will override the following methods:
- * #buildValue_()
- * at the very minimum, override this method to return the value of the
- * subject's property (or "virtual" property); it does not need to be
- * overridden if #buildValue() is overridden and its behavior changed
- * #setValue_(Object)
- * override this method if the client code needs to *set* the value of
- * the subject's property; oftentimes, though, the client code (e.g. UI)
- * will need only to *get* the value; it does not need to be
- * overridden if #setValue(Object) is overridden and its behavior changed
- * #buildValue()
- * override this method only if returning a null value when the subject is null
- * is unacceptable
- * #setValue(Object)
- * override this method only if something must be done when the subject
- * is null (e.g. throw an exception)
- */
-public abstract class PropertyAspectAdapter<S extends Model, T>
- extends AspectAdapter<S>
- implements WritablePropertyValueModel<T>
-{
- /**
- * Cache the current value of the aspect so we
- * can pass an "old value" when we fire a property change event.
- * We need this because the value may be calculated and may
- * not be in the property change event fired by the subject,
- * especially when dealing with multiple aspects.
- */
- protected T value;
-
- /** The name of the subject's properties that we use for the value. */
- protected final String[] propertyNames;
- protected static final String[] EMPTY_PROPERTY_NAMES = new String[0];
-
- /** A listener that listens to the appropriate properties of the subject. */
- protected final PropertyChangeListener propertyChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a PropertyAspectAdapter for the specified subject
- * and property.
- */
- protected PropertyAspectAdapter(String propertyName, S subject) {
- this(new String[] {propertyName}, subject);
- }
-
- /**
- * Construct a PropertyAspectAdapter for the specified subject
- * and properties.
- */
- protected PropertyAspectAdapter(String[] propertyNames, S subject) {
- this(new StaticPropertyValueModel<S>(subject), propertyNames);
- }
-
- /**
- * Construct a PropertyAspectAdapter for the specified subject holder
- * and properties.
- */
- protected PropertyAspectAdapter(PropertyValueModel<? extends S> subjectHolder, String... propertyNames) {
- super(subjectHolder);
- this.propertyNames = propertyNames;
- this.propertyChangeListener = this.buildPropertyChangeListener();
- // our value is null when we are not listening to the subject
- this.value = null;
- }
-
- /**
- * Construct a PropertyAspectAdapter for the specified subject holder
- * and properties.
- */
- protected PropertyAspectAdapter(PropertyValueModel<? extends S> subjectHolder, Collection<String> propertyNames) {
- this(subjectHolder, propertyNames.toArray(new String[propertyNames.size()]));
- }
-
- /**
- * Construct a PropertyAspectAdapter for an "unchanging" property in
- * the specified subject. This is useful for a property aspect that does not
- * change for a particular subject; but the subject will change, resulting in
- * a new property. (A TransformationPropertyValueModel could also be
- * used in this situation.)
- */
- protected PropertyAspectAdapter(PropertyValueModel<? extends S> subjectHolder) {
- this(subjectHolder, EMPTY_PROPERTY_NAMES);
- }
-
-
- // ********** initialization **********
-
- /**
- * The subject's property has changed, notify the listeners.
- */
- protected PropertyChangeListener buildPropertyChangeListener() {
- // transform the subject's property change events into VALUE property change events
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- PropertyAspectAdapter.this.propertyChanged();
- }
- @Override
- public String toString() {
- return "property change listener: " + Arrays.asList(PropertyAspectAdapter.this.propertyNames);
- }
- };
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- /**
- * Return the value of the subject's property.
- */
- @Override
- public final T getValue() {
- return this.value;
- }
-
-
- // ********** WritablePropertyValueModel implementation **********
-
- /**
- * Set the value of the subject's property.
- */
- public void setValue(T value) {
- if (this.subject != null) {
- this.setValue_(value);
- }
- }
-
- /**
- * Set the value of the subject's property.
- * At this point we can be sure that the subject is not null.
- * @see #setValue(Object)
- */
- protected void setValue_(T value) {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected Class<? extends ChangeListener> getListenerClass() {
- return PropertyChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return VALUE;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyPropertyChangeListeners(VALUE);
- }
-
- @Override
- protected void fireAspectChange(Object oldValue, Object newValue) {
- this.firePropertyChanged(VALUE, oldValue, newValue);
- }
-
- @Override
- protected void engageSubject() {
- super.engageSubject();
- // synch our value *after* we start listening to the subject,
- // since its value might change when a listener is added
- this.value = this.buildValue();
- }
-
- @Override
- protected void engageSubject_() {
- for (String propertyName : this.propertyNames) {
- ((Model) this.subject).addPropertyChangeListener(propertyName, this.propertyChangeListener);
- }
- }
-
- @Override
- protected void disengageSubject() {
- super.disengageSubject();
- // clear out our value when we are not listening to the subject
- this.value = null;
- }
-
- @Override
- protected void disengageSubject_() {
- for (String propertyName : this.propertyNames) {
- ((Model) this.subject).removePropertyChangeListener(propertyName, this.propertyChangeListener);
- }
- }
-
-
- // ********** AbstractModel implementation **********
-
- @Override
- public void toString(StringBuilder sb) {
- for (int i = 0; i < this.propertyNames.length; i++) {
- if (i != 0) {
- sb.append(", ");
- }
- sb.append(this.propertyNames[i]);
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * Return the aspect's value.
- * At this point the subject may be null.
- */
- protected T buildValue() {
- return (this.subject == null) ? null : this.buildValue_();
- }
-
- /**
- * Return the value of the subject's property.
- * At this point we can be sure that the subject is not null.
- * @see #buildValue()
- */
- protected T buildValue_() {
- throw new UnsupportedOperationException();
- }
-
- protected void propertyChanged() {
- T old = this.value;
- this.value = this.buildValue();
- this.fireAspectChange(old, this.value);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java
deleted file mode 100644
index 9dcc0d4e24..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * An adapter that allows us to make a PropertyValueModel behave like
- * a read-only, single-element CollectionValueModel, sorta.
- *
- * If the property's value is null, an empty iterator is returned
- * (i.e. you can't have a collection with a null element).
- */
-public class PropertyCollectionValueModelAdapter<E>
- extends AbstractModel
- implements CollectionValueModel<E>
-{
- /** The wrapped property value model. */
- protected final PropertyValueModel<? extends E> valueHolder;
-
- /** A listener that forwards any events fired by the value holder. */
- protected final PropertyChangeListener propertyChangeListener;
-
- /** Cache the value. */
- protected E value;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Wrap the specified ListValueModel.
- */
- public PropertyCollectionValueModelAdapter(PropertyValueModel<? extends E> valueHolder) {
- super();
- if (valueHolder == null) {
- throw new NullPointerException();
- }
- this.valueHolder = valueHolder;
- this.propertyChangeListener = this.buildPropertyChangeListener();
- // postpone building the value and listening to the underlying value
- // until we have listeners ourselves...
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, CollectionChangeListener.class, VALUES);
- }
-
- /**
- * The wrapped value has changed, forward an equivalent
- * collection change event to our listeners.
- */
- protected PropertyChangeListener buildPropertyChangeListener() {
- return new PropertyChangeListener() {
- @SuppressWarnings("unchecked")
- public void propertyChanged(PropertyChangeEvent event) {
- PropertyCollectionValueModelAdapter.this.valueChanged((E) event.getNewValue());
- }
- @Override
- public String toString() {
- return "property change listener";
- }
- };
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public Iterator<E> iterator() {
- return (this.value == null) ?
- EmptyIterator.<E>instance()
- :
- new SingleElementIterator<E>(this.value);
- }
-
- public int size() {
- return (this.value == null) ? 0 : 1;
- }
-
-
- // ********** extend change support **********
-
- /**
- * Override to start listening to the value holder if necessary.
- */
- @Override
- public void addCollectionChangeListener(CollectionChangeListener listener) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addCollectionChangeListener(listener);
- }
-
- /**
- * Override to start listening to the value holder if necessary.
- */
- @Override
- public void addCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- if (collectionName == VALUES && this.hasNoListeners()) {
- this.engageModel();
- }
- super.addCollectionChangeListener(collectionName, listener);
- }
-
- /**
- * Override to stop listening to the value holder if appropriate.
- */
- @Override
- public void removeCollectionChangeListener(CollectionChangeListener listener) {
- super.removeCollectionChangeListener(listener);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Override to stop listening to the value holder if appropriate.
- */
- @Override
- public void removeCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- super.removeCollectionChangeListener(collectionName, listener);
- if (collectionName == VALUES && this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** queries **********
-
- protected boolean hasListeners() {
- return this.hasAnyCollectionChangeListeners(VALUES);
- }
-
- protected boolean hasNoListeners() {
- return ! this.hasListeners();
- }
-
-
- // ********** behavior **********
-
- protected void engageModel() {
- this.valueHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.propertyChangeListener);
- // synch our value *after* we start listening to the value holder,
- // since its value might change when a listener is added
- this.value = this.valueHolder.getValue();
- }
-
- protected void disengageModel() {
- this.valueHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.propertyChangeListener);
- // clear out the value when we are not listening to the value holder
- this.value = null;
- }
-
- /**
- * synchronize our internal value with the wrapped value
- * and fire the appropriate events
- */
- protected void valueChanged(E newValue) {
- // put in "empty" check so we don't fire events unnecessarily
- if (this.value != null) {
- E oldValue = this.value;
- this.value = null;
- this.fireItemRemoved(VALUES, oldValue);
- }
- this.value = newValue;
- // put in "empty" check so we don't fire events unnecessarily
- if (this.value != null) {
- this.fireItemAdded(VALUES, this.value);
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.valueHolder);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyListValueModelAdapter.java
deleted file mode 100644
index 6826af4511..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyListValueModelAdapter.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * An adapter that allows us to make a PropertyValueModel behave like
- * a read-only, single-element ListValueModel, sorta.
- *
- * If the property's value is null, an empty iterator is returned
- * (i.e. you can't have a list with a null element).
- */
-public class PropertyListValueModelAdapter<E>
- extends AbstractModel
- implements ListValueModel<E>
-{
-
- /** The wrapped property value model. */
- protected final PropertyValueModel<? extends E> valueHolder;
-
- /** A listener that forwards any events fired by the value holder. */
- protected final PropertyChangeListener propertyChangeListener;
-
- /** Cache the value. */
- protected E value;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Wrap the specified property value model.
- */
- public PropertyListValueModelAdapter(PropertyValueModel<? extends E> valueHolder) {
- super();
- if (valueHolder == null) {
- throw new NullPointerException();
- }
- this.valueHolder = valueHolder;
- this.propertyChangeListener = this.buildPropertyChangeListener();
- // postpone building the value and listening to the underlying value
- // until we have listeners ourselves...
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, ListChangeListener.class, LIST_VALUES);
- }
-
- /**
- * The wrapped value has changed, forward an equivalent
- * list change event to our listeners.
- */
- protected PropertyChangeListener buildPropertyChangeListener() {
- return new PropertyChangeListener() {
- @SuppressWarnings("unchecked")
- public void propertyChanged(PropertyChangeEvent event) {
- PropertyListValueModelAdapter.this.valueChanged((E) event.getNewValue());
- }
- @Override
- public String toString() {
- return "property change listener";
- }
- };
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E> listIterator() {
- return (this.value == null) ?
- EmptyListIterator.<E>instance()
- :
- new SingleElementListIterator<E>(this.value);
- }
-
- public int size() {
- return (this.value == null) ? 0 : 1;
- }
-
- public E get(int index) {
- if (this.value == null) {
- throw this.ioobe(index, 0);
- }
- if (index > 0) {
- throw this.ioobe(index, 1);
- }
- return this.value;
- }
-
- protected static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
- public Object[] toArray() {
- return (this.value == null) ? EMPTY_OBJECT_ARRAY : new Object[] {this.value};
- }
-
-
- // ********** extend change support **********
-
- /**
- * Override to start listening to the value holder if necessary.
- */
- @Override
- public void addListChangeListener(ListChangeListener listener) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addListChangeListener(listener);
- }
-
- /**
- * Override to start listening to the value holder if necessary.
- */
- @Override
- public void addListChangeListener(String listName, ListChangeListener listener) {
- if (listName == LIST_VALUES && this.hasNoListeners()) {
- this.engageModel();
- }
- super.addListChangeListener(listName, listener);
- }
-
- /**
- * Override to stop listening to the value holder if appropriate.
- */
- @Override
- public void removeListChangeListener(ListChangeListener listener) {
- super.removeListChangeListener(listener);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Override to stop listening to the value holder if appropriate.
- */
- @Override
- public void removeListChangeListener(String listName, ListChangeListener listener) {
- super.removeListChangeListener(listName, listener);
- if (listName == LIST_VALUES && this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** queries **********
-
- protected boolean hasListeners() {
- return this.hasAnyListChangeListeners(LIST_VALUES);
- }
-
- protected boolean hasNoListeners() {
- return ! this.hasListeners();
- }
-
-
- // ********** behavior **********
-
- protected IndexOutOfBoundsException ioobe(int index, int size) {
- return new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
- }
-
- protected void engageModel() {
- this.valueHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.propertyChangeListener);
- // synch our value *after* we start listening to the value holder,
- // since its value might change when a listener is added
- this.value = this.valueHolder.getValue();
- }
-
- protected void disengageModel() {
- this.valueHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.propertyChangeListener);
- // clear out the value when we are not listening to the value holder
- this.value = null;
- }
-
- /**
- * synchronize our internal value with the wrapped value
- * and fire the appropriate events
- */
- protected void valueChanged(E newValue) {
- E oldValue = this.value;
- this.value = newValue;
- if (oldValue == null) {
- this.fireItemAdded(LIST_VALUES, 0, newValue);
- } else {
- if (newValue == null) {
- this.fireItemRemoved(LIST_VALUES, 0, oldValue);
- } else {
- this.fireItemReplaced(LIST_VALUES, 0, newValue, oldValue);
- }
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.valueHolder);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyValueModelWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyValueModelWrapper.java
deleted file mode 100644
index 0a4e550978..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyValueModelWrapper.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * another property value model, "lazily" listen to it, and propagate
- * its change notifications.
- */
-public abstract class PropertyValueModelWrapper<T>
- extends AbstractModel
-{
-
- /** The wrapped property value model. */
- protected final PropertyValueModel<? extends T> valueHolder;
-
- /** A listener that allows us to synch with changes to the wrapped value holder. */
- protected final PropertyChangeListener valueChangeListener;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Construct a property value model with the specified wrapped
- * property value model. The value holder is required.
- */
- protected PropertyValueModelWrapper(PropertyValueModel<? extends T> valueHolder) {
- super();
- if (valueHolder == null) {
- throw new NullPointerException();
- }
- this.valueHolder = valueHolder;
- this.valueChangeListener = this.buildValueChangeListener();
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, PropertyChangeListener.class, PropertyValueModel.VALUE);
- }
-
- protected PropertyChangeListener buildValueChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- PropertyValueModelWrapper.this.valueChanged(event);
- }
- @Override
- public String toString() {
- return "value change listener";
- }
- };
- }
-
-
- // ********** extend change support **********
-
- /**
- * Extend to start listening to the nested model if necessary.
- */
- @Override
- public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
- if (this.hasNoPropertyChangeListeners(PropertyValueModel.VALUE)) {
- this.engageValueHolder();
- }
- super.addPropertyChangeListener(listener);
- }
-
- /**
- * Extend to start listening to the nested model if necessary.
- */
- @Override
- public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- if (propertyName == PropertyValueModel.VALUE && this.hasNoPropertyChangeListeners(PropertyValueModel.VALUE)) {
- this.engageValueHolder();
- }
- super.addPropertyChangeListener(propertyName, listener);
- }
-
- /**
- * Extend to stop listening to the nested model if necessary.
- */
- @Override
- public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
- super.removePropertyChangeListener(listener);
- if (this.hasNoPropertyChangeListeners(PropertyValueModel.VALUE)) {
- this.disengageValueHolder();
- }
- }
-
- /**
- * Extend to stop listening to the nested model if necessary.
- */
- @Override
- public synchronized void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- super.removePropertyChangeListener(propertyName, listener);
- if (propertyName == PropertyValueModel.VALUE && this.hasNoPropertyChangeListeners(PropertyValueModel.VALUE)) {
- this.disengageValueHolder();
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * Begin listening to the value holder.
- */
- protected void engageValueHolder() {
- this.valueHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.valueChangeListener);
- }
-
- /**
- * Stop listening to the value holder.
- */
- protected void disengageValueHolder() {
- this.valueHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.valueChangeListener);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.valueHolder);
- }
-
-
- // ********** property change support **********
-
- /**
- * The value of the wrapped value holder has changed;
- * propagate the change notification appropriately.
- */
- protected abstract void valueChanged(PropertyChangeEvent event);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java
deleted file mode 100644
index aa242621c0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-
-/**
- * Implementation of CollectionValueModel and Collection that simply holds a
- * collection and notifies listeners of any changes.
- */
-public class SimpleCollectionValueModel<E>
- extends AbstractModel
- implements CollectionValueModel<E>, Collection<E>
-{
- /** The collection. */
- protected Collection<E> collection;
-
-
- // ********** constructors **********
-
- /**
- * Construct a CollectionValueModel for the specified collection.
- */
- public SimpleCollectionValueModel(Collection<E> collection) {
- super();
- if (collection == null) {
- throw new NullPointerException();
- }
- this.collection = collection;
- }
-
- /**
- * Construct a CollectionValueModel with an empty initial collection.
- */
- public SimpleCollectionValueModel() {
- this(new HashBag<E>());
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, CollectionChangeListener.class, VALUES);
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public Iterator<E> iterator() {
- return new LocalIterator<E>(this.collection.iterator());
- }
-
- public int size() {
- return this.collection.size();
- }
-
-
- // ********** Collection implementation **********
-
- public boolean isEmpty() {
- return this.collection.isEmpty();
- }
-
- public boolean contains(Object o) {
- return this.collection.contains(o);
- }
-
- public Object[] toArray() {
- return this.collection.toArray();
- }
-
- public <T extends Object> T[] toArray(T[] a) {
- return this.collection.toArray(a);
- }
-
- public boolean add(E o) {
- return this.addItemToCollection(o, this.collection, VALUES);
- }
-
- public boolean remove(Object o) {
- return this.removeItemFromCollection(o, this.collection, VALUES);
- }
-
- public boolean containsAll(Collection<?> c) {
- return this.collection.containsAll(c);
- }
-
- public boolean addAll(Collection<? extends E> c) {
- return this.addItemsToCollection(c, this.collection, VALUES);
- }
-
- public boolean removeAll(Collection<?> c) {
- return this.removeItemsFromCollection(c, this.collection, VALUES);
- }
-
- public boolean retainAll(Collection<?> c) {
- return this.retainItemsInCollection(c, this.collection, VALUES);
- }
-
- public void clear() {
- this.clearCollection(this.collection, VALUES);
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if ((o instanceof Collection) && (o instanceof CollectionValueModel)) {
- Collection<E> c1 = CollectionTools.collection(this.collection);
- @SuppressWarnings("unchecked")
- Collection<E> c2 = CollectionTools.collection(((Collection<E>) o).iterator());
- return c1.equals(c2);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return CollectionTools.collection(this.collection).hashCode();
- }
-
-
- // ********** additional behavior **********
-
- /**
- * Allow the collection to be replaced.
- */
- public void setCollection(Collection<E> collection) {
- if (collection == null) {
- throw new NullPointerException();
- }
- this.collection = collection;
- this.fireCollectionChanged(VALUES);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.collection);
- }
-
-
- // ********** iterator **********
-
- private class LocalIterator<T> implements Iterator<T> {
- private final Iterator<T> iterator;
- private T next;
-
- LocalIterator(Iterator<T> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public boolean hasNext() {
- return this.iterator.hasNext();
- }
-
- public T next() {
- return this.next = this.iterator.next();
- }
-
- @SuppressWarnings("synthetic-access")
- public void remove() {
- this.iterator.remove();
- SimpleCollectionValueModel.this.fireItemRemoved(VALUES, this.next);
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleListValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleListValueModel.java
deleted file mode 100644
index 7fafe63f2c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleListValueModel.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Implementation of ListValueModel and List that simply holds a
- * collection and notifies listeners of any changes.
- */
-public class SimpleListValueModel<E>
- extends AbstractModel
- implements ListValueModel<E>, List<E>
-{
- /** The list. */
- protected List<E> list;
-
-
- // ********** constructors **********
-
- /**
- * Construct a ListValueModel for the specified list.
- */
- public SimpleListValueModel(List<E> list) {
- super();
- if (list == null) {
- throw new NullPointerException();
- }
- this.list = list;
- }
-
- /**
- * Construct a ListValueModel with an empty initial list.
- */
- public SimpleListValueModel() {
- this(new ArrayList<E>());
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, ListChangeListener.class, LIST_VALUES);
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return new LocalIterator<E>(this.list.iterator());
- }
-
- public ListIterator<E> listIterator() {
- return new LocalListIterator<E>(this.list.listIterator());
- }
-
- public int size() {
- return this.list.size();
- }
-
- public E get(int index) {
- return this.list.get(index);
- }
-
-
- // ********** List implementation **********
-
- public boolean isEmpty() {
- return this.list.isEmpty();
- }
-
- public boolean contains(Object o) {
- return this.list.contains(o);
- }
-
- public Object[] toArray() {
- return this.list.toArray();
- }
-
- public <T extends Object> T[] toArray(T[] a) {
- return this.list.toArray(a);
- }
-
- public boolean add(E o) {
- return this.addItemToList(o, this.list, LIST_VALUES);
- }
-
- public boolean remove(Object o) {
- return this.removeItemFromList(o, this.list, LIST_VALUES);
- }
-
- public boolean containsAll(Collection<?> c) {
- return this.list.containsAll(c);
- }
-
- public boolean addAll(Collection<? extends E> c) {
- return this.addItemsToList(c, this.list, LIST_VALUES);
- }
-
- public boolean addAll(int index, Collection<? extends E> c) {
- return this.addItemsToList(index, c, this.list, LIST_VALUES);
- }
-
- public boolean removeAll(Collection<?> c) {
- return this.removeItemsFromList(c, this.list, LIST_VALUES);
- }
-
- public boolean retainAll(Collection<?> c) {
- return this.retainItemsInList(c, this.list, LIST_VALUES);
- }
-
- public void clear() {
- this.clearList(this.list, LIST_VALUES);
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if ((o instanceof List) && (o instanceof ListValueModel)) {
- List<E> l1 = CollectionTools.list(this.list);
- @SuppressWarnings("unchecked")
- List<E> l2 = CollectionTools.list(((List<E>) o).iterator());
- return l1.equals(l2);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return this.list.hashCode();
- }
-
- public E set(int index, E element) {
- return this.setItemInList(index, element, this.list, LIST_VALUES);
- }
-
- public void add(int index, E element) {
- this.addItemToList(index, element, this.list, LIST_VALUES);
- }
-
- public E remove(int index) {
- return this.removeItemFromList(index, this.list, LIST_VALUES);
- }
-
- public int indexOf(Object o) {
- return this.list.indexOf(o);
- }
-
- public int lastIndexOf(Object o) {
- return this.list.lastIndexOf(o);
- }
-
- public ListIterator<E> listIterator(int index) {
- return new LocalListIterator<E>(this.list.listIterator(index));
- }
-
- public List<E> subList(int fromIndex, int toIndex) {
- // TODO hmmm ~bjv
- throw new UnsupportedOperationException();
- }
-
-
- // ********** additional behavior **********
-
- /**
- * Allow the list to be replaced.
- */
- public void setList(List<E> list) {
- if (list == null) {
- throw new NullPointerException();
- }
- this.list = list;
- this.fireListChanged(LIST_VALUES);
- }
-
- /**
- * Move a single element.
- */
- public void move(int targetIndex, int sourceIndex) {
- this.moveItemInList(targetIndex, sourceIndex, this.list, LIST_VALUES);
- }
-
- /**
- * Move a sub-list of elements.
- */
- public void move(int targetIndex, int sourceIndex, int length) {
- this.moveItemsInList(targetIndex, sourceIndex, length, this.list, LIST_VALUES);
- }
-
- /**
- * Remove a range of elements.
- */
- public void remove(int index, int length) {
- this.removeItemsFromList(index, length, this.list, LIST_VALUES);
- }
-
- /**
- * Set a range of elements.
- */
- public void set(int index, List<E> elements) {
- this.setItemsInList(index, elements, this.list, LIST_VALUES);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.list);
- }
-
-
- // ********** iterators **********
-
- private class LocalIterator<T> implements Iterator<T> {
- private final Iterator<T> iterator;
- private int index = -1;
- private T next;
-
- LocalIterator(Iterator<T> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public boolean hasNext() {
- return this.iterator.hasNext();
- }
-
- public T next() {
- this.next = this.iterator.next();
- this.index++;
- return this.next;
- }
-
- @SuppressWarnings("synthetic-access")
- public void remove() {
- this.iterator.remove();
- SimpleListValueModel.this.fireItemRemoved(LIST_VALUES, this.index, this.next);
- }
-
- }
-
- private class LocalListIterator<T> implements ListIterator<T> {
- private final ListIterator<T> iterator;
- private int last = -1;
- private int next = 0;
- private T current;
-
- LocalListIterator(ListIterator<T> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public boolean hasNext() {
- return this.iterator.hasNext();
- }
-
- public T next() {
- this.current = this.iterator.next();
- this.last = this.next++;
- return this.current;
- }
-
- public int nextIndex() {
- return this.iterator.nextIndex();
- }
-
- public boolean hasPrevious() {
- return this.iterator.hasPrevious();
- }
-
- public T previous() {
- this.current = this.iterator.previous();
- this.last = --this.next;
- return this.current;
- }
-
- public int previousIndex() {
- return this.iterator.previousIndex();
- }
-
- @SuppressWarnings("synthetic-access")
- public void set(T o) {
- this.iterator.set(o);
- SimpleListValueModel.this.fireItemReplaced(LIST_VALUES, this.last, o, this.current);
- }
-
- @SuppressWarnings("synthetic-access")
- public void add(T o) {
- this.iterator.add(o);
- SimpleListValueModel.this.fireItemAdded(LIST_VALUES, this.next, o);
- }
-
- @SuppressWarnings("synthetic-access")
- public void remove() {
- this.iterator.remove();
- SimpleListValueModel.this.fireItemRemoved(LIST_VALUES, this.last, this.current);
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimplePropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimplePropertyValueModel.java
deleted file mode 100644
index e7248e65c5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimplePropertyValueModel.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * Implementation of WritablePropertyValueModel that simply holds on to an
- * object and uses it as the value.
- */
-public class SimplePropertyValueModel<T>
- extends AbstractModel
- implements WritablePropertyValueModel<T>
-{
- /** The value. */
- protected T value;
-
-
- /**
- * Construct a PropertyValueModel for the specified value.
- */
- public SimplePropertyValueModel(T value) {
- super();
- this.value = value;
- }
-
- /**
- * Construct a PropertyValueModel with a starting value of null.
- */
- public SimplePropertyValueModel() {
- this(null);
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, PropertyChangeListener.class, VALUE);
- }
-
-
- public T getValue() {
- return this.value;
- }
-
- public void setValue(T value) {
- T old = this.value;
- this.value = value;
- this.firePropertyChanged(VALUE, old, value);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.value);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java
deleted file mode 100644
index b912b9a207..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.Range;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * An adapter that allows us to make a <code>CollectionValueModel</code>
- * (or <code>ListValueModel</code>) behave like a <code>ListValueModel</code>
- * that keeps its contents sorted and notifies listeners appropriately.
- * <p>
- * The comparator can be changed at any time; allowing the same
- * adapter to be used with different sort criteria (e.g. when the user
- * wants to sort a list of files first by name, then by date, then by size).
- * <p>
- * NB: Since we only listen to the wrapped collection when we have
- * listeners ourselves and we can only stay in synch with the wrapped
- * collection while we are listening to it, results to various methods
- * (e.g. <code>#size()</code>, <code>#getItem(int)</code>) will be
- * unpredictable whenever
- * we do not have any listeners. This should not be too painful since,
- * most likely, client objects will also be listeners.
- */
-public class SortedListValueModelAdapter<E>
- extends CollectionListValueModelAdapter<E>
-{
- /**
- * A comparator used for sorting the elements;
- * if it is null, we use "natural ordering".
- */
- protected Comparator<E> comparator;
-
-
- // ********** constructors **********
-
- /**
- * Wrap the specified collection value model and sort its contents
- * using the specified comparator.
- */
- public SortedListValueModelAdapter(CollectionValueModel<? extends E> collectionHolder, Comparator<E> comparator) {
- super(collectionHolder);
- this.comparator = comparator;
- }
-
- /**
- * Wrap the specified collection value model and sort its contents
- * based on the elements' "natural ordering".
- */
- public SortedListValueModelAdapter(CollectionValueModel<? extends E> collectionHolder) {
- this(collectionHolder, null);
- }
-
- /**
- * Wrap the specified list value model and sort its contents
- * using the specified comparator.
- */
- public SortedListValueModelAdapter(ListValueModel<? extends E> listHolder, Comparator<E> comparator) {
- this(new ListCollectionValueModelAdapter<E>(listHolder), comparator);
- }
-
- /**
- * Wrap the specified list value model and sort its contents
- * based on the elements' "natural ordering".
- */
- public SortedListValueModelAdapter(ListValueModel<? extends E> listHolder) {
- this(listHolder, null);
- }
-
-
- // ********** accessors **********
-
- public void setComparator(Comparator<E> comparator) {
- this.comparator = comparator;
- this.sortList();
- }
-
-
- // ********** behavior **********
-
- /**
- * Sort the internal list before
- * sending out change notification.
- */
- @Override
- protected void postBuildList() {
- super.postBuildList();
- Collections.sort(this.list, this.comparator);
- }
-
- /**
- * the list will need to be sorted after the item is added
- */
- @Override
- protected void itemsAdded(CollectionChangeEvent event) {
- // first add the items and notify our listeners...
- super.itemsAdded(event);
- // ...then sort the list
- this.sortList();
- }
-
- /**
- * sort the list and notify our listeners, if necessary;
- */
- protected void sortList() {
- // save the unsorted state of the sorted list so we can minimize the number of "replaced" items
- @SuppressWarnings("unchecked")
- ArrayList<E> unsortedList = (ArrayList<E>) this.list.clone();
- Collections.sort(this.list, this.comparator);
- Range diffRange = CollectionTools.identityDiffRange(unsortedList, this.list);
- if (diffRange.size > 0) {
- List<E> unsortedItems = unsortedList.subList(diffRange.start, diffRange.end + 1);
- List<E> sortedItems = this.list.subList(diffRange.start, diffRange.end + 1);
- this.fireItemsReplaced(LIST_VALUES, diffRange.start, sortedItems, unsortedItems);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StatePropertyValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StatePropertyValueModelAdapter.java
deleted file mode 100644
index db6c0c916f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StatePropertyValueModelAdapter.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * a model, "lazily" listen to it, and convert
- * its state change notifications into property value model change
- * notifications.
- *
- * Subclasses must override:
- * - #buildValue()
- * to return the current property value, as derived from the
- * current model
- *
- * Subclasses might want to override:
- * - #stateChanged(StateChangeEvent event)
- * to improve performance (by not recalculating the value, if possible)
- */
-public abstract class StatePropertyValueModelAdapter<T>
- extends AspectPropertyValueModelAdapter<T>
-{
- /** The wrapped model. */
- protected final Model model;
-
- /** A listener that allows us to synch with changes to the wrapped model. */
- protected final StateChangeListener stateChangeListener;
-
-
- // ********** constructor/initialization **********
-
- /**
- * Construct a property value model with the specified wrapped model.
- */
- protected StatePropertyValueModelAdapter(Model model) {
- super();
- this.model = model;
- this.stateChangeListener = this.buildStateChangeListener();
- }
-
- protected StateChangeListener buildStateChangeListener() {
- return new StateChangeListener() {
- public void stateChanged(StateChangeEvent event) {
- StatePropertyValueModelAdapter.this.stateChanged(event);
- }
- @Override
- public String toString() {
- return "state change listener";
- }
- };
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the model.
- */
- @Override
- protected void engageModel_() {
- this.model.addStateChangeListener(this.stateChangeListener);
- }
-
- /**
- * Stop listening to the model.
- */
- @Override
- protected void disengageModel_() {
- this.model.removeStateChangeListener(this.stateChangeListener);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.model);
- }
-
-
- // ********** state change support **********
-
- /**
- * The model's state changed;
- * propagate the change notification appropriately.
- */
- protected void stateChanged(StateChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticCollectionValueModel.java
deleted file mode 100644
index 1dba4c3b74..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticCollectionValueModel.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-
-/**
- * Implementation of CollectionValueModel that can be used for
- * returning an iterator on a static collection, but still allows listeners to be added.
- * Listeners will NEVER be notified of any changes, because there should be none.
- */
-public class StaticCollectionValueModel<E>
- extends AbstractModel
- implements CollectionValueModel<E>
-{
- /** The collection. */
- protected final Collection<? extends E> collection;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a static CollectionValueModel for the specified collection.
- */
- public StaticCollectionValueModel(Collection<? extends E> collection) {
- super();
- if (collection == null) {
- throw new NullPointerException();
- }
- this.collection = collection;
- }
-
- // ********** CollectionValueModel implementation **********
-
- public int size() {
- return this.collection.size();
- }
-
- public Iterator<E> iterator() {
- return new ReadOnlyIterator<E>(this.collection.iterator());
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.collection);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticListValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticListValueModel.java
deleted file mode 100644
index 584d4acd32..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticListValueModel.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Implementation of ListValueModel that can be used for
- * returning a list iterator on a static list, but still allows listeners to be added.
- * Listeners will NEVER be notified of any changes, because there should be none.
- */
-public class StaticListValueModel<E>
- extends AbstractModel
- implements ListValueModel<E>
-{
- /** The value. */
- protected final List<? extends E> list;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a static ListValueModel for the specified list.
- */
- public StaticListValueModel(List<? extends E> list) {
- super();
- if (list == null) {
- throw new NullPointerException();
- }
- this.list = list;
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return new ReadOnlyIterator<E>(this.list.iterator());
- }
-
- public ListIterator<E> listIterator() {
- return new ReadOnlyListIterator<E>(this.list.listIterator());
- }
-
- public int size() {
- return this.list.size();
- }
-
- public E get(int index) {
- return this.list.get(index);
- }
-
- public Object[] toArray() {
- return this.list.toArray();
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.list);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticPropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticPropertyValueModel.java
deleted file mode 100644
index e5eccf3ae2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticPropertyValueModel.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * Implementation of PropertyValueModel that can be used for
- * returning a static value, but still allows listeners to be added.
- * Listeners will NEVER be notified of any changes, because there should be none.
- */
-public class StaticPropertyValueModel<T>
- extends AbstractModel
- implements PropertyValueModel<T>
-{
- /** The value. */
- protected final T value;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a static PropertyValueModel for the specified value.
- */
- public StaticPropertyValueModel(T value) {
- super();
- this.value = value;
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- public T getValue() {
- return this.value;
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.value);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticTreeValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticTreeValueModel.java
deleted file mode 100644
index 9929535e20..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticTreeValueModel.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.value.TreeValueModel;
-
-/**
- * Implementation of TreeValueModel that can be used for
- * returning an iterator on a static tree, but still allows listeners to be added.
- * Listeners will NEVER be notified of any changes, because there should be none.
- */
-public class StaticTreeValueModel<E>
- extends AbstractModel
- implements TreeValueModel<E>
-{
- /** The tree's nodes. */
- protected final Iterable<? extends E> nodes;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a read-only TreeValueModel for the specified nodes.
- */
- public StaticTreeValueModel(Iterable<? extends E> nodes) {
- super();
- if (nodes == null) {
- throw new NullPointerException();
- }
- this.nodes = nodes;
- }
-
- // ********** TreeValueModel implementation **********
-
- public Iterator<E> nodes() {
- return new ReadOnlyIterator<E>(this.nodes.iterator());
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, CollectionTools.collection(this.nodes()));
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java
deleted file mode 100644
index ad4a2a3418..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.Transformer;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * An adapter that allows us to transform a ListValueModel
- * (or CollectionValueModel) into a read-only ListValueModel
- * whose items are tranformations of the items in the wrapped
- * ListValueModel. It will keep its contents in synch with
- * the contents of the wrapped ListValueModel and notifies its
- * listeners of any changes.
- * <p>
- * The transformer can be changed at any time; allowing the same
- * adapter to be used with different transformations.
- * <p>
- * NB: Since we only listen to the wrapped list when we have
- * listeners ourselves and we can only stay in synch with the wrapped
- * list while we are listening to it, results to various methods
- * (e.g. #size(), #getItem(int)) will be unpredictable whenever
- * we do not have any listeners. This should not be too painful since,
- * most likely, client objects will also be listeners.
- */
-public class TransformationListValueModelAdapter<E1, E2>
- extends ListValueModelWrapper<E1>
- implements ListValueModel<E2>
-{
-
- /** This transforms the items, unless the subclass overrides #transformItem(Object). */
- protected Transformer<E1, E2> transformer;
-
- /** The list of transformed items. */
- protected final List<E2> transformedList;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the list holder is required.
- */
- public TransformationListValueModelAdapter(ListValueModel<? extends E1> listHolder, Transformer<E1, E2> transformer) {
- super(listHolder);
- this.transformer = transformer;
- this.transformedList = new ArrayList<E2>();
- }
-
- /**
- * Constructor - the list holder is required.
- */
- public TransformationListValueModelAdapter(ListValueModel<? extends E1> listHolder) {
- this(listHolder, Transformer.Null.<E1, E2>instance());
- }
-
- /**
- * Constructor - the collection holder is required.
- */
- public TransformationListValueModelAdapter(CollectionValueModel<? extends E1> collectionHolder, Transformer<E1, E2> transformer) {
- this(new CollectionListValueModelAdapter<E1>(collectionHolder), transformer);
- }
-
- /**
- * Constructor - the collection holder is required.
- */
- public TransformationListValueModelAdapter(CollectionValueModel<? extends E1> collectionHolder) {
- this(new CollectionListValueModelAdapter<E1>(collectionHolder));
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E2> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E2> listIterator() {
- return new ReadOnlyListIterator<E2>(this.transformedList);
- }
-
- public E2 get(int index) {
- return this.transformedList.get(index);
- }
-
- public int size() {
- return this.transformedList.size();
- }
-
- public Object[] toArray() {
- return this.transformedList.toArray();
- }
-
- // ********** behavior **********
-
- @Override
- protected void engageModel() {
- super.engageModel();
- // synch the transformed list *after* we start listening to the list holder,
- // since its value might change when a listener is added
- this.transformedList.addAll(this.transformItems(this.listHolder));
- }
-
- @Override
- protected void disengageModel() {
- super.disengageModel();
- // clear out the list when we are not listening to the collection holder
- this.transformedList.clear();
- }
-
- /**
- * Transform the items associated with the specified event.
- */
- protected List<E2> transformItems(ListChangeEvent event) {
- return this.transformItems(this.items(event), event.itemsSize());
- }
-
- /**
- * Transform the items in the specified list value model.
- */
- protected List<E2> transformItems(ListValueModel<? extends E1> lvm) {
- return this.transformItems(lvm.listIterator(), lvm.size());
- }
-
- /**
- * Transform the replaced items associated with the specified event.
- */
- protected List<E2> transformReplacedItems(ListChangeEvent event) {
- return this.transformItems(this.replacedItems(event), event.itemsSize());
- }
-
- /**
- * Transform the specified items.
- */
- protected List<E2> transformItems(ListIterator<? extends E1> items, int size) {
- List<E2> result = new ArrayList<E2>(size);
- while (items.hasNext()) {
- result.add(this.transformItem(items.next()));
- }
- return result;
- }
-
- /**
- * Transform the specified item.
- */
- protected E2 transformItem(E1 item) {
- return this.transformer.transform(item);
- }
-
- /**
- * Change the transformer and rebuild the collection.
- */
- public void setTransformer(Transformer<E1, E2> transformer) {
- this.transformer = transformer;
- this.rebuildTransformedList();
- }
-
- /**
- * Synchronize our cache with the wrapped collection.
- */
- protected void rebuildTransformedList() {
- this.transformedList.clear();
- this.transformedList.addAll(this.transformItems(this.listHolder));
- this.fireListChanged(LIST_VALUES);
- }
-
-
- // ********** list change support **********
-
- /**
- * Items were added to the wrapped list holder.
- * Transform them, add them to our transformation list,
- * and notify our listeners.
- */
- @Override
- protected void itemsAdded(ListChangeEvent event) {
- this.addItemsToList(event.getIndex(), this.transformItems(event), this.transformedList, LIST_VALUES);
- }
-
- /**
- * Items were removed from the wrapped list holder.
- * Remove the corresponding items from our transformation list
- * and notify our listeners.
- */
- @Override
- protected void itemsRemoved(ListChangeEvent event) {
- this.removeItemsFromList(event.getIndex(), event.itemsSize(), this.transformedList, LIST_VALUES);
- }
-
- /**
- * Items were replaced in the wrapped list holder.
- * Replace the corresponding items in our transformation list
- * and notify our listeners.
- */
- @Override
- protected void itemsReplaced(ListChangeEvent event) {
- this.setItemsInList(event.getIndex(), this.transformItems(event), this.transformedList, LIST_VALUES);
- }
-
- /**
- * Items were moved in the wrapped list holder.
- * Move the corresponding items in our transformation list
- * and notify our listeners.
- */
- @Override
- protected void itemsMoved(ListChangeEvent event) {
- this.moveItemsInList(event.getTargetIndex(), event.getSourceIndex(), event.getMoveLength(), this.transformedList, LIST_VALUES);
- }
-
- /**
- * The wrapped list holder was cleared.
- * Clear our transformation list and notify our listeners.
- */
- @Override
- protected void listCleared(ListChangeEvent event) {
- this.clearList(this.transformedList, LIST_VALUES);
- }
-
- /**
- * The wrapped list holder has changed in some dramatic fashion.
- * Rebuild our transformation list and notify our listeners.
- */
- @Override
- protected void listChanged(ListChangeEvent event) {
- this.rebuildTransformedList();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationPropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationPropertyValueModel.java
deleted file mode 100644
index 5d3b93e821..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationPropertyValueModel.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.Transformer;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * A <code>TransformationPropertyValueModel</code> wraps another
- * <code>PropertyValueModel</code> and uses a <code>Transformer</code>
- * to transform the wrapped value before it is returned by <code>value()</code>.
- * <p>
- * As an alternative to building a <code>Transformer</code>,
- * a subclass of <code>TransformationPropertyValueModel</code> can
- * either override the <code>transform_(Object)</code> method or,
- * if something other than null should be returned when the wrapped value
- * is null, override the <code>transform(Object)</code> method.
- */
-public class TransformationPropertyValueModel<T1, T2>
- extends PropertyValueModelWrapper<T1>
- implements PropertyValueModel<T2>
-{
- protected final Transformer<T1, T2> transformer;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Construct a property value model with the specified nested
- * property value model and the default transformer.
- * Use this constructor if you want to override the
- * <code>transform_(Object)</code> or <code>transform(Object)</code>
- * method instead of building a <code>Transformer</code>.
- */
- public TransformationPropertyValueModel(PropertyValueModel<? extends T1> valueHolder) {
- super(valueHolder);
- this.transformer = this.buildTransformer();
- }
-
- /**
- * Construct an property value model with the specified nested
- * property value model and transformer.
- */
- public TransformationPropertyValueModel(PropertyValueModel<? extends T1> valueHolder, Transformer<T1, T2> transformer) {
- super(valueHolder);
- this.transformer = transformer;
- }
-
- protected Transformer<T1, T2> buildTransformer() {
- return new DefaultTransformer();
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- public T2 getValue() {
- // transform the object returned by the nested value model before returning it
- return this.transform(this.valueHolder.getValue());
- }
-
-
- // ********** PropertyValueModelWrapper implementation **********
-
- @Override
- protected void valueChanged(PropertyChangeEvent event) {
- // transform the values before propagating the change event
- @SuppressWarnings("unchecked")
- Object oldValue = this.transform((T1) event.getOldValue());
- @SuppressWarnings("unchecked")
- Object newValue = this.transform((T1) event.getNewValue());
- this.firePropertyChanged(VALUE, oldValue, newValue);
- }
-
-
- // ********** behavior **********
-
- /**
- * Transform the specified value and return the result.
- * This is called by #value() and #valueChanged(PropertyChangeEvent).
- */
- protected T2 transform(T1 value) {
- return this.transformer.transform(value);
- }
-
- /**
- * Transform the specified, non-null, value and return the result.
- */
- protected T2 transform_(T1 value) {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** default transformer **********
-
- /**
- * The default transformer will return null if the wrapped value is null.
- * If the wrapped value is not null, it is transformed by a subclass
- * implementation of #transform_(Object).
- */
- protected class DefaultTransformer implements Transformer<T1, T2> {
- public T2 transform(T1 value) {
- return (value == null) ? null : TransformationPropertyValueModel.this.transform_(value);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationWritablePropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationWritablePropertyValueModel.java
deleted file mode 100644
index aa5cc63c5b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationWritablePropertyValueModel.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.BidiTransformer;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * A <code>TransformationWritablePropertyValueModel</code> wraps another
- * <code>WritablePropertyValueModel</code> and uses a <code>BidiTransformer</code>
- * to:<ul>
- * <li>transform the wrapped value before it is returned by <code>value()</code>
- * <li>"reverse-transform" the new value that comes in via
- * <code>setValue(Object)</code>
- * </ul>
- * As an alternative to building a <code>BidiTransformer</code>,
- * a subclass of <code>TransformationWritablePropertyValueModel</code> can
- * override the <code>transform_(Object)</code> and
- * <code>reverseTransform_(Object)</code> methods; or,
- * if something other than null should be returned when the wrapped value
- * is null or the new value is null, override the <code>transform(Object)</code>
- * and <code>reverseTransform(Object)</code> methods.
- */
-public class TransformationWritablePropertyValueModel<T1, T2>
- extends TransformationPropertyValueModel<T1, T2>
- implements WritablePropertyValueModel<T2>
-{
-
- // ********** constructors/initialization **********
-
- /**
- * Construct a writable property value model with the specified nested
- * writable property value model and the default bidi transformer.
- * Use this constructor if you want to override the
- * <code>transform_(Object)</code> and <code>reverseTransform_(Object)</code>
- * (or <code>transform(Object)</code> and <code>reverseTransform(Object)</code>)
- * methods instead of building a <code>BidiTransformer</code>.
- */
- public TransformationWritablePropertyValueModel(WritablePropertyValueModel<T1> valueHolder) {
- super(valueHolder);
- }
-
- /**
- * Construct a writable property value model with the specified nested
- * writable property value model and bidi transformer.
- */
- public TransformationWritablePropertyValueModel(WritablePropertyValueModel<T1> valueHolder, BidiTransformer<T1, T2> transformer) {
- super(valueHolder, transformer);
- }
-
- @Override
- protected BidiTransformer<T1, T2> buildTransformer() {
- return new DefaultBidiTransformer();
- }
-
-
- // ********** WritablePropertyValueModel implementation **********
-
- public void setValue(T2 value) {
- // "reverse-transform" the object before passing it to the the nested value model
- this.valueHolder().setValue(this.reverseTransform(value));
- }
-
-
- // ********** behavior **********
-
- /**
- * "Reverse-transform" the specified value and return the result.
- * This is called by #setValue(Object).
- */
- protected T1 reverseTransform(T2 value) {
- return this.transformer().reverseTransform(value);
- }
-
- /**
- * "Reverse-transform" the specified, non-null, value and return the result.
- */
- protected T1 reverseTransform_(T2 value) {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** queries **********
-
- /**
- * Our constructors accept only a WritablePropertyValueModel<T1>.
- */
- @SuppressWarnings("unchecked")
- protected WritablePropertyValueModel<T1> valueHolder() {
- return (WritablePropertyValueModel<T1>) this.valueHolder;
- }
-
- /**
- * Our constructors accept only a bidirectional transformer.
- */
- protected BidiTransformer<T1, T2> transformer() {
- return (BidiTransformer<T1, T2>) this.transformer;
- }
-
-
- // ********** default bidi transformer **********
-
- /**
- * The default bidi transformer will return null if the wrapped value is null.
- * If the wrapped value is not null, it is transformed by a subclass
- * implementation of #transform_(Object).
- * The default bidi transformer will also return null if the new value is null.
- * If the new value is not null, it is reverse-transformed by a subclass
- * implementation of #reverseTransform_(Object).
- */
- protected class DefaultBidiTransformer
- extends DefaultTransformer
- implements BidiTransformer<T1, T2>
- {
- public T1 reverseTransform(T2 value) {
- return (value == null) ? null : TransformationWritablePropertyValueModel.this.reverseTransform_(value);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreeAspectAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreeAspectAdapter.java
deleted file mode 100644
index ad131da203..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreeAspectAdapter.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.TreeValueModel;
-
-/**
- * This extension of PropertyAdapter provides TreeChange support.
- * This allows us to convert a set of one or more trees into
- * a single tree, NODES.
- *
- * The typical subclass will override the following methods:
- * #nodes_()
- * at the very minimum, override this method to return an iterator
- * on the subject's tree aspect; it does not need to be overridden if
- * #nodes() is overridden and its behavior changed
- * #nodes()
- * override this method only if returning an empty iterator when the
- * subject is null is unacceptable
- */
-public abstract class TreeAspectAdapter<S extends Model, E>
- extends AspectAdapter<S>
- implements TreeValueModel<E>
-{
- /**
- * The name of the subject's trees that we use for the value.
- */
- protected final String[] treeNames;
- protected static final String[] EMPTY_TREE_NAMES = new String[0];
-
- /** A listener that listens to the subject's tree aspect. */
- protected final TreeChangeListener treeChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a TreeAspectAdapter for the specified subject
- * and tree.
- */
- protected TreeAspectAdapter(String treeName, S subject) {
- this(new String[] {treeName}, subject);
- }
-
- /**
- * Construct a TreeAspectAdapter for the specified subject
- * and trees.
- */
- protected TreeAspectAdapter(String[] treeNames, S subject) {
- this(new StaticPropertyValueModel<S>(subject), treeNames);
- }
-
- /**
- * Construct a TreeAspectAdapter for the specified subject holder
- * and trees.
- */
- protected TreeAspectAdapter(PropertyValueModel<? extends S> subjectHolder, String... treeNames) {
- super(subjectHolder);
- this.treeNames = treeNames;
- this.treeChangeListener = this.buildTreeChangeListener();
- }
-
- /**
- * Construct a TreeAspectAdapter for the specified subject holder
- * and trees.
- */
- protected TreeAspectAdapter(PropertyValueModel<? extends S> subjectHolder, Collection<String> treeNames) {
- this(subjectHolder, treeNames.toArray(new String[treeNames.size()]));
- }
-
- /**
- * Construct a TreeAspectAdapter for an "unchanging" tree in
- * the specified subject. This is useful for a tree aspect that does not
- * change for a particular subject; but the subject will change, resulting in
- * a new tree.
- */
- protected TreeAspectAdapter(PropertyValueModel<? extends S> subjectHolder) {
- this(subjectHolder, EMPTY_TREE_NAMES);
- }
-
-
- // ********** initialization **********
-
- /**
- * The subject's tree aspect has changed, notify the listeners.
- */
- protected TreeChangeListener buildTreeChangeListener() {
- // transform the subject's tree change events into VALUE tree change events
- return new TreeChangeListener() {
- public void nodeAdded(TreeChangeEvent event) {
- TreeAspectAdapter.this.nodeAdded(event);
- }
- public void nodeRemoved(TreeChangeEvent event) {
- TreeAspectAdapter.this.nodeRemoved(event);
- }
- public void treeCleared(TreeChangeEvent event) {
- TreeAspectAdapter.this.treeCleared(event);
- }
- public void treeChanged(TreeChangeEvent event) {
- TreeAspectAdapter.this.treeChanged(event);
- }
- @Override
- public String toString() {
- return "tree change listener: " + Arrays.asList(TreeAspectAdapter.this.treeNames);
- }
- };
- }
-
-
- // ********** TreeValueModel implementation **********
-
- /**
- * Return the nodes of the subject's tree aspect.
- */
- public Iterator<E> nodes() {
- return (this.subject == null) ? EmptyIterator.<E>instance() : this.nodes_();
- }
-
- /**
- * Return the nodes of the subject's tree aspect.
- * At this point we can be sure that the subject is not null.
- * @see #nodes()
- */
- protected Iterator<E> nodes_() {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected Object getValue() {
- return this.nodes();
- }
-
- @Override
- protected Class<? extends ChangeListener> getListenerClass() {
- return TreeChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return NODES;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyTreeChangeListeners(NODES);
- }
-
- @Override
- protected void fireAspectChange(Object oldValue, Object newValue) {
- this.fireTreeChanged(NODES);
- }
-
- @Override
- protected void engageSubject_() {
- for (String treeName : this.treeNames) {
- ((Model) this.subject).addTreeChangeListener(treeName, this.treeChangeListener);
- }
- }
-
- @Override
- protected void disengageSubject_() {
- for (String treeName : this.treeNames) {
- ((Model) this.subject).removeTreeChangeListener(treeName, this.treeChangeListener);
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- for (int i = 0; i < this.treeNames.length; i++) {
- if (i != 0) {
- sb.append(", ");
- }
- sb.append(this.treeNames[i]);
- }
- }
-
-
- // ********** behavior **********
-
- protected void nodeAdded(TreeChangeEvent event) {
- this.fireNodeAdded(NODES, event.getPath());
- }
-
- protected void nodeRemoved(TreeChangeEvent event) {
- this.fireNodeRemoved(NODES, event.getPath());
- }
-
- protected void treeCleared(TreeChangeEvent event) {
- this.fireTreeCleared(NODES);
- }
-
- protected void treeChanged(TreeChangeEvent event) {
- this.fireTreeChanged(NODES, event.getPath());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreePropertyValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreePropertyValueModelAdapter.java
deleted file mode 100644
index 11b6f1a2b9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreePropertyValueModelAdapter.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
-import org.eclipse.jpt.utility.model.value.TreeValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * a tree value model, "lazily" listen to it, and convert
- * its change notifications into property value model change
- * notifications.
- *
- * Subclasses must override:
- * - #buildValue()
- * to return the current property value, as derived from the
- * current collection value
- *
- * Subclasses might want to override:
- * - #stateChanged(StateChangeEvent event)
- * to improve performance (by not recalculating the value, if possible)
- */
-public abstract class TreePropertyValueModelAdapter<T>
- extends AspectPropertyValueModelAdapter<T>
-{
- /** The wrapped tree value model. */
- protected final TreeValueModel<?> treeHolder;
-
- /** A listener that allows us to synch with changes to the wrapped tree holder. */
- protected final TreeChangeListener treeChangeListener;
-
-
- // ********** constructor/initialization **********
-
- /**
- * Construct a property value model with the specified wrapped
- * tree value model.
- */
- protected TreePropertyValueModelAdapter(TreeValueModel<?> treeHolder) {
- super();
- this.treeHolder = treeHolder;
- this.treeChangeListener = this.buildTreeChangeListener();
- }
-
- protected TreeChangeListener buildTreeChangeListener() {
- return new TreeChangeListener() {
- public void nodeAdded(TreeChangeEvent event) {
- TreePropertyValueModelAdapter.this.nodeAdded(event);
- }
- public void nodeRemoved(TreeChangeEvent event) {
- TreePropertyValueModelAdapter.this.nodeRemoved(event);
- }
- public void treeCleared(TreeChangeEvent event) {
- TreePropertyValueModelAdapter.this.treeCleared(event);
- }
- public void treeChanged(TreeChangeEvent event) {
- TreePropertyValueModelAdapter.this.treeChanged(event);
- }
- @Override
- public String toString() {
- return "tree change listener";
- }
- };
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the tree holder.
- */
- @Override
- protected void engageModel_() {
- this.treeHolder.addTreeChangeListener(this.treeChangeListener);
- }
-
- /**
- * Stop listening to the tree holder.
- */
- @Override
- protected void disengageModel_() {
- this.treeHolder.removeTreeChangeListener(this.treeChangeListener);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.treeHolder);
- }
-
-
- // ********** state change support **********
-
- /**
- * Nodes were added to the wrapped tree holder;
- * propagate the change notification appropriately.
- */
- protected void nodeAdded(TreeChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * Nodes were removed from the wrapped tree holder;
- * propagate the change notification appropriately.
- */
- protected void nodeRemoved(TreeChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * The wrapped tree holder was cleared;
- * propagate the change notification appropriately.
- */
- protected void treeCleared(TreeChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * The wrapped tree holder changed;
- * propagate the change notification appropriately.
- */
- protected void treeChanged(TreeChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueAspectAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueAspectAdapter.java
deleted file mode 100644
index d47c50f4a2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueAspectAdapter.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * Abstract model that provides behavior for wrapping a property
- * value model and listening for changes to aspects of the *value* contained
- * by the property value model. Changes to the actual value are also monitored.
- *
- * This is useful if you have a value that may change, but whose aspects can also
- * change in a fashion that might be of interest to the client.
- *
- * NB: Clients will need to listen for two different change notifications: a property
- * change event will be be fired when the value changes; a state change event
- * will be fired when an aspect of the value changes.
- *
- * Subclasses need to override two methods:
- *
- * #engageValue_()
- * begin listening to the appropriate aspect of the value and call
- * #valueAspectChanged(Object) whenever the aspect changes
- *
- * #disengageValue_()
- * stop listening to the appropriate aspect of the value
- */
-public abstract class ValueAspectAdapter<T>
- extends PropertyValueModelWrapper<T>
- implements WritablePropertyValueModel<T>
-{
- /** Cache the value so we can disengage. */
- protected T value;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Constructor - the value holder is required.
- */
- protected ValueAspectAdapter(WritablePropertyValueModel<T> valueHolder) {
- super(valueHolder);
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- this.value = null;
- }
-
- /**
- * Override to allow both property value model change and state change
- * listeners.
- */
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new ChangeSupport(this);
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- public T getValue() {
- return this.value;
- }
-
-
- // ********** WritablePropertyValueModel implementation **********
-
- public void setValue(T value) {
- this.valueHolder().setValue(value);
- }
-
-
- // ********** PropertyValueModelWrapper implementation **********
-
- @Override
- protected void valueChanged(PropertyChangeEvent event) {
- this.disengageValue();
- this.engageValue();
- this.firePropertyChanged(event.cloneWithSource(this));
- }
-
-
- // ********** extend change support **********
-
- @Override
- public synchronized void addStateChangeListener(StateChangeListener listener) {
- if (this.hasNoStateChangeListeners()) {
- this.engageValue();
- }
- super.addStateChangeListener(listener);
- }
-
- @Override
- public synchronized void removeStateChangeListener(StateChangeListener listener) {
- super.removeStateChangeListener(listener);
- if (this.hasNoStateChangeListeners()) {
- this.disengageValue();
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the current value.
- */
- protected void engageValue() {
- this.value = this.valueHolder.getValue();
- if (this.value != null) {
- this.engageValue_();
- }
- }
-
- /**
- * Start listening to the current value.
- * At this point we can be sure that the value is not null.
- */
- protected abstract void engageValue_();
-
- /**
- * Stop listening to the current value.
- */
- protected void disengageValue() {
- if (this.value != null) {
- this.disengageValue_();
- this.value = null;
- }
- }
-
- /**
- * Stop listening to the current value.
- * At this point we can be sure that the value is not null.
- */
- protected abstract void disengageValue_();
-
- /**
- * Subclasses should call this method whenever the value's aspect changes.
- */
- protected void valueAspectChanged() {
- this.fireStateChanged();
- }
-
- /**
- * Our constructors accept only a WritablePropertyValueModel<T1>.
- */
- @SuppressWarnings("unchecked")
- protected WritablePropertyValueModel<T> valueHolder() {
- return (WritablePropertyValueModel<T>) this.valueHolder;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueCollectionAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueCollectionAdapter.java
deleted file mode 100644
index 2cdb74ea34..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueCollectionAdapter.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * Extend ValueAspectAdapter to listen to one or more collection
- * aspects of the value in the wrapped value model.
- */
-public class ValueCollectionAdapter<T extends Model>
- extends ValueAspectAdapter<T>
-{
-
- /** The names of the value's collections that we listen to. */
- protected final String[] collectionNames;
-
- /** Listener that listens to the value. */
- protected final CollectionChangeListener valueCollectionListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified value collections.
- */
- public ValueCollectionAdapter(WritablePropertyValueModel<T> valueHolder, String... collectionNames) {
- super(valueHolder);
- this.collectionNames = collectionNames;
- this.valueCollectionListener = this.buildValueCollectionListener();
- }
-
-
- // ********** initialization **********
-
- /**
- * All we really care about is the fact that a Collection aspect has
- * changed. Do the same thing no matter which event occurs.
- */
- protected CollectionChangeListener buildValueCollectionListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent event) {
- ValueCollectionAdapter.this.valueAspectChanged();
- }
- public void itemsRemoved(CollectionChangeEvent event) {
- ValueCollectionAdapter.this.valueAspectChanged();
- }
- public void collectionCleared(CollectionChangeEvent event) {
- ValueCollectionAdapter.this.valueAspectChanged();
- }
- public void collectionChanged(CollectionChangeEvent event) {
- ValueCollectionAdapter.this.valueAspectChanged();
- }
- @Override
- public String toString() {
- return "value collection listener: " + Arrays.asList(ValueCollectionAdapter.this.collectionNames);
- }
- };
- }
-
- @Override
- protected void engageValue_() {
- for (String collectionName : this.collectionNames) {
- this.value.addCollectionChangeListener(collectionName, this.valueCollectionListener);
- }
- }
-
- @Override
- protected void disengageValue_() {
- for (String collectionName : this.collectionNames) {
- this.value.removeCollectionChangeListener(collectionName, this.valueCollectionListener);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueListAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueListAdapter.java
deleted file mode 100644
index 224d100319..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueListAdapter.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * Extend ValueAspectAdapter to listen to one or more list
- * aspects of the value in the wrapped value model.
- */
-public class ValueListAdapter<T extends Model>
- extends ValueAspectAdapter<T>
-{
-
- /** The names of the value's lists that we listen to. */
- protected final String[] listNames;
-
- /** Listener that listens to the value. */
- protected final ListChangeListener valueListListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified value lists.
- */
- public ValueListAdapter(WritablePropertyValueModel<T> valueHolder, String... listNames) {
- super(valueHolder);
- this.listNames = listNames;
- this.valueListListener = this.buildValueListListener();
- }
-
-
- // ********** initialization **********
-
- /**
- * All we really care about is the fact that a List aspect has
- * changed. Do the same thing no matter which event occurs.
- */
- protected ListChangeListener buildValueListListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent event) {
- ValueListAdapter.this.valueAspectChanged();
- }
- public void itemsRemoved(ListChangeEvent event) {
- ValueListAdapter.this.valueAspectChanged();
- }
- public void itemsReplaced(ListChangeEvent event) {
- ValueListAdapter.this.valueAspectChanged();
- }
- public void itemsMoved(ListChangeEvent event) {
- ValueListAdapter.this.valueAspectChanged();
- }
- public void listCleared(ListChangeEvent event) {
- ValueListAdapter.this.valueAspectChanged();
- }
- public void listChanged(ListChangeEvent event) {
- ValueListAdapter.this.valueAspectChanged();
- }
- @Override
- public String toString() {
- return "value list listener: " + Arrays.asList(ValueListAdapter.this.listNames);
- }
- };
- }
-
- @Override
- protected void engageValue_() {
- for (String listName : this.listNames) {
- this.value.addListChangeListener(listName, this.valueListListener);
- }
- }
-
- @Override
- protected void disengageValue_() {
- for (String listName : this.listNames) {
- this.value.removeListChangeListener(listName, this.valueListListener);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValuePropertyAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValuePropertyAdapter.java
deleted file mode 100644
index 0c40e891cc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValuePropertyAdapter.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * Extend ValueAspectAdapter to listen to one or more
- * properties of the value in the wrapped value model.
- */
-public class ValuePropertyAdapter<T extends Model>
- extends ValueAspectAdapter<T>
-{
- /** The names of the value's properties that we listen to. */
- protected final String[] propertyNames;
-
- /** Listener that listens to the value. */
- protected final PropertyChangeListener valuePropertyListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified value properties.
- */
- public ValuePropertyAdapter(WritablePropertyValueModel<T> valueHolder, String... propertyNames) {
- super(valueHolder);
- this.propertyNames = propertyNames;
- this.valuePropertyListener = this.buildValuePropertyListener();
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildValuePropertyListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- ValuePropertyAdapter.this.valueAspectChanged();
- }
- @Override
- public String toString() {
- return "value property listener: " + Arrays.asList(ValuePropertyAdapter.this.propertyNames);
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void engageValue_() {
- for (String propertyName : this.propertyNames) {
- this.value.addPropertyChangeListener(propertyName, this.valuePropertyListener);
- }
- }
-
- @Override
- protected void disengageValue_() {
- for (String propertyName : this.propertyNames) {
- this.value.removePropertyChangeListener(propertyName, this.valuePropertyListener);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueStateAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueStateAdapter.java
deleted file mode 100644
index d516fdbf1b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueStateAdapter.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * Extend ValueAspectAdapter to listen to the
- * "state" of the value in the wrapped value model.
- */
-public class ValueStateAdapter<T extends Model>
- extends ValueAspectAdapter<T>
-{
- /** Listener that listens to value. */
- protected final StateChangeListener valueStateListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the value state.
- */
- public ValueStateAdapter(WritablePropertyValueModel<T> valueHolder) {
- super(valueHolder);
- this.valueStateListener = this.buildValueStateListener();
- }
-
-
- // ********** initialization **********
-
- protected StateChangeListener buildValueStateListener() {
- return new StateChangeListener() {
- public void stateChanged(StateChangeEvent event) {
- ValueStateAdapter.this.valueAspectChanged();
- }
- @Override
- public String toString() {
- return "value state listener";
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void engageValue_() {
- this.value.addStateChangeListener(this.valueStateListener);
- }
-
- @Override
- protected void disengageValue_() {
- this.value.removeStateChangeListener(this.valueStateListener);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueTreeAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueTreeAdapter.java
deleted file mode 100644
index b1c9c53f54..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueTreeAdapter.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * Extend ValueAspectAdapter to listen to one or more
- * tree aspects of the value in the wrapped value model.
- */
-public class ValueTreeAdapter<T extends Model>
- extends ValueAspectAdapter<T>
-{
- /** The names of the value's trees that we listen to. */
- protected final String[] treeNames;
-
- /** Listener that listens to the value. */
- protected final TreeChangeListener valueTreeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified value trees.
- */
- public ValueTreeAdapter(WritablePropertyValueModel<T> valueHolder, String... treeNames) {
- super(valueHolder);
- this.treeNames = treeNames;
- this.valueTreeListener = this.buildValueTreeListener();
- }
-
-
- // ********** initialization **********
-
- protected TreeChangeListener buildValueTreeListener() {
- return new TreeChangeListener() {
- public void nodeAdded(TreeChangeEvent event) {
- ValueTreeAdapter.this.valueAspectChanged();
- }
- public void nodeRemoved(TreeChangeEvent event) {
- ValueTreeAdapter.this.valueAspectChanged();
- }
- public void treeCleared(TreeChangeEvent event) {
- ValueTreeAdapter.this.valueAspectChanged();
- }
- public void treeChanged(TreeChangeEvent event) {
- ValueTreeAdapter.this.valueAspectChanged();
- }
- @Override
- public String toString() {
- return "value tree listener: " + Arrays.asList(ValueTreeAdapter.this.treeNames);
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void engageValue_() {
- for (String treeName : this.treeNames) {
- this.value.addTreeChangeListener(treeName, this.valueTreeListener);
- }
- }
-
- @Override
- protected void disengageValue_() {
- for (String treeName : this.treeNames) {
- this.value.removeTreeChangeListener(treeName, this.valueTreeListener);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencePropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencePropertyValueModel.java
deleted file mode 100644
index c6cca7232a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencePropertyValueModel.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.prefs;
-
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.Preferences;
-
-import org.eclipse.jpt.utility.internal.BidiStringConverter;
-import org.eclipse.jpt.utility.internal.model.value.AspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * This adapter wraps a Preference and converts it into a PropertyValueModel.
- * It listens for the appropriate "preference" changes and converts them into
- * VALUE property changes. It also allows the specification of a default value
- * for the Preference, which, by default, is null (and is probably *not* a very
- * good default).
- *
- * You can configure whether the preference's value is returned,
- * unchanged, as a string or as some other object (e.g. an Integer) by
- * setting the adapter's converter. Internally, the preference's value
- * is stored as the converted object; and the conversions take place
- * when reading or writing from the preferences node or retrieving the
- * value from an event fired by the preferences node.
- *
- * This adapter is a bit different from most other adapters because the
- * change events fired off by a Preferences node are asynchronous from
- * the change itself. (AbstractPreferences uses an event dispatch daemon.)
- * As a result, a client can set our value with #setValue(Object) and we
- * will return from that method before we ever receive notification from
- * the Preferences node that *it* has changed. This means we cannot
- * rely on that event to keep our internally cached value in synch.
- */
-public class PreferencePropertyValueModel<P>
- extends AspectAdapter<Preferences>
- implements WritablePropertyValueModel<P>
-{
- /** The key to the preference we use for the value. */
- protected final String key;
-
- /**
- * Cache the current (object) value of the preference so we
- * can pass an "old value" when we fire a property change event.
- */
- protected P value;
-
- /**
- * The default (object) value returned if there is no value
- * associated with the preference.
- */
- protected final P defaultValue;
-
- /**
- * This converter is used to convert the preference's
- * string value to and from an object.
- */
- protected final BidiStringConverter<P> converter;
-
- /** A listener that listens to the appropriate preference. */
- protected final PreferenceChangeListener preferenceChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified preference.
- * The default value of the preference will be null.
- */
- public PreferencePropertyValueModel(Preferences preferences, String key) {
- this(preferences, key, null);
- }
-
- /**
- * Construct an adapter for the specified preference with
- * the specified default value for the preference.
- */
- public PreferencePropertyValueModel(Preferences preferences, String key, P defaultValue) {
- this(preferences, key, defaultValue, BidiStringConverter.Default.<P>instance());
- }
-
- /**
- * Construct an adapter for the specified preference with
- * the specified default value for the preference.
- */
- public PreferencePropertyValueModel(Preferences preferences, String key, P defaultValue, BidiStringConverter<P> converter) {
- this(new StaticPropertyValueModel<Preferences>(preferences), key, defaultValue, converter);
- }
-
- /**
- * Construct an adapter for the specified preference with
- * the specified default value for the preference.
- */
- public static PreferencePropertyValueModel<Boolean> forBoolean(Preferences preferences, String key, boolean defaultValue) {
- return new PreferencePropertyValueModel<Boolean>(
- preferences,
- key,
- defaultValue ? Boolean.TRUE : Boolean.FALSE,
- BidiStringConverter.BooleanConverter.instance()
- );
- }
-
- /**
- * Construct an adapter for the specified preference with
- * the specified default value for the preference.
- */
- public static PreferencePropertyValueModel<Integer> forInteger(Preferences preferences, String key, int defaultValue) {
- return new PreferencePropertyValueModel<Integer>(
- preferences,
- key,
- new Integer(defaultValue),
- BidiStringConverter.IntegerConverter.instance()
- );
- }
-
- /**
- * Construct an adapter for the specified preference.
- * The default value of the preference will be null.
- */
- public PreferencePropertyValueModel(PropertyValueModel<? extends Preferences> preferencesHolder, String key) {
- this(preferencesHolder, key, null);
- }
-
- /**
- * Construct an adapter for the specified preference with
- * the specified default value for the preference.
- */
- public PreferencePropertyValueModel(PropertyValueModel<? extends Preferences> preferencesHolder, String key, P defaultValue) {
- this(preferencesHolder, key, defaultValue, BidiStringConverter.Default.<P>instance());
- }
-
- /**
- * Construct an adapter for the specified preference with
- * the specified default value for the preference.
- */
- public PreferencePropertyValueModel(PropertyValueModel<? extends Preferences> preferencesHolder, String key, P defaultValue, BidiStringConverter<P> converter) {
- super(preferencesHolder);
- this.key = key;
- this.defaultValue = defaultValue;
- this.converter = converter;
- this.preferenceChangeListener = this.buildPreferenceChangeListener();
- // our value is null when we are not listening to the preference
- this.value = null;
- }
-
-
- // ********** initialization **********
-
- /**
- * A preference has changed, notify the listeners if necessary.
- */
- protected PreferenceChangeListener buildPreferenceChangeListener() {
- // transform the preference change events into VALUE property change events
- return new PreferenceChangeListener() {
- public void preferenceChange(PreferenceChangeEvent event) {
- PreferencePropertyValueModel.this.preferenceChanged(event.getKey(), event.getNewValue());
- }
- @Override
- public String toString() {
- return "preference change listener";
- }
- };
- }
-
-
- // ********** ValueModel implementation **********
-
- /**
- * Return the cached (converted) value.
- */
- @Override
- public synchronized P getValue() {
- return this.value;
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- /**
- * Set the cached value, then set the appropriate preference value.
- */
- public synchronized void setValue(P value) {
- if (this.hasNoListeners()) {
- return; // no changes allowed when we have no listeners
- }
-
- Object old = this.value;
- this.value = value;
- this.fireAspectChange(old, value);
-
- if ((this.subject != null) && this.shouldSetPreference(old, value)) {
- this.setValue_(value);
- }
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected Class<? extends ChangeListener> getListenerClass() {
- return PropertyChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return VALUE;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyPropertyChangeListeners(VALUE);
- }
-
- @Override
- protected void fireAspectChange(Object oldValue, Object newValue) {
- this.firePropertyChanged(VALUE, oldValue, newValue);
- }
-
- @Override
- protected void engageSubject_() {
- this.subject.addPreferenceChangeListener(this.preferenceChangeListener);
- this.value = this.buildValue();
- }
-
- @Override
- protected void disengageSubject_() {
- try {
- this.subject.removePreferenceChangeListener(this.preferenceChangeListener);
- } catch (IllegalStateException ex) {
- // for some odd reason, we are not allowed to remove a listener from a "dead"
- // preferences node; so handle the exception that gets thrown here
- if ( ! ex.getMessage().equals("Node has been removed.")) {
- // if it is not the expected exception, re-throw it
- throw ex;
- }
- }
- this.value = null;
- }
-
-
- // ********** AbstractModel implementation **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.key);
- sb.append(" => ");
- sb.append(this.value);
- }
-
-
- // ********** public API **********
-
- /**
- * Return the preference's key.
- */
- public String getKey() {
- return this.key;
- }
-
-
- // ********** internal methods **********
-
- /**
- * Return the preference's value.
- * At this point the subject may be null.
- */
- protected P buildValue() {
- return (this.subject == null) ? null : this.buildValue_();
- }
-
- /**
- * Return the appropriate preference, converted to the appropriate object.
- * At this point we can be sure that the subject is not null.
- */
- protected P buildValue_() {
- return this.convertToObject(this.subject.get(this.key, this.convertToString(this.defaultValue)));
- }
-
- /**
- * Set the appropriate preference after converting the value to a string.
- * At this point we can be sure that the subject is not null.
- */
- protected void setValue_(P value) {
- this.subject.put(this.key, this.convertToString(value));
- }
-
- /**
- * Return whether the specified new value should be passed
- * through to the preference. By default, only if the value has changed,
- * will it be passed through to the preference. This also has the
- * effect of not creating new preferences in the "backing store"
- * if the new value is the same as the default value.
- *
- * Subclasses can override this method to return true if they
- * would like to ALWAYS pass through the new value to the preference.
- */
- protected boolean shouldSetPreference(Object oldValue, Object newValue) {
- return this.attributeValueHasChanged(oldValue, newValue);
- }
-
- /**
- * Convert the specified object to a string that can be stored as
- * the value of the preference.
- */
- protected String convertToString(P o) {
- return this.converter.convertToString(o);
- }
-
- /**
- * Convert the specified preference value string to an
- * appropriately-typed object to be returned to the client.
- */
- protected P convertToObject(String s) {
- return this.converter.convertToObject(s);
- }
-
- protected void preferenceChanged(String prefKey, String newValue) {
- if (prefKey.equals(this.key)) {
- this.preferenceChanged();
- }
- }
-
- /**
- * The underlying preference changed; either because we changed it
- * in #setValue_(Object) or a third-party changed it.
- * If this is called because of our own change, the event will be
- * swallowed because the old and new values are the same.
- */
- protected synchronized void preferenceChanged() {
- Object old = this.value;
- this.value = this.buildValue();
- this.fireAspectChange(old, this.value);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java
deleted file mode 100644
index c4cef6640f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.prefs;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.prefs.BackingStoreException;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.Preferences;
-
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.utility.internal.model.value.AspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * This adapter wraps a Preferences node and converts its preferences into a
- * CollectionValueModel of PreferencePropertyValueModels. It listens for
- * "preference" changes and converts them into VALUE collection changes.
- */
-public class PreferencesCollectionValueModel<P>
- extends AspectAdapter<Preferences>
- implements CollectionValueModel<PreferencePropertyValueModel<P>>
-{
-
- /** Cache the current preferences, stored in models and keyed by name. */
- protected final HashMap<String, PreferencePropertyValueModel<P>> preferences;
-
- /** A listener that listens to the preferences node for added or removed preferences. */
- protected final PreferenceChangeListener preferenceChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified preferences node.
- */
- public PreferencesCollectionValueModel(Preferences preferences) {
- this(new StaticPropertyValueModel<Preferences>(preferences));
- }
-
- /**
- * Construct an adapter for the specified preferences node.
- */
- public PreferencesCollectionValueModel(PropertyValueModel<? extends Preferences> preferencesHolder) {
- super(preferencesHolder);
- this.preferences = new HashMap<String, PreferencePropertyValueModel<P>>();
- this.preferenceChangeListener = this.buildPreferenceChangeListener();
- }
-
-
- // ********** initialization **********
-
- /**
- * A preferences have changed, notify the listeners.
- */
- protected PreferenceChangeListener buildPreferenceChangeListener() {
- // transform the preference change events into VALUE collection change events
- return new PreferenceChangeListener() {
- public void preferenceChange(PreferenceChangeEvent event) {
- PreferencesCollectionValueModel.this.preferenceChanged(event.getKey(), event.getNewValue());
- }
- @Override
- public String toString() {
- return "preference change listener";
- }
- };
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- /**
- * Return an iterator on the preference models.
- */
- public synchronized Iterator<PreferencePropertyValueModel<P>> iterator() {
- return this.preferences.values().iterator();
- }
-
- public synchronized int size() {
- return this.preferences.size();
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected Object getValue() {
- return this.iterator();
- }
-
- @Override
- protected Class<? extends ChangeListener> getListenerClass() {
- return CollectionChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return VALUES;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyCollectionChangeListeners(VALUES);
- }
-
- @Override
- protected void fireAspectChange(Object oldValue, Object newValue) {
- this.fireCollectionChanged(VALUES);
- }
-
- @Override
- protected void engageSubject_() {
- this.subject.addPreferenceChangeListener(this.preferenceChangeListener);
- for (Iterator<PreferencePropertyValueModel<P>> stream = this.preferenceModels(); stream.hasNext(); ) {
- PreferencePropertyValueModel<P> preferenceModel = stream.next();
- this.preferences.put(preferenceModel.getKey(), preferenceModel);
- }
- }
-
- @Override
- protected void disengageSubject_() {
- try {
- this.subject.removePreferenceChangeListener(this.preferenceChangeListener);
- } catch (IllegalStateException ex) {
- // for some odd reason, we are not allowed to remove a listener from a "dead"
- // preferences node; so handle the exception that gets thrown here
- if ( ! ex.getMessage().equals("Node has been removed.")) {
- // if it is not the expected exception, re-throw it
- throw ex;
- }
- }
- this.preferences.clear();
- }
-
-
- // ********** AbstractModel implementation **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.subject);
- }
-
-
- // ********** internal methods **********
-
- /**
- * Return an iterator on the preference models.
- * At this point we can be sure that the subject is not null.
- */
- protected Iterator<PreferencePropertyValueModel<P>> preferenceModels() {
- String[] keys;
- try {
- keys = this.subject.keys();
- } catch (BackingStoreException ex) {
- throw new RuntimeException(ex);
- }
- return new TransformationIterator<String, PreferencePropertyValueModel<P>>(new ArrayIterator<String>(keys)) {
- @Override
- protected PreferencePropertyValueModel<P> transform(String key) {
- return PreferencesCollectionValueModel.this.buildPreferenceModel(key);
- }
- };
- }
-
- /**
- * Override this method to tweak the model used to wrap the
- * specified preference (e.g. to customize the model's converter).
- */
- protected PreferencePropertyValueModel<P> buildPreferenceModel(String key) {
- return new PreferencePropertyValueModel<P>(this.subjectHolder, key);
- }
-
- protected synchronized void preferenceChanged(String key, String newValue) {
- if (newValue == null) {
- // a preference was removed
- PreferencePropertyValueModel<P> preferenceModel = this.preferences.remove(key);
- this.fireItemRemoved(VALUES, preferenceModel);
- } else if ( ! this.preferences.containsKey(key)) {
- // a preference was added
- PreferencePropertyValueModel<P> preferenceModel = this.buildPreferenceModel(key);
- this.preferences.put(key, preferenceModel);
- this.fireItemAdded(VALUES, preferenceModel);
- } else {
- // a preference's value changed - do nothing
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/AbstractTreeModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/AbstractTreeModel.java
deleted file mode 100644
index 0e464155f5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/AbstractTreeModel.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import java.io.Serializable;
-
-import javax.swing.event.EventListenerList;
-import javax.swing.event.TreeModelEvent;
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.TreeModel;
-
-/**
- * Abstract class that should have been provided by the JDK
- * (à la javax.swing.AbstractListModel). This class provides:
- * - support for a collection of listeners
- * - a number of convenience methods for firing events for those listeners
- */
-public abstract class AbstractTreeModel
- implements TreeModel, Serializable
-{
- /** Our listeners. */
- protected final EventListenerList listenerList;
-
-
- // ********** constructors/initialization **********
-
- protected AbstractTreeModel() {
- super();
- this.listenerList = new EventListenerList();
- }
-
-
- // ********** partial TreeModel implementation **********
-
- public void addTreeModelListener(TreeModelListener l) {
- this.listenerList.add(TreeModelListener.class, l);
- }
-
- public void removeTreeModelListener(TreeModelListener l) {
- this.listenerList.remove(TreeModelListener.class, l);
- }
-
-
- // ********** queries **********
-
- /**
- * Return the model's current collection of listeners.
- * (There seems to be a pattern of making this type of method public;
- * although it should probably be protected....)
- */
- public TreeModelListener[] treeModelListeners() {
- return this.listenerList.getListeners(TreeModelListener.class);
- }
-
- /**
- * Return whether this model has no listeners.
- */
- protected boolean hasNoTreeModelListeners() {
- return this.listenerList.getListenerCount(TreeModelListener.class) == 0;
- }
-
- /**
- * Return whether this model has any listeners.
- */
- protected boolean hasTreeModelListeners() {
- return ! this.hasNoTreeModelListeners();
- }
-
-
- // ********** behavior **********
-
- /**
- * Notify listeners of a model change.
- * A significant property of the nodes changed, but the nodes themselves
- * are still the same objects.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeNodesChanged(Object[] path, int[] childIndices, Object[] children) {
- // guaranteed to return a non-null array
- Object[] listeners = this.listenerList.getListenerList();
- TreeModelEvent event = null;
- // process the listeners last to first, notifying
- // those that are interested in this event
- for (int i = listeners.length-2; i>=0; i-=2) {
- if (listeners[i]==TreeModelListener.class) {
- // lazily create the event
- if (event == null) {
- event = new TreeModelEvent(this, path, childIndices, children);
- }
- ((TreeModelListener) listeners[i+1]).treeNodesChanged(event);
- }
- }
- }
-
-
- /**
- * Notify listeners of a model change.
- * A significant property of the node changed, but the node itself is the same object.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeNodeChanged(Object[] path, int childIndex, Object child) {
- this.fireTreeNodesChanged(path, new int[] {childIndex}, new Object[] {child});
- }
-
- /**
- * Notify listeners of a model change.
- * A significant property of the root changed, but the root itself is the same object.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeRootChanged(Object root) {
- this.fireTreeNodesChanged(new Object[] {root}, null, null);
- }
-
- /**
- * Notify listeners of a model change.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeNodesInserted(Object[] path, int[] childIndices, Object[] children) {
- // guaranteed to return a non-null array
- Object[] listeners = this.listenerList.getListenerList();
- TreeModelEvent event = null;
- // process the listeners last to first, notifying
- // those that are interested in this event
- for (int i = listeners.length-2; i>=0; i-=2) {
- if (listeners[i]==TreeModelListener.class) {
- // lazily create the event
- if (event == null) {
- event = new TreeModelEvent(this, path, childIndices, children);
- }
- ((TreeModelListener) listeners[i+1]).treeNodesInserted(event);
- }
- }
- }
-
- /**
- * Notify listeners of a model change.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeNodeInserted(Object[] path, int childIndex, Object child) {
- this.fireTreeNodesInserted(path, new int[] {childIndex}, new Object[] {child});
- }
-
- /**
- * Notify listeners of a model change.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeNodesRemoved(Object[] path, int[] childIndices, Object[] children) {
- // guaranteed to return a non-null array
- Object[] listeners = this.listenerList.getListenerList();
- TreeModelEvent event = null;
- // process the listeners last to first, notifying
- // those that are interested in this event
- for (int i = listeners.length-2; i>=0; i-=2) {
- if (listeners[i]==TreeModelListener.class) {
- // lazily create the event
- if (event == null) {
- event = new TreeModelEvent(this, path, childIndices, children);
- }
- ((TreeModelListener) listeners[i+1]).treeNodesRemoved(event);
- }
- }
- }
-
- /**
- * Notify listeners of a model change.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeNodeRemoved(Object[] path, int childIndex, Object child) {
- this.fireTreeNodesRemoved(path, new int[] {childIndex}, new Object[] {child});
- }
-
- /**
- * Notify listeners of a model change.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeStructureChanged(Object[] path) {
- // guaranteed to return a non-null array
- Object[] listeners = this.listenerList.getListenerList();
- TreeModelEvent event = null;
- // process the listeners last to first, notifying
- // those that are interested in this event
- for (int i = listeners.length-2; i>=0; i-=2) {
- if (listeners[i]==TreeModelListener.class) {
- // lazily create the event
- if (event == null) {
- event = new TreeModelEvent(this, path);
- }
- ((TreeModelListener) listeners[i+1]).treeStructureChanged(event);
- }
- }
- }
-
- /**
- * Notify listeners of a model change.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeRootReplaced(Object newRoot) {
- this.fireTreeStructureChanged(new Object[] {newRoot});
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/CheckBoxModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/CheckBoxModelAdapter.java
deleted file mode 100644
index 126cbfa561..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/CheckBoxModelAdapter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * This javax.swing.ButtonModel can be used to keep a listener
- * (e.g. a JCheckBox) in synch with a PropertyValueModel that
- * holds a boolean.
- *
- * Maybe not the richest class in our toolbox, but it was the
- * victim of refactoring.... ~bjv
- */
-public class CheckBoxModelAdapter
- extends ToggleButtonModelAdapter
-{
-
- // ********** constructors **********
-
- /**
- * Constructor - the boolean holder is required.
- */
- public CheckBoxModelAdapter(WritablePropertyValueModel<Boolean> booleanHolder, boolean defaultValue) {
- super(booleanHolder, defaultValue);
- }
-
- /**
- * Constructor - the boolean holder is required.
- * The default value will be false.
- */
- public CheckBoxModelAdapter(WritablePropertyValueModel<Boolean> booleanHolder) {
- super(booleanHolder);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ColumnAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ColumnAdapter.java
deleted file mode 100644
index 482b5d2468..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ColumnAdapter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-
-/**
- * This adapter is used by the table model adapter to
- * convert a model object into the models used for each of
- * the cells for the object's corresponding row in the table.
- */
-public interface ColumnAdapter {
- /**
- * Return the number of columns in the table.
- * Typically this is static.
- */
- int columnCount();
-
- /**
- * Return the name of the specified column.
- */
- String columnName(int index);
-
- /**
- * Return the class of the specified column.
- */
- Class<?> columnClass(int index);
-
- /**
- * Return whether the specified column is editable.
- * Typically this is the same for every row.
- */
- boolean columnIsEditable(int index);
-
- /**
- * Return the cell models for the specified subject
- * that corresponds to a single row in the table.
- */
- WritablePropertyValueModel<Object>[] cellModels(Object subject);
-
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ComboBoxModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ComboBoxModelAdapter.java
deleted file mode 100644
index b6f30cda1d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ComboBoxModelAdapter.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import javax.swing.ComboBoxModel;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * This javax.swing.ComboBoxModel can be used to keep a ListDataListener
- * (e.g. a JComboBox) in synch with a ListValueModel (or a CollectionValueModel).
- * For combo boxes, the model object that holds the current selection is
- * typically a different model object than the one that holds the collection
- * of choices.
- *
- * For example, a MWReference (the selectionOwner) has an attribute
- * "sourceTable" (the collectionOwner)
- * which holds on to a collection of MWDatabaseFields. When the selection
- * is changed this model will keep the listeners aware of the changes.
- * The inherited list model will keep its listeners aware of changes to the
- * collection model
- *
- * In addition to the collection holder required by the superclass,
- * an instance of this ComboBoxModel must be supplied with a
- * selection holder, which is a PropertyValueModel that provides access
- * to the selection (typically a PropertyAspectAdapter).
- */
-public class ComboBoxModelAdapter
- extends ListModelAdapter
- implements ComboBoxModel
-{
- protected final WritablePropertyValueModel<Object> selectionHolder;
- protected final PropertyChangeListener selectionListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the list holder and selection holder are required;
- */
- public ComboBoxModelAdapter(ListValueModel<?> listHolder, WritablePropertyValueModel<Object> selectionHolder) {
- super(listHolder);
- if (selectionHolder == null) {
- throw new NullPointerException();
- }
- this.selectionHolder = selectionHolder;
- this.selectionListener = this.buildSelectionListener();
- }
-
- /**
- * Constructor - the collection holder and selection holder are required;
- */
- public ComboBoxModelAdapter(CollectionValueModel<?> collectionHolder, WritablePropertyValueModel<Object> selectionHolder) {
- super(collectionHolder);
- if (selectionHolder == null) {
- throw new NullPointerException();
- }
- this.selectionHolder = selectionHolder;
- this.selectionListener = this.buildSelectionListener();
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildSelectionListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildSelectionListener_());
- }
-
- protected PropertyChangeListener buildSelectionListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- // notify listeners that the selection has changed
- ComboBoxModelAdapter.this.fireSelectionChanged();
- }
- @Override
- public String toString() {
- return "selection listener";
- }
- };
- }
-
-
- // ********** ComboBoxModel implementation **********
-
- public Object getSelectedItem() {
- return this.selectionHolder.getValue();
- }
-
- public void setSelectedItem(Object selectedItem) {
- this.selectionHolder.setValue(selectedItem);
- }
-
-
- // ********** behavior **********
-
- /**
- * Extend to engage the selection holder.
- */
- @Override
- protected void engageModel() {
- super.engageModel();
- this.selectionHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.selectionListener);
- }
-
- /**
- * Extend to disengage the selection holder.
- */
- @Override
- protected void disengageModel() {
- this.selectionHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.selectionListener);
- super.disengageModel();
- }
-
- /**
- * Notify the listeners that the selection has changed.
- */
- protected void fireSelectionChanged() {
- // I guess this will work...
- this.fireContentsChanged(this, -1, -1);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.selectionHolder + ":" + this.listHolder);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DateSpinnerModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DateSpinnerModelAdapter.java
deleted file mode 100644
index 8d0256b4da..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DateSpinnerModelAdapter.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import java.util.Calendar;
-import java.util.Date;
-
-import javax.swing.SpinnerDateModel;
-import javax.swing.event.ChangeListener;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * This javax.swing.SpinnerDateModel can be used to keep a ChangeListener
- * (e.g. a JSpinner) in synch with a PropertyValueModel that holds a date.
- *
- * This class must be a sub-class of SpinnerDateModel because of some
- * crappy jdk code.... ~bjv
- * @see javax.swing.JSpinner#createEditor(javax.swing.SpinnerModel)
- *
- * If this class needs to be modified, it would behoove us to review the
- * other, similar classes:
- * @see ListSpinnerModelAdapter
- * @see NumberSpinnerModelAdapter
- */
-public class DateSpinnerModelAdapter
- extends SpinnerDateModel
-{
-
- /**
- * The default spinner value; used when the underlying model date value is null.
- * The default is the current date.
- */
- private final Date defaultValue;
-
- /** A value model on the underlying date. */
- private final WritablePropertyValueModel<Object> dateHolder;
-
- /** A listener that allows us to synchronize with changes made to the underlying date. */
- private final PropertyChangeListener dateChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the date holder is required.
- * The default spinner value is the current date.
- */
- public DateSpinnerModelAdapter(WritablePropertyValueModel<Object> dateHolder) {
- this(dateHolder, new Date());
- }
-
- /**
- * Constructor - the date holder and default value are required.
- */
- public DateSpinnerModelAdapter(WritablePropertyValueModel<Object> dateHolder, Date defaultValue) {
- this(dateHolder, null, null, Calendar.DAY_OF_MONTH, defaultValue);
- }
-
- /**
- * Constructor - the date holder is required.
- * The default spinner value is the current date.
- */
- public DateSpinnerModelAdapter(WritablePropertyValueModel<Object> dateHolder, Comparable<?> start, Comparable<?> end, int calendarField) {
- this(dateHolder, start, end, calendarField, new Date());
- }
-
- /**
- * Constructor - the date holder is required.
- */
- public DateSpinnerModelAdapter(WritablePropertyValueModel<Object> dateHolder, Comparable<?> start, Comparable<?> end, int calendarField, Date defaultValue) {
- super(dateHolder.getValue() == null ? defaultValue : (Date) dateHolder.getValue(), start, end, calendarField);
- this.dateHolder = dateHolder;
- this.dateChangeListener = this.buildDateChangeListener();
- // postpone listening to the underlying date
- // until we have listeners ourselves...
- this.defaultValue = defaultValue;
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildDateChangeListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildDateChangeListener_());
- }
-
- protected PropertyChangeListener buildDateChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- DateSpinnerModelAdapter.this.synchronize(event.getNewValue());
- }
- @Override
- public String toString() {
- return "date listener";
- }
- };
- }
-
-
- // ********** SpinnerModel implementation **********
-
- /**
- * Extend to check whether this method is being called before we
- * have any listeners.
- * This is necessary because some crappy jdk code gets the value
- * from the model *before* listening to the model. ~bjv
- * @see javax.swing.JSpinner.DefaultEditor(javax.swing.JSpinner)
- */
- @Override
- public Object getValue() {
- if (this.getChangeListeners().length == 0) {
- // sorry about this "lateral" call to super ~bjv
- super.setValue(this.spinnerValueOf(this.dateHolder.getValue()));
- }
- return super.getValue();
- }
-
- /**
- * Extend to update the underlying date directly.
- * The resulting event will be ignored: @see #synchronize(Object).
- */
- @Override
- public void setValue(Object value) {
- super.setValue(value);
- this.dateHolder.setValue(value);
- }
-
- /**
- * Extend to start listening to the underlying date if necessary.
- */
- @Override
- public void addChangeListener(ChangeListener listener) {
- if (this.getChangeListeners().length == 0) {
- this.dateHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.dateChangeListener);
- this.synchronize(this.dateHolder.getValue());
- }
- super.addChangeListener(listener);
- }
-
- /**
- * Extend to stop listening to the underlying date if appropriate.
- */
- @Override
- public void removeChangeListener(ChangeListener listener) {
- super.removeChangeListener(listener);
- if (this.getChangeListeners().length == 0) {
- this.dateHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.dateChangeListener);
- }
- }
-
-
- // ********** queries **********
-
- protected Date getDefaultValue() {
- return this.defaultValue;
- }
-
- /**
- * Convert to a non-null value.
- */
- protected Object spinnerValueOf(Object value) {
- return (value == null) ? this.getDefaultValue() : value;
- }
-
-
- // ********** behavior **********
-
- /**
- * Set the spinner value if it has changed.
- */
- void synchronize(Object value) {
- Object newValue = this.spinnerValueOf(value);
- // check to see whether the spinner date has already been synchronized
- // (via #setValue())
- if ( ! this.getValue().equals(newValue)) {
- this.setValue(newValue);
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.dateHolder);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DocumentAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DocumentAdapter.java
deleted file mode 100644
index 50f04d9c97..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DocumentAdapter.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import java.io.Serializable;
-import java.util.EventObject;
-
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.event.EventListenerList;
-import javax.swing.event.UndoableEditEvent;
-import javax.swing.event.UndoableEditListener;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.Document;
-import javax.swing.text.Element;
-import javax.swing.text.PlainDocument;
-import javax.swing.text.Position;
-import javax.swing.text.Segment;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * This javax.swing.text.Document can be used to keep a DocumentListener
- * (e.g. a JTextField) in synch with a PropertyValueModel that holds a string.
- *
- * NB: This model should only be used for "small" documents;
- * i.e. documents used by text fields, not text panes.
- * @see #synchronizeDelegate(String)
- */
-public class DocumentAdapter
- implements Document, Serializable
-{
-
- /** The delegate document whose behavior we "enhance". */
- protected final Document delegate;
-
- /** A listener that allows us to forward any changes made to the delegate document. */
- protected final CombinedListener delegateListener;
-
- /** A value model on the underlying model string. */
- protected final WritablePropertyValueModel<String> stringHolder;
-
- /** A listener that allows us to synchronize with changes made to the underlying model string. */
- protected final PropertyChangeListener stringListener;
-
- /** The event listener list for the document. */
- protected final EventListenerList listenerList = new EventListenerList();
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the string holder is required.
- * Wrap the specified document.
- */
- public DocumentAdapter(WritablePropertyValueModel<String> stringHolder, Document delegate) {
- super();
- if (stringHolder == null || delegate == null) {
- throw new NullPointerException();
- }
- this.stringHolder = stringHolder;
- // postpone listening to the underlying model string
- // until we have listeners ourselves...
- this.delegate = delegate;
- this.stringListener = this.buildStringListener();
- this.delegateListener = this.buildDelegateListener();
- }
-
- /**
- * Constructor - the string holder is required.
- * Wrap a plain document.
- */
- public DocumentAdapter(WritablePropertyValueModel<String> stringHolder) {
- this(stringHolder, new PlainDocument());
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildStringListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildStringListener_());
- }
-
- protected PropertyChangeListener buildStringListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- DocumentAdapter.this.stringChanged(event);
- }
- @Override
- public String toString() {
- return "string listener";
- }
- };
- }
-
- protected CombinedListener buildDelegateListener() {
- return new InternalListener();
- }
-
-
- // ********** Document implementation **********
-
- public int getLength() {
- return this.delegate.getLength();
- }
-
- /**
- * Extend to start listening to the underlying models if necessary.
- */
- public void addDocumentListener(DocumentListener listener) {
- if (this.listenerList.getListenerCount(DocumentListener.class) == 0) {
- this.delegate.addDocumentListener(this.delegateListener);
- this.engageStringHolder();
- }
- this.listenerList.add(DocumentListener.class, listener);
- }
-
- /**
- * Extend to stop listening to the underlying models if appropriate.
- */
- public void removeDocumentListener(DocumentListener listener) {
- this.listenerList.remove(DocumentListener.class, listener);
- if (this.listenerList.getListenerCount(DocumentListener.class) == 0) {
- this.disengageStringHolder();
- this.delegate.removeDocumentListener(this.delegateListener);
- }
- }
-
- /**
- * Extend to start listening to the delegate document if necessary.
- */
- public void addUndoableEditListener(UndoableEditListener listener) {
- if (this.listenerList.getListenerCount(UndoableEditListener.class) == 0) {
- this.delegate.addUndoableEditListener(this.delegateListener);
- }
- this.listenerList.add(UndoableEditListener.class, listener);
- }
-
- /**
- * Extend to stop listening to the delegate document if appropriate.
- */
- public void removeUndoableEditListener(UndoableEditListener listener) {
- this.listenerList.remove(UndoableEditListener.class, listener);
- if (this.listenerList.getListenerCount(UndoableEditListener.class) == 0) {
- this.delegate.removeUndoableEditListener(this.delegateListener);
- }
- }
-
- public Object getProperty(Object key) {
- return this.delegate.getProperty(key);
- }
-
- public void putProperty(Object key, Object value) {
- this.delegate.putProperty(key, value);
- }
-
- /**
- * Extend to update the underlying model string directly.
- * The resulting event will be ignored: @see #synchronizeDelegate(String).
- */
- public void remove(int offset, int len) throws BadLocationException {
- this.delegate.remove(offset, len);
- this.stringHolder.setValue(this.delegate.getText(0, this.delegate.getLength()));
- }
-
- /**
- * Extend to update the underlying model string directly.
- * The resulting event will be ignored: @see #synchronizeDelegate(String).
- */
- public void insertString(int offset, String insertedString, AttributeSet a) throws BadLocationException {
- this.delegate.insertString(offset, insertedString, a);
- this.stringHolder.setValue(this.delegate.getText(0, this.delegate.getLength()));
- }
-
- public String getText(int offset, int length) throws BadLocationException {
- return this.delegate.getText(offset, length);
- }
-
- public void getText(int offset, int length, Segment txt) throws BadLocationException {
- this.delegate.getText(offset, length, txt);
- }
-
- public Position getStartPosition() {
- return this.delegate.getStartPosition();
- }
-
- public Position getEndPosition() {
- return this.delegate.getEndPosition();
- }
-
- public Position createPosition(int offs) throws BadLocationException {
- return this.delegate.createPosition(offs);
- }
-
- public Element[] getRootElements() {
- return this.delegate.getRootElements();
- }
-
- public Element getDefaultRootElement() {
- return this.delegate.getDefaultRootElement();
- }
-
- public void render(Runnable r) {
- this.delegate.render(r);
- }
-
-
- // ********** queries **********
-
- public DocumentListener[] documentListeners() {
- return this.listenerList.getListeners(DocumentListener.class);
- }
-
- public UndoableEditListener[] undoableEditListeners() {
- return this.listenerList.getListeners(UndoableEditListener.class);
- }
-
-
- // ********** behavior **********
-
- /**
- * A third party has modified the underlying model string.
- * Synchronize the delegate document accordingly.
- */
- protected void stringChanged(PropertyChangeEvent event) {
- this.synchronizeDelegate((String) event.getNewValue());
- }
-
- /**
- * Replace the document's entire text string with the new string.
- */
- protected void synchronizeDelegate(String s) {
- try {
- int len = this.delegate.getLength();
- // check to see whether the delegate has already been synchronized
- // (via #insertString() or #remove())
- if ( ! this.delegate.getText(0, len).equals(s)) {
- this.delegate.remove(0, len);
- this.delegate.insertString(0, s, null);
- }
- } catch (BadLocationException ex) {
- throw new IllegalStateException(ex.getMessage()); // this should not happen...
- }
- }
-
- protected void engageStringHolder() {
- this.stringHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.stringListener);
- this.synchronizeDelegate(this.stringHolder.getValue());
- }
-
- protected void disengageStringHolder() {
- this.stringHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.stringListener);
- }
-
- protected void delegateChangedUpdate(DocumentEvent event) {
- // no need to lazy-initialize the event;
- // we wouldn't get here if we did not have listeners...
- DocumentEvent ee = new InternalDocumentEvent(this, event);
- DocumentListener[] listeners = this.documentListeners();
- for (int i = listeners.length; i-- > 0; ) {
- listeners[i].changedUpdate(ee);
- }
- }
-
- protected void delegateInsertUpdate(DocumentEvent event) {
- // no need to lazy-initialize the event;
- // we wouldn't get here if we did not have listeners...
- DocumentEvent ee = new InternalDocumentEvent(this, event);
- DocumentListener[] listeners = this.documentListeners();
- for (int i = listeners.length; i-- > 0; ) {
- listeners[i].insertUpdate(ee);
- }
- }
-
- protected void delegateRemoveUpdate(DocumentEvent event) {
- // no need to lazy-initialize the event;
- // we wouldn't get here if we did not have listeners...
- DocumentEvent ee = new InternalDocumentEvent(this, event);
- DocumentListener[] listeners = this.documentListeners();
- for (int i = listeners.length; i-- > 0; ) {
- listeners[i].removeUpdate(ee);
- }
- }
-
- protected void delegateUndoableEditHappened(UndoableEditEvent event) {
- // no need to lazy-initialize the event;
- // we wouldn't get here if we did not have listeners...
- UndoableEditEvent ee = new UndoableEditEvent(this, event.getEdit());
- UndoableEditListener[] listeners = this.undoableEditListeners();
- for (int i = listeners.length; i-- > 0; ) {
- listeners[i].undoableEditHappened(ee);
- }
- }
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.stringHolder);
- }
-
-
-// ********** inner class **********
-
- protected interface CombinedListener extends DocumentListener, UndoableEditListener {
- // just consolidate the two interfaces
- }
-
- protected class InternalListener implements CombinedListener {
- public void changedUpdate(DocumentEvent event) {
- DocumentAdapter.this.delegateChangedUpdate(event);
- }
- public void insertUpdate(DocumentEvent event) {
- DocumentAdapter.this.delegateInsertUpdate(event);
- }
- public void removeUpdate(DocumentEvent event) {
- DocumentAdapter.this.delegateRemoveUpdate(event);
- }
- public void undoableEditHappened(UndoableEditEvent event) {
- DocumentAdapter.this.delegateUndoableEditHappened(event);
- }
- }
-
- protected static class InternalDocumentEvent
- extends EventObject
- implements DocumentEvent
- {
- protected DocumentEvent delegate;
-
- protected InternalDocumentEvent(Document document, DocumentEvent delegate) {
- super(document);
- this.delegate = delegate;
- }
- public ElementChange getChange(Element elem) {
- return this.delegate.getChange(elem);
- }
- public Document getDocument() {
- return (Document) this.source;
- }
- public int getLength() {
- return this.delegate.getLength();
- }
- public int getOffset() {
- return this.delegate.getOffset();
- }
- public EventType getType() {
- return this.delegate.getType();
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListModelAdapter.java
deleted file mode 100644
index e4ad741c12..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListModelAdapter.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import javax.swing.AbstractListModel;
-import javax.swing.event.ListDataListener;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTListChangeListenerWrapper;
-import org.eclipse.jpt.utility.internal.model.value.CollectionListValueModelAdapter;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * This javax.swing.ListModel can be used to keep a ListDataListener
- * (e.g. a JList) in synch with a ListValueModel (or a CollectionValueModel).
- *
- * An instance of this ListModel *must* be supplied with a value model,
- * which is a ListValueModel on the bound list or a CollectionValueModel
- * on the bound collection. This is required - the list (or collection)
- * itself can be null, but the value model that holds it cannot.
- */
-public class ListModelAdapter
- extends AbstractListModel
-{
- /** A value model on the underlying model list. */
- protected ListValueModel<?> listHolder;
-
- /**
- * Cache the size of the list for "dramatic" changes.
- * @see #listChanged(ListChangeEvent)
- */
- protected int listSize;
-
- /** A listener that allows us to forward changes made to the underlying model list. */
- protected final ListChangeListener listChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Default constructor - initialize stuff.
- */
- private ListModelAdapter() {
- super();
- this.listSize = 0;
- this.listChangeListener = this.buildListChangeListener();
- }
-
- /**
- * Constructor - the list holder is required.
- */
- public ListModelAdapter(ListValueModel<?> listHolder) {
- this();
- this.setModel(listHolder);
- }
-
- /**
- * Constructor - the collection holder is required.
- */
- public ListModelAdapter(CollectionValueModel<?> collectionHolder) {
- this();
- this.setModel(collectionHolder);
- }
-
-
- // ********** initialization **********
-
- protected ListChangeListener buildListChangeListener() {
- return new AWTListChangeListenerWrapper(this.buildListChangeListener_());
- }
-
- protected ListChangeListener buildListChangeListener_() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent event) {
- ListModelAdapter.this.itemsAdded(event);
- }
- public void itemsRemoved(ListChangeEvent event) {
- ListModelAdapter.this.itemsRemoved(event);
- }
- public void itemsReplaced(ListChangeEvent event) {
- ListModelAdapter.this.itemsReplaced(event);
- }
- public void itemsMoved(ListChangeEvent event) {
- ListModelAdapter.this.itemsMoved(event);
- }
- public void listCleared(ListChangeEvent event) {
- ListModelAdapter.this.listCleared();
- }
- public void listChanged(ListChangeEvent event) {
- ListModelAdapter.this.listChanged();
- }
- @Override
- public String toString() {
- return "list listener";
- }
- };
- }
-
-
- // ********** ListModel implementation **********
-
- public int getSize() {
- return this.listHolder.size();
- }
-
- public Object getElementAt(int index) {
- return this.listHolder.get(index);
- }
-
- /**
- * Extend to start listening to the underlying model list if necessary.
- */
- @Override
- public void addListDataListener(ListDataListener l) {
- if (this.hasNoListDataListeners()) {
- this.engageModel();
- this.listSize = this.listHolder.size();
- }
- super.addListDataListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model list if appropriate.
- */
- @Override
- public void removeListDataListener(ListDataListener l) {
- super.removeListDataListener(l);
- if (this.hasNoListDataListeners()) {
- this.disengageModel();
- this.listSize = 0;
- }
- }
-
-
- // ********** public API **********
-
- /**
- * Return the underlying list model.
- */
- public ListValueModel<?> model() {
- return this.listHolder;
- }
-
- /**
- * Set the underlying list model.
- */
- public void setModel(ListValueModel<?> listHolder) {
- if (listHolder == null) {
- throw new NullPointerException();
- }
- boolean hasListeners = this.hasListDataListeners();
- if (hasListeners) {
- this.disengageModel();
- }
- this.listHolder = listHolder;
- if (hasListeners) {
- this.engageModel();
- this.listChanged();
- }
- }
-
- /**
- * Set the underlying collection model.
- */
- @SuppressWarnings("unchecked")
- public void setModel(CollectionValueModel<?> collectionHolder) {
- this.setModel(new CollectionListValueModelAdapter(collectionHolder));
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether this model has no listeners.
- */
- protected boolean hasNoListDataListeners() {
- return this.getListDataListeners().length == 0;
- }
-
- /**
- * Return whether this model has any listeners.
- */
- protected boolean hasListDataListeners() {
- return ! this.hasNoListDataListeners();
- }
-
-
- // ********** behavior **********
-
- protected void engageModel() {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
- protected void disengageModel() {
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
-
-
- // ********** list change support **********
-
- /**
- * Items were added to the underlying model list.
- * Notify listeners of the changes.
- */
- protected void itemsAdded(ListChangeEvent event) {
- int start = event.getIndex();
- int end = start + event.itemsSize() - 1;
- this.fireIntervalAdded(this, start, end);
- this.listSize += event.itemsSize();
- }
-
- /**
- * Items were removed from the underlying model list.
- * Notify listeners of the changes.
- */
- protected void itemsRemoved(ListChangeEvent event) {
- int start = event.getIndex();
- int end = start + event.itemsSize() - 1;
- this.fireIntervalRemoved(this, start, end);
- this.listSize -= event.itemsSize();
- }
-
- /**
- * Items were replaced in the underlying model list.
- * Notify listeners of the changes.
- */
- protected void itemsReplaced(ListChangeEvent event) {
- int start = event.getIndex();
- int end = start + event.itemsSize() - 1;
- this.fireContentsChanged(this, start, end);
- }
-
- /**
- * Items were moved in the underlying model list.
- * Notify listeners of the changes.
- */
- protected void itemsMoved(ListChangeEvent event) {
- int start = Math.min(event.getSourceIndex(), event.getTargetIndex());
- int end = Math.max(event.getSourceIndex(), event.getTargetIndex()) + event.getMoveLength() - 1;
- this.fireContentsChanged(this, start, end);
- }
-
- /**
- * The underlying model list was cleared.
- * Notify listeners of the changes.
- */
- protected void listCleared() {
- if (this.listSize != 0) {
- this.fireIntervalRemoved(this, 0, this.listSize - 1);
- this.listSize = 0;
- }
- }
-
- /**
- * The underlying model list has changed "dramatically".
- * Notify listeners of the changes.
- */
- protected void listChanged() {
- if (this.listSize != 0) {
- this.fireIntervalRemoved(this, 0, this.listSize - 1);
- }
- this.listSize = this.listHolder.size();
- if (this.listSize != 0) {
- this.fireIntervalAdded(this, 0, this.listSize - 1);
- }
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.listHolder);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListSpinnerModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListSpinnerModelAdapter.java
deleted file mode 100644
index d8ee7b4220..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListSpinnerModelAdapter.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import java.util.Arrays;
-import java.util.List;
-
-import javax.swing.SpinnerListModel;
-import javax.swing.event.ChangeListener;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * This javax.swing.SpinnerListModel can be used to keep a ChangeListener
- * (e.g. a JSpinner) in synch with a PropertyValueModel that holds a value
- * in the list.
- *
- * This class must be a sub-class of SpinnerListModel because of some
- * crappy jdk code.... ~bjv
- * @see javax.swing.JSpinner#createEditor(javax.swing.SpinnerModel)
- *
- * NB: This model should only be used for values that have a reasonably
- * inexpensive #equals() implementation.
- * @see #synchronize(Object)
- *
- * If this class needs to be modified, it would behoove us to review the
- * other, similar classes:
- * @see DateSpinnerModelAdapter
- * @see NumberSpinnerModelAdapter
- */
-public class ListSpinnerModelAdapter
- extends SpinnerListModel
-{
-
- /**
- * The default spinner value; used when the underlying model value is null.
- * The default is the first item on the list.
- */
- private final Object defaultValue;
-
- /** A value model on the underlying value. */
- private final WritablePropertyValueModel<Object> valueHolder;
-
- /** A listener that allows us to synchronize with changes made to the underlying value. */
- private final PropertyChangeListener valueChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the value holder is required.
- * Use the model value itself as the default spinner value.
- */
- public ListSpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder) {
- this(valueHolder, valueHolder.getValue());
- }
-
- /**
- * Constructor - the value holder is required.
- */
- public ListSpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder, Object defaultValue) {
- this(valueHolder, new Object[] {defaultValue}, defaultValue);
- }
-
- /**
- * Constructor - the value holder is required.
- * Use the first item in the list of values as the default spinner value.
- */
- public ListSpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder, Object[] values) {
- this(valueHolder, values, values[0]);
- }
-
- /**
- * Constructor - the value holder is required.
- */
- public ListSpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder, Object[] values, Object defaultValue) {
- this(valueHolder, Arrays.asList(values), defaultValue);
- }
-
- /**
- * Constructor - the value holder is required.
- * Use the first item in the list of values as the default spinner value.
- */
- public ListSpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder, List<Object> values) {
- this(valueHolder, values, values.get(0));
- }
-
- /**
- * Constructor - the value holder is required.
- */
- public ListSpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder, List<Object> values, Object defaultValue) {
- super(values);
- this.valueHolder = valueHolder;
- this.valueChangeListener = this.buildValueChangeListener();
- // postpone listening to the underlying value
- // until we have listeners ourselves...
- this.defaultValue = defaultValue;
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildValueChangeListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildValueChangeListener_());
- }
-
- protected PropertyChangeListener buildValueChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- ListSpinnerModelAdapter.this.synchronize(event.getNewValue());
- }
- @Override
- public String toString() {
- return "value listener";
- }
- };
- }
-
-
- // ********** SpinnerModel implementation **********
-
- /**
- * Extend to check whether this method is being called before we
- * have any listeners.
- * This is necessary because some crappy jdk code gets the value
- * from the model *before* listening to the model. ~bjv
- * @see javax.swing.JSpinner.DefaultEditor(javax.swing.JSpinner)
- */
- @Override
- public Object getValue() {
- if (this.getChangeListeners().length == 0) {
- // sorry about this "lateral" call to super ~bjv
- super.setValue(this.spinnerValueOf(this.valueHolder.getValue()));
- }
- return super.getValue();
- }
-
- /**
- * Extend to update the underlying value directly.
- * The resulting event will be ignored: @see #synchronize(Object).
- */
- @Override
- public void setValue(Object value) {
- super.setValue(value);
- this.valueHolder.setValue(value);
- }
-
- /**
- * Extend to start listening to the underlying value if necessary.
- */
- @Override
- public void addChangeListener(ChangeListener listener) {
- if (this.getChangeListeners().length == 0) {
- this.valueHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.valueChangeListener);
- this.synchronize(this.valueHolder.getValue());
- }
- super.addChangeListener(listener);
- }
-
- /**
- * Extend to stop listening to the underlying value if appropriate.
- */
- @Override
- public void removeChangeListener(ChangeListener listener) {
- super.removeChangeListener(listener);
- if (this.getChangeListeners().length == 0) {
- this.valueHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.valueChangeListener);
- }
- }
-
-
- // ********** queries **********
-
- protected Object getDefaultValue() {
- return this.defaultValue;
- }
-
- /**
- * Convert to a non-null value.
- */
- protected Object spinnerValueOf(Object value) {
- return (value == null) ? this.getDefaultValue() : value;
- }
-
-
- // ********** behavior **********
-
- /**
- * Set the spinner value if it has changed.
- */
- void synchronize(Object value) {
- Object newValue = this.spinnerValueOf(value);
- // check to see whether the spinner value has already been synchronized
- // (via #setValue())
- if ( ! this.getValue().equals(newValue)) {
- this.setValue(newValue);
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.valueHolder);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java
deleted file mode 100644
index 3188aa4bfc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import javax.swing.SpinnerNumberModel;
-import javax.swing.event.ChangeListener;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * This javax.swing.SpinnerNumberModel can be used to keep a ChangeListener
- * (e.g. a JSpinner) in synch with a PropertyValueModel that holds a number.
- *
- * This class must be a sub-class of SpinnerNumberModel because of some
- * crappy jdk code.... ~bjv
- * @see javax.swing.JSpinner#createEditor(javax.swing.SpinnerModel)
- *
- * If this class needs to be modified, it would behoove us to review the
- * other, similar classes:
- * @see DateSpinnerModelAdapter
- * @see ListSpinnerModelAdapter
- */
-public class NumberSpinnerModelAdapter
- extends SpinnerNumberModel
-{
-
- /**
- * The default spinner value; used when the
- * underlying model number value is null.
- */
- private final Number defaultValue;
-
- /** A value model on the underlying number. */
- private final WritablePropertyValueModel<Number> numberHolder;
-
- /**
- * A listener that allows us to synchronize with
- * changes made to the underlying number.
- */
- private final PropertyChangeListener numberChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the number holder is required.
- * The default spinner value is zero.
- * The step size is one.
- */
- public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder) {
- this(numberHolder, 0);
- }
-
- /**
- * Constructor - the number holder is required.
- * The step size is one.
- */
- public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder, int defaultValue) {
- this(numberHolder, null, null, new Integer(1), new Integer(defaultValue));
- }
-
- /**
- * Constructor - the number holder is required.
- * Use the minimum value as the default spinner value.
- */
- public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder, int minimum, int maximum, int stepSize) {
- this(numberHolder, minimum, maximum, stepSize, minimum);
- }
-
- /**
- * Constructor - the number holder is required.
- */
- public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder, int minimum, int maximum, int stepSize, int defaultValue) {
- this(numberHolder, new Integer(minimum), new Integer(maximum), new Integer(stepSize), new Integer(defaultValue));
- }
-
- /**
- * Constructor - the number holder is required.
- * Use the minimum value as the default spinner value.
- */
- public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder, double value, double minimum, double maximum, double stepSize) {
- this(numberHolder, value, minimum, maximum, stepSize, minimum);
- }
-
- /**
- * Constructor - the number holder is required.
- */
- public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder, double value, double minimum, double maximum, double stepSize, double defaultValue) {
- this(numberHolder, new Double(minimum), new Double(maximum), new Double(stepSize), new Double(defaultValue));
- }
-
- /**
- * Constructor - the number holder is required.
- */
- public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder, Comparable<?> minimum, Comparable<?> maximum, Number stepSize, Number defaultValue) {
- super(numberHolder.getValue() == null ? defaultValue : (Number) numberHolder.getValue(), minimum, maximum, stepSize);
- this.numberHolder = numberHolder;
- this.numberChangeListener = this.buildNumberChangeListener();
- // postpone listening to the underlying number
- // until we have listeners ourselves...
- this.defaultValue = defaultValue;
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildNumberChangeListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildNumberChangeListener_());
- }
-
- protected PropertyChangeListener buildNumberChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- NumberSpinnerModelAdapter.this.synchronize(event.getNewValue());
- }
- @Override
- public String toString() {
- return "number listener";
- }
- };
- }
-
-
- // ********** SpinnerModel implementation **********
-
- /**
- * Extend to check whether this method is being called before we
- * have any listeners.
- * This is necessary because some crappy jdk code gets the value
- * from the model *before* listening to the model. ~bjv
- * @see javax.swing.JSpinner.DefaultEditor(javax.swing.JSpinner)
- */
- @Override
- public Object getValue() {
- if (this.getChangeListeners().length == 0) {
- // sorry about this "lateral" call to super ~bjv
- super.setValue(this.spinnerValueOf(this.numberHolder.getValue()));
- }
- return super.getValue();
- }
-
- /**
- * Extend to update the underlying number directly.
- * The resulting event will be ignored: @see #synchronizeDelegate(Object).
- */
- @Override
- public void setValue(Object value) {
- super.setValue(value);
- this.numberHolder.setValue((Number) value);
- }
-
- /**
- * Extend to start listening to the underlying number if necessary.
- */
- @Override
- public void addChangeListener(ChangeListener listener) {
- if (this.getChangeListeners().length == 0) {
- this.numberHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.numberChangeListener);
- this.synchronize(this.numberHolder.getValue());
- }
- super.addChangeListener(listener);
- }
-
- /**
- * Extend to stop listening to the underlying number if appropriate.
- */
- @Override
- public void removeChangeListener(ChangeListener listener) {
- super.removeChangeListener(listener);
- if (this.getChangeListeners().length == 0) {
- this.numberHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.numberChangeListener);
- }
- }
-
-
- // ********** queries **********
-
- protected Number getDefaultValue() {
- return this.defaultValue;
- }
-
- /**
- * Convert to a non-null value.
- */
- protected Object spinnerValueOf(Object value) {
- return (value == null) ? this.getDefaultValue() : value;
- }
-
-
- // ********** behavior **********
-
- /**
- * Set the spinner value if it has changed.
- */
- void synchronize(Object value) {
- Object newValue = this.spinnerValueOf(value);
- // check to see whether the date has already been synchronized
- // (via #setValue())
- if ( ! this.getValue().equals(newValue)) {
- this.setValue(newValue);
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.numberHolder);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ObjectListSelectionModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ObjectListSelectionModel.java
deleted file mode 100644
index 61d2e3701f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ObjectListSelectionModel.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import javax.swing.DefaultListSelectionModel;
-import javax.swing.ListModel;
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-import javax.swing.event.ListSelectionListener;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-/**
- * This ListSelectionModel is aware of the ListModel and
- * provides convenience methods to access and set the
- * selected *objects*, as opposed to the selected *indexes*.
- */
-public class ObjectListSelectionModel
- extends DefaultListSelectionModel
-{
- /** The list model referenced by the list selection model. */
- private final ListModel listModel;
-
- /** A listener that allows us to clear the selection when the list model has changed. */
- private final ListDataListener listDataListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a list selection model for the specified list model.
- */
- public ObjectListSelectionModel(ListModel listModel) {
- super();
- this.listModel = listModel;
- this.listDataListener = this.buildListDataListener();
- }
-
-
- // ********** initialization **********
-
- private ListDataListener buildListDataListener() {
- return new ListDataListener() {
- public void intervalAdded(ListDataEvent event) {
- // this does not affect the selection
- }
- public void intervalRemoved(ListDataEvent event) {
- // this does not affect the selection
- }
- public void contentsChanged(ListDataEvent event) {
- ObjectListSelectionModel.this.listModelContentsChanged(event);
- }
- @Override
- public String toString() {
- return "list data listener";
- }
- };
- }
-
- /**
- * Typically, the selection does not need to be cleared when the
- * contents of the list have changed. Most of the time this just
- * means an item has changed in a way that affects its display string
- * or icon. We typically only use the class for edits involving
- * single selection.
- * A subclass can override this method if the selection
- * should be cleared because a change could mean the selection is invalid.
- */
- protected void listModelContentsChanged(ListDataEvent event) {
- /**this.clearSelection();*/
- }
-
-
- // ********** ListSelectionModel implementation **********
-
- @Override
- public void addListSelectionListener(ListSelectionListener l) {
- if (this.hasNoListSelectionListeners()) {
- this.listModel.addListDataListener(this.listDataListener);
- }
- super.addListSelectionListener(l);
- }
-
- @Override
- public void removeListSelectionListener(ListSelectionListener l) {
- super.removeListSelectionListener(l);
- if (this.hasNoListSelectionListeners()) {
- this.listModel.removeListDataListener(this.listDataListener);
- }
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether this model has no listeners.
- */
- protected boolean hasNoListSelectionListeners() { // private-protected
- return this.getListSelectionListeners().length == 0;
- }
-
- /**
- * Return the list model referenced by the list selection model.
- */
- public ListModel getListModel() {
- return this.listModel;
- }
-
- public int selectedValuesSize() {
- int min = this.getMinSelectionIndex();
- int max = this.getMaxSelectionIndex();
-
- if ((min < 0) || (max < 0)) {
- return 0;
- }
-
- int n = 0;
- int count = this.getListModel().getSize();
- for (int i = min; i <= max; i++) {
- if (this.isSelectedIndex(i) && (i < count)) {
- n++;
- }
- }
- return n;
- }
-
- /**
- * Return the first selected value.
- * Return null if the selection is empty.
- */
- public Object selectedValue() {
- int index = this.getMinSelectionIndex();
- if (index == -1) {
- return null;
- }
- if (this.getListModel().getSize() <= index) {
- return null;
- }
- return this.getListModel().getElementAt(index);
- }
-
- /**
- * Return an array of the selected values.
- */
- public Object[] selectedValues() {
- int min = this.getMinSelectionIndex();
- int max = this.getMaxSelectionIndex();
-
- if ((min < 0) || (max < 0)) {
- return new Object[0];
- }
-
- int maxSize = (max - min) + 1;
- Object[] temp = new Object[maxSize];
- int n = 0;
- int count = this.getListModel().getSize();
- for (int i = min; i <= max; i++) {
- if (this.isSelectedIndex(i) && (i < count)) {
- temp[n++] = this.getListModel().getElementAt(i);
- }
- }
- if (n == maxSize) {
- // all the elements in the range were selected
- return temp;
- }
- // only some of the elements in the range were selected
- Object[] result = new Object[n];
- System.arraycopy(temp, 0, result, 0, n);
- return result;
- }
-
- /**
- * Return an array of the selected indices in order.
- */
- public int[] selectedIndices() {
- int min = this.getMinSelectionIndex();
- int max = this.getMaxSelectionIndex();
-
- if ((min < 0) || (max < 0)) {
- return new int[0];
- }
-
- int maxSize = (max - min) + 1;
- int[] temp = new int[maxSize];
- int n = 0;
- int count = this.getListModel().getSize();
- for (int i = min; i <= max; i++) {
- if (this.isSelectedIndex(i) && (i < count)) {
- temp[n++] = i;
- }
- }
- if (n == maxSize) {
- // all the elements in the range were selected
- Arrays.sort(temp);
- return temp;
- }
- // only some of the elements in the range were selected
- int[] result = new int[n];
- System.arraycopy(temp, 0, result, 0, n);
- Arrays.sort(result);
- return result;
- }
-
- /**
- * Set the selected value.
- */
- public void setSelectedValue(Object object) {
- this.setSelectedValues(CollectionTools.singletonIterator(object));
- }
-
- /**
- * Set the current set of selected objects to the specified objects.
- * @see javax.swing.ListSelectionModel#setSelectionInterval(int, int)
- */
- public void setSelectedValues(Iterator<?> objects) {
- this.setValueIsAdjusting(true);
- this.clearSelection();
- this.addSelectedValuesInternal(objects);
- this.setValueIsAdjusting(false);
- }
-
- /**
- * Set the current set of selected objects to the specified objects.
- * @see javax.swing.ListSelectionModel#setSelectionInterval(int, int)
- */
- public void setSelectedValues(Collection<?> objects) {
- this.setSelectedValues(objects.iterator());
- }
-
- /**
- * Set the current set of selected objects to the specified objects.
- * @see javax.swing.ListSelectionModel#setSelectionInterval(int, int)
- */
- public void setSelectedValues(Object[] objects) {
- this.setSelectedValues(CollectionTools.iterator(objects));
- }
-
- /**
- * Add the specified object to the current set of selected objects.
- * @see javax.swing.ListSelectionModel#addSelectionInterval(int, int)
- */
- public void addSelectedValue(Object object) {
- this.addSelectedValues(CollectionTools.singletonIterator(object));
- }
-
- /**
- * Add the specified objects to the current set of selected objects.
- * @see javax.swing.ListSelectionModel#addSelectionInterval(int, int)
- */
- public void addSelectedValues(Iterator<?> objects) {
- this.setValueIsAdjusting(true);
- this.addSelectedValuesInternal(objects);
- this.setValueIsAdjusting(false);
- }
-
- /**
- * Add the specified objects to the current set of selected objects.
- * @see javax.swing.ListSelectionModel#addSelectionInterval(int, int)
- */
- public void addSelectedValues(Collection<?> objects) {
- this.addSelectedValues(objects.iterator());
- }
-
- /**
- * Add the specified objects to the current set of selected objects.
- * @see javax.swing.ListSelectionModel#addSelectionInterval(int, int)
- */
- public void addSelectedValues(Object[] objects) {
- this.addSelectedValues(CollectionTools.iterator(objects));
- }
-
- /**
- * Remove the specified object from the current set of selected objects.
- * @see javax.swing.ListSelectionModel#removeSelectionInterval(int, int)
- */
- public void removeSelectedValue(Object object) {
- this.removeSelectedValues(CollectionTools.singletonIterator(object));
- }
-
- /**
- * Remove the specified objects from the current set of selected objects.
- * @see javax.swing.ListSelectionModel#removeSelectionInterval(int, int)
- */
- public void removeSelectedValues(Iterator<?> objects) {
- this.setValueIsAdjusting(true);
- ListModel lm = this.getListModel();
- int lmSize = lm.getSize();
- while (objects.hasNext()) {
- int index = this.indexOf(objects.next(), lm, lmSize);
- this.removeSelectionInterval(index, index);
- }
- this.setValueIsAdjusting(false);
- }
-
- /**
- * Remove the specified objects from the current set of selected objects.
- * @see javax.swing.ListSelectionModel#removeSelectionInterval(int, int)
- */
- public void removeSelectedValues(Collection<?> objects) {
- this.removeSelectedValues(objects.iterator());
- }
-
- /**
- * Remove the specified objects from the current set of selected objects.
- * @see javax.swing.ListSelectionModel#removeSelectionInterval(int, int)
- */
- public void removeSelectedValues(Object[] objects) {
- this.removeSelectedValues(CollectionTools.iterator(objects));
- }
-
- /**
- * @see javax.swing.ListSelectionModel#getAnchorSelectionIndex()
- * Return null if the anchor selection is empty.
- */
- public Object getAnchorSelectedValue() {
- int index = this.getAnchorSelectionIndex();
- if (index == -1) {
- return null;
- }
- return this.getListModel().getElementAt(index);
- }
-
- /**
- * @see javax.swing.ListSelectionModel#setAnchorSelectionIndex(int)
- */
- public void setAnchorSelectedValue(Object object) {
- this.setAnchorSelectionIndex(this.indexOf(object));
- }
-
- /**
- * @see javax.swing.ListSelectionModel#getLeadSelectionIndex()
- * Return null if the lead selection is empty.
- */
- public Object getLeadSelectedValue() {
- int index = this.getLeadSelectionIndex();
- if (index == -1) {
- return null;
- }
- return this.getListModel().getElementAt(index);
- }
-
- /**
- * @see javax.swing.ListSelectionModel#setLeadSelectionIndex(int)
- */
- public void setLeadSelectedValue(Object object) {
- this.setLeadSelectionIndex(this.indexOf(object));
- }
-
- /**
- * @see javax.swing.ListSelectionModel#getMaxSelectionIndex()
- * Return null if the max selection is empty.
- */
- public Object getMaxSelectedValue() {
- int index = this.getMaxSelectionIndex();
- if (index == -1) {
- return null;
- }
- return this.getListModel().getElementAt(index);
- }
-
- /**
- * @see javax.swing.ListSelectionModel#getMinSelectionIndex()
- * Return null if the min selection is empty.
- */
- public Object getMinSelectedValue() {
- int index = this.getMinSelectionIndex();
- if (index == -1) {
- return null;
- }
- return this.getListModel().getElementAt(index);
- }
-
- /**
- * @see javax.swing.ListSelectionModel#isSelectedIndex(int)
- */
- public boolean valueIsSelected(Object object) {
- return this.isSelectedIndex(this.indexOf(object));
- }
-
- /**
- * Add the specified objects to the current set of selected objects,
- * without wrapping the actions in "adjusting" events.
- */
- private void addSelectedValuesInternal(Iterator<?> objects) {
- ListModel lm = this.getListModel();
- int listModelSize = lm.getSize();
- while (objects.hasNext()) {
- int index = this.indexOf(objects.next(), lm, listModelSize);
- this.addSelectionInterval(index, index);
- }
- }
-
- /**
- * Return the index in the list model of the specified object.
- * Return -1 if the object is not in the list model.
- */
- private int indexOf(Object object) {
- ListModel lm = this.getListModel();
- return this.indexOf(object, lm, lm.getSize());
- }
-
- /**
- * Return the index in the list model of the specified object.
- * Return -1 if the object is not in the list model.
- */
- // we're just jerking around with performance optimizations here
- // (in memory of Phil...);
- // call this method inside loops that do not modify the listModel
- private int indexOf(Object object, ListModel lm, int listModelSize) {
- for (int i = listModelSize; i-- > 0; ) {
- if (lm.getElementAt(i) == object) {
- return i;
- }
- }
- return -1;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/PrimitiveListTreeModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/PrimitiveListTreeModel.java
deleted file mode 100644
index 2eb4b4dd0f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/PrimitiveListTreeModel.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.MutableTreeNode;
-import javax.swing.tree.TreeNode;
-import javax.swing.tree.TreePath;
-
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTListChangeListenerWrapper;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * This TreeModel implementation provides a tree with a "null" root that
- * has a set of "primitive" children. These "primitive" children do not have
- * children themselves, making the tree a maximum of 2 levels deep.
- * This model automatically synchronizes the root's children with a
- * ListValueModel that holds a collection of primitive (non-model) objects
- * (e.g. Strings).
- *
- * This is useful for providing an "editable" list of primitives. Since the JDK
- * does not provide us with an editable listbox, we must use an editable tree.
- * We wrap everything in DefaultMutableTreeNodes.
- *
- * Subclasses must implement #primitiveChanged(int, Object) and update
- * the model appropriately. This method is called when the user edits the
- * list directly and presses <Enter>.
- *
- * The JTree using this model must be configured as "editable":
- * tree.setEditable(true);
- */
-// TODO convert to use an adapter instead of requiring subclass
-public abstract class PrimitiveListTreeModel
- extends DefaultTreeModel
-{
- /** a model on the list of primitives */
- private final ListValueModel<?> listHolder;
-
- /** a listener that handles the adding, removing, and replacing of the primitives */
- private final ListChangeListener listChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Public constructor - the list holder is required
- */
- public PrimitiveListTreeModel(ListValueModel<?> listHolder) {
- super(new DefaultMutableTreeNode(null, true)); // true = the root can have children
- if (listHolder == null) {
- throw new NullPointerException();
- }
- this.listHolder = listHolder;
- this.listChangeListener = this.buildListChangeListener();
- // postpone listening to the model until we have listeners ourselves
- }
-
- protected ListChangeListener buildListChangeListener() {
- return new AWTListChangeListenerWrapper(this.buildListChangeListener_());
- }
-
- protected ListChangeListener buildListChangeListener_() {
- return new PrimitiveListChangeListener();
- }
-
-
- // ********** behavior **********
-
- /**
- * Subclasses should override this method to update the
- * model appropriately. The primitive at the specified index was
- * edited directly by the user and the new value is as specified.
- * Convert the value appropriately and place it in the model.
- */
- protected abstract void primitiveChanged(int index, Object newValue);
-
-
- // ********** TreeModel implementation **********
-
- /**
- * Override to change the underlying model instead of changing the node directly.
- */
- @Override
- public void valueForPathChanged(TreePath path, Object newValue) {
- TreeNode node = (TreeNode) path.getLastPathComponent();
- int index = ((TreeNode) this.getRoot()).getIndex(node);
- this.primitiveChanged(index, newValue);
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addTreeModelListener(TreeModelListener l) {
- if (this.getTreeModelListeners().length == 0) {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- this.synchronizeList();
- }
- super.addTreeModelListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model if appropriate.
- */
- @Override
- public void removeTreeModelListener(TreeModelListener l) {
- super.removeTreeModelListener(l);
- if (this.getTreeModelListeners().length == 0) {
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * Synchronize our list of nodes with the list of primitives
- */
- void synchronizeList() {
- this.clearList();
- this.buildList();
- }
-
- void clearList() {
- int childcount = this.root.getChildCount();
- for (int i = childcount - 1; i >= 0; i--) {
- this.removeNodeFromParent((MutableTreeNode)this.root.getChildAt(i));
- }
- }
-
- private void buildList() {
- for (Iterator<?> stream = this.listHolder.iterator(); stream.hasNext(); ) {
- this.addPrimitive(stream.next());
- }
- }
-
- /**
- * Add the specified primitive to the end of the list.
- */
- private void addPrimitive(Object primitive) {
- this.insertPrimitive(this.root.getChildCount(), primitive);
- }
-
- /**
- * Create a node for the specified primitive
- * and insert it as a child of the root.
- */
- void insertPrimitive(int index, Object primitive) {
- DefaultMutableTreeNode node = new DefaultMutableTreeNode(primitive, false); // don't allow children on the child node
- this.insertNodeInto(node, (MutableTreeNode) this.root, index);
- }
-
- /**
- * Remove node at the specified index.
- */
- MutableTreeNode removeNode(int index) {
- MutableTreeNode node = (MutableTreeNode) this.root.getChildAt(index);
- this.removeNodeFromParent(node);
- return node;
- }
-
- /**
- * Replace the user object of the node at childIndex.
- */
- void replacePrimitive(int index, Object primitive) {
- MutableTreeNode node = (MutableTreeNode) this.root.getChildAt(index);
- node.setUserObject(primitive);
- this.nodeChanged(node);
- }
-
-
- // ********** inner class **********
-
- private class PrimitiveListChangeListener implements ListChangeListener {
- PrimitiveListChangeListener() {
- super();
- }
-
- public void itemsAdded(ListChangeEvent event) {
- int i = event.getIndex();
- for (ListIterator<?> stream = event.items(); stream.hasNext(); ) {
- PrimitiveListTreeModel.this.insertPrimitive(i++, stream.next());
- }
- }
-
- public void itemsRemoved(ListChangeEvent event) {
- for (int i = 0; i < event.itemsSize(); i++) {
- PrimitiveListTreeModel.this.removeNode(event.getIndex());
- }
- }
-
- public void itemsReplaced(ListChangeEvent event) {
- int i = event.getIndex();
- for (ListIterator<?> stream = event.items(); stream.hasNext(); ) {
- PrimitiveListTreeModel.this.replacePrimitive(i++, stream.next());
- }
- }
-
- public void itemsMoved(ListChangeEvent event) {
- ArrayList<MutableTreeNode> temp = new ArrayList<MutableTreeNode>(event.getMoveLength());
- for (int i = 0; i < event.getMoveLength(); i++) {
- temp.add(PrimitiveListTreeModel.this.removeNode(event.getSourceIndex()));
- }
- int i = event.getTargetIndex();
- for (MutableTreeNode node : temp) {
- PrimitiveListTreeModel.this.insertPrimitive(i++, node);
- }
- }
-
- public void listCleared(ListChangeEvent event) {
- PrimitiveListTreeModel.this.clearList();
- }
-
- public void listChanged(ListChangeEvent event) {
- PrimitiveListTreeModel.this.synchronizeList();
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/RadioButtonModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/RadioButtonModelAdapter.java
deleted file mode 100644
index 1caee488c8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/RadioButtonModelAdapter.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import org.eclipse.jpt.utility.internal.BidiFilter;
-import org.eclipse.jpt.utility.internal.BidiTransformer;
-import org.eclipse.jpt.utility.internal.model.value.FilteringWritablePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.TransformationWritablePropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * This javax.swing.ButtonModel can be used to keep a listener
- * (e.g. a JRadioButton) in synch with a (typically shared)
- * PropertyValueModel that holds one value out of a set of values.
- *
- * NOTE: Do *not* use this model with a ButtonGroup, since the
- * shared value holder and the wrappers built by this adapter will
- * keep the appropriate radio button checked. Also, this allows
- * us to uncheck all the radio buttons in a group when the shared
- * value is null.
- */
-public class RadioButtonModelAdapter
- extends ToggleButtonModelAdapter
-{
-
- // ********** constructors **********
-
- /**
- * Constructor - the value holder is required.
- */
- public RadioButtonModelAdapter(WritablePropertyValueModel<Object> valueHolder, Object buttonValue, boolean defaultValue) {
- super(buildBooleanHolder(valueHolder, buttonValue), defaultValue);
- }
-
- /**
- * Constructor - the value holder is required.
- * The default value will be false.
- */
- public RadioButtonModelAdapter(WritablePropertyValueModel<Object> valueHolder, Object buttonValue) {
- super(buildBooleanHolder(valueHolder, buttonValue));
- }
-
-
- // ********** static methods **********
-
- /**
- * Build up a set of wrappers that will convert the
- * specified value holder and button value to/from a boolean.
- *
- * If the value holder's value matches the button value,
- * the wrapper will return true. Likewise, if the value holder's
- * value is set to true, the wrapper will set the value holder's
- * value to the button value.
- */
- public static WritablePropertyValueModel<Boolean> buildBooleanHolder(WritablePropertyValueModel<Object> valueHolder, Object buttonValue) {
- WritablePropertyValueModel<Object> filteringPVM = new FilteringWritablePropertyValueModel<Object>(valueHolder, new RadioButtonFilter(buttonValue));
- return new TransformationWritablePropertyValueModel<Object, Boolean>(filteringPVM, new RadioButtonTransformer(buttonValue));
- }
-
-
- // ********** overrides **********
-
- /**
- * The user cannot de-select a radio button - the user
- * can only *select* a radio button. Only the model can
- * cause a radio button to be de-selected. We use the
- * ARMED flag to indicate whether we are being de-selected
- * by the user.
- */
- @Override
- public void setSelected(boolean b) {
- // do not allow the user to de-select a radio button
- // radio buttons can
- if ((b == false) && this.isArmed()) {
- return;
- }
- super.setSelected(b);
- }
-
-
- // ********** inner classes **********
-
- /**
- * This filter will only pass through a new value to the wrapped
- * value holder when it matches the configured button value.
- */
- public static class RadioButtonFilter implements BidiFilter<Object> {
- private Object buttonValue;
-
- public RadioButtonFilter(Object buttonValue) {
- super();
- this.buttonValue = buttonValue;
- }
-
- /**
- * always return the wrapped value
- */
- public boolean accept(Object value) {
- return true;
- }
-
- /**
- * pass through the value to the wrapped property value model
- * *only* when it matches our button value
- */
- public boolean reverseAccept(Object value) {
- return value == this.buttonValue;
- }
-
- }
-
- /**
- * This transformer will convert the wrapped value to Boolean.TRUE
- * when it matches the configured button value.
- */
- public static class RadioButtonTransformer implements BidiTransformer<Object, Boolean> {
- private Object buttonValue;
-
- public RadioButtonTransformer(Object buttonValue) {
- super();
- this.buttonValue = buttonValue;
- }
-
- /**
- * if the wrapped value matches our button value return true,
- * if it is some other value return false;
- * but if it is null simply pass it through because it will cause the
- * button model's default value to be used
- */
- public Boolean transform(Object value) {
- return (value == null) ? null : Boolean.valueOf(value == this.buttonValue);
- }
-
- /**
- * if the new value is true, pass through the our button value;
- * otherwise pass through null
- */
- public Object reverseTransform(Boolean value) {
- return (value.booleanValue()) ? this.buttonValue : null;
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/SpinnerModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/SpinnerModelAdapter.java
deleted file mode 100644
index 6cd893d878..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/SpinnerModelAdapter.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import javax.swing.AbstractSpinnerModel;
-import javax.swing.SpinnerModel;
-import javax.swing.SpinnerNumberModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * This javax.swing.SpinnerModel can be used to keep a ChangeListener
- * (e.g. a JSpinner) in synch with a PropertyValueModel that holds a value.
- *
- * Note: it is likely you want to use one of the following classes instead of
- * this one:
- * DateSpinnerModelAdapter
- * NumberSpinnerModelAdapter
- * ListSpinnerModelAdapter
- *
- * NB: This model should only be used for values that have a fairly
- * inexpensive #equals() implementation.
- * @see #synchronizeDelegate(Object)
- */
-public class SpinnerModelAdapter
- extends AbstractSpinnerModel
-{
- /** The delegate spinner model whose behavior we "enhance". */
- protected final SpinnerModel delegate;
-
- /** A listener that allows us to forward any changes made to the delegate spinner model. */
- protected final ChangeListener delegateListener;
-
- /** A value model on the underlying value. */
- protected final WritablePropertyValueModel<Object> valueHolder;
-
- /** A listener that allows us to synchronize with changes made to the underlying value. */
- protected final PropertyChangeListener valueListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the value holder and delegate are required.
- */
- public SpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder, SpinnerModel delegate) {
- super();
- if (valueHolder == null || delegate == null) {
- throw new NullPointerException();
- }
- this.valueHolder = valueHolder;
- this.delegate = delegate;
- // postpone listening to the underlying value
- // until we have listeners ourselves...
- this.valueListener = this.buildValueListener();
- this.delegateListener = this.buildDelegateListener();
- }
-
- /**
- * Constructor - the value holder is required.
- * This will wrap a simple number spinner model.
- */
- public SpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder) {
- this(valueHolder, new SpinnerNumberModel());
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildValueListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildValueListener_());
- }
-
- protected PropertyChangeListener buildValueListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- SpinnerModelAdapter.this.valueChanged(event);
- }
- @Override
- public String toString() {
- return "value listener";
- }
- };
- }
-
- /**
- * expand access a bit for inner class
- */
- @Override
- protected void fireStateChanged() {
- super.fireStateChanged();
- }
-
- protected ChangeListener buildDelegateListener() {
- return new ChangeListener() {
- public void stateChanged(ChangeEvent event) {
- // forward the event, with this as the source
- SpinnerModelAdapter.this.fireStateChanged();
- }
- @Override
- public String toString() {
- return "delegate listener";
- }
- };
- }
-
-
- // ********** SpinnerModel implementation **********
-
- public Object getValue() {
- return this.delegate.getValue();
- }
-
- /**
- * Extend to update the underlying value directly.
- * The resulting event will be ignored: @see #synchronizeDelegate(Object).
- */
- public void setValue(Object value) {
- this.delegate.setValue(value);
- this.valueHolder.setValue(value);
- }
-
- public Object getNextValue() {
- return this.delegate.getNextValue();
- }
-
- public Object getPreviousValue() {
- return this.delegate.getPreviousValue();
- }
-
- /**
- * Extend to start listening to the underlying value if necessary.
- */
- @Override
- public void addChangeListener(ChangeListener listener) {
- if (this.listenerList.getListenerCount(ChangeListener.class) == 0) {
- this.delegate.addChangeListener(this.delegateListener);
- this.engageValueHolder();
- }
- super.addChangeListener(listener);
- }
-
- /**
- * Extend to stop listening to the underlying value if appropriate.
- */
- @Override
- public void removeChangeListener(ChangeListener listener) {
- super.removeChangeListener(listener);
- if (this.listenerList.getListenerCount(ChangeListener.class) == 0) {
- this.disengageValueHolder();
- this.delegate.removeChangeListener(this.delegateListener);
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * A third party has modified the underlying value.
- * Synchronize the delegate model accordingly.
- */
- protected void valueChanged(PropertyChangeEvent event) {
- this.synchronizeDelegate(event.getNewValue());
- }
-
- /**
- * Set the delegate's value if it has changed.
- */
- protected void synchronizeDelegate(Object value) {
- // check to see whether the delegate has already been synchronized
- // (via #setValue())
- if ( ! this.delegate.getValue().equals(value)) {
- this.delegate.setValue(value);
- }
- }
-
- protected void engageValueHolder() {
- this.valueHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.valueListener);
- this.synchronizeDelegate(this.valueHolder.getValue());
- }
-
- protected void disengageValueHolder() {
- this.valueHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.valueListener);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.valueHolder);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TableModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TableModelAdapter.java
deleted file mode 100644
index 8196118331..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TableModelAdapter.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.swing.event.TableModelListener;
-import javax.swing.table.AbstractTableModel;
-
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTListChangeListenerWrapper;
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.utility.internal.model.value.CollectionListValueModelAdapter;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * This TableModel can be used to keep a TableModelListener (e.g. a JTable)
- * in synch with a ListValueModel that holds a collection of model objects,
- * each of which corresponds to a row in the table.
- * Typically, each column of the table will be bound to a different aspect
- * of the contained model objects.
- *
- * For example, a MWTable has an attribute 'databaseFields' that holds
- * a collection of MWDatabaseFields that would correspond to the rows of
- * a JTable; and each MWDatabaseField has a number
- * of attributes (e.g. name, type, size) that can be bound to the columns of
- * a row in the JTable. As these database fields are added, removed, and
- * changed, this model will keep the listeners aware of the changes.
- *
- * An instance of this TableModel must be supplied with a
- * list holder (e.g. the 'databaseFields'), which is a value
- * model on the bound collection This is required - the
- * collection itself can be null, but the list value model that
- * holds it is required. Typically this list will be sorted (@see
- * SortedListValueModelAdapter).
- *
- * This TableModel must also be supplied with a ColumnAdapter that
- * will be used to configure the headers, renderers, editors, and contents
- * of the various columns.
- *
- * Design decision:
- * Cell listener options (from low space/high time to high space/low time):
- * - 1 cell listener listening to every cell (this is the current implementation)
- * - 1 cell listener per row
- * - 1 cell listener per cell
- */
-public class TableModelAdapter<E>
- extends AbstractTableModel
-{
- /**
- * a list of user objects that are converted to
- * rows via the column adapter
- */
- private ListValueModel<? extends E> listHolder;
- private final ListChangeListener listChangeListener;
-
- /**
- * each row is an array of cell models
- */
- // declare as ArrayList so we can use #ensureCapacity(int)
- private final ArrayList<WritablePropertyValueModel<Object>[]> rows;
-
- /**
- * client-supplied adapter that provides with the various column
- * settings and converts the objects in the LVM
- * into an array of cell models
- */
- private final ColumnAdapter columnAdapter;
-
- /**
- * the single listener that listens to every cell's model
- */
- private final PropertyChangeListener cellListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a table model adapter for the specified objects
- * and adapter.
- */
- public TableModelAdapter(ListValueModel<? extends E> listHolder, ColumnAdapter columnAdapter) {
- super();
- if (listHolder == null) {
- throw new NullPointerException();
- }
- this.listHolder = listHolder;
- this.columnAdapter = columnAdapter;
- this.listChangeListener = this.buildListChangeListener();
- this.rows = new ArrayList<WritablePropertyValueModel<Object>[]>();
- this.cellListener = this.buildCellListener();
- }
-
- /**
- * Construct a table model adapter for the specified objects
- * and adapter.
- */
- public TableModelAdapter(CollectionValueModel<? extends E> collectionHolder, ColumnAdapter columnAdapter) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder), columnAdapter);
- }
-
-
- // ********** initialization **********
-
- protected ListChangeListener buildListChangeListener() {
- return new AWTListChangeListenerWrapper(this.buildListChangeListener_());
- }
-
- protected ListChangeListener buildListChangeListener_() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent event) {
- TableModelAdapter.this.addRows(event.getIndex(), event.itemsSize(), this.items(event));
- }
- public void itemsRemoved(ListChangeEvent event) {
- TableModelAdapter.this.removeRows(event.getIndex(), event.itemsSize());
- }
- public void itemsReplaced(ListChangeEvent event) {
- TableModelAdapter.this.replaceRows(event.getIndex(), this.items(event));
- }
- public void itemsMoved(ListChangeEvent event) {
- TableModelAdapter.this.moveRows(event.getTargetIndex(), event.getSourceIndex(), event.getMoveLength());
- }
- public void listCleared(ListChangeEvent event) {
- TableModelAdapter.this.clearTable();
- }
- public void listChanged(ListChangeEvent event) {
- TableModelAdapter.this.rebuildTable();
- }
- /**
- * minimize scope of suppressed warnings
- */
- @SuppressWarnings("unchecked")
- protected Iterator<Object> items(ListChangeEvent event) {
- return (Iterator<Object>) event.items();
- }
- @Override
- public String toString() {
- return "list listener";
- }
- };
- }
-
-
- protected PropertyChangeListener buildCellListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildCellListener_());
- }
-
- protected PropertyChangeListener buildCellListener_() {
- return new PropertyChangeListener() {
- @SuppressWarnings("unchecked")
- public void propertyChanged(PropertyChangeEvent event) {
- TableModelAdapter.this.cellChanged((WritablePropertyValueModel<Object>) event.getSource());
- }
- @Override
- public String toString() {
- return "cell listener";
- }
- };
- }
-
-
- // ********** TableModel implementation **********
-
- public int getColumnCount() {
- return this.columnAdapter.columnCount();
- }
-
- public int getRowCount() {
- return this.rows.size();
- }
-
- @Override
- public String getColumnName(int column) {
- return this.columnAdapter.columnName(column);
- }
-
- @Override
- public Class<?> getColumnClass(int columnIndex) {
- return this.columnAdapter.columnClass(columnIndex);
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return this.columnAdapter.columnIsEditable(columnIndex);
- }
-
- public Object getValueAt(int rowIndex, int columnIndex) {
- WritablePropertyValueModel<Object>[] row = this.rows.get(rowIndex);
- return row[columnIndex].getValue();
- }
-
- @Override
- public void setValueAt(Object value, int rowIndex, int columnIndex) {
- WritablePropertyValueModel<Object>[] row = this.rows.get(rowIndex);
- row[columnIndex].setValue(value);
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addTableModelListener(TableModelListener l) {
- if (this.hasNoTableModelListeners()) {
- this.engageModel();
- }
- super.addTableModelListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model if necessary.
- */
- @Override
- public void removeTableModelListener(TableModelListener l) {
- super.removeTableModelListener(l);
- if (this.hasNoTableModelListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** public API **********
-
- /**
- * Return the underlying list model.
- */
- public ListValueModel<? extends E> getModel() {
- return this.listHolder;
- }
-
- /**
- * Set the underlying list model.
- */
- public void setModel(ListValueModel<E> listHolder) {
- if (listHolder == null) {
- throw new NullPointerException();
- }
- boolean hasListeners = this.hasTableModelListeners();
- if (hasListeners) {
- this.disengageModel();
- }
- this.listHolder = listHolder;
- if (hasListeners) {
- this.engageModel();
- this.fireTableDataChanged();
- }
- }
-
- /**
- * Set the underlying collection model.
- */
- public void setModel(CollectionValueModel<E> collectionHolder) {
- this.setModel(new CollectionListValueModelAdapter<E>(collectionHolder));
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether this model has no listeners.
- */
- protected boolean hasNoTableModelListeners() {
- return this.listenerList.getListenerCount(TableModelListener.class) == 0;
- }
-
- /**
- * Return whether this model has any listeners.
- */
- protected boolean hasTableModelListeners() {
- return ! this.hasNoTableModelListeners();
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the list of objects and the various aspects
- * of the objects that make up the rows.
- */
- private void engageModel() {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- this.engageAllCells();
- }
-
- /**
- * Convert the objects into rows and listen to the cells.
- */
- private void engageAllCells() {
- this.rows.ensureCapacity(this.listHolder.size());
- for (Iterator<? extends E> stream = this.listHolder.iterator(); stream.hasNext(); ) {
- WritablePropertyValueModel<Object>[] row = this.columnAdapter.cellModels(stream.next());
- this.engageRow(row);
- this.rows.add(row);
- }
- }
-
- /**
- * Listen to the cells in the specified row.
- */
- private void engageRow(WritablePropertyValueModel<Object>[] row) {
- for (int i = row.length; i-- > 0; ) {
- row[i].addPropertyChangeListener(PropertyValueModel.VALUE, this.cellListener);
- }
- }
-
- /**
- * Stop listening.
- */
- private void disengageModel() {
- this.disengageAllCells();
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
- private void disengageAllCells() {
- for (WritablePropertyValueModel<Object>[] row : this.rows) {
- this.disengageRow(row);
- }
- this.rows.clear();
- }
-
- private void disengageRow(WritablePropertyValueModel<Object>[] row) {
- for (int i = row.length; i-- > 0; ) {
- row[i].removePropertyChangeListener(PropertyValueModel.VALUE, this.cellListener);
- }
- }
-
- /**
- * brute-force search for the cell(s) that changed...
- */
- void cellChanged(WritablePropertyValueModel<Object> cellHolder) {
- for (int i = this.rows.size(); i-- > 0; ) {
- WritablePropertyValueModel<Object>[] row = this.rows.get(i);
- for (int j = row.length; j-- > 0; ) {
- if (row[j] == cellHolder) {
- this.fireTableCellUpdated(i, j);
- }
- }
- }
- }
-
- /**
- * convert the items to rows
- */
- void addRows(int index, int size, Iterator<Object> items) {
- List<WritablePropertyValueModel<Object>[]> newRows = new ArrayList<WritablePropertyValueModel<Object>[]>(size);
- while (items.hasNext()) {
- WritablePropertyValueModel<Object>[] row = this.columnAdapter.cellModels(items.next());
- this.engageRow(row);
- newRows.add(row);
- }
- this.rows.addAll(index, newRows);
- this.fireTableRowsInserted(index, index + size - 1);
- }
-
- void removeRows(int index, int size) {
- for (int i = 0; i < size; i++) {
- this.disengageRow(this.rows.remove(index));
- }
- this.fireTableRowsDeleted(index, index + size - 1);
- }
-
- void replaceRows(int index, Iterator<Object> items) {
- int i = index;
- while (items.hasNext()) {
- WritablePropertyValueModel<Object>[] row = this.rows.get(i);
- this.disengageRow(row);
- row = this.columnAdapter.cellModels(items.next());
- this.engageRow(row);
- this.rows.set(i, row);
- i++;
- }
- this.fireTableRowsUpdated(index, i - 1);
- }
-
- void moveRows(int targetIndex, int sourceIndex, int length) {
- ArrayList<WritablePropertyValueModel<Object>[]> temp = new ArrayList<WritablePropertyValueModel<Object>[]>(length);
- for (int i = 0; i < length; i++) {
- temp.add(this.rows.remove(sourceIndex));
- }
- this.rows.addAll(targetIndex, temp);
-
- int start = Math.min(targetIndex, sourceIndex);
- int end = Math.max(targetIndex, sourceIndex) + length - 1;
- this.fireTableRowsUpdated(start, end);
- }
-
- void clearTable() {
- this.disengageAllCells();
- this.fireTableDataChanged();
- }
-
- void rebuildTable() {
- this.disengageAllCells();
- this.engageAllCells();
- this.fireTableDataChanged();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ToggleButtonModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ToggleButtonModelAdapter.java
deleted file mode 100644
index 4673babc36..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ToggleButtonModelAdapter.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import java.awt.event.ActionListener;
-import java.awt.event.ItemListener;
-
-import javax.swing.JToggleButton.ToggleButtonModel;
-import javax.swing.event.ChangeListener;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * This javax.swing.ButtonModel can be used to keep a listener
- * (e.g. a JCheckBox or a JRadioButton) in synch with a PropertyValueModel
- * on a boolean.
- */
-public class ToggleButtonModelAdapter
- extends ToggleButtonModel
-{
- /**
- * The default setting for the toggle button; for when the underlying model is null.
- * The default [default value] is false (i.e. the toggle button is unchecked/empty).
- */
- protected final boolean defaultValue;
-
- /** A value model on the underlying model boolean. */
- protected final WritablePropertyValueModel<Boolean> booleanHolder;
-
- /**
- * A listener that allows us to synchronize with
- * changes made to the underlying model boolean.
- */
- protected final PropertyChangeListener booleanChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the boolean holder is required.
- */
- public ToggleButtonModelAdapter(WritablePropertyValueModel<Boolean> booleanHolder, boolean defaultValue) {
- super();
- if (booleanHolder == null) {
- throw new NullPointerException();
- }
- this.booleanHolder = booleanHolder;
- this.booleanChangeListener = this.buildBooleanChangeListener();
- // postpone listening to the underlying model
- // until we have listeners ourselves...
- this.defaultValue = defaultValue;
- }
-
- /**
- * Constructor - the boolean holder is required.
- * The default value will be false.
- */
- public ToggleButtonModelAdapter(WritablePropertyValueModel<Boolean> booleanHolder) {
- this(booleanHolder, false);
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildBooleanChangeListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildBooleanChangeListener_());
- }
-
- protected PropertyChangeListener buildBooleanChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- ToggleButtonModelAdapter.this.booleanChanged(event);
- }
- @Override
- public String toString() {
- return "boolean listener";
- }
- };
- }
-
-
- // ********** ButtonModel implementation **********
-
- /**
- * Extend to update the underlying model if necessary.
- */
- @Override
- public void setSelected(boolean b) {
- if (this.isSelected() != b) { // stop the recursion!
- super.setSelected(b);//put the super call first, otherwise the following gets called twice
- this.booleanHolder.setValue(Boolean.valueOf(b));
- }
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addActionListener(ActionListener l) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addActionListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model if appropriate.
- */
- @Override
- public void removeActionListener(ActionListener l) {
- super.removeActionListener(l);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addItemListener(ItemListener l) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addItemListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model if appropriate.
- */
- @Override
- public void removeItemListener(ItemListener l) {
- super.removeItemListener(l);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addChangeListener(ChangeListener l) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addChangeListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model if appropriate.
- */
- @Override
- public void removeChangeListener(ChangeListener l) {
- super.removeChangeListener(l);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether we have no listeners at all.
- */
- protected boolean hasNoListeners() {
- return this.listenerList.getListenerCount() == 0;
- }
-
- protected boolean getDefaultValue() {
- return this.defaultValue;
- }
-
-
- // ********** behavior **********
-
- /**
- * Synchronize with the specified value.
- * If it is null, use the default value (which is typically false).
- */
- protected void setSelected(Boolean value) {
- if (value == null) {
- this.setSelected(this.getDefaultValue());
- } else {
- this.setSelected(value.booleanValue());
- }
- }
-
- /**
- * The underlying model has changed - synchronize accordingly.
- */
- protected void booleanChanged(PropertyChangeEvent event) {
- this.setSelected((Boolean) event.getNewValue());
- }
-
- protected void engageModel() {
- this.booleanHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.booleanChangeListener);
- this.setSelected(this.booleanHolder.getValue());
- }
-
- protected void disengageModel() {
- this.booleanHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.booleanChangeListener);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.booleanHolder);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TreeModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TreeModelAdapter.java
deleted file mode 100644
index 0d3ea8a683..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TreeModelAdapter.java
+++ /dev/null
@@ -1,724 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.model.value.swing;
-
-import java.util.ArrayList;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.TreePath;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTListChangeListenerWrapper;
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.utility.internal.model.listener.awt.AWTStateChangeListenerWrapper;
-import org.eclipse.jpt.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.TreeNodeValueModel;
-
-/**
- * This javax.swing.tree.TreeModel can be used to keep a TreeModelListener
- * (e.g. a JTree) in synch with a tree of TreeNodeValueModel objects. Unlike
- * javax.swing.tree.DefaultTreeModel, you do not add and remove nodes with
- * methods implemented here. You can add and remove nodes by adding and
- * removing them directly to/from the nodes (or, more typically, the domain
- * objects the nodes are wrapping and listening to).
- *
- * Due to limitations in JTree, the root of the tree can never be null,
- * which, typically, should not be a problem. (If you want to display an empty
- * tree you can set the JTree's treeModel to null.)
- */
-public class TreeModelAdapter<T>
- extends AbstractTreeModel
-{
- /**
- * A value model on the underlying tree's root node and its
- * corresponding listener. This allows clients to swap out
- * the entire tree. Due to limitations in JTree, the root should
- * never be set to null while we have listeners.
- */
- private final PropertyValueModel<TreeNodeValueModel<T>> rootHolder;
- private final PropertyChangeListener rootListener;
-
- /**
- * A listener that notifies us when a node's internal
- * "state" changes (as opposed to the node's value or list of
- * children), allowing us to forward notification to our listeners.
- */
- private final StateChangeListener nodeStateListener;
-
- /**
- * A listener that notifies us when a node's "value"
- * changes (as opposed to the node's state or list of
- * children), allowing us to forward notification to our listeners.
- * Typically, this will only happen with nodes that hold
- * primitive data.
- */
- private final PropertyChangeListener nodeValueListener;
-
- /**
- * A listener that notifies us when an underlying node's
- * "list" of children changes, allowing us to keep our
- * internal tree in synch with the underlying tree model.
- */
- private final ListChangeListener childrenListener;
-
- /* these attributes make up our internal tree */
- /**
- * The root cannot be null while we have listeners, which is
- * most of the time. The root is cached so we can disengage
- * from it when it has been swapped out.
- */
- private TreeNodeValueModel<T> root;
-
- /**
- * Map the nodes to their lists of children.
- * We cache these so we can swap out the entire list of children
- * when we receive a #listChanged() event (which does not include
- * the items that were affected).
- * @see EventChangePolicy#rebuildChildren()
- */
- final IdentityHashMap<TreeNodeValueModel<T>, List<TreeNodeValueModel<T>>> childrenLists;
-
- /**
- * Map the children models to their parents.
- * We cache these so we can figure out the "real" source of the
- * list change events (the parent).
- * @see EventChangePolicy#parent()
- */
- final IdentityHashMap<ListValueModel<TreeNodeValueModel<T>>, TreeNodeValueModel<T>> parents;
-
-
- // ********** constructors **********
-
- /**
- * Construct a tree model for the specified root.
- */
- public TreeModelAdapter(PropertyValueModel<TreeNodeValueModel<T>> rootHolder) {
- super();
- if (rootHolder == null) {
- throw new NullPointerException();
- }
- this.rootHolder = rootHolder;
- this.rootListener = this.buildRootListener();
- this.nodeStateListener = this.buildNodeStateListener();
- this.nodeValueListener = this.buildNodeValueListener();
- this.childrenListener = this.buildChildrenListener();
- this.childrenLists = new IdentityHashMap<TreeNodeValueModel<T>, List<TreeNodeValueModel<T>>>();
- this.parents = new IdentityHashMap<ListValueModel<TreeNodeValueModel<T>>, TreeNodeValueModel<T>>();
- }
-
- /**
- * Construct a tree model for the specified root.
- */
- public TreeModelAdapter(TreeNodeValueModel<T> root) {
- this(new StaticPropertyValueModel<TreeNodeValueModel<T>>(root));
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildRootListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildRootListener_());
- }
-
- protected PropertyChangeListener buildRootListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- TreeModelAdapter.this.rootChanged();
- }
- @Override
- public String toString() {
- return "root listener";
- }
- };
- }
-
- protected PropertyChangeListener buildNodeValueListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildNodeValueListener_());
- }
-
- protected PropertyChangeListener buildNodeValueListener_() {
- return new PropertyChangeListener() {
- @SuppressWarnings("unchecked")
- public void propertyChanged(PropertyChangeEvent event) {
- TreeModelAdapter.this.nodeChanged((TreeNodeValueModel<T>) event.getSource());
- }
- @Override
- public String toString() {
- return "node value listener";
- }
- };
- }
-
- protected StateChangeListener buildNodeStateListener() {
- return new AWTStateChangeListenerWrapper(this.buildNodeStateListener_());
- }
-
- protected StateChangeListener buildNodeStateListener_() {
- return new StateChangeListener() {
- @SuppressWarnings("unchecked")
- public void stateChanged(StateChangeEvent event) {
- TreeModelAdapter.this.nodeChanged((TreeNodeValueModel<T>) event.getSource());
- }
- @Override
- public String toString() {
- return "node state listener";
- }
- };
- }
-
- protected ListChangeListener buildChildrenListener() {
- return new AWTListChangeListenerWrapper(this.buildChildrenListener_());
- }
-
- protected ListChangeListener buildChildrenListener_() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent event) {
- new EventChangePolicy(event).addChildren();
- }
- public void itemsRemoved(ListChangeEvent event) {
- new EventChangePolicy(event).removeChildren();
- }
- public void itemsReplaced(ListChangeEvent event) {
- new EventChangePolicy(event).replaceChildren();
- }
- public void itemsMoved(ListChangeEvent event) {
- new EventChangePolicy(event).moveChildren();
- }
- public void listCleared(ListChangeEvent event) {
- new EventChangePolicy(event).clearChildren();
- }
- public void listChanged(ListChangeEvent event) {
- new EventChangePolicy(event).rebuildChildren();
- }
- @Override
- public String toString() {
- return "children listener";
- }
- };
- }
-
-
- // ********** TreeModel implementation **********
-
- public Object getRoot() {
- return this.root;
- }
-
- @SuppressWarnings("unchecked")
- public Object getChild(Object parent, int index) {
- return ((TreeNodeValueModel<T>) parent).child(index);
- }
-
- @SuppressWarnings("unchecked")
- public int getChildCount(Object parent) {
- return ((TreeNodeValueModel<T>) parent).childrenSize();
- }
-
- @SuppressWarnings("unchecked")
- public boolean isLeaf(Object node) {
- return ((TreeNodeValueModel<T>) node).isLeaf();
- }
-
- @SuppressWarnings("unchecked")
- public void valueForPathChanged(TreePath path, Object newValue) {
- ((TreeNodeValueModel<T>) path.getLastPathComponent()).setValue((T) newValue);
- }
-
- @SuppressWarnings("unchecked")
- public int getIndexOfChild(Object parent, Object child) {
- return ((TreeNodeValueModel<T>) parent).indexOfChild((TreeNodeValueModel<T>) child);
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addTreeModelListener(TreeModelListener l) {
- if (this.hasNoTreeModelListeners()) {
- this.engageModel();
- }
- super.addTreeModelListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model if appropriate.
- */
- @Override
- public void removeTreeModelListener(TreeModelListener l) {
- super.removeTreeModelListener(l);
- if (this.hasNoTreeModelListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * Listen to the root and all the other nodes
- * in the underlying tree model.
- */
- private void engageModel() {
- this.rootHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.rootListener);
- this.root = this.rootHolder.getValue();
- if (this.root == null) {
- throw new NullPointerException(); // the root cannot be null while we have listeners
- }
- this.engageNode(this.root);
- this.addRoot();
- }
-
- /**
- * Add the root and all of the nodes to the underlying tree.
- */
- private void addRoot() {
- this.addNode(0, this.root);
- }
-
- /**
- * Stop listening to the root and all the other
- * nodes in the underlying tree model.
- */
- private void disengageModel() {
- this.removeRoot();
- this.disengageNode(this.root);
- this.root = null;
- this.rootHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.rootListener);
- }
-
- /**
- * Remove the root and all of the nodes from the underlying tree.
- */
- private void removeRoot() {
- this.removeNode(0, this.root);
- }
-
- /**
- * The root has been swapped.
- * This method is a bit gnarly because the API for notifying listeners
- * that the root has changed is a bit inconsistent with that used for
- * non-root nodes.
- */
- void rootChanged() {
- TreeNodeValueModel<T> newRoot = this.rootHolder.getValue();
- if (newRoot == null) {
- throw new NullPointerException(); // the root cannot be null while we have listeners
- }
- // remove all the current root's children from the tree
- // and remove the it from the internal tree
- this.removeRoot();
-
- // save the old root and swap in the new root
- TreeNodeValueModel<T> oldRoot = this.root;
- this.root = newRoot;
-
- // we must be listening to both the old and new roots when we fire the event
- // because their values can be affected by whether they have listeners
- this.engageNode(this.root);
- this.fireTreeRootReplaced(this.root);
- // now we can stop listening to the old root
- this.disengageNode(oldRoot);
-
- // add the new root to the internal tree and
- // add all its children to the tree also
- this.addRoot();
- }
-
- /**
- * Either the "value" or the "state" of the specified node has changed,
- * forward notification to our listeners.
- */
- void nodeChanged(TreeNodeValueModel<T> node) {
- TreeNodeValueModel<T> parent = node.parent();
- if (parent == null) {
- this.fireTreeRootChanged(node);
- } else {
- this.fireTreeNodeChanged(parent.path(), parent.indexOfChild(node), node);
- }
- }
-
- /**
- * Listen to the nodes, notify our listeners that the nodes were added,
- * and then add the nodes to our internal tree.
- * We must listen to the nodes before notifying anybody, because
- * adding a listener can change the value of a node.
- */
- void addChildren(TreeNodeValueModel<T>[] path, int[] childIndices, TreeNodeValueModel<T>[] children) {
- int len = childIndices.length;
- for (int i = 0; i < len; i++) {
- this.engageNode(children[i]);
- }
- this.fireTreeNodesInserted(path, childIndices, children);
- for (int i = 0; i < len; i++) {
- this.addNode(childIndices[i], children[i]);
- }
- }
-
- /**
- * Listen to the node and its children model.
- */
- private void engageNode(TreeNodeValueModel<T> node) {
- node.addStateChangeListener(this.nodeStateListener);
- node.addPropertyChangeListener(PropertyValueModel.VALUE, this.nodeValueListener);
- node.childrenModel().addListChangeListener(ListValueModel.LIST_VALUES, this.childrenListener);
- }
-
- /**
- * Add the node to our internal tree;
- * then recurse down through the node's children,
- * adding them to the internal tree also.
- */
- private void addNode(int index, TreeNodeValueModel<T> node) {
- this.addNodeToInternalTree(node.parent(), index, node, node.childrenModel());
- new NodeChangePolicy(node).addChildren();
- }
-
- /**
- * Add the specified node to our internal tree.
- */
- private void addNodeToInternalTree(TreeNodeValueModel<T> parent, int index, TreeNodeValueModel<T> node, ListValueModel<TreeNodeValueModel<T>> childrenModel) {
- List<TreeNodeValueModel<T>> siblings = this.childrenLists.get(parent);
- if (siblings == null) {
- siblings = new ArrayList<TreeNodeValueModel<T>>();
- this.childrenLists.put(parent, siblings);
- }
- siblings.add(index, node);
-
- this.parents.put(childrenModel, node);
- }
-
- /**
- * Remove nodes from our internal tree, notify our listeners that the
- * nodes were removed, then stop listening to the nodes.
- * We must listen to the nodes until after notifying anybody, because
- * removing a listener can change the value of a node.
- */
- void removeChildren(TreeNodeValueModel<T>[] path, int[] childIndices, TreeNodeValueModel<T>[] children) {
- int len = childIndices.length;
- for (int i = 0; i < len; i++) {
- // the indices slide down a notch each time we remove a child
- this.removeNode(childIndices[i] - i, children[i]);
- }
- this.fireTreeNodesRemoved(path, childIndices, children);
- for (int i = 0; i < len; i++) {
- this.disengageNode(children[i]);
- }
- }
-
- /**
- * First, recurse down through the node's children,
- * removing them from our internal tree;
- * then remove the node itself from our internal tree.
- */
- private void removeNode(int index, TreeNodeValueModel<T> node) {
- new NodeChangePolicy(node).removeChildren();
- this.removeNodeFromInternalTree(node.parent(), index, node, node.childrenModel());
- }
-
- /**
- * Remove the specified node from our internal tree.
- */
- private void removeNodeFromInternalTree(TreeNodeValueModel<T> parent, int index, TreeNodeValueModel<T> node, ListValueModel<TreeNodeValueModel<T>> childrenModel) {
- this.parents.remove(childrenModel);
-
- List<TreeNodeValueModel<T>> siblings = this.childrenLists.get(parent);
- siblings.remove(index);
- if (siblings.isEmpty()) {
- this.childrenLists.remove(parent);
- }
- }
-
- /**
- * Stop listening to the node and its children model.
- */
- private void disengageNode(TreeNodeValueModel<T> node) {
- node.childrenModel().removeListChangeListener(ListValueModel.LIST_VALUES, this.childrenListener);
- node.removePropertyChangeListener(PropertyValueModel.VALUE, this.nodeValueListener);
- node.removeStateChangeListener(this.nodeStateListener);
- }
-
- void moveChildren(TreeNodeValueModel<T> parent, int targetIndex, int sourceIndex, int length) {
- List<TreeNodeValueModel<T>> childrenList = this.childrenLists.get(parent);
- ArrayList<TreeNodeValueModel<T>> temp = new ArrayList<TreeNodeValueModel<T>>(length);
- for (int i = 0; i < length; i++) {
- temp.add(childrenList.remove(sourceIndex));
- }
- childrenList.addAll(targetIndex, temp);
-
- this.fireTreeStructureChanged(parent.path());
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.root);
- }
-
-
- // ********** inner classes **********
-
- /**
- * Coalesce some of the common change policy behavior.
- */
- private abstract class ChangePolicy {
-
- ChangePolicy() {
- super();
- }
-
- /**
- * Add the current set of children.
- */
- void addChildren() {
- TreeModelAdapter.this.addChildren(this.parent().path(), this.childIndices(), this.childArray());
- }
-
- /**
- * Remove the current set of children.
- */
- void removeChildren() {
- TreeModelAdapter.this.removeChildren(this.parent().path(), this.childIndices(), this.childArray());
- }
-
- /**
- * Return an array of the indices of the current set of children,
- * which should be contiguous.
- */
- int[] childIndices() {
- return this.buildIndices(this.childrenStartIndex(), this.childrenSize());
- }
-
- /**
- * Return an array of the current set of children.
- */
- TreeNodeValueModel<T>[] childArray() {
- return this.buildArray(this.children(), this.childrenSize());
- }
-
- /**
- * Build an array to hold the elements in the specified iterator.
- * If they are different sizes, something is screwed up...
- */
- TreeNodeValueModel<T>[] buildArray(Iterator<TreeNodeValueModel<T>> stream, int size) {
- @SuppressWarnings("unchecked")
- TreeNodeValueModel<T>[] array = new TreeNodeValueModel[size];
- for (int i = 0; stream.hasNext(); i++) {
- array[i] = stream.next();
- }
- return array;
- }
-
- /**
- * Return a set of indices, starting at zero and
- * continuing for the specified size.
- */
- int[] buildIndices(int size) {
- return buildIndices(0, size);
- }
-
- /**
- * Return a set of indices, starting at the specified index and
- * continuing for the specified size.
- */
- int[] buildIndices(int start, int size) {
- int[] indices = new int[size];
- int index = start;
- for (int i = 0; i < size; i++) {
- indices[i] = index++;
- }
- return indices;
- }
-
- /**
- * Return the parent of the current set of children.
- */
- abstract TreeNodeValueModel<T> parent();
-
- /**
- * Return the starting index for the current set of children.
- */
- abstract int childrenStartIndex();
-
- /**
- * Return the size of the current set of children.
- */
- abstract int childrenSize();
-
- /**
- * Return an interator on the current set of children.
- */
- abstract Iterator<TreeNodeValueModel<T>> children();
-
- }
-
-
- /**
- * Wraps a ListChangeEvent for adding, removing, replacing,
- * and changing children.
- */
- private class EventChangePolicy extends ChangePolicy {
- private ListChangeEvent event;
-
- EventChangePolicy(ListChangeEvent event) {
- this.event = event;
- }
-
- /**
- * Map the ListChangeEvent's source to the corresponding parent.
- */
- @Override
- TreeNodeValueModel<T> parent() {
- return TreeModelAdapter.this.parents.get(this.event.getSource());
- }
-
- /**
- * The ListChangeEvent's item index is the children start index.
- */
- @Override
- int childrenStartIndex() {
- return this.event.getIndex();
- }
-
- /**
- * The ListChangeEvent's size is the children size.
- */
- @Override
- int childrenSize() {
- return this.event.itemsSize();
- }
-
- /**
- * The ListChangeEvent's items are the children.
- */
- @Override
- @SuppressWarnings("unchecked")
- Iterator<TreeNodeValueModel<T>> children() {
- return (Iterator<TreeNodeValueModel<T>>) this.event.items();
- }
-
- /**
- * Remove the old nodes and add the new ones.
- */
- void replaceChildren() {
- TreeNodeValueModel<T>[] parentPath = this.parent().path();
- int[] childIndices = this.childIndices();
- TreeModelAdapter.this.removeChildren(parentPath, childIndices, this.replacedChildren());
- TreeModelAdapter.this.addChildren(parentPath, childIndices, this.childArray());
- }
-
- /**
- * Remove the old nodes and add the new ones.
- */
- void moveChildren() {
- TreeModelAdapter.this.moveChildren(this.parent(), this.event.getTargetIndex(), this.event.getSourceIndex(), this.event.getMoveLength());
- }
-
- /**
- * Clear all the nodes.
- */
- void clearChildren() {
- TreeNodeValueModel<T> parent = this.parent();
- TreeNodeValueModel<T>[] parentPath = parent.path();
- List<TreeNodeValueModel<T>> childrenList = TreeModelAdapter.this.childrenLists.get(parent);
- int[] childIndices = this.buildIndices(childrenList.size());
- TreeNodeValueModel<T>[] childArray = this.buildArray(childrenList.iterator(), childrenList.size());
- TreeModelAdapter.this.removeChildren(parentPath, childIndices, childArray);
- }
-
- /**
- * Remove all the old nodes and add all the new nodes.
- */
- void rebuildChildren() {
- TreeNodeValueModel<T> parent = this.parent();
- TreeNodeValueModel<T>[] parentPath = parent.path();
- List<TreeNodeValueModel<T>> childrenList = TreeModelAdapter.this.childrenLists.get(parent);
- int[] childIndices = this.buildIndices(childrenList.size());
- TreeNodeValueModel<T>[] childArray = this.buildArray(childrenList.iterator(), childrenList.size());
- TreeModelAdapter.this.removeChildren(parentPath, childIndices, childArray);
-
- childIndices = this.buildIndices(parent.childrenModel().size());
- childArray = this.buildArray(parent.childrenModel().iterator(), parent.childrenSize());
- TreeModelAdapter.this.addChildren(parentPath, childIndices, childArray);
- }
-
- /**
- * The ListChangeEvent's replaced items are the replaced children.
- */
- @SuppressWarnings("unchecked")
- TreeNodeValueModel<T>[] replacedChildren() {
- return this.buildArray((Iterator<TreeNodeValueModel<T>>) this.event.replacedItems(), this.event.itemsSize());
- }
-
- }
-
-
- /**
- * Wraps a TreeNodeValueModel for adding and removing its children.
- */
- private class NodeChangePolicy extends ChangePolicy {
- private TreeNodeValueModel<T> node;
-
- NodeChangePolicy(TreeNodeValueModel<T> node) {
- this.node = node;
- }
-
- /**
- * The node itself is the parent.
- */
- @Override
- TreeNodeValueModel<T> parent() {
- return this.node;
- }
-
- /**
- * Since we will always be dealing with all of the node's
- * children, the children start index is always zero.
- */
- @Override
- int childrenStartIndex() {
- return 0;
- }
-
- /**
- * Since we will always be dealing with all of the node's
- * children, the children size is always equal to the size
- * of the children model.
- */
- @Override
- int childrenSize() {
- return this.node.childrenModel().size();
- }
-
- /**
- * Since we will always be dealing with all of the node's
- * children, the children are all the objects held by
- * the children model.
- */
- @Override
- Iterator<TreeNodeValueModel<T>> children() {
- return this.node.childrenModel().iterator();
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AbstractNode.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AbstractNode.java
deleted file mode 100644
index 845237bf90..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AbstractNode.java
+++ /dev/null
@@ -1,941 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.node;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-import java.util.Vector;
-
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.CallbackChangeSupport;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-
-/**
- * Base class for Node classes.
- * Provides support for the following:
- * initialization
- * enforced object identity wrt #equals()/#hashCode()
- * containment hierarchy (parent/child)
- * user comment
- * dirty flag
- * problems
- * sorting
- *
- * Typically, subclasses should consider implementing the following methods:
- * the appropriate constructors
- * (with the appropriately-restrictive type declaration for parent)
- * #initialize()
- * #initialize(Node parentNode)
- * #checkParent(Node parentNode)
- * #addChildrenTo(List list)
- * #nodeRemoved(Node)
- * #validator()
- * #transientAspectNames() or
- * #addTransientAspectNamesTo(Set transientAspectNames)
- * #addProblemsTo(List currentProblems)
- * #nonValidatedAspectNames()
- * #addNonValidatedAspectNamesTo(Set nonValidatedAspectNames)
- * #displayString()
- * #toString(StringBuilder sb)
- */
-public abstract class AbstractNode
- extends AbstractModel
- implements Node, CallbackChangeSupport.Source
-{
-
- /** Containment hierarchy. */
- private Node parent; // pseudo-final
-
- /** Track whether the node has changed. */
- private volatile boolean dirty;
- private volatile boolean dirtyBranch;
-
- /**
- * The node's problems, as calculated during validation.
- * This list should only be modified via a ProblemSynchronizer,
- * allowing for asynchronous modification from another thread.
- */
- private Vector<Problem> problems; // pseudo-final
- private static final Object[] EMPTY_PROBLEM_MESSAGE_ARGUMENTS = new Object[0];
-
- /**
- * Cache the node's "branch" problems, as calculated during validation.
- * This list should only be modified via a ProblemSynchronizer,
- * allowing for asynchronous modification from another thread.
- * This must be recalculated every time this node or one of its
- * descendants changes it problems.
- */
- private Vector<Problem> branchProblems; // pseudo-final
-
- /** User comment. */
- private volatile String comment;
-
-
- // ********** static fields **********
-
- /**
- * Sets of transient aspect names, keyed by class.
- * This is built up lazily, as the objects are modified.
- */
- private static final HashMap<Class<? extends AbstractNode>, HashSet<String>> transientAspectNameSets = new HashMap<Class<? extends AbstractNode>, HashSet<String>>();
-
- /**
- * Sets of non-validated aspect names, keyed by class.
- * This is built up lazily, as the objects are modified.
- */
- private static final HashMap<Class<? extends AbstractNode>, HashSet<String>> nonValidatedAspectNameSets = new HashMap<Class<? extends AbstractNode>, HashSet<String>>();
-
-
- // ********** constructors **********
-
- /**
- * Most objects must have a parent.
- * Use this constructor to create a new node.
- * @see #initialize(Node)
- */
- protected AbstractNode(Node parent) {
- super();
- this.initialize(parent);
- }
-
-
- // ********** initialization **********
-
- /**
- * Initialize a newly-created instance.
- * @see #initialize(Node)
- */
- @Override
- protected void initialize() {
- super.initialize();
- this.comment = "";
-
- // a new object is dirty, by definition
- this.dirty = true;
- this.dirtyBranch = true;
-
- this.problems = new Vector<Problem>();
- this.branchProblems = new Vector<Problem>();
-
- // when you override this method, don't forget to include:
- // super.initialize();
- }
-
- /**
- * Initialize a newly-created instance.
- * @see #initialize()
- */
- protected void initialize(Node parentNode) {
- this.checkParent(parentNode);
- this.parent = parentNode;
- // when you override this method, don't forget to include:
- // super.initialize(parentNode);
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new CallbackChangeSupport(this);
- }
-
-
- // ********** equality **********
-
- /**
- * Enforce object identity - do not allow objects to be equal unless
- * they are the same object.
- * Do NOT override this method - we rely on object identity extensively.
- */
- @Override
- public final boolean equals(Object o) {
- return this == o;
- }
-
- /**
- * Enforce object identity - do not allow objects to be equal unless
- * they are the same object.
- * Do NOT override this method - we rely on object identity extensively.
- */
- @Override
- public final int hashCode() {
- return super.hashCode();
- }
-
-
- // ********** containment hierarchy (parent/children) **********
-
- /**
- * INTRA-TREE API?
- * Return the node's parent in the containment hierarchy.
- * Most nodes must have a parent.
- * @see #children()
- */
- public Node getParent() {
- return this.parent;
- }
-
- /**
- * Throw an IllegalArgumentException if the parent is not valid
- * for the node.
- * By default require a non-null parent. Override if other restrictions exist
- * or the parent should be null.
- * NB: Root node model implementations will need to override this method.
- */
- protected void checkParent(Node parentNode) {
- if (parentNode == null) {
- throw new IllegalArgumentException("The parent node cannot be null");
- }
- }
-
- /**
- * INTRA-TREE API?
- * Return the node's children, which are also nodes.
- * Do NOT override this method.
- * Override #addChildrenTo(List).
- * @see #getParent()
- * @see #addChildrenTo(java.util.List)
- */
- public final Iterator<Node> children() {
- List<Node> children = new ArrayList<Node>();
- this.addChildrenTo(children);
- return children.iterator();
- }
-
- /**
- * Subclasses should override this method to add their children
- * to the specified list.
- * @see #children()
- */
- protected void addChildrenTo(List<Node> list) {
- // this class has no children, subclasses will...
- // when you override this method, don't forget to include:
- // super.addChildrenTo(list);
- }
-
- /**
- * INTRA-TREE API?
- * Return the containment hierarchy's root node.
- * Most nodes must have a root.
- * @see #getParent()
- * NB: Assume the root has no parent.
- */
- public Node root() {
- Node p = this.parent;
- return (p == null) ? this : p.root();
- }
-
- /**
- * Return whether the node is a descendant of the specified node.
- * By definition, a node is a descendant of itself.
- */
- public boolean isDescendantOf(Node node) {
- return (this == node) || this.parentIsDescendantOf(node);
- }
-
- protected boolean parentIsDescendantOf(Node node) {
- return (this.parent != null) && this.parent.isDescendantOf(node);
- }
-
- /**
- * Return a collection holding all the node's "references", and all
- * the node's descendants' "references". "References" are
- * objects that are "referenced" by another object, as opposed
- * to "owned" by another object.
- */
- public Iterator<Node.Reference> branchReferences() {
- Collection<Node.Reference> branchReferences = new ArrayList<Node.Reference>(1000); // start big
- this.addBranchReferencesTo(branchReferences);
- return branchReferences.iterator();
- }
-
- /**
- * INTRA-TREE API
- * Add the node's "references", and all the node's descendants'
- * "references", to the specified collection. "References" are
- * objects that are "referenced" by another object, as opposed
- * to "owned" by another object.
- * This method is of particular concern to Handles, since most
- * (hopefully all) "references" are held by Handles.
- * @see Reference
- * @see #children()
- */
- public void addBranchReferencesTo(Collection<Node.Reference> branchReferences) {
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.addBranchReferencesTo(branchReferences);
- }
- }
-
- /**
- * Return all the nodes in the object's branch of the tree,
- * including the node itself. The nodes will probably returned
- * in "depth-first" order.
- * Only really used for testing and debugging.
- */
- public Iterator<Node> allNodes() {
- Collection<Node> nodes = new ArrayList<Node>(1000); // start big
- this.addAllNodesTo(nodes);
- return nodes.iterator();
- }
-
- /**
- * INTRA-TREE API?
- * Add all the nodes in the object's branch of the tree,
- * including the node itself, to the specified collection.
- * Only really used for testing and debugging.
- */
- public void addAllNodesTo(Collection<Node> nodes) {
- nodes.add(this);
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.addAllNodesTo(nodes);
- }
- }
-
-
- // ********** model synchronization support **********
-
- /**
- * INTRA-TREE API
- * This is a general notification that the specified node has been
- * removed from the tree. The node receiving this notification
- * should perform any necessary updates to remain in synch
- * with the tree (e.g. clearing out or replacing any references
- * to the removed node or any of the removed node's descendants).
- * @see #isDescendantOf(Node)
- */
- public void nodeRemoved(Node node) {
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.nodeRemoved(node);
- }
- // when you override this method, don't forget to include:
- // super.nodeRemoved(node);
- }
-
- /**
- * convenience method
- * return whether node1 is a descendant of node2;
- * node1 can be null
- */
- protected boolean nodeIsDescendantOf(Node node1, Node node2) {
- return (node1 != null) && node1.isDescendantOf(node2);
- }
-
- /**
- * INTRA-TREE API
- * This is a general notification that the specified node has been
- * renamed. The node receiving this notification should mark its
- * branch dirty if necessary (i.e. it references the renamed node
- * or one of its descendants). This method is of particular concern
- * to Handles.
- * @see #isDescendantOf(Node)
- */
- public void nodeRenamed(Node node) {
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.nodeRenamed(node);
- }
- // when you override this method, don't forget to include:
- // super.nodeRenamed(node);
- }
-
-
- // ********** user comment **********
-
- /**
- * Return the object's user comment.
- */
- public final String comment() {
- return this.comment;
- }
-
- /**
- * Set the object's user comment.
- */
- public final void setComment(String comment) {
- Object old = this.comment;
- this.comment = comment;
- this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
- }
-
-
- // ********** change support **********
-
- /**
- * An aspect of the node has changed:
- * - if it is a persistent aspect, mark the object dirty
- * - if it is a significant aspect, validate the object
- */
- public void aspectChanged(String aspectName) {
- if (this.aspectIsPersistent(aspectName)) {
- // System.out.println(Thread.currentThread() + " dirty change: " + this + ": " + aspectName);
- this.markDirty();
- }
- if (this.aspectChangeRequiresValidation(aspectName)) {
- // System.out.println(Thread.currentThread() + " validation change: " + this + ": " + aspectName);
- this.validate();
- }
- }
-
- protected void validate() {
- this.getValidator().validate();
- }
-
- /**
- * INTRA-TREE API
- * Return a validator that will be invoked whenever a
- * "validated" aspect of the node tree changes.
- * Typically only the root node directly holds a validator.
- * NB: Root node model implementations will need to override this method.
- */
- public Node.Validator getValidator() {
- if (this.parent == null) {
- throw new IllegalStateException("This node should not be firing change events during its construction.");
- }
- return this.parent.getValidator();
- }
-
- /**
- * Set a validator that will be invoked whenever a
- * "validated" aspect of the node tree changes.
- * Typically only the root node directly holds a validator.
- * NB: Root node model implementations will need to override this method.
- */
- public void setValidator(Node.Validator validator) {
- if (this.parent == null) {
- throw new IllegalStateException("This root node should implement #setValidator(Node.Validator).");
- }
- throw new UnsupportedOperationException("Only root nodes implement #setValidator(Node.Validator).");
- }
-
-
- // ********** dirty flag support **********
-
- /**
- * Return whether any persistent aspects of the object
- * have changed since the object was last read or saved.
- * This does NOT include changes to the object's descendants.
- */
- public final boolean isDirty() {
- return this.dirty;
- }
-
- /**
- * Return whether any persistent aspects of the object,
- * or any of its descendants, have changed since the object and
- * its descendants were last read or saved.
- */
- public final boolean isDirtyBranch() {
- return this.dirtyBranch;
- }
-
- /**
- * Return whether the object is unmodified
- * since it was last read or saved.
- * This does NOT include changes to the object's descendants.
- */
- public final boolean isClean() {
- return ! this.dirty;
- }
-
- /**
- * Return whether the object and all of its descendants
- * are unmodified since the object and
- * its descendants were last read or saved.
- */
- public final boolean isCleanBranch() {
- return ! this.dirtyBranch;
- }
-
- /**
- * Set the dirty branch flag setting. This is set to true
- * when either the object or one of its descendants becomes dirty.
- */
- private void setIsDirtyBranch(boolean dirtyBranch) {
- boolean old = this.dirtyBranch;
- this.dirtyBranch = dirtyBranch;
- this.firePropertyChanged(DIRTY_BRANCH_PROPERTY, old, dirtyBranch);
- }
-
- /**
- * Mark the object as dirty and as a dirty branch.
- * An object is marked dirty when either a "persistent" attribute
- * has changed or its save location has changed.
- */
- private void markDirty() {
- this.dirty = true;
- this.markBranchDirty();
- }
-
- /**
- * INTRA-TREE API
- * Mark the node and its parent as dirty branches.
- * This message is propagated up the containment
- * tree when a particular node becomes dirty.
- */
- public void markBranchDirty() {
- // short-circuit any unnecessary propagation
- if (this.dirtyBranch) {
- // if this is already a dirty branch, the parent must be also
- return;
- }
-
- this.setIsDirtyBranch(true);
- this.markParentBranchDirty();
- }
-
- protected void markParentBranchDirty() {
- if (this.parent != null) {
- this.parent.markBranchDirty();
- }
- }
-
- /**
- * Mark the object and all its descendants as dirty.
- * This is used when the save location of some
- * top-level object is changed and the entire
- * containment tree must be marked dirty so it
- * will be written out.
- */
- public final void markEntireBranchDirty() {
- this.markDirty();
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.markEntireBranchDirty();
- }
- }
-
- /**
- * Mark the object and all its descendants as clean.
- * Then notify the object's parent that it (the parent)
- * might now be a clean branch also.
- * Typically used when the object has just been
- * read in or written out.
- */
- public final void markEntireBranchClean() {
- this.cascadeMarkEntireBranchClean();
- this.markParentBranchCleanIfPossible();
- }
-
- protected void markParentBranchCleanIfPossible() {
- if (this.parent != null) {
- this.parent.markBranchCleanIfPossible();
- }
- }
-
- /**
- * INTRA-TREE API
- * Mark the node and all its descendants as clean.
- * Typically used when the node has just been
- * read in or written out.
- * This method is for internal use only; it is not for
- * client use.
- * Not the best of method names.... :-(
- */
- public final void cascadeMarkEntireBranchClean() {
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.cascadeMarkEntireBranchClean();
- }
- this.dirty = false;
- this.setIsDirtyBranch(false);
- }
-
- /**
- * INTRA-TREE API
- * A child node's branch has been marked clean. If the node
- * itself is clean and if all of its children are also clean, the
- * node's branch can be marked clean. Then, if the node's
- * branch is clean, the node will notify its parent that it might
- * be clean also. This message is propagated up the containment
- * tree when a particular node becomes clean.
- */
- public final void markBranchCleanIfPossible() {
- // short-circuit any unnecessary propagation
- if (this.dirty) {
- // if the object is "locally" dirty, it is still a dirty branch
- return;
- }
-
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- if (child.isDirtyBranch()) {
- return;
- }
- }
-
- this.setIsDirtyBranch(false);
- this.markParentBranchCleanIfPossible();
- }
-
- private boolean aspectIsPersistent(String aspectName) {
- return ! this.aspectIsTransient(aspectName);
- }
-
- private boolean aspectIsTransient(String aspectName) {
- return this.transientAspectNames().contains(aspectName);
- }
-
- /**
- * Return a set of the object's transient aspect names.
- * These are the aspects that, when they change, will NOT cause the
- * object to be marked dirty.
- * If you need instance-based calculation of your transient aspects,
- * override this method. If class-based calculation is sufficient,
- * override #addTransientAspectNamesTo(Set).
- */
- protected final Set<String> transientAspectNames() {
- synchronized (transientAspectNameSets) {
- HashSet<String> transientAspectNames = transientAspectNameSets.get(this.getClass());
- if (transientAspectNames == null) {
- transientAspectNames = new HashSet<String>();
- this.addTransientAspectNamesTo(transientAspectNames);
- transientAspectNameSets.put(this.getClass(), transientAspectNames);
- }
- return transientAspectNames;
- }
- }
-
- /**
- * Add the object's transient aspect names to the specified set.
- * These are the aspects that, when they change, will NOT cause the
- * object to be marked dirty.
- * If class-based calculation of your transient aspects is sufficient,
- * override this method. If you need instance-based calculation,
- * override #transientAspectNames().
- */
- protected void addTransientAspectNamesTo(Set<String> transientAspectNames) {
- transientAspectNames.add(DIRTY_BRANCH_PROPERTY);
- transientAspectNames.add(BRANCH_PROBLEMS_LIST);
- transientAspectNames.add(HAS_BRANCH_PROBLEMS_PROPERTY);
- // when you override this method, don't forget to include:
- // super.addTransientAspectNamesTo(transientAspectNames);
- }
-
- /**
- * Return the dirty nodes in the object's branch of the tree,
- * including the node itself (if appropriate).
- * Only really used for testing and debugging.
- */
- public final Iterator<Node> allDirtyNodes() {
- return new FilteringIterator<Node, Node>(this.allNodes()) {
- @Override
- protected boolean accept(Node node) {
- return (node instanceof AbstractNode) && ((AbstractNode) node).isDirty();
- }
- };
- }
-
-
- // ********** problems **********
-
- /**
- * Return the node's problems.
- * This does NOT include the problems of the node's descendants.
- * @see #branchProblems()
- */
- public final Iterator<Problem> problems() {
- return new CloneIterator<Problem>(this.problems); // removes are not allowed
- }
-
- /**
- * Return the size of the node's problems.
- * This does NOT include the problems of the node's descendants.
- * @see #branchProblemsSize()
- */
- public final int problemsSize() {
- return this.problems.size();
- }
-
- /**
- * Return whether the node has problems
- * This does NOT include the problems of the node's descendants.
- * @see #hasBranchProblems()
- */
- public final boolean hasProblems() {
- return ! this.problems.isEmpty();
- }
-
- /**
- * Return all the node's problems along with all the
- * node's descendants' problems.
- */
- public final ListIterator<Problem> branchProblems() {
- return new CloneListIterator<Problem>(this.branchProblems); // removes are not allowed
- }
-
- /**
- * Return the size of all the node's problems along with all the
- * node's descendants' problems.
- */
- public final int branchProblemsSize() {
- return this.branchProblems.size();
- }
-
- /**
- * Return whether the node or any of its descendants have problems.
- */
- public final boolean hasBranchProblems() {
- return ! this.branchProblems.isEmpty();
- }
-
- public final boolean containsBranchProblem(Problem problem) {
- return this.branchProblems.contains(problem);
- }
-
- protected final Problem buildProblem(String messageKey, Object... messageArguments) {
- return new DefaultProblem(this, messageKey, messageArguments);
- }
-
- protected final Problem buildProblem(String messageKey) {
- return this.buildProblem(messageKey, EMPTY_PROBLEM_MESSAGE_ARGUMENTS);
- }
-
- /**
- * Validate the node and all of its descendants,
- * and update their sets of "branch" problems.
- * If the node's "branch" problems have changed,
- * notify the node's parent.
- */
- public void validateBranch() {
- if (this.validateBranchInternal()) {
- // if our "branch" problems have changed, then
- // our parent must rebuild its "branch" problems also
- this.rebuildParentBranchProblems();
- }
- }
-
- protected void rebuildParentBranchProblems() {
- if (this.parent != null) {
- this.parent.rebuildBranchProblems();
- }
- }
-
- /**
- * INTRA-TREE API
- * Validate the node and all of its descendants,
- * and update their sets of "branch" problems.
- * Return true if the collection of "branch" problems has changed.
- * This method is for internal use only; it is not for
- * client use.
- */
- public boolean validateBranchInternal() {
- // rebuild "branch" problems in children first
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- // ignore the return value because we are going to rebuild our "branch"
- // problems no matter what, to see if they have changed
- child.validateBranchInternal();
- }
-
- this.problems.clear();
- this.addProblemsTo(this.problems);
-
- return this.checkBranchProblems();
- }
-
- /**
- * Check for any problems and add them to the specified list.
- * This method should ONLY add problems for this particular node;
- * it should NOT add problems for any of this node's descendants
- * or ancestors. (Although there will be times when it is debatable
- * as to which node a problem "belongs" to....)
- *
- * NB: This method should NOT modify ANY part of the node's state!
- * It is a READ-ONLY behavior. ONLY the list of current problems
- * passed in to the method should be modified.
- */
- protected void addProblemsTo(List<Problem> currentProblems) {
- // The default is to do nothing.
- // When you override this method, don't forget to include:
- // super.addProblemsTo(currentProblems);
- }
-
- /**
- * Rebuild the "branch" problems and return whether they have
- * changed.
- * NB: The entire collection of "branch" problems must be re-calculated
- * with EVERY "significant" change - we cannot keep it in synch via
- * change notifications because if a descendant with problems is
- * removed or replaced we will not receive notification that its
- * problems were removed from our "branch" problems.
- */
- private boolean checkBranchProblems() {
- Vector<Problem> oldBranchProblems = new Vector<Problem>(this.branchProblems);
- int oldSize = this.branchProblems.size();
-
- this.branchProblems.clear();
- this.branchProblems.addAll(this.problems);
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.addBranchProblemsTo(this.branchProblems);
- }
-
- // if the size has changed to or from zero, our virtual flag has changed
- int newSize = this.branchProblems.size();
- if ((oldSize == 0) && (newSize != 0)) {
- this.firePropertyChanged(HAS_BRANCH_PROBLEMS_PROPERTY, false, true);
- } else if ((oldSize != 0) && (newSize == 0)) {
- this.firePropertyChanged(HAS_BRANCH_PROBLEMS_PROPERTY, true, false);
- }
-
- if (oldBranchProblems.equals(this.branchProblems)) {
- return false; // our "branch" problems did not change
- }
- // our "branch" problems changed
- this.fireListChanged(BRANCH_PROBLEMS_LIST);
- return true;
- }
-
- /**
- * INTRA-TREE API
- * Add all the problems of the node and all
- * the problems of its descendants to the
- * specified collection.
- */
- public final void addBranchProblemsTo(List<Problem> list) {
- list.addAll(this.branchProblems);
- }
-
- /**
- * INTRA-TREE API
- * A child node's "branch" problems changed;
- * therefore the node's "branch" problems have changed also and
- * must be rebuilt.
- */
- public final void rebuildBranchProblems() {
- if ( ! this.checkBranchProblems()) {
- throw new IllegalStateException("we should not get here unless our \"branch\" problems have changed");
- }
- this.rebuildParentBranchProblems();
- }
-
- /**
- * Clear the node's "branch" problems and the "branch"
- * problems of all of its descendants.
- * If the node's "branch" problems have changed,
- * notify the node's parent.
- */
- public final void clearAllBranchProblems() {
- if (this.clearAllBranchProblemsInternal()) {
- // if our "branch" problems have changed, then
- // our parent must rebuild its "branch" problems also
- this.rebuildParentBranchProblems();
- }
- }
-
- /**
- * INTRA-TREE API
- * Clear the node's "branch" problems and the "branch"
- * problems of all of its descendants.
- * Return true if the collection of "branch" problems has changed.
- * This method is for internal use only; it is not for
- * client use.
- */
- public final boolean clearAllBranchProblemsInternal() {
- if (this.branchProblems.isEmpty()) {
- return false;
- }
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- // ignore the return value because we are going to clear our "branch"
- // problems no matter what
- child.clearAllBranchProblemsInternal();
- }
- this.problems.clear();
- this.branchProblems.clear();
- this.firePropertyChanged(HAS_BRANCH_PROBLEMS_PROPERTY, true, false);
- this.fireListChanged(BRANCH_PROBLEMS_LIST);
- return true;
- }
-
- /**
- * Return whether a change to specified aspect requires a re-validation
- * of the node's tree.
- */
- private boolean aspectChangeRequiresValidation(String aspectName) {
- return ! this.aspectChangeDoesNotRequireValidation(aspectName);
- }
-
- private boolean aspectChangeDoesNotRequireValidation(String aspectName) {
- return this.nonValidatedAspectNames().contains(aspectName);
- }
-
- /**
- * Return a set of the object's "non-validated" aspect names.
- * These are the aspects that, when they change, will NOT cause the
- * object (or its containing tree) to be validated, i.e. checked for problems.
- * If you need instance-based calculation of your "non-validated" aspects,
- * override this method. If class-based calculation is sufficient,
- * override #addNonValidatedAspectNamesTo(Set).
- */
- protected final Set<String> nonValidatedAspectNames() {
- synchronized (nonValidatedAspectNameSets) {
- HashSet<String> nonValidatedAspectNames = nonValidatedAspectNameSets.get(this.getClass());
- if (nonValidatedAspectNames == null) {
- nonValidatedAspectNames = new HashSet<String>();
- this.addNonValidatedAspectNamesTo(nonValidatedAspectNames);
- nonValidatedAspectNameSets.put(this.getClass(), nonValidatedAspectNames);
- }
- return nonValidatedAspectNames;
- }
- }
-
- /**
- * Add the object's "non-validated" aspect names to the specified set.
- * These are the aspects that, when they change, will NOT cause the
- * object (or its containing tree) to be validated, i.e. checked for problems.
- * If class-based calculation of your "non-validated" aspects is sufficient,
- * override this method. If you need instance-based calculation,
- * override #nonValidatedAspectNames().
- */
- protected void addNonValidatedAspectNamesTo(Set<String> nonValidatedAspectNames) {
- nonValidatedAspectNames.add(COMMENT_PROPERTY);
- nonValidatedAspectNames.add(DIRTY_BRANCH_PROPERTY);
- nonValidatedAspectNames.add(BRANCH_PROBLEMS_LIST);
- nonValidatedAspectNames.add(HAS_BRANCH_PROBLEMS_PROPERTY);
- // when you override this method, don't forget to include:
- // super.addNonValidatedAspectNamesTo(nonValidatedAspectNames);
- }
-
-
- // ********** display methods **********
-
- /**
- * Compare display strings.
- */
- public int compareTo(Node node) {
- return DEFAULT_COMPARATOR.compare(this, node);
- }
-
- /**
- * Return a developer-friendly String. If you want something useful for
- * displaying in a user interface, use #displayString().
- * If you want to give more information in your #toString(),
- * override #toString(StringBuilder sb).
- * Whatever you add to that string buffer will show up between the parentheses.
- * @see AbstractModel#toString(StringBuilder sb)
- * @see #displayString()
- */
- @Override
- public final String toString() {
- return super.toString();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AsynchronousValidator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AsynchronousValidator.java
deleted file mode 100644
index fd2059cc8c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AsynchronousValidator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.node;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.SynchronizedBoolean;
-
-/**
- * This implementation of the PluggableValidator.Delegate interface
- * simply sets a shared "validate" flag to true. This should trigger a
- * separate "validation" thread to begin validating the appropriate
- * branch of nodes.
- */
-public class AsynchronousValidator
- implements PluggableValidator.Delegate
-{
- private SynchronizedBoolean validateFlag;
-
- /**
- * Construct a validator delegate with the specified shared
- * "validate" flag. This flag should be shared with
- * another thread that will perform the actual validation.
- */
- public AsynchronousValidator(SynchronizedBoolean validateFlag) {
- super();
- this.validateFlag = validateFlag;
- }
-
- /**
- * Set the shared "validate" flag to true, triggering
- * an asynchronous validation of the appropriate
- * branch of nodes.
- */
- public void validate() {
- this.validateFlag.setTrue();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.validateFlag);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/DefaultProblem.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/DefaultProblem.java
deleted file mode 100644
index 75f5741ca3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/DefaultProblem.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.node;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * This class is a straightforward implementation of the Problem interface.
- */
-public class DefaultProblem
- implements Problem
-{
- private final Node source;
- private final String messageKey;
- private final Object[] messageArguments;
-
-
- DefaultProblem(Node source, String messageKey, Object[] messageArguments) {
- super();
- this.source = source;
- this.messageKey = messageKey;
- this.messageArguments = messageArguments;
- }
-
-
- // ********** Problem implementation **********
-
- public Node source() {
- return this.source;
- }
-
- public String messageKey() {
- return this.messageKey;
- }
-
- public Object[] messageArguments() {
- return this.messageArguments;
- }
-
-
- // ********** Object overrides **********
-
- /**
- * We implement #equals(Object) because problems are repeatedly
- * re-calculated and the resulting problems merged with the existing
- * set of problems; and we want to keep the original problems and
- * ignore any freshly-generated duplicates.
- * Also, problems are not saved to disk....
- */
- @Override
- public boolean equals(Object o) {
- if ( ! (o instanceof Problem)) {
- return false;
- }
- Problem other = (Problem) o;
- return this.source == other.source()
- && this.messageKey.equals(other.messageKey())
- && Arrays.equals(this.messageArguments, other.messageArguments());
- }
-
- @Override
- public int hashCode() {
- return this.source.hashCode() ^ this.messageKey.hashCode();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.messageKey);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Node.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Node.java
deleted file mode 100644
index 2936883fce..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Node.java
+++ /dev/null
@@ -1,419 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.node;
-
-import java.text.Collator;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * This interface defines the methods that must be implemented
- * by any class whose instances are to be part of a containment hierarchy
- * that supports a "dirty" state and validation "problems".
- *
- * Note: Methods marked "INTRA-TREE API" are typically only used by
- * the nodes themselves, as opposed to clients of the nodes. These
- * methods are called by a node on either its parent or its children.
- */
-public interface Node extends Model, Comparable<Node> {
-
-
- // ********** containment hierarchy (parent/children) **********
-
- /**
- * INTRA-TREE API?
- * Return the node's parent in the containment hierarchy.
- * Most nodes must have a parent. The parent is immutable.
- * @see #children()
- */
- Node getParent();
-
- /**
- * INTRA-TREE API?
- * Return the node's children, which are also nodes.
- * @see #getParent()
- */
- Iterator<Node> children();
-
- /**
- * INTRA-TREE API?
- * Return the containment hierarchy's root node.
- * Most nodes must have a root.
- * @see #getParent()
- */
- Node root();
-
- /**
- * Return whether the node is a descendant of the specified node.
- * By definition, a node is a descendant of itself.
- */
- boolean isDescendantOf(Node node);
-
- /**
- * INTRA-TREE API
- * Add the node's "references", and all the node's descendants'
- * "references", to the specified collection. "References" are
- * objects that are "referenced" by another object, as opposed
- * to "owned" by another object.
- * This method is of particular concern to Handles, since most
- * (hopefully all) "references" are held by Handles.
- * @see Reference
- * @see #children()
- */
- void addBranchReferencesTo(Collection<Node.Reference> branchReferences);
-
- /**
- * INTRA-TREE API?
- * Add all the nodes in the object's branch of the tree,
- * including the node itself, to the specified collection.
- * Only really used for testing and debugging.
- */
- void addAllNodesTo(Collection<Node> nodes);
-
-
- // ********** model synchronization support **********
-
- /**
- * INTRA-TREE API
- * This is a general notification that the specified node has been
- * removed from the tree. The node receiving this notification
- * should perform any necessary updates to remain in synch
- * with the tree (e.g. clearing out or replacing any references
- * to the removed node or any of the removed node's descendants).
- * @see #isDescendantOf(Node)
- */
- void nodeRemoved(Node node);
-
- /**
- * INTRA-TREE API
- * This is a general notification that the specified node has been
- * renamed. The node receiving this notification should mark its
- * branch dirty if necessary (i.e. it references the renamed node
- * or one of its descendants). This method is of particular concern
- * to Handles.
- * @see #isDescendantOf(Node)
- */
- void nodeRenamed(Node node);
-
-
- // ********** dirty flag support **********
-
- /**
- * Return whether any persistent aspects of the node,
- * or any of its descendants, have changed since the node and
- * its descendants were last read or saved.
- */
- boolean isDirtyBranch();
- String DIRTY_BRANCH_PROPERTY = "dirtyBranch";
-
- /**
- * INTRA-TREE API
- * Mark the node and its parent as dirty branches.
- * This message is propagated up the containment
- * tree when a particular node becomes dirty.
- */
- void markBranchDirty();
-
- /**
- * Mark the node and all its descendants as dirty.
- * This is used when the save location of some
- * top-level node is changed and the entire
- * containment tree must be marked dirty so it
- * will be written out.
- */
- void markEntireBranchDirty();
-
- /**
- * INTRA-TREE API
- * A child node's branch has been marked clean. If the node
- * itself is clean and if all of its children are also clean, the
- * node's branch can be marked clean. Then, if the node's
- * branch is clean, the node will notify its parent that it might
- * be clean also. This message is propagated up the containment
- * tree when a particular node becomes clean.
- */
- void markBranchCleanIfPossible();
-
- /**
- * INTRA-TREE API
- * Mark the node and all its descendants as clean.
- * Typically used when the node has just been
- * read in or written out.
- * This method is for internal use only; it is not for
- * client use.
- * Not the best of method names.... :-(
- */
- void cascadeMarkEntireBranchClean();
-
-
- // ********** problems **********
-
- /**
- * INTRA-TREE API
- * Return a validator that will be invoked whenever a
- * "validated" aspect of the node tree changes.
- * Typically only the root node directly holds a validator.
- */
- Validator getValidator();
-
- /**
- * Set a validator that will be invoked whenever a
- * "validated" aspect of the node tree changes.
- * Typically only the root node directly holds a validator.
- */
- void setValidator(Validator validator);
-
- /**
- * Validate the node and its descendants.
- * This is an explicit request invoked by a client; and it will
- * typically be followed by a call to one of the following methods:
- * #branchProblems()
- * #hasBranchProblems()
- * Whether the node maintains its problems on the fly
- * or waits until this method is called is determined by the
- * implementation.
- * @see Problem
- */
- void validateBranch();
-
- /**
- * INTRA-TREE API
- * Validate the node and all of its descendants,
- * and update their sets of "branch" problems.
- * Return true if the collection of "branch" problems has changed.
- * This method is for internal use only; it is not for
- * client use.
- */
- boolean validateBranchInternal();
-
- /**
- * Return all the node's problems along with all the
- * node's descendants' problems.
- */
- ListIterator<Problem> branchProblems();
- String BRANCH_PROBLEMS_LIST = "branchProblems";
-
- /**
- * Return the size of all the node's problems along with all the
- * node's descendants' problems.
- */
- int branchProblemsSize();
-
- /**
- * Return whether the node or any of its descendants have problems.
- */
- boolean hasBranchProblems();
- String HAS_BRANCH_PROBLEMS_PROPERTY = "hasBranchProblems";
-
- /**
- * Return whether the node contains the specified branch problem.
- */
- boolean containsBranchProblem(Problem problem);
-
- /**
- * INTRA-TREE API
- * Something changed, rebuild the node's collection of branch problems.
- */
- void rebuildBranchProblems();
-
- /**
- * INTRA-TREE API
- * Add the node's problems, and all the node's descendants'
- * problems, to the specified list.
- * A call to this method should be immediately preceded by a call to
- * #validateBranch() or all of the problems might not be
- * added to the list.
- * @see Problem
- */
- void addBranchProblemsTo(List<Problem> branchProblems);
-
- /**
- * Clear the node's "branch" problems and the "branch"
- * problems of all of its descendants.
- */
- void clearAllBranchProblems();
-
- /**
- * INTRA-TREE API
- * Clear the node's "branch" problems and the "branch"
- * problems of all of its descendants.
- * Return true if the collection of "branch" problems has changed.
- * This method is for internal use only; it is not for
- * client use.
- */
- boolean clearAllBranchProblemsInternal();
-
-
- // ********** comment **********
-
- /**
- * Return the user comment concerning the node.
- */
- String comment();
- String COMMENT_PROPERTY = "comment";
-
- /**
- * Set the user comment concerning the node.
- */
- void setComment(String comment);
-
-
- // ********** displaying/sorting **********
-
- /**
- * Return a string representation of the model, suitable for sorting.
- */
- String displayString();
-
-
- // ********** sub-interfaces **********
-
- /**
- * Simple interface defining a "reference" between two nodes.
- * @see Node#addBranchReferencesTo(java.util.Collection)
- */
- interface Reference {
-
- /**
- * Return the "source" node of the reference, i.e. the node that
- * references the "target" node.
- */
- Node source();
-
- /**
- * Return the "target" node of the reference, i.e. the node that
- * is referenced by the "source" node.
- */
- Node target();
-
- }
-
-
- /**
- * A validator will validate a node as appropriate.
- * Typically the validation will
- * - occur whenever a node has changed
- * - encompass the entire tree containing the node
- * - execute asynchronously
- */
- interface Validator {
-
- /**
- * A "significant" aspect has changed;
- * validate the node as appropriate
- */
- void validate();
-
- /**
- * Stop all validation of the node until #resume() is called.
- * This can be used to improve the performance of any long-running
- * action that triggers numerous changes to the node. Be sure to
- * match a call to this method with a corresponding call to
- * #resume().
- */
- void pause();
-
- /**
- * Resume validation of the node. This method can only be
- * called after a matching call to #pause().
- */
- void resume();
-
- }
-
-
- // ********** helper implementations **********
-
- /**
- * Straightforward implementation of the Reference interface
- * defined above.
- */
- public class SimpleReference implements Reference {
- private Node source;
- private Node target;
- public SimpleReference(Node source, Node target) {
- super();
- if (source == null || target == null) {
- throw new NullPointerException();
- }
- this.source = source;
- this.target = target;
- }
- public Node source() {
- return this.source;
- }
- public Node target() {
- return this.target;
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.source + " => " + this.target);
- }
- }
-
- /**
- * Typical comparator that can be used to sort a collection of nodes.
- * Sort based on display string:
- * - identical objects are equal (which means that cannot
- * co-exist in a SortedSet)
- * - use the default collator (which typically interleaves
- * lower- and upper-case letters)
- * - allow duplicate display strings (from different objects)
- * - try to return consistent results for same object pairs
- */
- Comparator<Node> DEFAULT_COMPARATOR =
- new Comparator<Node>() {
- public int compare(Node node1, Node node2) {
- // disallow duplicates based on object identity
- if (node1 == node2) {
- return 0;
- }
-
- // first compare display strings using the default collator
- int result = Collator.getInstance().compare(node1.displayString(), node2.displayString());
- if (result != 0) {
- return result;
- }
-
- // then compare using object-id
- result = System.identityHashCode(node1) - System.identityHashCode(node2);
- if (result != 0) {
- return result;
- }
-
- // It's unlikely that we get to this point; but, just in case, we will return -1.
- // Unfortunately, this introduces some mild unpredictability to the sort order
- // (unless the objects are always passed into this method in the same order).
- return -1; // if all else fails, indicate that o1 < o2
- }
- @Override
- public String toString() {
- return "Node.DEFAULT_COMPARATOR";
- }
- };
-
-
- /**
- * This validator does nothing to validate the node.
- */
- Validator NULL_VALIDATOR =
- new PluggableValidator(PluggableValidator.Delegate.Null.instance()) {
- @Override
- public String toString() {
- return "Node.NULL_VALIDATOR";
- }
- };
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/PluggableValidator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/PluggableValidator.java
deleted file mode 100644
index c44f8aab43..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/PluggableValidator.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.node;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.SynchronizedBoolean;
-
-/**
- * This implementation of the Validator interface implements the
- * pause/resume portion of the protocol, but delegates the actual
- * validation to a "pluggable" delegate.
- */
-public class PluggableValidator
- implements Node.Validator
-{
- private boolean pause;
- private boolean validateOnResume;
- private final Delegate delegate;
-
-
- /**
- * Convenience factory method.
- */
- public static Node.Validator buildAsynchronousValidator(SynchronizedBoolean validateFlag) {
- return new PluggableValidator(new AsynchronousValidator(validateFlag));
- }
-
- /**
- * Convenience factory method.
- */
- public static Node.Validator buildSynchronousValidator(Node node) {
- return new PluggableValidator(new SynchronousValidator(node));
- }
-
- /**
- * Construct a validator with the specified delegate.
- */
- public PluggableValidator(Delegate delegate) {
- super();
- this.pause = false;
- this.validateOnResume = false;
- this.delegate = delegate;
- }
-
- public synchronized void validate() {
- if (this.pause) {
- this.validateOnResume = true;
- } else {
- this.delegate.validate();
- }
- }
-
- public synchronized void pause() {
- if (this.pause) {
- throw new IllegalStateException("already paused");
- }
- this.pause = true;
- }
-
- public synchronized void resume() {
- if ( ! this.pause) {
- throw new IllegalStateException("not paused");
- }
- this.pause = false;
- // validate any changes that occurred while the validation was paused
- if (this.validateOnResume) {
- this.validateOnResume = false;
- this.delegate.validate();
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.delegate);
- }
-
-
- // ********** member interface **********
-
- /**
- * Interface implemented by any delegates of a pluggable validator.
- */
- public interface Delegate {
-
- /**
- * The validator is not "paused" - perform the appropriate validation.
- */
- void validate();
-
-
- /**
- * This delegate does nothing.
- */
- final class Null implements Delegate {
- public static final Delegate INSTANCE = new Null();
- public static Delegate instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void validate() {
- // do nothing
- }
- @Override
- public String toString() {
- return "PluggableValidator.Delegate.Null";
- }
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Problem.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Problem.java
deleted file mode 100644
index 4f8e730362..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Problem.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.node;
-
-/**
- * Define an interface describing the problems associated with a node.
- */
-public interface Problem {
-
- /**
- * Return the node most closely associated with the problem.
- */
- Node source();
-
- /**
- * Return a key that can be used to uniquely identify the problem's message.
- */
- String messageKey();
-
- /**
- * Return the arguments associate with the problem's message.
- */
- Object[] messageArguments();
-
- /**
- * Return whether the problem is equal to the specified object.
- * It is equal if the specified object is a implementation of the
- * Problem interface and its source, message key, and message
- * arguments are all equal to this problem's.
- */
- boolean equals(Object o);
-
- /**
- * Return the problem's hash code, which should calculated as an
- * XOR of the source's hash code and the message key's hash code.
- */
- int hashCode();
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/RunnableValidation.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/RunnableValidation.java
deleted file mode 100644
index 4234010fce..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/RunnableValidation.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.node;
-
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import org.eclipse.jpt.utility.internal.SynchronizedBoolean;
-
-/**
- * This implementation of Runnable will asynchronously validate
- * a branch of nodes. It will wait until a shared "validate" flag is
- * set to validate the branch. Once the the branch is validated,
- * the thread will quiesce until the flag is set again.
- *
- * There are two ways to stop this thread:
- * - Thread.interrupt()
- * - set the "continue" flag to false
- * For now, these two are equivalent; but in the future we might
- * pass the "continue" flag to the Node.validateBranch()
- * method so we can short-circuit the validation instead of waiting
- * until the entire branch is validated.
- */
-public class RunnableValidation
- implements Runnable
-{
- /** The node whose branch this thread will validate. */
- private final Node node;
-
- /** When this flag is set to true, we kick off the validation routine. */
- private final SynchronizedBoolean validateFlag;
-
- /** When this flag is set to false, we allow this thread to die. */
- private final SynchronizedBoolean continueFlag;
-
- /** Log any exceptions encountered during validation with the following settings. */
- private final Logger exceptionLogger;
- private final Level exceptionLevel;
- private final String exceptionMessage;
-
-
- /**
- * Construct a validation thread.
- */
- public RunnableValidation(
- Node node,
- SynchronizedBoolean validateFlag,
- SynchronizedBoolean continueFlag,
- Logger exceptionLogger,
- Level exceptionLevel,
- String exceptionMessage
- ) {
- super();
- this.node = node;
- this.validateFlag = validateFlag;
- this.continueFlag = continueFlag;
- this.exceptionLogger = exceptionLogger;
- this.exceptionLevel = exceptionLevel;
- this.exceptionMessage = exceptionMessage;
- }
-
-
- // ********** Runnable Implementation **********
-
- /**
- * Loop while the "continue" flag is true and the thread
- * has not been interrupted by another thread.
- * In each loop: Wait until the "validate" flag is set to true,
- * then set it back to false and validate the branch of nodes.
- */
- public void run() {
- while (this.continueFlag.isTrue()) {
- try {
- this.validateFlag.waitToSetFalse();
- } catch (InterruptedException ex) {
- // we were interrupted while waiting, must be quittin' time
- return;
- }
- this.validateNode();
- }
- }
-
- /**
- * Validate the node, logging any exceptions.
- * If an exception occurs, we terminate the validation until the
- * "validation" flag is set again. Some exceptions occur because
- * of concurrent changes to the model that occur *after* validation
- * starts but before it completes an entire pass over the model. If that
- * is the case, things should be OK; because the exception will be
- * caught and the "validation" flag will have been set again *during* the
- * initial validation pass. So when we return from catching the exception
- * we will simply re-start the validation, hopefully with the model in
- * a consistent state that will prevent another exception from
- * occurring. Of course, if we have any exceptions that are *not*
- * the result of the model being in an inconsistent state, we will
- * probably fill the log; and those exceptions are bugs that need
- * to be fixed. (!) Hopefully the user will notice the enormous log and
- * contact support.... ~bjv
- */
- private void validateNode() {
- try {
- this.node.validateBranch();
- } catch (Throwable ex) {
- this.logException(ex);
- }
- }
-
- /**
- * We need to do all this because Logger#log(LogRecord) does not pass through
- * Logger#doLog(LogRecord) like all the other Logger#log(...) methods.
- */
- private void logException(Throwable ex) {
- LogRecord logRecord = new LogRecord(this.exceptionLevel, this.exceptionMessage);
- logRecord.setParameters(new Object[] { this.node.displayString() });
- logRecord.setThrown(ex);
- logRecord.setLoggerName(this.exceptionLogger.getName());
- logRecord.setResourceBundle(this.exceptionLogger.getResourceBundle());
- this.exceptionLogger.log(logRecord);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/SynchronousValidator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/SynchronousValidator.java
deleted file mode 100644
index ede6b8b8f0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/SynchronousValidator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.node;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- * This implementation of the PluggableValidator.Delegate interface
- * will validate the node immediately.
- *
- * This is useful for debugging in a single thread or generating
- * problem reports.
- */
-public class SynchronousValidator
- implements PluggableValidator.Delegate
-{
- private final Node node;
-
- /**
- * Construct a validator that will immediately validate the
- * specified node.
- */
- public SynchronousValidator(Node node) {
- super();
- this.node = node;
- }
-
- public void validate() {
- this.node.validateBranch();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.node);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/CachingComboBoxModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/CachingComboBoxModel.java
deleted file mode 100644
index 8ebe2617e6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/CachingComboBoxModel.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import javax.swing.ComboBoxModel;
-
-/**
- * This interface allows a client to better control the performance of
- * a combo box model by allowing the client to specify when it is
- * acceptable for the model to "cache" and "uncache" its list of elements.
- * The model may ignore these hints if appropriate.
- */
-public interface CachingComboBoxModel extends ComboBoxModel {
-
- /**
- * Cache the comboBoxModel List. If you call this, you
- * must make sure to call uncacheList() as well. Otherwise
- * stale data will be in the ComboBox until cacheList() is
- * called again or uncacheList() is called.
- */
- void cacheList();
-
- /**
- * Clear the cached list. Next time the list is needed it will
- * be built when it is not cached.
- */
- void uncacheList();
-
- /**
- * Check to see if the list is already cached. This can be used for
- * MouseEvents, since they are not terribly predictable.
- */
- boolean isCached();
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/CheckBoxTableCellRenderer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/CheckBoxTableCellRenderer.java
deleted file mode 100644
index 6cbd37ddd2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/CheckBoxTableCellRenderer.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.BorderFactory;
-import javax.swing.Icon;
-import javax.swing.JCheckBox;
-import javax.swing.JTable;
-import javax.swing.SwingConstants;
-import javax.swing.UIManager;
-import javax.swing.border.Border;
-
-import org.eclipse.jpt.utility.internal.swing.TableCellEditorAdapter.ImmediateEditListener;
-
-/**
- * Make the cell look like a check box.
- */
-public class CheckBoxTableCellRenderer implements TableCellEditorAdapter.Renderer {
-
- /** the component used to paint the cell */
- private final JCheckBox checkBox;
-
- /** the listener to be notified on an immediate edit */
- protected TableCellEditorAdapter.ImmediateEditListener immediateEditListener;
-
- /** "normal" border - assume the default table "focus" border is 1 pixel thick */
- private static final Border NO_FOCUS_BORDER = BorderFactory.createEmptyBorder(1, 1, 1, 1);
-
-
- // ********** constructors/initialization **********
-
- /**
- * Construct a cell renderer with no label or icon.
- */
- public CheckBoxTableCellRenderer() {
- super();
- this.checkBox = this.buildCheckBox();
- // by default, check boxes do not paint their borders
- this.checkBox.setBorderPainted(true);
- // this setting is recommended for check boxes inside of trees and tables
- this.checkBox.setBorderPaintedFlat(true);
- }
-
- /**
- * Construct a cell renderer with the specified text and icon,
- * either of which may be null.
- */
- public CheckBoxTableCellRenderer(String text, Icon icon) {
- this();
- this.setText(text);
- this.setIcon(icon);
- }
-
- /**
- * Construct a cell renderer with the specified text.
- */
- public CheckBoxTableCellRenderer(String text) {
- this(text, null);
- }
-
- /**
- * Construct a cell renderer with the specified icon.
- */
- public CheckBoxTableCellRenderer(Icon icon) {
- this(null, icon);
- }
-
- protected JCheckBox buildCheckBox() {
- JCheckBox cb = new JCheckBox();
- cb.addActionListener(this.buildActionListener());
- return cb;
- }
-
- private ActionListener buildActionListener() {
- return new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (CheckBoxTableCellRenderer.this.immediateEditListener != null) {
- CheckBoxTableCellRenderer.this.immediateEditListener.immediateEdit();
- }
- }
- };
- }
-
-
- // ********** TableCellRenderer implementation **********
-
- public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
- this.checkBox.setHorizontalAlignment(SwingConstants.CENTER);
- this.checkBox.setComponentOrientation(table.getComponentOrientation());
- this.checkBox.setFont(table.getFont());
- this.checkBox.setEnabled(table.isEnabled());
-
- this.checkBox.setForeground(this.foregroundColor(table, value, selected, hasFocus, row, column));
- this.checkBox.setBackground(this.backgroundColor(table, value, selected, hasFocus, row, column));
- // once the colors are set, calculate opaque setting
- this.checkBox.setOpaque(this.cellIsOpaqueIn(table, value, selected, hasFocus, row, column));
- this.checkBox.setBorder(this.border(table, value, selected, hasFocus, row, column));
-
- this.setValue(value);
- return this.checkBox;
- }
-
- /**
- * Return the cell's foreground color.
- */
- protected Color foregroundColor(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
- if (selected) {
- if (hasFocus && table.isCellEditable(row, column)) {
- return UIManager.getColor("Table.focusCellForeground");
- }
- return table.getSelectionForeground();
- }
- return table.getForeground();
- }
-
- /**
- * Return the cell's background color.
- */
- protected Color backgroundColor(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
- if (selected) {
- if (hasFocus && table.isCellEditable(row, column)) {
- return UIManager.getColor("Table.focusCellBackground");
- }
- return table.getSelectionBackground();
- }
- return table.getBackground();
- }
-
- /**
- * Return the cell's border.
- */
- protected Border border(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
- return hasFocus ? UIManager.getBorder("Table.focusCellHighlightBorder") : NO_FOCUS_BORDER;
- }
-
- /**
- * Return whether the cell should be opaque in the table.
- * If the cell's background is the same as the table's background
- * and table is opaque, we don't need to paint the background -
- * the table will do it.
- */
- protected boolean cellIsOpaqueIn(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
- Color cellBackground = this.checkBox.getBackground();
- Color tableBackground = table.getBackground();
- return ! (table.isOpaque() && cellBackground.equals(tableBackground));
- }
-
- /**
- * Set the check box's value.
- */
- protected void setValue(Object value) {
- // CR#3999318 - This null check needs to be removed once JDK bug is fixed
- if (value == null) {
- value = Boolean.FALSE;
- }
- this.checkBox.setSelected(((Boolean) value).booleanValue());
- }
-
-
- // ********** TableCellEditorAdapter.Renderer implementation **********
-
- public Object getValue() {
- return Boolean.valueOf(this.checkBox.isSelected());
- }
-
- public void setImmediateEditListener(ImmediateEditListener listener) {
- this.immediateEditListener = listener;
- }
-
- // ********** public API **********
-
- /**
- * Set the check box's text; which by default is blank.
- */
- public void setText(String text) {
- this.checkBox.setText(text);
- }
-
- /**
- * Set the check box's icon; which by default is not present.
- */
- public void setIcon(Icon icon) {
- this.checkBox.setIcon(icon);
- }
-
- /**
- * Return the renderer's preferred height. This allows you
- * to set the table's row height to something the check box
- * will look good in....
- */
- public int preferredHeight() {
- // add in space for the border top and bottom
- return (int) this.checkBox.getPreferredSize().getHeight() + 2;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ComboBoxTableCellRenderer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ComboBoxTableCellRenderer.java
deleted file mode 100644
index d0db82bbdf..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ComboBoxTableCellRenderer.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Graphics;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.BorderFactory;
-import javax.swing.ComboBoxModel;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JTable;
-import javax.swing.ListCellRenderer;
-import javax.swing.SwingConstants;
-import javax.swing.UIManager;
-import javax.swing.border.Border;
-import javax.swing.event.PopupMenuEvent;
-import javax.swing.event.PopupMenuListener;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-
-/**
- * Make the cell look like a combo-box.
- */
-public class ComboBoxTableCellRenderer implements TableCellEditorAdapter.Renderer {
-
- /* caching the combo box because we are caching the comboBoxModel.
- * Everytime we rebuilt the comboBox we would set the model on it and not
- * remove the model from the old combo box. This meant that new listeners
- * kept being added to the comboBoxModel for every comboBox build.
- * Not sure if there is a way to clear out the old combo box, or why
- * we were buildig a new combo box every time so I went with caching it.
- */
- private JComboBox comboBox;
-
- /** the items used to populate the combo box */
- private CachingComboBoxModel model;
- private ListCellRenderer renderer;
- Object value;
- private static int height = -1;
- boolean fakeFocusFlag;
-
- /** the listener to be notified on an immediate edit */
- protected TableCellEditorAdapter.ImmediateEditListener immediateEditListener;
-
- /** hold the original colors of the combo-box */
- private static Color defaultForeground;
- private static Color defaultBackground;
-
- /** "normal" border - assume the default table "focus" border is 1 pixel thick */
- private static final Border NO_FOCUS_BORDER = BorderFactory.createEmptyBorder(1, 1, 1, 1);
-
-
- // ********** constructors/initialization **********
-
- /**
- * Default constructor.
- */
- private ComboBoxTableCellRenderer() {
- super();
- initialize();
- }
-
- /**
- * Construct a cell renderer that uses the specified combo-box model.
- */
- public ComboBoxTableCellRenderer(ComboBoxModel model) {
- this(new NonCachingComboBoxModel(model));
- }
-
- /**
- * Construct a cell renderer that uses the specified caching combo-box model.
- */
- public ComboBoxTableCellRenderer(CachingComboBoxModel model) {
- this();
- this.model = model;
- }
-
- /**
- * Construct a cell renderer that uses the specified
- * combo-box model and renderer.
- */
- public ComboBoxTableCellRenderer(ComboBoxModel model, ListCellRenderer renderer) {
- this(new NonCachingComboBoxModel(model), renderer);
- }
-
- /**
- * Construct a cell renderer that uses the specified
- * caching combo-box model and renderer.
- */
- public ComboBoxTableCellRenderer(CachingComboBoxModel model, ListCellRenderer renderer) {
- this(model);
- this.renderer = renderer;
- }
-
- protected void initialize() {
- // save the original colors of the combo-box, so we
- // can use them to paint non-selected cells
- if (height == -1) {
- JComboBox cb = new JComboBox();
- cb.addItem("m");
-
- // add in space for the border top and bottom
- height = cb.getPreferredSize().height + 2;
-
- defaultForeground = cb.getForeground();
- defaultBackground = cb.getBackground();
- }
- }
-
- static JLabel prototypeLabel = new JLabel("Prototype", new EmptyIcon(16), SwingConstants.LEADING);
-
- protected JComboBox buildComboBox() {
-
- final JComboBox result = new JComboBox() {
- private boolean fakeFocus;
- @Override
- public boolean hasFocus() {
- return fakeFocus || super.hasFocus();
- }
- @Override
- public void paint(Graphics g) {
- fakeFocus = ComboBoxTableCellRenderer.this.fakeFocusFlag;
- super.paint(g);
- fakeFocus = false;
- }
- //wrap the renderer to deal with the prototypeDisplayValue
- @Override
- public void setRenderer(final ListCellRenderer aRenderer) {
- super.setRenderer(new ListCellRenderer(){
- public Component getListCellRendererComponent(JList list, Object v, int index, boolean isSelected, boolean cellHasFocus) {
- if (v == prototypeLabel) {
- return prototypeLabel;
- }
- return aRenderer.getListCellRendererComponent(list, v, index, isSelected, cellHasFocus);
- }
- });
- }
- @Override
- public int getSelectedIndex() {
- boolean listNotCached = !listIsCached();
- if (listNotCached) {
- cacheList();
- }
-
- int index = super.getSelectedIndex();
-
- if (listNotCached) {
- uncacheList();
- }
- return index;
- }
-
- };
- // stole this code from javax.swing.DefaultCellEditor
- result.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
- result.addActionListener(this.buildActionListener());
- result.addPopupMenuListener(this.buildPopupMenuListener());
-
- //These are used to workaround problems with Swing trying to
- //determine the size of a comboBox with a large model
- result.setPrototypeDisplayValue(prototypeLabel);
- getListBox(result).setPrototypeCellValue(prototypeLabel);
-
- return result;
- }
-
-
- private JList getListBox(JComboBox result) {
- return (JList) ClassTools.fieldValue(result.getUI(), "listBox");
- }
-
-
- private ActionListener buildActionListener() {
- return new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- JComboBox cb = (JComboBox) e.getSource();
- Object selectedItem = cb.getSelectedItem();
-
- // Only update the selected item and invoke immediateEdit() if the
- // selected item actually changed, during the initialization of the
- // editing, the model changes and causes this method to be invoked,
- // it causes CR#3963675 to occur because immediateEdit() stop the
- // editing, which is done at the wrong time
- if (ComboBoxTableCellRenderer.this.value != selectedItem) {
- ComboBoxTableCellRenderer.this.value = cb.getSelectedItem();
- ComboBoxTableCellRenderer.this.immediateEdit();
- }
- }
- };
- }
-
- void immediateEdit() {
- if (this.immediateEditListener != null) {
- this.immediateEditListener.immediateEdit();
- }
- }
-
- private PopupMenuListener buildPopupMenuListener() {
- return new PopupMenuListener() {
-
- public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
- if (listIsCached()) {
- uncacheList();
- }
- cacheList();
- }
-
- public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
- if (listIsCached()) {
- uncacheList();
- }
-
- }
-
- public void popupMenuCanceled(PopupMenuEvent e) {
- if (listIsCached()) {
- uncacheList();
- }
- }
- };
- }
-
-
- void cacheList() {
- this.model.cacheList();
- }
-
- void uncacheList() {
- this.model.uncacheList();
- }
-
- boolean listIsCached() {
- return this.model.isCached();
- }
- // ********** TableCellRenderer implementation **********
-
- public Component getTableCellRendererComponent(JTable table, Object val, boolean selected, boolean hasFocus, int row, int column) {
- this.fakeFocusFlag = selected || hasFocus;
- if (this.comboBox == null) {
- this.comboBox = this.buildComboBox();
-
- this.comboBox.setComponentOrientation(table.getComponentOrientation());
- this.comboBox.setModel(this.model);
- if (this.renderer != null) {
- this.comboBox.setRenderer(this.renderer);
- }
- this.comboBox.setFont(table.getFont());
- this.comboBox.setEnabled(table.isEnabled());
- this.comboBox.setBorder(this.border(table, val, selected, hasFocus, row, column));
- }
-
- // We need to go through the model since JComboBox might prevent us from
- // selecting the value. This can happen when the value is not contained
- // in the model, see CR#3950044 for an example
- this.model.setSelectedItem(val);
-
- return this.comboBox;
- }
-
- /**
- * Return the cell's foreground color.
- */
- protected Color foregroundColor(JTable table, Object val, boolean selected, boolean hasFocus, int row, int column) {
- if (selected) {
- if (hasFocus && table.isCellEditable(row, column)) {
- return defaultForeground;
- }
- return table.getSelectionForeground();
- }
- return defaultForeground;
- }
-
- /**
- * Return the cell's background color.
- */
- protected Color backgroundColor(JTable table, Object val, boolean selected, boolean hasFocus, int row, int column) {
- if (selected) {
- if (hasFocus && table.isCellEditable(row, column)) {
- return defaultBackground;
- }
- return table.getSelectionBackground();
- }
- return defaultBackground;
- }
-
- /**
- * Return the cell's border.
- */
- protected Border border(JTable table, Object val, boolean selected, boolean hasFocus, int row, int column) {
- return hasFocus ?
- UIManager.getBorder("Table.focusCellHighlightBorder")
- :
- NO_FOCUS_BORDER;
- }
-
-
- // ********** TableCellEditorAdapter.Renderer implementation **********
-
- public Object getValue() {
- return this.value;
- }
-
- public void setImmediateEditListener(TableCellEditorAdapter.ImmediateEditListener listener) {
- this.immediateEditListener = listener;
- }
-
-
- // ********** public API **********
-
- /**
- * Return the renderer's preferred height. This allows you
- * to set the row height to something the combo-box will look good in....
- */
- public int preferredHeight() {
- return height;
- }
-
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/Displayable.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/Displayable.java
deleted file mode 100644
index 492f18ffd9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/Displayable.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import java.text.Collator;
-import java.util.Comparator;
-
-import javax.swing.Icon;
-
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * Used by general-purpose UI models and renderers to cast
- * application model objects to something displayable.
- */
-public interface Displayable
- extends Model, Comparable<Displayable>
-{
-
- /**
- * Return a string that can be used to identify the model
- * in a textual UI setting (typically the object's name).
- * When the display string changes, the model should fire
- * the appropriate change notification:
- * this.firePropertyChanged(DISPLAY_STRING_PROPERTY, oldDisplayString, this.displayString());
- */
- String displayString();
- String DISPLAY_STRING_PROPERTY = "displayString";
-
- /**
- * Return an icon that can be used to identify the model
- * in a UI component that supports icons (the icon can be null).
- * When the icon changes, the model should fire
- * the appropriate change notification:
- * this.firePropertyChanged(ICON_PROPERTY, oldIcon, this.icon());
- */
- Icon icon();
- String ICON_PROPERTY = "icon";
-
-
- // ********** helper implementations **********
-
- Collator DEFAULT_COLLATOR = Collator.getInstance();
-
- /**
- * Since all displayable objects must be comparable, provide a
- * typical comparator that can be used to sort a collection of
- * displayable objects.
- * Sort based on display string:
- * - identical objects are equal (which means they cannot
- * co-exist in a SortedSet)
- * - use the default collator (which typically interleaves
- * lower- and upper-case letters)
- * - allow duplicate display strings (from different objects)
- * - try to return consistent results for same object pairs
- */
- Comparator<Displayable> DEFAULT_COMPARATOR =
- new Comparator<Displayable>() {
- public int compare(Displayable d1, Displayable d2) {
- // disallow duplicates based on object identity
- if (d1 == d2) {
- return 0;
- }
-
- // first compare display strings using the default collator
- int result = DEFAULT_COLLATOR.compare(d1.displayString(), d2.displayString());
- if (result != 0) {
- return result;
- }
-
- // then compare using object-id
- result = System.identityHashCode(d1) - System.identityHashCode(d2);
- if (result != 0) {
- return result;
- }
-
- // It's unlikely that we get to this point; but, just in case, we will return -1.
- // Unfortunately, this introduces some mild unpredictability to the sort order
- // (unless the objects are always passed into this method in the same order).
- return -1; // if all else fails, indicate that o1 < o2
- }
- @Override
- public String toString() {
- return "Displayable.DEFAULT_COMPARATOR";
- }
- };
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/EmptyIcon.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/EmptyIcon.java
deleted file mode 100644
index 802251f212..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/EmptyIcon.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import java.awt.Component;
-import java.awt.Graphics;
-
-import javax.swing.Icon;
-
-/**
- * Implement the Icon interface with an icon that has a size but
- * does not paint anything on the graphics context.
- */
-public class EmptyIcon
- implements Icon
-{
- private final int width;
- private final int height;
-
- public static final EmptyIcon NULL_INSTANCE = new EmptyIcon(0);
-
-
- public EmptyIcon(int width, int height) {
- super();
- this.width = width;
- this.height = height;
- }
-
- public EmptyIcon(int size) {
- this(size, size);
- }
-
-
- // ********** Icon implementation **********
-
- public void paintIcon(Component c, Graphics g, int x, int y) {
- // don't paint anything for an empty icon
- }
-
- public int getIconWidth() {
- return this.width;
- }
-
- public int getIconHeight() {
- return this.height;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListBrowser.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListBrowser.java
deleted file mode 100644
index d59f3e04d3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListBrowser.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import javax.swing.Icon;
-import javax.swing.JComboBox;
-import javax.swing.JOptionPane;
-import javax.swing.ListModel;
-
-/**
- * This implementation of LongListComponent.Browser uses a
- * JOptionPane to prompt the user for the selection. The JOPtionPane
- * is passed a FilteringListPanel to assist the user in making
- * a selection.
- */
-public class FilteringListBrowser<T>
- implements ListChooser.ListBrowser
-{
- private FilteringListPanel<T> panel;
-
- /**
- * Default constructor.
- */
- public FilteringListBrowser() {
- super();
- this.panel = this.buildPanel();
- }
-
- protected FilteringListPanel<T> buildPanel() {
- return new LocalFilteringListPanel<T>();
- }
-
- /**
- * Prompt the user using a JOptionPane with a filtering
- * list panel.
- */
- public void browse(ListChooser chooser) {
- this.initializeCellRenderer(chooser);
-
- int option =
- JOptionPane.showOptionDialog(
- chooser,
- this.message(chooser),
- this.title(chooser),
- this.optionType(chooser),
- this.messageType(chooser),
- this.icon(chooser),
- this.selectionValues(chooser),
- this.initialSelectionValue(chooser)
- );
-
- if (option == JOptionPane.OK_OPTION) {
- chooser.getModel().setSelectedItem(this.panel.selection());
- }
-
- // clear the text field so the list box is re-filtered
- this.panel.textField().setText("");
- }
-
- protected void initializeCellRenderer(JComboBox comboBox) {
- // default behavior should be to use the cell renderer from the combobox.
- this.panel.listBox().setCellRenderer(comboBox.getRenderer());
- }
-
- /**
- * the message can be anything - here we build a component
- */
- protected Object message(JComboBox comboBox) {
- this.panel.setCompleteList(this.convertToArray(comboBox.getModel()));
- this.panel.setSelection(comboBox.getModel().getSelectedItem());
- return this.panel;
- }
-
- protected String title(JComboBox comboBox) {
- return null;
- }
-
- protected int optionType(JComboBox comboBox) {
- return JOptionPane.OK_CANCEL_OPTION;
- }
-
- protected int messageType(JComboBox comboBox) {
- return JOptionPane.QUESTION_MESSAGE;
- }
-
- protected Icon icon(JComboBox comboBox) {
- return null;
- }
-
- protected Object[] selectionValues(JComboBox comboBox) {
- return null;
- }
-
- protected Object initialSelectionValue(JComboBox comboBox) {
- return null;
- }
-
- /**
- * Convert the list of objects in the specified list model
- * into an array.
- */
- protected Object[] convertToArray(ListModel model) {
- int size = model.getSize();
- Object[] result = new Object[size];
- for (int i = 0; i < size; i++) {
- result[i] = model.getElementAt(i);
- }
- return result;
- }
-
-
- // ********** custom panel **********
-
- protected static class LocalFilteringListPanel<S> extends FilteringListPanel<S> {
- protected static final Object[] EMPTY_ARRAY = new Object[0];
-
- protected LocalFilteringListPanel() {
- super(EMPTY_ARRAY, null);
- }
-
- /**
- * Disable the performance tweak because JOptionPane
- * will try open wide enough to disable the horizontal scroll bar;
- * and it looks a bit clumsy.
- */
- @Override
- protected String prototypeCellValue() {
- return null;
- }
-
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListPanel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListPanel.java
deleted file mode 100644
index af9a56dac8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListPanel.java
+++ /dev/null
@@ -1,457 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Font;
-
-import javax.swing.AbstractListModel;
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-import javax.swing.ListCellRenderer;
-import javax.swing.ListModel;
-import javax.swing.ListSelectionModel;
-import javax.swing.border.Border;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-
-import org.eclipse.jpt.utility.internal.SimpleStringMatcher;
-import org.eclipse.jpt.utility.internal.StringConverter;
-import org.eclipse.jpt.utility.internal.StringMatcher;
-
-/**
- * This panel presents an entry field and a list box of choices that
- * allows the user to filter the entries in the list box by entering
- * a pattern in the entry field.
- *
- * By default, two wildcards are allowed in the pattern:
- * '*' will match any set of zero or more characters
- * '?' will match any single character
- *
- * The panel consists of 4 components that can be customized:
- * - 1 text field
- * - 1 list box
- * - 2 labels, one for each of the above
- *
- * Other aspects of the panel's behavior can be changed:
- * - the string converter determines how the objects in the
- * list are converted to strings and compared to the pattern
- * entered in the text field; by default the converter simply
- * uses the result of the object's #toString() method
- * (if you replace the string converter, you will probably
- * want to replace the list box's cell renderer also)
- * - the string matcher can also be changed if you would
- * like different pattern matching behavior than that
- * described above
- * - you can specify the maximum size of the list - this may
- * force the user to enter a pattern restrictive enough
- * to result in a list smaller than the maximum size; the
- * default is -1, which disables the restriction
- *
- * This panel is not a typical panel, in the sense that it does not share
- * its model with clients via value models. Instead, this panel's model
- * is set and queried directly because it is designed to be used in a
- * dialog that directs the user's behavior (as opposed to a "normal"
- * window).
- */
-public class FilteringListPanel<T> extends JPanel {
-
- /**
- * The complete list of available choices
- * (as opposed to the partial list held by the list box).
- */
- private Object[] completeList;
-
- /**
- * An adapter used to convert the objects in the list
- * to strings so they can be run through the matcher
- * and displayed in the text field.
- */
- StringConverter<T> stringConverter;
-
- /** The text field. */
- private JTextField textField;
- private JLabel textFieldLabel;
- private DocumentListener textFieldListener;
-
- /** The list box. */
- private JList listBox;
- private JLabel listBoxLabel;
-
- /** The maximum number of entries displayed in the list box. */
- private int maxListSize;
-
- /**
- * The matcher used to filter the list against
- * the pattern entered in the text field. By default,
- * this allows the two wildcard characters described in
- * the class comment.
- */
- private StringMatcher stringMatcher;
-
- /**
- * Performance tweak: We use this buffer instead of
- * a temporary variable during filtering so we don't have
- * to keep re-allocating it.
- */
- private Object[] buffer;
-
- private static final Border TEXT_FIELD_LABEL_BORDER = BorderFactory.createEmptyBorder(0, 0, 5, 0);
- private static final Border LIST_BOX_LABEL_BORDER = BorderFactory.createEmptyBorder(5, 0, 5, 0);
-
-
- // ********** constructors **********
-
- /**
- * Construct a FilteringListPanel with the specified list of choices
- * and initial selection. Use the default string converter to convert the
- * choices and selection to strings (which simply calls #toString() on
- * the objects).
- */
- public FilteringListPanel(Object[] completeList, Object initialSelection) {
- this(completeList, initialSelection, StringConverter.Default.<T>instance());
- }
-
- /**
- * Construct a FilteringListPanel with the specified list of choices
- * and initial selection. Use the specified string converter to convert the
- * choices and selection to strings.
- */
- public FilteringListPanel(Object[] completeList, Object initialSelection, StringConverter<T> stringConverter) {
- super(new BorderLayout());
- this.completeList = completeList;
- this.stringConverter = stringConverter;
- this.initialize(initialSelection);
- }
-
-
- // ********** initialization **********
-
- private void initialize(Object initialSelection) {
- this.maxListSize = this.defaultMaxListSize();
- this.buffer = this.buildBuffer();
-
- this.textFieldListener = this.buildTextFieldListener();
-
- this.stringMatcher = this.buildStringMatcher();
-
- this.initializeLayout(initialSelection);
- }
-
- private Object[] buildBuffer() {
- return new Object[this.max()];
- }
-
- /**
- * Return the current max number of entries allowed in the list box.
- */
- private int max() {
- if (this.maxListSize == -1) {
- return this.completeList.length;
- }
- return Math.min(this.maxListSize, this.completeList.length);
- }
-
- /**
- * Build a listener that will listen to changes in the text field
- * and filter the list appropriately.
- */
- private DocumentListener buildTextFieldListener() {
- return new DocumentListener() {
- public void insertUpdate(DocumentEvent e) {
- FilteringListPanel.this.filterList();
- }
- public void changedUpdate(DocumentEvent e) {
- FilteringListPanel.this.filterList();
- }
- public void removeUpdate(DocumentEvent e) {
- FilteringListPanel.this.filterList();
- }
- @Override
- public String toString() {
- return "text field listener";
- }
- };
- }
-
- private int defaultMaxListSize() {
- return -1;
- }
-
- private StringMatcher buildStringMatcher() {
- return new SimpleStringMatcher<T>();
- }
-
- private void initializeLayout(Object initialSelection) {
- // text field
- JPanel textFieldPanel = new JPanel(new BorderLayout());
- this.textFieldLabel = new JLabel();
- this.textFieldLabel.setBorder(TEXT_FIELD_LABEL_BORDER);
- textFieldPanel.add(this.textFieldLabel, BorderLayout.NORTH);
-
- this.textField = new JTextField();
- this.textField.getDocument().addDocumentListener(this.textFieldListener);
- this.textFieldLabel.setLabelFor(this.textField);
- textFieldPanel.add(this.textField, BorderLayout.CENTER);
-
- this.add(textFieldPanel, BorderLayout.NORTH);
-
- // list box
- JPanel listBoxPanel = new JPanel(new BorderLayout());
- this.listBoxLabel = new JLabel();
- this.listBoxLabel.setBorder(LIST_BOX_LABEL_BORDER);
- listBoxPanel.add(this.listBoxLabel, BorderLayout.NORTH);
-
- this.listBox = new JList();
- this.listBox.setDoubleBuffered(true);
- this.listBox.setModel(this.buildPartialArrayListModel(this.completeList, this.max()));
- this.listBox.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- // performance tweak(?)
- this.listBox.setPrototypeCellValue(this.prototypeCellValue());
- this.listBox.setPrototypeCellValue(null);
- this.listBox.setCellRenderer(this.buildDefaultCellRenderer());
- this.listBoxLabel.setLabelFor(this.listBox);
- // bug 2777802 - scroll bars shouldn't be on the tab sequence
- JScrollPane listBoxScrollPane = new JScrollPane(this.listBox);
- listBoxScrollPane.getHorizontalScrollBar().setFocusable(false);
- listBoxScrollPane.getVerticalScrollBar().setFocusable(false);
- listBoxPanel.add(listBoxScrollPane, BorderLayout.CENTER);
-
- // initialize the widgets
- this.listBox.setSelectedValue(initialSelection, true);
- this.textField.select(0, this.textField.getText().length());
-
- this.add(listBoxPanel, BorderLayout.CENTER);
- }
-
-
- // ********** public API **********
-
- public Object selection() {
- return this.listBox.getSelectedValue();
- }
-
- public void setSelection(Object selection) {
- this.listBox.setSelectedValue(selection, true);
- }
-
- public Object[] completeList() {
- return this.completeList;
- }
-
- /**
- * rebuild the filtering buffer and re-apply the filter
- * to the new list
- */
- public void setCompleteList(Object[] completeList) {
- this.completeList = completeList;
- if (this.buffer.length < this.max()) {
- // the buffer will never shrink - might want to re-consider... ~bjv
- this.buffer = this.buildBuffer();
- }
- this.filterList();
- }
-
- public int maxListSize() {
- return this.maxListSize;
- }
-
- public void setMaxListSize(int maxListSize) {
- this.maxListSize = maxListSize;
- if (this.buffer.length < this.max()) {
- // the buffer will never shrink - might want to re-consider... ~bjv
- this.buffer = this.buildBuffer();
- }
- this.filterList();
- }
-
- public StringConverter<T> stringConverter() {
- return this.stringConverter;
- }
-
- /**
- * apply the new filter to the list
- */
- public void setStringConverter(StringConverter<T> stringConverter) {
- this.stringConverter = stringConverter;
- this.filterList();
- }
-
- /**
- * allow client code to access the text field
- * (so we can set the focus)
- */
- public JTextField textField() {
- return this.textField;
- }
-
- /**
- * allow client code to access the text field label
- */
- public JLabel textFieldLabel() {
- return this.textFieldLabel;
- }
-
- /**
- * convenience method
- */
- public void setTextFieldLabelText(String text) {
- this.textFieldLabel.setText(text);
- }
-
- /**
- * allow client code to access the list box
- * (so we can add mouse listeners for double-clicking)
- */
- public JList listBox() {
- return this.listBox;
- }
-
- /**
- * convenience method
- */
- public void setListBoxCellRenderer(ListCellRenderer renderer) {
- this.listBox.setCellRenderer(renderer);
- }
-
- /**
- * allow client code to access the list box label
- */
- public JLabel listBoxLabel() {
- return this.listBoxLabel;
- }
-
- /**
- * convenience method
- */
- public void setListBoxLabelText(String text) {
- this.listBoxLabel.setText(text);
- }
-
- /**
- * convenience method
- */
- public void setComponentsFont(Font font) {
- this.textFieldLabel.setFont(font);
- this.textField.setFont(font);
- this.listBoxLabel.setFont(font);
- this.listBox.setFont(font);
- }
-
- public StringMatcher stringMatcher() {
- return this.stringMatcher;
- }
-
- /**
- * re-apply the filter to the list
- */
- public void setStringMatcher(StringMatcher stringMatcher) {
- this.stringMatcher = stringMatcher;
- this.filterList();
- }
-
-
- // ********** internal methods **********
-
- /**
- * Allow subclasses to disable performance tweak
- * by returning null here.
- */
- protected String prototypeCellValue() {
- return "==========> A_STRING_THAT_IS_DEFINITELY_LONGER_THAN_EVERY_STRING_IN_THE_LIST <==========";
- }
-
- /**
- * By default, use the string converter to build the text
- * used by the list box's cell renderer.
- */
- protected ListCellRenderer buildDefaultCellRenderer() {
- return new SimpleListCellRenderer() {
- @Override
- @SuppressWarnings("unchecked")
- protected String buildText(Object value) {
- return FilteringListPanel.this.stringConverter.convertToString((T) value);
- }
- };
- }
-
- /**
- * Something has changed that requires us to filter the list.
- *
- * This method is synchronized because a fast typist can
- * generate events quicker than we can filter the list. (? ~bjv)
- */
- synchronized void filterList() {
- // temporarily stop listening to the list box selection, since we will
- // be changing the selection during the filtering and don't want
- // that to affect the text field
- this.filterList(this.textField.getText());
- }
-
- /**
- * Filter the contents of the list box to match the
- * specified pattern.
- */
- private void filterList(String pattern) {
- if (pattern.length() == 0) {
- this.listBox.setModel(this.buildPartialArrayListModel(this.completeList, this.max()));
- } else {
- this.stringMatcher.setPatternString(pattern);
- int j = 0;
- int len = this.completeList.length;
- int max = this.max();
- for (int i = 0; i < len; i++) {
- if (this.stringMatcher.matches(this.stringConverter.convertToString(this.entry(i)))) {
- this.buffer[j++] = this.completeList[i];
- }
- if (j == max) {
- break;
- }
- }
- this.listBox.setModel(this.buildPartialArrayListModel(this.buffer, j));
- }
-
- // after filtering the list, determine the appropriate selection
- if (this.listBox.getModel().getSize() == 0) {
- this.listBox.getSelectionModel().clearSelection();
- } else {
- this.listBox.getSelectionModel().setAnchorSelectionIndex(0);
- this.listBox.getSelectionModel().setLeadSelectionIndex(0);
- this.listBox.ensureIndexIsVisible(0);
- }
- }
-
- /**
- * minimize scope of suppressed warnings
- */
- @SuppressWarnings("unchecked")
- private T entry(int index) {
- return (T) this.completeList[index];
- }
-
- /**
- * Build a list model that wraps only a portion of the specified array.
- * The model will include the array entries from 0 to (size - 1).
- */
- private ListModel buildPartialArrayListModel(final Object[] array, final int size) {
- return new AbstractListModel() {
- public int getSize() {
- return size;
- }
- public Object getElementAt(int index) {
- return array[index];
- }
- };
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ListChooser.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ListChooser.java
deleted file mode 100644
index 2ddca8b367..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ListChooser.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import java.awt.AWTEvent;
-import java.awt.AWTException;
-import java.awt.Component;
-import java.awt.EventQueue;
-import java.awt.Point;
-import java.awt.Robot;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-
-import javax.swing.ComboBoxModel;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.ListCellRenderer;
-import javax.swing.SwingConstants;
-import javax.swing.event.PopupMenuEvent;
-import javax.swing.event.PopupMenuListener;
-import javax.swing.plaf.basic.BasicComboBoxUI;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-
-/**
- * This component provides a way to handle selecting an item from a
- * list that may grow too large to be handled conveniently by a combo-box.
- * If the list's size is less than the designated "long" list size,
- * the choice list will be displayed in a normal combo-box popup;
- * otherwise, a dialog will be used to prompt the user to choose a selection.
- *
- * To change the browse mechanism, subclasses may
- * - override the method #buildBrowser()
- * - override the method #browse(), in which case the method
- * #buildBrowser() may be ignored.
- */
-public class ListChooser
- extends JComboBox
-{
-
- /** the size of a "long" list - anything smaller is a "short" list */
- int longListSize = DEFAULT_LONG_LIST_SIZE;
-
- /** the default size of a "long" list, which is 20 (to match JOptionPane's behavior) */
- public static final int DEFAULT_LONG_LIST_SIZE = 20;
-
- /** property change associated with long list size */
- public static final String LONG_LIST_SIZE_PROPERTY = "longListSize";
-
- static JLabel prototypeLabel = new JLabel("Prototype", new EmptyIcon(17), SwingConstants.LEADING);
-
- /**
- * whether the chooser is choosable. if a chooser is not choosable,
- * it only serves as a display widget. a user may not change its
- * selected value.
- */
- boolean choosable = true;
-
- /** property change associated with choosable */
- public static final String CHOOSABLE_PROPERTY = "choosable";
-
- /** the browser used to make a selection from the long list - typically via a dialog */
- private ListBrowser browser;
-
- private NodeSelector nodeSelector;
-
- /** INTERNAL - The popup is being shown. Used to prevent infinite loop. */
- boolean popupAlreadyInProgress;
-
-
- // **************** Constructors ******************************************
-
- /**
- * Construct a list chooser for the specified model.
- */
- public ListChooser(ComboBoxModel model) {
- this(model, new NodeSelector.DefaultNodeSelector());
- }
-
- public ListChooser(CachingComboBoxModel model) {
- this(model, new NodeSelector.DefaultNodeSelector());
- }
-
- public ListChooser(ComboBoxModel model, NodeSelector nodeSelector) {
- this(new NonCachingComboBoxModel(model), nodeSelector);
- }
-
- public ListChooser(CachingComboBoxModel model, NodeSelector nodeSelector) {
- super(model);
- this.initialize();
- this.nodeSelector = nodeSelector;
- }
- // **************** Initialization ****************************************
-
- protected void initialize() {
- this.addPopupMenuListener(this.buildPopupMenuListener());
- this.setRenderer(new DefaultListCellRenderer());
- this.addKeyListener(buildF3KeyListener());
-
- //These are used to workaround problems with Swing trying to
- //determine the size of a comboBox with a large model
- setPrototypeDisplayValue(prototypeLabel);
- listBox().setPrototypeCellValue(prototypeLabel);
- }
-
-
- private JList listBox() {
- return (JList) ClassTools.fieldValue(this.ui, "listBox");
- }
-
- /**
- * When the popup is about to be shown, the event is consumed, and
- * PopupHandler determines whether to reshow the popup or to show
- * the long list browser.
- */
- private PopupMenuListener buildPopupMenuListener() {
- return new PopupMenuListener() {
- public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
- ListChooser.this.aboutToShowPopup();
- }
- public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
- // do nothing
- }
- public void popupMenuCanceled(PopupMenuEvent e) {
- // do nothing
- }
- @Override
- public String toString() {
- return "pop-up menu listener";
- }
- };
- }
-
- /**
- * If this code is being reached due to the PopupHandler already being in progress,
- * then do nothing. Otherwise, set the flag to true and launch the PopupHandler.
- */
- void aboutToShowPopup() {
- if (this.popupAlreadyInProgress) {
- return;
- }
-
- this.popupAlreadyInProgress = true;
- EventQueue.invokeLater(new PopupHandler());
- }
-
-
- private KeyListener buildF3KeyListener() {
- return new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_F3) {
- goToSelectedItem();
- }
- }
- @Override
- public String toString() {
- return "F3 key listener";
- }
- };
- }
-
- public void goToSelectedItem() {
- if (getSelectedItem() != null) {
- ListChooser.this.nodeSelector.selectNodeFor(getSelectedItem());
- }
- }
-
- // **************** Browsing **********************************************
-
- /**
- * Lazily initialize because subclasses may have further initialization to do
- * before browser can be built.
- */
- protected void browse() {
- if (this.browser == null) {
- this.browser = this.buildBrowser();
- }
-
- this.browser.browse(this);
- }
-
- /**
- * Return the "browser" used to make a selection from the long list,
- * typically via a dialog.
- */
- protected ListChooser.ListBrowser buildBrowser() {
- return new SimpleListBrowser();
- }
-
-
- // **************** Choosable functionality *******************************
-
- /** override behavior - consume selection if chooser is not choosable */
- @Override
- public void setSelectedIndex(int anIndex) {
- if (this.choosable) {
- super.setSelectedIndex(anIndex);
- }
- }
-
- private void updateArrowButton() {
- try {
- BasicComboBoxUI comboBoxUi = (BasicComboBoxUI) ListChooser.this.getUI();
- JButton arrowButton = (JButton) ClassTools.fieldValue(comboBoxUi, "arrowButton");
- arrowButton.setEnabled(this.isEnabled() && this.choosable);
- }
- catch (Exception e) {
- // this is a huge hack to try and make the combo box look right,
- // so if it doesn't work, just swallow the exception
- }
- }
-
-
- // **************** List Caching *******************************
-
- void cacheList() {
- ((CachingComboBoxModel) getModel()).cacheList();
- }
-
- void uncacheList() {
- ((CachingComboBoxModel) getModel()).uncacheList();
- }
-
- boolean listIsCached() {
- return ((CachingComboBoxModel) getModel()).isCached();
- }
-
- // **************** Public ************************************************
-
- public int longListSize() {
- return this.longListSize;
- }
-
- public void setLongListSize(int newLongListSize) {
- int oldLongListSize = this.longListSize;
- this.longListSize = newLongListSize;
- this.firePropertyChange(LONG_LIST_SIZE_PROPERTY, oldLongListSize, newLongListSize);
- }
-
- public boolean isChoosable() {
- return this.choosable;
- }
-
- public void setChoosable(boolean newValue) {
- boolean oldValue = this.choosable;
- this.choosable = newValue;
- this.firePropertyChange(CHOOSABLE_PROPERTY, oldValue, newValue);
- this.updateArrowButton();
- }
-
- // **************** Handle selecting null as a value **********************
-
- private boolean selectedIndexIsNoneSelectedItem(int index) {
- return index == -1 &&
- getModel().getSize() > 0 &&
- getModel().getElementAt(0) == null;
- }
-
- @Override
- public int getSelectedIndex() {
- boolean listNotCached = !listIsCached();
- if (listNotCached) {
- cacheList();
- }
-
- int index = super.getSelectedIndex();
-
- // Use index 0 to show the <none selected> item since the actual value is
- // null and JComboBox does not handle null values
- if (selectedIndexIsNoneSelectedItem(index)) {
- index = 0;
- }
-
- if (listNotCached) {
- uncacheList();
- }
- return index;
- }
-
- //wrap the renderer to deal with the prototypeDisplayValue
- @Override
- public void setRenderer(final ListCellRenderer aRenderer) {
- super.setRenderer(new ListCellRenderer(){
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- if (value == prototypeLabel) {
- return prototypeLabel;
- }
- return aRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- }
- });
- }
-
-
- // **************** Member classes ****************************************
-
- /**
- * Define the API required by this ListChooser when it must
- * prompt the user to select an item from the "long" list.
- */
- public interface ListBrowser
- {
- /**
- * Prompt the user to make a selection from the specified
- * combo-box's model.
- */
- void browse(ListChooser parentChooser);
- }
-
-
- /**
- * Runnable class that consumes popup window and determines whether
- * to reshow popup or to launch browser, based on the size of the list.
- */
- private class PopupHandler
- implements Runnable
- {
- /** The mouse event */
- private MouseEvent lastMouseEvent;
-
- /** The component from which the last mouse event was thrown */
- private JComponent eventComponent;
-
- /** The location of the component at the time the last mouse event was thrown */
- private Point componentLocation;
-
- /** The location of the mouse at the time the last mouse event was thrown */
- private Point mouseLocation;
-
-
- PopupHandler() {
- this.initialize();
- }
-
- private void initialize() {
- AWTEvent event = EventQueue.getCurrentEvent();
-
- if (event instanceof MouseEvent) {
- this.lastMouseEvent = (MouseEvent) event;
- this.eventComponent = (JComponent) this.lastMouseEvent.getSource();
- this.componentLocation = this.eventComponent.getLocationOnScreen();
- this.mouseLocation = this.lastMouseEvent.getPoint();
- }
- else {
- this.eventComponent = null;
- this.componentLocation = null;
- this.mouseLocation = null;
- }
- }
-
- public void run() {
- ListChooser.this.hidePopup();
-
- cacheList();
- if (ListChooser.this.choosable == true) {
- // If the combo box model is of sufficient length, the browser will be shown.
- // Asking the combo box model for its size should be enough to ensure that
- // its size is recalculated.
- if (ListChooser.this.getModel().getSize() > ListChooser.this.longListSize) {
- this.checkComboBoxButton();
- ListChooser.this.browse();
- }
- else {
- ListChooser.this.showPopup();
- this.checkMousePosition();
- }
- }
- if (listIsCached()) {
- uncacheList();
- }
-
- ListChooser.this.popupAlreadyInProgress = false;
- }
-
- /** If this is not done, the button never becomes un-pressed */
- private void checkComboBoxButton() {
- try {
- BasicComboBoxUI comboBoxUi = (BasicComboBoxUI) ListChooser.this.getUI();
- JButton arrowButton = (JButton) ClassTools.fieldValue(comboBoxUi, "arrowButton");
- arrowButton.getModel().setPressed(false);
- }
- catch (Exception e) {
- // this is a huge hack to try and make the combo box look right,
- // so if it doesn't work, just swallow the exception
- }
- }
-
- /**
- * Moves the mouse back to its original position before any jiggery pokery that we've done.
- */
- private void checkMousePosition() {
- if (this.eventComponent == null) {
- return;
- }
-
- final Point newComponentLocation = this.eventComponent.getLocationOnScreen();
- boolean componentMoved =
- newComponentLocation.x - this.componentLocation.x != 0
- || newComponentLocation.y - this.componentLocation.y != 0;
-
- if (componentMoved) {
- try {
- new Robot().mouseMove(
- newComponentLocation.x + this.mouseLocation.x,
- newComponentLocation.y + this.mouseLocation.y
- );
- }
- catch (AWTException ex) {
- // move failed - do nothing
- }
- }
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/NodeSelector.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/NodeSelector.java
deleted file mode 100644
index f8b4d148e5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/NodeSelector.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-/**
- * This will be called when the user presses F3 or chooses
- * 'Go To' in the context menu
- */
-public interface NodeSelector
-{
- /**
- * Select the appropriate Node in the tree or the editor panel.
- */
- void selectNodeFor(Object item);
-
- /**
- * This NodeSelector will do nothing when selectNodeFor(Object) is called
- */
- class DefaultNodeSelector implements NodeSelector {
-
- public void selectNodeFor(Object item) {
- //default is to do nothing
- }
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/NonCachingComboBoxModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/NonCachingComboBoxModel.java
deleted file mode 100644
index ee7226457f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/NonCachingComboBoxModel.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import javax.swing.ComboBoxModel;
-import javax.swing.event.ListDataListener;
-
-/**
- * This implementation of the CachingComboBoxModel interface can be used
- * whenever there is no need for caching (i.e. the contents of the selection
- * list can be generated with little latency). All the normal ComboBoxModel
- * behavior is delegated to a client-supplied ComboBoxModel.
- */
-public class NonCachingComboBoxModel implements CachingComboBoxModel {
- private ComboBoxModel wrappedComboBoxModel;
-
- public NonCachingComboBoxModel(ComboBoxModel wrappedComboBoxModel) {
- this.wrappedComboBoxModel = wrappedComboBoxModel;
- }
-
-
- // ********** CachingComboBoxModel implementation **********
-
- public void cacheList() {
- //do nothing
- }
-
- public void uncacheList() {
- //do nothing
- }
-
- public boolean isCached() {
- return false;
- }
-
-
- // ********** ComboBoxModel implementation **********
-
- public void setSelectedItem(Object anItem) {
- this.wrappedComboBoxModel.setSelectedItem(anItem);
- }
-
- public Object getSelectedItem() {
- return this.wrappedComboBoxModel.getSelectedItem();
- }
-
-
- // ********** ListModel implementation **********
-
- public int getSize() {
- return this.wrappedComboBoxModel.getSize();
- }
-
- public Object getElementAt(int index) {
- return this.wrappedComboBoxModel.getElementAt(index);
- }
-
- public void addListDataListener(ListDataListener l) {
- this.wrappedComboBoxModel.addListDataListener(l);
- }
-
- public void removeListDataListener(ListDataListener l) {
- this.wrappedComboBoxModel.removeListDataListener(l);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SimpleDisplayable.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SimpleDisplayable.java
deleted file mode 100644
index d46d8e12e3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SimpleDisplayable.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import javax.swing.Icon;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-
-/**
- * This implementation of Displayable converts any Object
- * to a Displayable. Subclass it to override #displayString() and
- * #icon() if necessary. Change notification will be fired if the
- * object is changed.
- *
- * This can be used for Strings - the display string
- * will simply be the String itself.
- */
-public class SimpleDisplayable
- extends AbstractModel
- implements Displayable
-{
- /** The object to be converted to a Displayable. */
- protected Object object;
-
-
- /**
- * Construct a displayable for the specified object.
- */
- public SimpleDisplayable(Object object) {
- super();
- this.object = object;
- }
-
- public SimpleDisplayable(boolean b) {
- this(Boolean.valueOf(b));
- }
-
- public SimpleDisplayable(char c) {
- this(new Character(c));
- }
-
- public SimpleDisplayable(byte b) {
- this(new Byte(b));
- }
-
- public SimpleDisplayable(short s) {
- this(new Short(s));
- }
-
- public SimpleDisplayable(int i) {
- this(new Integer(i));
- }
-
- public SimpleDisplayable(long l) {
- this(new Long(l));
- }
-
- public SimpleDisplayable(float f) {
- this(new Float(f));
- }
-
- public SimpleDisplayable(double d) {
- this(new Double(d));
- }
-
-
- // ********** Displayable implementation **********
-
- public String displayString() {
- return this.object.toString();
- }
-
- public Icon icon() {
- return null;
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(Displayable o) {
- return DEFAULT_COMPARATOR.compare(this, o);
- }
-
-
- // ********** accessors **********
-
- public Object getObject() {
- return this.object;
- }
-
- public void setObject(Object object) {
- String oldDisplayString = this.displayString();
- Icon oldIcon = this.icon();
- this.object = object;
- this.firePropertyChanged(DISPLAY_STRING_PROPERTY, oldDisplayString, this.displayString());
- this.firePropertyChanged(ICON_PROPERTY, oldIcon, this.icon());
- }
-
- public boolean getBoolean() {
- return ((Boolean) this.object).booleanValue();
- }
-
- public void setBoolean(boolean b) {
- this.setObject(Boolean.valueOf(b));
- }
-
- public char getChar() {
- return ((Character) this.object).charValue();
- }
-
- public void setChar(char c) {
- this.setObject(new Character(c));
- }
-
- public byte getByte() {
- return ((Byte) this.object).byteValue();
- }
-
- public void setByte(byte b) {
- this.setObject(new Byte(b));
- }
-
- public short getShort() {
- return ((Short) this.object).shortValue();
- }
-
- public void setShort(short s) {
- this.setObject(new Short(s));
- }
-
- public int getInt() {
- return ((Integer) this.object).intValue();
- }
-
- public void setInt(int i) {
- this.setObject(new Integer(i));
- }
-
- public long getLong() {
- return ((Long) this.object).longValue();
- }
-
- public void setLong(long l) {
- this.setObject(new Long(l));
- }
-
- public float getFloat() {
- return ((Float) this.object).floatValue();
- }
-
- public void setFloat(float f) {
- this.setObject(new Float(f));
- }
-
- public double getDouble() {
- return ((Double) this.object).doubleValue();
- }
-
- public void setDouble(double d) {
- this.setObject(new Double(d));
- }
-
-
- // ********** override methods **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.object);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SimpleListBrowser.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SimpleListBrowser.java
deleted file mode 100644
index 7215c6a387..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SimpleListBrowser.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import javax.swing.Icon;
-import javax.swing.JComboBox;
-import javax.swing.JOptionPane;
-import javax.swing.ListModel;
-
-/**
- * This implementation of ListChooser.Browser uses a
- * JOptionPane to prompt the user for the selection. Subclasses
- * can change the dialog's title, message, and/or icon.
- */
-public class SimpleListBrowser
- implements ListChooser.ListBrowser
-{
- /** Default constructor */
- protected SimpleListBrowser() {
- super();
- }
-
- /**
- * Prompt the user using a JOptionPane.
- */
- public void browse(ListChooser chooser) {
- Object selection =
- JOptionPane.showInputDialog(
- chooser,
- this.message(chooser),
- this.title(chooser),
- this.messageType(chooser),
- this.icon(chooser),
- this.selectionValues(chooser),
- this.initialSelectionValue(chooser)
- );
-
- if (selection != null) {
- chooser.getModel().setSelectedItem(selection);
- }
- }
-
- protected Object message(JComboBox comboBox) {
- return null;
- }
-
- protected String title(JComboBox comboBox) {
- return null;
- }
-
- protected int messageType(JComboBox comboBox) {
- return JOptionPane.QUESTION_MESSAGE;
- }
-
- protected Icon icon(JComboBox comboBox) {
- return null;
- }
-
- protected Object[] selectionValues(JComboBox comboBox) {
- return this.convertToArray(comboBox.getModel());
- }
-
- protected Object initialSelectionValue(JComboBox comboBox) {
- return comboBox.getModel().getSelectedItem();
- }
-
- /**
- * Convert the list of objects in the specified list model
- * into an array.
- */
- protected Object[] convertToArray(ListModel model) {
- int size = model.getSize();
- Object[] result = new Object[size];
- for (int i = 0; i < size; i++) {
- result[i] = model.getElementAt(i);
- }
- return result;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SimpleListCellRenderer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SimpleListCellRenderer.java
deleted file mode 100644
index facf5d3c65..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SimpleListCellRenderer.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import java.awt.Component;
-
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.Icon;
-import javax.swing.JList;
-
-/**
- * This renderer should behave the same as the DefaultListCellRenderer;
- * but it slightly refactors the calculation of the icon and text of the list
- * cell so that subclasses can easily override the methods that build
- * the icon and text.
- *
- * In most cases, you need only override:
- * #buildIcon(Object value)
- * #buildText(Object value)
- */
-public class SimpleListCellRenderer
- extends DefaultListCellRenderer
-{
-
- /**
- * Construct a simple renderer.
- */
- public SimpleListCellRenderer() {
- super();
- }
-
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- // substitute null for the cell value so nothing is drawn initially...
- super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus);
- this.setOpaque(true);
-
- // ...then set the icon and text manually
- this.setIcon(this.buildIcon(list, value, index, isSelected, cellHasFocus));
- this.setText(this.buildText(list, value, index, isSelected, cellHasFocus));
-
- this.setToolTipText(this.buildToolTipText(list, value, index, isSelected, cellHasFocus));
-
- // the context will be initialized only if a reader is running
- if (this.accessibleContext != null) {
- this.accessibleContext.setAccessibleName(this.buildAccessibleName(list, value, index, isSelected, cellHasFocus));
- }
-
- return this;
- }
-
- /**
- * Return the icon representation of the specified cell
- * value and other settings. (Even more settings are
- * accessible via inherited getters: hasFocus, isEnabled, etc.)
- */
- protected Icon buildIcon(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- return this.buildIcon(value);
- }
-
- /**
- * Return the icon representation of the specified cell
- * value. The default is to display no icon at all unless the
- * value itself is an icon.
- */
- protected Icon buildIcon(Object value) {
- // replicate the default behavior
- return (value instanceof Icon) ? (Icon) value : null;
- }
-
- /**
- * Return the textual representation of the specified cell
- * value and other settings. (Even more settings are
- * accessible via inherited getters: hasFocus, isEnabled, etc.)
- */
- protected String buildText(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- return this.buildText(value);
- }
-
- /**
- * Return the textual representation of the specified cell
- * value. The default is to display the object's default string
- * representation (as returned by #toString()); unless the
- * value itself is an icon, in which case no text is displayed.
- */
- protected String buildText(Object value) {
- return (value instanceof Icon) ? "" : ((value == null) ? "" : value.toString());
- }
-
- /**
- * Return the text displayed when the cursor lingers over the specified cell.
- * (Even more settings are accessible via inherited getters: hasFocus, isEnabled, etc.)
- */
- protected String buildToolTipText(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- return this.buildToolTipText(value);
- }
-
- /**
- * Return the text displayed when the cursor lingers over the specified cell.
- */
- protected String buildToolTipText(Object value) {
- return null;
- }
-
- /**
- * Return the accessible name to be given to the component used to render
- * the given value and other settings. (Even more settings are accessible via
- * inherited getters: hasFocus, isEnabled, etc.)
- */
- protected String buildAccessibleName(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- return this.buildAccessibleName(value);
- }
-
- /**
- * Return the accessible name to be given to the component used to render
- * the given value.
- */
- protected String buildAccessibleName(Object value) {
- return null;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SpinnerTableCellRenderer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SpinnerTableCellRenderer.java
deleted file mode 100644
index ad071e4ac9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/SpinnerTableCellRenderer.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import java.awt.Color;
-import java.awt.Component;
-
-import javax.swing.BorderFactory;
-import javax.swing.JComponent;
-import javax.swing.JSpinner;
-import javax.swing.JTable;
-import javax.swing.SpinnerModel;
-import javax.swing.UIManager;
-import javax.swing.border.Border;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-/**
- * Make the cell look like a spinner.
- */
-public class SpinnerTableCellRenderer implements TableCellEditorAdapter.Renderer {
-
- /** the component used to paint the cell */
- protected JSpinner spinner;
-
- /** the listener to be notified on an immediate edit */
- protected TableCellEditorAdapter.ImmediateEditListener immediateEditListener;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Construct a cell renderer that uses the default
- * spinner model, which is a "number" model.
- */
- public SpinnerTableCellRenderer() {
- super();
- this.initialize();
- }
-
- /**
- * Construct a cell renderer that uses the specified
- * spinner model, which will determine how the values are displayed.
- */
- public SpinnerTableCellRenderer(SpinnerModel model) {
- this();
- this.setModel(model);
- }
-
- protected void initialize() {
- this.spinner = this.buildSpinner();
- }
-
- protected JSpinner buildSpinner() {
- JSpinner s = new JSpinner();
- s.addChangeListener(this.buildChangeListener());
- return s;
- }
-
- private ChangeListener buildChangeListener() {
- return new ChangeListener() {
- public void stateChanged(ChangeEvent e) {
- if (SpinnerTableCellRenderer.this.immediateEditListener != null) {
- SpinnerTableCellRenderer.this.immediateEditListener.immediateEdit();
- }
- }
- };
- }
-
-
- // ********** TableCellRenderer implementation **********
-
- public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
- this.spinner.setComponentOrientation(table.getComponentOrientation());
- this.spinner.setFont(table.getFont());
- this.spinner.setEnabled(table.isEnabled());
-
- JComponent editor = this.editor();
- editor.setForeground(this.foregroundColor(table, value, selected, hasFocus, row, column));
- editor.setBackground(this.backgroundColor(table, value, selected, hasFocus, row, column));
- this.spinner.setBorder(this.border(table, value, selected, hasFocus, row, column));
-
- this.setValue(value);
- return this.spinner;
- }
-
- /**
- * Return the cell's foreground color.
- */
- protected Color foregroundColor(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
- if (selected) {
- if (hasFocus && table.isCellEditable(row, column)) {
- return UIManager.getColor("Table.focusCellForeground");
- }
- return table.getSelectionForeground();
- }
- return table.getForeground();
- }
-
- /**
- * Return the cell's background color.
- */
- protected Color backgroundColor(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
- if (selected) {
- if (hasFocus && table.isCellEditable(row, column)) {
- return UIManager.getColor("Table.focusCellBackground");
- }
- return table.getSelectionBackground();
- }
- return table.getBackground();
- }
-
- /**
- * Return the cell's border.
- */
- protected Border border(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
- if (hasFocus) {
- return UIManager.getBorder("Table.focusCellHighlightBorder");
- }
- if (selected) {
- return BorderFactory.createLineBorder(table.getSelectionBackground(), 1);
- }
- return BorderFactory.createLineBorder(table.getBackground(), 1);
- }
-
- /**
- * Return the editor component whose colors should be set
- * by the renderer.
- */
- protected JComponent editor() {
- JComponent editor = this.spinner.getEditor();
- if (editor instanceof JSpinner.DefaultEditor) {
- // typically, the editor will be the default or one of its subclasses...
- editor = ((JSpinner.DefaultEditor) editor).getTextField();
- }
- return editor;
- }
-
- /**
- * Set the spinner's value
- */
- protected void setValue(Object value) {
- // CR#3999318 - This null check needs to be removed once JDK bug is fixed
- if (value == null) {
- value = new Integer(0);
- }
- this.spinner.setValue(value);
- }
-
-
- // ********** TableCellEditorAdapter.Renderer implementation **********
-
- public Object getValue() {
- return this.spinner.getValue();
- }
-
- public void setImmediateEditListener(TableCellEditorAdapter.ImmediateEditListener listener) {
- this.immediateEditListener = listener;
- }
-
-
- // ********** public API **********
-
- /**
- * Set the spinner's model.
- */
- public void setModel(SpinnerModel model) {
- this.spinner.setModel(model);
- }
-
- /**
- * Return the renderer's preferred height. This allows you
- * to set the row height to something the spinner will look good in....
- */
- public int preferredHeight() {
- // add in space for the border top and bottom
- return (int) this.spinner.getPreferredSize().getHeight() + 2;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/TableCellEditorAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/TableCellEditorAdapter.java
deleted file mode 100644
index 0118692cc8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/TableCellEditorAdapter.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.internal.swing;
-
-import java.awt.Component;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.JTable;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-
-/**
- * A table cell editor that wraps a table cell renderer.
- */
-public class TableCellEditorAdapter extends AbstractCellEditor implements TableCellEditor {
-
- /** delegate to a renderer */
- private Renderer renderer;
-
-
- // ********** constructors/initialization **********
-
- private TableCellEditorAdapter() {
- super();
- }
-
- /**
- * Construct a cell editor that behaves like the specified renderer.
- */
- public TableCellEditorAdapter(Renderer renderer) {
- this();
- this.initialize(renderer);
- }
-
- protected void initialize(Renderer r) {
- this.renderer = r;
- r.setImmediateEditListener(this.buildImmediateEditListener());
- }
-
- private ImmediateEditListener buildImmediateEditListener() {
- return new ImmediateEditListener() {
- public void immediateEdit() {
- TableCellEditorAdapter.this.stopCellEditing();
- }
- };
- }
-
-
- // ********** CellEditor implementation **********
-
- public Object getCellEditorValue() {
- return this.renderer.getValue();
- }
-
-
- // ********** TableCellEditor implementation **********
-
- public Component getTableCellEditorComponent(JTable table, Object value, boolean selected, int row, int column) {
- return this.renderer.getTableCellRendererComponent(table, value, selected, true, row, column);
- }
-
-
- // ********** Member classes **********************************************
-
- /**
- * This interface defines the methods that must be implemented by a renderer
- * that can be wrapped by a TableCellEditorAdapter.
- */
- public interface Renderer extends TableCellRenderer {
-
- /**
- * Return the current value of the renderer.
- */
- Object getValue();
-
- /**
- * Set the immediate edit listener
- */
- void setImmediateEditListener(ImmediateEditListener listener);
- }
-
-
- public interface ImmediateEditListener {
-
- /**
- * Called when the renderer does an "immediate edit"
- */
- void immediateEdit();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/Model.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/Model.java
deleted file mode 100644
index 33f2fd2afd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/Model.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model;
-
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
-
-/**
- * Interface to be implemented by models that notify listeners of
- * changes to bound properties, collections, lists, and/or trees.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface Model {
-
- // ********** state change **********
-
- /**
- * Add a listener that listens to all state change events.
- * The same listener may be added more than once and will be called
- * as many times as it is added. The listener cannot be null.
- */
- void addStateChangeListener(StateChangeListener listener);
-
- /**
- * Remove the specified state change listener. If the listener
- * was added more than once, it will be notified one less time
- * after being removed. An exception will be thrown if the
- * listener is null or if the listener was never added.
- */
- void removeStateChangeListener(StateChangeListener listener);
-
-
- // ********** property change **********
-
- /**
- * Add a listener that listens to all property change events,
- * regardless of the property name associated with that event.
- * The same listener may be added more than once and will be called
- * as many times as it is added. The listener cannot be null.
- */
- void addPropertyChangeListener(PropertyChangeListener listener);
-
- /**
- * Add a listener that listens to all property change events with
- * the specified property name.
- * The same listener may be added more than once and will be called
- * as many times as it is added. The listener cannot be null.
- */
- void addPropertyChangeListener(String propertyName, PropertyChangeListener listener);
-
- /**
- * Remove a listener that listens to all property change events,
- * regardless of the property name associated with that event.
- * If the listener was added more than once, it will be notified one less
- * time after being removed. An exception will be thrown if the
- * listener is null or if the listener was never added.
- */
- void removePropertyChangeListener(PropertyChangeListener listener);
-
- /**
- * Remove a listener that listens to all property change events,
- * with the specified property name.
- * If the listener was added more than once, it will be notified one less
- * time after being removed. An exception will be thrown if the
- * listener is null or if the listener was never added.
- */
- void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
-
-
- // ********** collection change **********
-
- /**
- * Add a listener that listens to all collection change events,
- * regardless of the collection name associated with that event.
- * The same listener may be added more than once and will be called
- * as many times as it is added. The listener cannot be null.
- */
- void addCollectionChangeListener(CollectionChangeListener listener);
-
- /**
- * Add a listener that listens to all collection change events with
- * the specified collection name.
- * The same listener may be added more than once and will be called
- * as many times as it is added. The listener cannot be null.
- */
- void addCollectionChangeListener(String collectionName, CollectionChangeListener listener);
-
- /**
- * Remove a listener that listens to all collection change events,
- * regardless of the collection name associated with that event.
- * If the listener was added more than once, it will be notified one less
- * time after being removed. An exception will be thrown if the
- * listener is null or if the listener was never added.
- */
- void removeCollectionChangeListener(CollectionChangeListener listener);
-
- /**
- * Remove a listener that listens to all collection change events,
- * with the specified collection name.
- * If the listener was added more than once, it will be notified one less
- * time after being removed. An exception will be thrown if the
- * listener is null or if the listener was never added.
- */
- void removeCollectionChangeListener(String collectionName, CollectionChangeListener listener);
-
-
- // ********** list change **********
-
- /**
- * Add a listener that listens to all list change events,
- * regardless of the list name associated with that event.
- * The same listener may be added more than once and will be called
- * as many times as it is added. The listener cannot be null.
- */
- void addListChangeListener(ListChangeListener listener);
-
- /**
- * Add a listener that listens to all list change events with
- * the specified list name.
- * The same listener may be added more than once and will be called
- * as many times as it is added. The listener cannot be null.
- */
- void addListChangeListener(String listName, ListChangeListener listener);
-
- /**
- * Remove a listener that listens to all list change events,
- * regardless of the list name associated with that event.
- * If the listener was added more than once, it will be notified one less
- * time after being removed. An exception will be thrown if the
- * listener is null or if the listener was never added.
- */
- void removeListChangeListener(ListChangeListener listener);
-
- /**
- * Remove a listener that listens to all list change events,
- * with the specified list name.
- * If the listener was added more than once, it will be notified one less
- * time after being removed. An exception will be thrown if the
- * listener is null or if the listener was never added.
- */
- void removeListChangeListener(String listName, ListChangeListener listener);
-
-
- // ********** tree change **********
-
- /**
- * Add a listener that listens to all tree change events,
- * regardless of the tree name associated with that event.
- * The same listener may be added more than once and will be called
- * as many times as it is added. The listener cannot be null.
- */
- void addTreeChangeListener(TreeChangeListener listener);
-
- /**
- * Add a listener that listens to all tree change events with
- * the specified tree name.
- * The same listener may be added more than once and will be called
- * as many times as it is added. The listener cannot be null.
- */
- void addTreeChangeListener(String treeName, TreeChangeListener listener);
-
- /**
- * Remove a listener that listens to all tree change events,
- * regardless of the tree name associated with that event.
- * If the listener was added more than once, it will be notified one less
- * time after being removed. An exception will be thrown if the
- * listener is null or if the listener was never added.
- */
- void removeTreeChangeListener(TreeChangeListener listener);
-
- /**
- * Remove a listener that listens to all tree change events,
- * with the specified tree name.
- * If the listener was added more than once, it will be notified one less
- * time after being removed. An exception will be thrown if the
- * listener is null or if the listener was never added.
- */
- void removeTreeChangeListener(String treeName, TreeChangeListener listener);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/ChangeEvent.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/ChangeEvent.java
deleted file mode 100644
index a794045b7a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/ChangeEvent.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.event;
-
-import java.util.EventObject;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * Abstract class for all the change events that can be fired by models.
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public abstract class ChangeEvent extends EventObject {
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a new change event.
- *
- * @param source The object on which the event initially occurred.
- */
- protected ChangeEvent(Model source) {
- super(source);
- }
-
- /**
- * Covariant override.
- */
- @Override
- public Model getSource() {
- return (Model) super.getSource();
- }
-
- /**
- * Return the name of the aspect of the source that changed.
- * May be null if inappropriate.
- */
- public abstract String getAspectName();
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- public abstract ChangeEvent cloneWithSource(Model newSource);
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.getAspectName());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/CollectionChangeEvent.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/CollectionChangeEvent.java
deleted file mode 100644
index fbbad13412..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/CollectionChangeEvent.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.event;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * A "collection change" event gets delivered whenever a model changes a "bound"
- * or "constrained" collection. A CollectionChangeEvent is sent as an
- * argument to the CollectionChangeListener.
- *
- * Normally a CollectionChangeEvent is accompanied by the collection name and
- * the items that were added to or removed from the changed collection.
- *
- * Design options:
- * - create a collection to wrap a single added or removed item
- * (this is the option we implemented below and in collaborating code)
- * since there is no way to optimize downstream code for
- * single items, we take another performance hit by building
- * a collection each time (@see Collections#singleton(Object))
- * and forcing downstream code to use an iterator every time
- *
- * - fire a separate event for each item added or removed
- * eliminates any potential for optimizations to downstream code
- *
- * - add protocol to support both single items and collections
- * adds conditional logic to downstream code
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class CollectionChangeEvent extends ChangeEvent {
-
- /** Name of the collection that changed. */
- private final String collectionName;
-
- /** The items that were added to or removed from the collection. May be empty, if not known. */
- private final Collection<?> items;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new collection change event.
- *
- * @param source The object on which the event initially occurred.
- * @param collectionName The programmatic name of the collection that was changed.
- * @param items The items that were added to or removed from the collection.
- */
- public CollectionChangeEvent(Model source, String collectionName, Collection<?> items) {
- super(source);
- if ((collectionName == null) || (items == null)) {
- throw new NullPointerException();
- }
- this.collectionName = collectionName;
- this.items = Collections.unmodifiableCollection(items);
- }
-
- /**
- * Construct a new collection change event.
- *
- * @param source The object on which the event initially occurred.
- * @param collectionName The programmatic name of the collection that was changed.
- */
- public CollectionChangeEvent(Model source, String collectionName) {
- this(source, collectionName, Collections.emptySet());
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the programmatic name of the collection that was changed.
- */
- public String getCollectionName() {
- return this.collectionName;
- }
-
- @Override
- public String getAspectName() {
- return this.collectionName;
- }
-
- /**
- * Return an iterator on the items that were added to or
- * removed from the collection.
- * May be empty if inappropriate or unknown.
- */
- public Iterator<?> items() {
- return this.items.iterator();
- }
-
- /**
- * Return the number of items that were added to or
- * removed from the collection.
- * May be 0 if inappropriate or unknown.
- */
- public int itemsSize() {
- return this.items.size();
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- @Override
- public CollectionChangeEvent cloneWithSource(Model newSource) {
- return new CollectionChangeEvent(newSource, this.collectionName, this.items);
- }
-
- /**
- * Return a copy of the event with the specified source and collection name
- * replacing the current source and collection name.
- */
- public CollectionChangeEvent cloneWithSource(Model newSource, String newCollectionName) {
- return new CollectionChangeEvent(newSource, newCollectionName, this.items);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/ListChangeEvent.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/ListChangeEvent.java
deleted file mode 100644
index c1eff08e04..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/ListChangeEvent.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.event;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * A "list change" event gets delivered whenever a model changes a "bound"
- * or "constrained" list. A ListChangeEvent is sent as an
- * argument to the ListChangeListener.
- *
- * Normally a ListChangeEvent is accompanied by the list name,
- * the items that were added to or removed from the changed list,
- * and the index of where the items are or were in the list.
- *
- * Design options:
- * - create a list to wrap a single added or removed item
- * (this is the option we implemented below and in collaborating code)
- * since there is no way to optimize downstream code for
- * single items, we take another performance hit by building
- * a list each time (@see Collections#singletonList(Object))
- * and forcing downstream code to use a list iterator every time
- *
- * - fire a separate event for each item added or removed
- * eliminates any potential for optimizations to downstream code
- *
- * - add protocol to support both single items and collections
- * adds conditional logic to downstream code
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class ListChangeEvent extends ChangeEvent {
-
- /**
- * Name of the list that changed.
- */
- private final String listName;
-
- /**
- * The index at which the items were added, removed, or replaced.
- * In the case of "moved" items, this will be the "target" index.
- * May be -1, if not known.
- */
- private final int index;
-
- /**
- * The items that were added to or removed from the list. In the case of
- * "replaced" items, these are the new items in the list.
- * In the case of "moved" items, this will be empty.
- * May be empty, if not known.
- */
- private final List<?> items;
-
- /**
- * The items in the list that were replaced by the items listed above,
- * in #items. May be empty, if not known.
- */
- private final List<?> replacedItems;
-
- /**
- * In the case of "moved" items, this will be the "source" index.
- * May be -1, if not known.
- */
- private final int sourceIndex;
-
- /**
- * In the case of "moved" items, this will be the number of items moved.
- * May be -1, if not known.
- */
- private final int moveLength;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- protected ListChangeEvent(Model source, String listName, int index, List<?> items, List<?> replacedItems, int sourceIndex, int moveLength) {
- super(source);
- if ((listName == null) || (items == null) || (replacedItems == null)) {
- throw new NullPointerException();
- }
- this.listName = listName;
- this.index = index;
- this.items = Collections.unmodifiableList(items);
- this.replacedItems = Collections.unmodifiableList(replacedItems);
- this.sourceIndex = sourceIndex;
- this.moveLength = moveLength;
- }
-
- /**
- * Construct a new list change event for a list of replaced items.
- *
- * @param source The object on which the event initially occurred.
- * @param listName The programmatic name of the list that was changed.
- * @param index The index at which the items in the list were replaced.
- * @param items The new items in the list.
- * @param replacedItems The items in the list that were replaced.
- */
- public ListChangeEvent(Model source, String listName, int index, List<?> items, List<?> replacedItems) {
- this(source, listName, index, items, replacedItems, -1, -1);
- }
-
- /**
- * Construct a new list change event for a list of added or removed items.
- *
- * @param source The object on which the event initially occurred.
- * @param listName The programmatic name of the list that was changed.
- * @param index The index at which the items were added to or removed from the list.
- * @param items The items that were added to or removed from the list.
- */
- public ListChangeEvent(Model source, String listName, int index, List<?> items) {
- this(source, listName, index, items, Collections.emptyList(), -1, -1);
- }
-
- /**
- * Construct a new list change event for a list of moved items.
- *
- * @param source The object on which the event initially occurred.
- * @param listName The programmatic name of the list that was changed.
- * @param targetIndex The index to which the items were moved.
- * @param sourceIndex The index from which the items were moved.
- */
- public ListChangeEvent(Model source, String listName, int targetIndex, int sourceIndex, int length) {
- this(source, listName, targetIndex, Collections.emptyList(), Collections.emptyList(), sourceIndex, length);
- }
-
- /**
- * Construct a new list change event.
- *
- * @param source The object on which the event initially occurred.
- * @param listName The programmatic name of the list that was changed.
- */
- public ListChangeEvent(Model source, String listName) {
- this(source, listName, -1, Collections.emptyList(), Collections.emptyList(), -1, -1);
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the programmatic name of the list that was changed.
- */
- public String getListName() {
- return this.listName;
- }
-
- @Override
- public String getAspectName() {
- return this.listName;
- }
-
- /**
- * Return the index at which the items were added to, removed from,
- * or replaced in the list.
- * In the case of "moved" items, this will be the "target" index.
- * May be -1 if inappropriate or unknown.
- */
- public int getIndex() {
- return this.index;
- }
-
- /**
- * Return a list iterator on the items that were added to or
- * removed from the list. In the case of "replaced" items, these
- * are the new items in the list.
- * May be empty if inappropriate or unknown.
- */
- public ListIterator<?> items() {
- return this.items.listIterator();
- }
-
- /**
- * Return the number of items that were added to,
- * removed from, or replaced in the list.
- * May be 0 if inappropriate or unknown.
- */
- public int itemsSize() {
- return this.items.size();
- }
-
-
- // ********** replace **********
-
- /**
- * Return a list iterator on the items in the list that were replaced.
- * May be empty if inappropriate or unknown.
- */
- public ListIterator<?> replacedItems() {
- return this.replacedItems.listIterator();
- }
-
-
- // ********** move **********
-
- /**
- * In the case of "moved" items, this will be the "target" index.
- * May be -1 if inappropriate or unknown.
- */
- public int getTargetIndex() {
- return this.index;
- }
-
- /**
- * In the case of "moved" items, this will be the "source" index.
- * May be -1 if inappropriate or unknown.
- */
- public int getSourceIndex() {
- return this.sourceIndex;
- }
-
- /**
- * In the case of "moved" items, this will be the number of items moved.
- * May be -1 if inappropriate or unknown.
- */
- public int getMoveLength() {
- return this.moveLength;
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- @Override
- public ListChangeEvent cloneWithSource(Model newSource) {
- return new ListChangeEvent(newSource, this.listName, this.index, this.items, this.replacedItems, this.sourceIndex, this.moveLength);
- }
-
- /**
- * Return a copy of the event with the specified source and list name
- * replacing the current source and list name.
- */
- public ListChangeEvent cloneWithSource(Model newSource, String newListName) {
- return new ListChangeEvent(newSource, newListName, this.index, this.items, this.replacedItems, this.sourceIndex, this.moveLength);
- }
-
- /**
- * Return a copy of the event with the specified source and list name
- * replacing the current source and list name and displacing
- * the index by the specified amount.
- */
- public ListChangeEvent cloneWithSource(Model newSource, String newListName, int offset) {
- return new ListChangeEvent(newSource, newListName, this.index + offset, this.items, this.replacedItems, this.sourceIndex + offset, this.moveLength);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/PropertyChangeEvent.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/PropertyChangeEvent.java
deleted file mode 100644
index ee2fa2f8b2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/PropertyChangeEvent.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.event;
-
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * A "property change" event gets delivered whenever a model changes a "bound"
- * or "constrained" property. A PropertyChangeEvent is sent as an
- * argument to the PropertyChangeListener.
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class PropertyChangeEvent extends ChangeEvent {
-
- /** Name of the property that changed. */
- private final String propertyName;
-
- /** The property's old value, before the change. */
- private final Object oldValue;
-
- /** The property's new value, after the change. */
- private final Object newValue;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new property change event.
- *
- * @param source The object on which the event initially occurred.
- * @param propertyName The programmatic name of the property that was changed.
- * @param oldValue The old value of the property.
- * @param newValue The new value of the property.
- */
- public PropertyChangeEvent(Model source, String propertyName, Object oldValue, Object newValue) {
- super(source);
- if (propertyName == null) {
- throw new NullPointerException();
- }
- this.propertyName = propertyName;
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the programmatic name of the property that was changed.
- */
- public String getPropertyName() {
- return this.propertyName;
- }
-
- @Override
- public String getAspectName() {
- return this.propertyName;
- }
-
- /**
- * Return the old value of the property.
- */
- public Object getOldValue() {
- return this.oldValue;
- }
-
- /**
- * Return the new value of the property.
- */
- public Object getNewValue() {
- return this.newValue;
- }
-
-
- // ********** cloning **********
-
- @Override
- public PropertyChangeEvent cloneWithSource(Model newSource) {
- return new PropertyChangeEvent(newSource, this.propertyName, this.oldValue, this.newValue);
- }
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source and the property name.
- */
- public PropertyChangeEvent cloneWithSource(Model newSource, String newPropertyName) {
- return new PropertyChangeEvent(newSource, newPropertyName, this.oldValue, this.newValue);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/StateChangeEvent.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/StateChangeEvent.java
deleted file mode 100644
index 52e3690e69..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/StateChangeEvent.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.event;
-
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * A generic "state change" event gets delivered whenever a model changes to
- * such extent that it cannot be delineated all aspects of it that have changed.
- * A StateChangeEvent is sent as an argument to the StateChangeListener.
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class StateChangeEvent extends ChangeEvent {
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new state change event.
- *
- * @param source The object on which the event initially occurred.
- */
- public StateChangeEvent(Model source) {
- super(source);
- }
-
-
- // ********** standard state **********
-
- @Override
- public String getAspectName() {
- return null; // the point of the event is that the name is unknown...
- }
-
-
- // ********** cloning **********
-
- @Override
- public StateChangeEvent cloneWithSource(Model newSource) {
- return new StateChangeEvent(newSource);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/TreeChangeEvent.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/TreeChangeEvent.java
deleted file mode 100644
index 2272020490..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/event/TreeChangeEvent.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.event;
-
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * A "tree change" event gets delivered whenever a model changes a "bound"
- * or "constrained" tree. A TreeChangeEvent is sent as an
- * argument to the TreeChangeListener.
- *
- * Normally a TreeChangeEvent is accompanied by the tree name and a path
- * to the part of the tree that was changed.
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class TreeChangeEvent extends ChangeEvent {
-
- /** Name of the tree that changed. */
- private final String treeName;
-
- /**
- * Path to the parent of the part of the tree that was changed.
- * May be empty, if not known or if the entire tree changed.
- */
- protected final Object[] path;
-
- private static final Object[] EMPTY_PATH = new Object[0];
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new tree change event.
- *
- * @param source The object on which the event initially occurred.
- * @param treeName The programmatic name of the tree that was changed.
- * @param path The path to the part of the tree that was changed.
- */
- public TreeChangeEvent(Model source, String treeName, Object[] path) {
- super(source);
- if ((treeName == null) || (path == null)) {
- throw new NullPointerException();
- }
- this.treeName = treeName;
- this.path = path;
- }
-
- /**
- * Construct a new tree change event.
- *
- * @param source The object on which the event initially occurred.
- * @param treeName The programmatic name of the tree that was changed.
- */
- public TreeChangeEvent(Model source, String treeName) {
- this(source, treeName, EMPTY_PATH);
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the programmatic name of the tree that was changed.
- */
- public String getTreeName() {
- return this.treeName;
- }
-
- @Override
- public String getAspectName() {
- return this.treeName;
- }
-
- /**
- * Return the path to the part of the tree that was changed.
- * May be empty, if not known.
- */
- public Object[] getPath() {
- return this.path;
- }
-
-
- // ********** cloning **********
-
- @Override
- public TreeChangeEvent cloneWithSource(Model newSource) {
- return new TreeChangeEvent(newSource, this.treeName, this.path);
- }
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source and the tree name.
- */
- public TreeChangeEvent cloneWithSource(Model newSource, String newTreeName) {
- return new TreeChangeEvent(newSource, newTreeName, this.path);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ChangeListener.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ChangeListener.java
deleted file mode 100644
index d29a7a7de2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ChangeListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.listener;
-
-import java.util.EventListener;
-
-/**
- * Marker interface.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ChangeListener extends EventListener {
- // nothing for now
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/CollectionChangeAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/CollectionChangeAdapter.java
deleted file mode 100644
index 88b1359e16..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/CollectionChangeAdapter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.listener;
-
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-
-/**
- * Convenience implementation of CollectionChangeListener.
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class CollectionChangeAdapter implements CollectionChangeListener {
-
- /**
- * Default constructor.
- */
- public CollectionChangeAdapter() {
- super();
- }
-
- public void itemsAdded(CollectionChangeEvent event) {
- // do nothing
- }
-
- public void itemsRemoved(CollectionChangeEvent event) {
- // do nothing
- }
-
- public void collectionCleared(CollectionChangeEvent event) {
- // do nothing
- }
-
- public void collectionChanged(CollectionChangeEvent event) {
- // do nothing
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/CollectionChangeListener.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/CollectionChangeListener.java
deleted file mode 100644
index 210388b923..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/CollectionChangeListener.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.listener;
-
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-
-/**
- * A "collection change" event gets fired whenever a model changes a "bound"
- * collection. You can register a CollectionChangeListener with a source
- * model so as to be notified of any bound collection updates.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface CollectionChangeListener extends ChangeListener {
-
- /**
- * This method gets called when items are added to a bound collection.
- *
- * @param event A CollectionChangeEvent describing the event source,
- * the collection that changed, and the items that were added.
- */
- void itemsAdded(CollectionChangeEvent event);
-
- /**
- * This method gets called when items are removed from a bound collection.
- *
- * @param event A CollectionChangeEvent describing the event source,
- * the collection that changed, and the items that were removed.
- */
- void itemsRemoved(CollectionChangeEvent event);
-
- /**
- * This method gets called when a bound collection is cleared.
- *
- * @param event A CollectionChangeEvent describing the event source
- * and the collection that changed.
- */
- void collectionCleared(CollectionChangeEvent event);
-
- /**
- * This method gets called when a bound collection is changed in a manner
- * that is not easily characterized by the other methods in this interface.
- *
- * @param event A CollectionChangeEvent describing the event source
- * and the collection that changed.
- */
- void collectionChanged(CollectionChangeEvent event);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ListChangeAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ListChangeAdapter.java
deleted file mode 100644
index 052abc5cf4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ListChangeAdapter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.listener;
-
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-
-/**
- * Convenience implementation of ListChangeListener.
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class ListChangeAdapter implements ListChangeListener {
-
- /**
- * Default constructor.
- */
- public ListChangeAdapter() {
- super();
- }
-
- public void itemsAdded(ListChangeEvent event) {
- // do nothing
- }
-
- public void itemsRemoved(ListChangeEvent event) {
- // do nothing
- }
-
- public void itemsReplaced(ListChangeEvent event) {
- // do nothing
- }
-
- public void itemsMoved(ListChangeEvent event) {
- // do nothing
- }
-
- public void listCleared(ListChangeEvent event) {
- // do nothing
- }
-
- public void listChanged(ListChangeEvent event) {
- // do nothing
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ListChangeListener.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ListChangeListener.java
deleted file mode 100644
index 74eab3a002..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ListChangeListener.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.listener;
-
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-
-/**
- * A "list change" event gets fired whenever a model changes a "bound"
- * list. You can register a ListChangeListener with a source
- * model so as to be notified of any bound list updates.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ListChangeListener extends ChangeListener {
-
- /**
- * This method gets called when items are added to a bound list.
- *
- * @param event A ListChangeEvent describing the event source,
- * the list that changed, the items that were added, and the index
- * at which the items were added.
- */
- void itemsAdded(ListChangeEvent event);
-
- /**
- * This method gets called when items are removed from a bound list.
- *
- * @param event A ListChangeEvent describing the event source,
- * the list that changed, the items that were removed, and the index
- * at which the items were removed.
- */
- void itemsRemoved(ListChangeEvent event);
-
- /**
- * This method gets called when items in a bound list are replaced.
- *
- * @param event A ListChangeEvent describing the event source,
- * the list that changed, the items that were added, the items that were
- * replaced, and the index at which the items were replaced.
- */
- void itemsReplaced(ListChangeEvent event);
-
- /**
- * This method gets called when items in a bound list are moved.
- *
- * @param event A ListChangeEvent describing the event source,
- * the list that changed, and the indices of where items were moved
- * from and to.
- */
- void itemsMoved(ListChangeEvent event);
-
- /**
- * This method gets called when a bound list is cleared.
- *
- * @param event A ListChangeEvent object describing the event source
- * and the list that changed.
- */
- void listCleared(ListChangeEvent event);
-
- /**
- * This method gets called when a bound list is changed in a manner
- * that is not easily characterized by the other methods in this interface.
- *
- * @param event A ListChangeEvent object describing the event source
- * and the list that changed.
- */
- void listChanged(ListChangeEvent event);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/MultiMethodReflectiveChangeListener.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/MultiMethodReflectiveChangeListener.java
deleted file mode 100644
index 8fb5b6d2d7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/MultiMethodReflectiveChangeListener.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.listener;
-
-import java.lang.reflect.Method;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-
-/**
- * This class is used by ReflectiveChangeListener when the requested listener
- * needs to implement multiple methods (i.e. CollectionChangeListener,
- * ListChangeListener, or TreeChangeListener).
- */
-class MultiMethodReflectiveChangeListener
- extends ReflectiveChangeListener
- implements CollectionChangeListener, ListChangeListener, TreeChangeListener
-{
- /** the methods we will invoke on the target object */
- private final Method addMethod;
- private final Method removeMethod;
- private final Method replaceMethod; // this can be null
- private final Method moveMethod; // this can be null
- private final Method clearMethod;
- private final Method changeMethod;
-
-
- /**
- * The "replace" and "move" methods are optional.
- */
- MultiMethodReflectiveChangeListener(Object target, Method addMethod, Method removeMethod, Method replaceMethod, Method moveMethod, Method clearMethod, Method changeMethod) {
- super(target);
- this.addMethod = addMethod;
- this.removeMethod = removeMethod;
- this.replaceMethod = replaceMethod;
- this.moveMethod = moveMethod;
- this.clearMethod = clearMethod;
- this.changeMethod = changeMethod;
- }
-
- /**
- * No "replace" or "move" methods.
- */
- MultiMethodReflectiveChangeListener(Object target, Method addMethod, Method removeMethod, Method clearMethod, Method changeMethod) {
- this(target, addMethod, removeMethod, null, null, clearMethod, changeMethod);
- }
-
-
- // ********** CollectionChangeListener implementation **********
-
- private void invoke(Method method, CollectionChangeEvent event) {
- if (method.getParameterTypes().length == 0) {
- ClassTools.executeMethod(method, this.target, EMPTY_COLLECTION_CHANGE_EVENT_ARRAY);
- } else {
- ClassTools.executeMethod(method, this.target, new CollectionChangeEvent[] {event});
- }
- }
-
- public void itemsAdded(CollectionChangeEvent event) {
- this.invoke(this.addMethod, event);
- }
-
- public void itemsRemoved(CollectionChangeEvent event) {
- this.invoke(this.removeMethod, event);
- }
-
- public void collectionCleared(CollectionChangeEvent event) {
- this.invoke(this.clearMethod, event);
- }
-
- public void collectionChanged(CollectionChangeEvent event) {
- this.invoke(this.changeMethod, event);
- }
-
-
- // ********** ListChangeListener implementation **********
-
- private void invoke(Method method, ListChangeEvent event) {
- if (method.getParameterTypes().length == 0) {
- ClassTools.executeMethod(method, this.target, EMPTY_LIST_CHANGE_EVENT_ARRAY);
- } else {
- ClassTools.executeMethod(method, this.target, new ListChangeEvent[] {event});
- }
- }
-
- public void itemsAdded(ListChangeEvent event) {
- this.invoke(this.addMethod, event);
- }
-
- public void itemsRemoved(ListChangeEvent event) {
- this.invoke(this.removeMethod, event);
- }
-
- public void itemsReplaced(ListChangeEvent event) {
- this.invoke(this.replaceMethod, event);
- }
-
- public void itemsMoved(ListChangeEvent event) {
- this.invoke(this.moveMethod, event);
- }
-
- public void listCleared(ListChangeEvent event) {
- this.invoke(this.clearMethod, event);
- }
-
- public void listChanged(ListChangeEvent event) {
- this.invoke(this.changeMethod, event);
- }
-
-
- // ********** TreeChangeListener implementation **********
-
- private void invoke(Method method, TreeChangeEvent event) {
- if (method.getParameterTypes().length == 0) {
- ClassTools.executeMethod(method, this.target, EMPTY_TREE_CHANGE_EVENT_ARRAY);
- } else {
- ClassTools.executeMethod(method, this.target, new TreeChangeEvent[] {event});
- }
- }
-
- public void nodeAdded(TreeChangeEvent event) {
- this.invoke(this.addMethod, event);
- }
-
- public void nodeRemoved(TreeChangeEvent event) {
- this.invoke(this.removeMethod, event);
- }
-
- public void treeCleared(TreeChangeEvent event) {
- this.invoke(this.clearMethod, event);
- }
-
- public void treeChanged(TreeChangeEvent event) {
- this.invoke(this.changeMethod, event);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/PropertyChangeListener.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/PropertyChangeListener.java
deleted file mode 100644
index f76bed7d39..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/PropertyChangeListener.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.listener;
-
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-
-/**
- * A "property change" event gets fired whenever a model changes a "bound"
- * property. You can register a PropertyChangeListener with a source
- * model so as to be notified of any bound property updates.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface PropertyChangeListener extends ChangeListener {
-
- /**
- * This method gets called when a model has changed a bound property.
- *
- * @param event A StateChangeEvent describing the event source
- * and the property's old and new values.
- */
- void propertyChanged(PropertyChangeEvent event);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ReflectiveChangeListener.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ReflectiveChangeListener.java
deleted file mode 100644
index a4f81ee657..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/ReflectiveChangeListener.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.listener;
-
-import java.lang.reflect.Method;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.model.event.ChangeEvent;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-
-/**
- * This factory builds listeners that reflectively forward ChangeEvents.
- * If you are worried about having too many little classes that have to be
- * loaded and maintained by the class loader, you can use one of these.
- * Of course, this comes with the additional overhead of reflection....
- * Also note that the validity of the method name is not checked at compile
- * time, but at runtime; although we *do* check the method as soon as the
- * listener is instantiated.
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public abstract class ReflectiveChangeListener {
-
- /** the target object on which we will invoke the method */
- protected final Object target;
-
-
- protected static final Class<StateChangeEvent> STATE_CHANGE_EVENT_CLASS = StateChangeEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<StateChangeEvent>[] STATE_CHANGE_EVENT_CLASS_ARRAY = new Class[] {STATE_CHANGE_EVENT_CLASS};
- protected static final StateChangeEvent[] EMPTY_STATE_CHANGE_EVENT_ARRAY = new StateChangeEvent[0];
-
- protected static final Class<PropertyChangeEvent> PROPERTY_CHANGE_EVENT_CLASS = PropertyChangeEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<PropertyChangeEvent>[] PROPERTY_CHANGE_EVENT_CLASS_ARRAY = new Class[] {PROPERTY_CHANGE_EVENT_CLASS};
- protected static final PropertyChangeEvent[] EMPTY_PROPERTY_CHANGE_EVENT_ARRAY = new PropertyChangeEvent[0];
-
- protected static final Class<CollectionChangeEvent> COLLECTION_CHANGE_EVENT_CLASS = CollectionChangeEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<CollectionChangeEvent>[] COLLECTION_CHANGE_EVENT_CLASS_ARRAY = new Class[] {COLLECTION_CHANGE_EVENT_CLASS};
- protected static final CollectionChangeEvent[] EMPTY_COLLECTION_CHANGE_EVENT_ARRAY = new CollectionChangeEvent[0];
-
- protected static final Class<ListChangeEvent> LIST_CHANGE_EVENT_CLASS = ListChangeEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<ListChangeEvent>[] LIST_CHANGE_EVENT_CLASS_ARRAY = new Class[] {LIST_CHANGE_EVENT_CLASS};
- protected static final ListChangeEvent[] EMPTY_LIST_CHANGE_EVENT_ARRAY = new ListChangeEvent[0];
-
- protected static final Class<TreeChangeEvent> TREE_CHANGE_EVENT_CLASS = TreeChangeEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<TreeChangeEvent>[] TREE_CHANGE_EVENT_CLASS_ARRAY = new Class[] {TREE_CHANGE_EVENT_CLASS};
- protected static final TreeChangeEvent[] EMPTY_TREE_CHANGE_EVENT_ARRAY = new TreeChangeEvent[0];
-
-
-
- // ********** helper methods **********
-
- /**
- * Find and return a method implemented by the target that can be invoked
- * reflectively when a change event occurs.
- */
- private static Method findChangeListenerMethod(Object target, String methodName, Class<? extends ChangeEvent>[] eventClassArray) {
- Method method;
- try {
- method = ClassTools.method(target, methodName, eventClassArray);
- } catch (NoSuchMethodException ex1) {
- try {
- method = ClassTools.method(target, methodName);
- } catch (NoSuchMethodException ex2) {
- throw new RuntimeException(ex2); // "checked" exceptions bite
- }
- }
- return method;
- }
-
- /**
- * Check whether the specified method is suitable for being invoked when a
- * change event has occurred. Throw an exception if it is not suitable.
- */
- private static void checkChangeListenerMethod(Method method, Class<? extends ChangeEvent> eventClass) {
- Class<?>[] parmTypes = method.getParameterTypes();
- int parmTypesLength = parmTypes.length;
- if (parmTypesLength == 0) {
- return;
- }
- if ((parmTypesLength == 1) && parmTypes[0].isAssignableFrom(eventClass)) {
- return;
- }
- throw new IllegalArgumentException(method.toString());
- }
-
-
- // ********** factory methods: StateChangeListener **********
-
- /**
- * Construct a state change listener that will invoke the specified method
- * on the specified target.
- */
- public static StateChangeListener buildStateChangeListener(Object target, Method method) {
- checkChangeListenerMethod(method, STATE_CHANGE_EVENT_CLASS);
- return new SingleMethodReflectiveChangeListener(target, method);
- }
-
- /**
- * Construct a state change listener that will invoke the specified method
- * on the specified target. If a single-argument method with the specified
- * name and appropriate argument is found, it will be invoked; otherwise,
- * a zero-argument method with the specified name will be invoked.
- */
- public static StateChangeListener buildStateChangeListener(Object target, String methodName) {
- return buildStateChangeListener(target, findChangeListenerMethod(target, methodName, STATE_CHANGE_EVENT_CLASS_ARRAY));
- }
-
-
- // ********** factory methods: PropertyChangeListener **********
-
- /**
- * Construct a property change listener that will invoke the specified method
- * on the specified target.
- */
- public static PropertyChangeListener buildPropertyChangeListener(Object target, Method method) {
- checkChangeListenerMethod(method, PROPERTY_CHANGE_EVENT_CLASS);
- return new SingleMethodReflectiveChangeListener(target, method);
- }
-
- /**
- * Construct a property change listener that will invoke the specified method
- * on the specified target. If a single-argument method with the specified
- * name and appropriate argument is found, it will be invoked; otherwise,
- * a zero-argument method with the specified name will be invoked.
- */
- public static PropertyChangeListener buildPropertyChangeListener(Object target, String methodName) {
- return buildPropertyChangeListener(target, findChangeListenerMethod(target, methodName, PROPERTY_CHANGE_EVENT_CLASS_ARRAY));
- }
-
-
- // ********** factory methods: CollectionChangeListener **********
-
- /**
- * Construct a collection change listener that will invoke the specified methods
- * on the specified target.
- */
- public static CollectionChangeListener buildCollectionChangeListener(Object target, Method addMethod, Method removeMethod, Method clearMethod, Method changeMethod) {
- checkChangeListenerMethod(addMethod, COLLECTION_CHANGE_EVENT_CLASS);
- checkChangeListenerMethod(removeMethod, COLLECTION_CHANGE_EVENT_CLASS);
- checkChangeListenerMethod(clearMethod, COLLECTION_CHANGE_EVENT_CLASS);
- checkChangeListenerMethod(changeMethod, COLLECTION_CHANGE_EVENT_CLASS);
- return new MultiMethodReflectiveChangeListener(target, addMethod, removeMethod, clearMethod, changeMethod);
- }
-
- /**
- * Construct a collection change listener that will invoke the specified method
- * on the specified target for any change event.
- */
- public static CollectionChangeListener buildCollectionChangeListener(Object target, Method method) {
- return buildCollectionChangeListener(target, method, method, method, method);
- }
-
- /**
- * Construct a collection change listener that will invoke the specified methods
- * on the specified target for change events. If a single-argument method
- * with the specified name and appropriate argument is found, it will be invoked;
- * otherwise, a zero-argument method with the specified name will be invoked.
- */
- public static CollectionChangeListener buildCollectionChangeListener(Object target, String addMethodName, String removeMethodName, String clearMethodName, String changeMethodName) {
- return buildCollectionChangeListener(
- target,
- findChangeListenerMethod(target, addMethodName, COLLECTION_CHANGE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, removeMethodName, COLLECTION_CHANGE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, clearMethodName, COLLECTION_CHANGE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, changeMethodName, COLLECTION_CHANGE_EVENT_CLASS_ARRAY)
- );
- }
-
- /**
- * Construct a collection change listener that will invoke the specified method
- * on the specified target for any change event. If a single-argument method
- * with the specified name and appropriate argument is found, it will be invoked;
- * otherwise, a zero-argument method with the specified name will be invoked.
- */
- public static CollectionChangeListener buildCollectionChangeListener(Object target, String methodName) {
- return buildCollectionChangeListener(target, findChangeListenerMethod(target, methodName, COLLECTION_CHANGE_EVENT_CLASS_ARRAY));
- }
-
-
- // ********** factory methods: ListChangeListener **********
-
- /**
- * Construct a list change listener that will invoke the specified methods
- * on the specified target.
- */
- public static ListChangeListener buildListChangeListener(Object target, Method addMethod, Method removeMethod, Method replaceMethod, Method moveMethod, Method clearMethod, Method changeMethod) {
- checkChangeListenerMethod(addMethod, LIST_CHANGE_EVENT_CLASS);
- checkChangeListenerMethod(removeMethod, LIST_CHANGE_EVENT_CLASS);
- checkChangeListenerMethod(replaceMethod, LIST_CHANGE_EVENT_CLASS);
- checkChangeListenerMethod(moveMethod, LIST_CHANGE_EVENT_CLASS);
- checkChangeListenerMethod(clearMethod, LIST_CHANGE_EVENT_CLASS);
- checkChangeListenerMethod(changeMethod, LIST_CHANGE_EVENT_CLASS);
- return new MultiMethodReflectiveChangeListener(target, addMethod, removeMethod, replaceMethod, moveMethod, clearMethod, changeMethod);
- }
-
- /**
- * Construct a list change listener that will invoke the specified method
- * on the specified target for any change event.
- */
- public static ListChangeListener buildListChangeListener(Object target, Method method) {
- return buildListChangeListener(target, method, method, method, method, method, method);
- }
-
- /**
- * Construct a list change listener that will invoke the specified methods
- * on the specified target for change events. If a single-argument method
- * with the specified name and appropriate argument is found, it will be invoked;
- * otherwise, a zero-argument method with the specified name will be invoked.
- */
- public static ListChangeListener buildListChangeListener(Object target, String addMethodName, String removeMethodName, String replaceMethodName, String moveMethodName, String clearMethodName, String changeMethodName) {
- return buildListChangeListener(
- target,
- findChangeListenerMethod(target, addMethodName, LIST_CHANGE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, removeMethodName, LIST_CHANGE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, replaceMethodName, LIST_CHANGE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, moveMethodName, LIST_CHANGE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, clearMethodName, LIST_CHANGE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, changeMethodName, LIST_CHANGE_EVENT_CLASS_ARRAY)
- );
- }
-
- /**
- * Construct a list change listener that will invoke the specified method
- * on the specified target for any change event. If a single-argument method
- * with the specified name and appropriate argument is found, it will be invoked;
- * otherwise, a zero-argument method with the specified name will be invoked.
- */
- public static ListChangeListener buildListChangeListener(Object target, String methodName) {
- return buildListChangeListener(target, findChangeListenerMethod(target, methodName, LIST_CHANGE_EVENT_CLASS_ARRAY));
- }
-
-
- // ********** factory methods: TreeChangeListener **********
-
- /**
- * Construct a tree change listener that will invoke the specified methods
- * on the specified target.
- */
- public static TreeChangeListener buildTreeChangeListener(Object target, Method addMethod, Method removeMethod, Method clearMethod, Method changeMethod) {
- checkChangeListenerMethod(addMethod, TREE_CHANGE_EVENT_CLASS);
- checkChangeListenerMethod(removeMethod, TREE_CHANGE_EVENT_CLASS);
- checkChangeListenerMethod(clearMethod, TREE_CHANGE_EVENT_CLASS);
- checkChangeListenerMethod(changeMethod, TREE_CHANGE_EVENT_CLASS);
- return new MultiMethodReflectiveChangeListener(target, addMethod, removeMethod, clearMethod, changeMethod);
- }
-
- /**
- * Construct a tree change listener that will invoke the specified method
- * on the specified target for any change event.
- */
- public static TreeChangeListener buildTreeChangeListener(Object target, Method method) {
- return buildTreeChangeListener(target, method, method, method, method);
- }
-
- /**
- * Construct a tree change listener that will invoke the specified methods
- * on the specified target for change events. If a single-argument method
- * with the specified name and appropriate argument is found, it will be invoked;
- * otherwise, a zero-argument method with the specified name will be invoked.
- */
- public static TreeChangeListener buildTreeChangeListener(Object target, String addMethodName, String removeMethodName, String clearMethodName, String changeMethodName) {
- return buildTreeChangeListener(
- target,
- findChangeListenerMethod(target, addMethodName, TREE_CHANGE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, removeMethodName, TREE_CHANGE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, clearMethodName, TREE_CHANGE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, changeMethodName, TREE_CHANGE_EVENT_CLASS_ARRAY)
- );
- }
-
- /**
- * Construct a tree change listener that will invoke the specified method
- * on the specified target for any change event. If a single-argument method
- * with the specified name and appropriate argument is found, it will be invoked;
- * otherwise, a zero-argument method with the specified name will be invoked.
- */
- public static TreeChangeListener buildTreeChangeListener(Object target, String methodName) {
- return buildTreeChangeListener(target, findChangeListenerMethod(target, methodName, TREE_CHANGE_EVENT_CLASS_ARRAY));
- }
-
-
- // ********** constructor **********
-
- /**
- * Construct a listener that will invoke the specified method
- * on the specified target.
- */
- protected ReflectiveChangeListener(Object target) {
- super();
- this.target = target;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/SingleMethodReflectiveChangeListener.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/SingleMethodReflectiveChangeListener.java
deleted file mode 100644
index b7cc753aa2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/SingleMethodReflectiveChangeListener.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.listener;
-
-import java.lang.reflect.Method;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-
-/**
- * This class is used by ReflectiveChangeListener when the requested listener
- * need only implement a single method (i.e. StateChangeListener or
- * PropertyChangeListener).
- */
-class SingleMethodReflectiveChangeListener
- extends ReflectiveChangeListener
- implements StateChangeListener, PropertyChangeListener
-{
-
- /** the method we will invoke on the target object */
- private final Method method;
- /** cache the number of arguments */
- private final boolean methodIsZeroArgument;
-
- SingleMethodReflectiveChangeListener(Object target, Method method) {
- super(target);
- this.method = method;
- this.methodIsZeroArgument = method.getParameterTypes().length == 0;
- }
-
-
- // ********** StateChangeListener implementation **********
-
- public void stateChanged(StateChangeEvent event) {
- if (this.methodIsZeroArgument) {
- ClassTools.executeMethod(this.method, this.target, EMPTY_STATE_CHANGE_EVENT_ARRAY);
- } else {
- ClassTools.executeMethod(this.method, this.target, new StateChangeEvent[] {event});
- }
- }
-
-
- // ********** PropertyChangeListener implementation **********
-
- public void propertyChanged(PropertyChangeEvent event) {
- if (this.methodIsZeroArgument) {
- ClassTools.executeMethod(this.method, this.target, EMPTY_PROPERTY_CHANGE_EVENT_ARRAY);
- } else {
- ClassTools.executeMethod(this.method, this.target, new PropertyChangeEvent[] {event});
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/StateChangeListener.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/StateChangeListener.java
deleted file mode 100644
index 1ce6ba5d69..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/StateChangeListener.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.listener;
-
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-
-/**
- * A generic "state change" event gets delivered whenever a model changes to
- * such extent that it cannot be delineated all aspects of it that have changed.
- * You can register a StateChangeListener with a source model so as to be notified
- * of any such changes.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface StateChangeListener extends ChangeListener {
-
- /**
- * This method gets called when a model has changed in some general fashion.
- *
- * @param event A StateChangeEvent describing the event source.
- */
- void stateChanged(StateChangeEvent event);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/TreeChangeAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/TreeChangeAdapter.java
deleted file mode 100644
index 3b46202fd1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/TreeChangeAdapter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.listener;
-
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-
-/**
- * Convenience implementation of TreeChangeListener.
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class TreeChangeAdapter implements TreeChangeListener {
-
- /**
- * Default constructor.
- */
- public TreeChangeAdapter() {
- super();
- }
-
- public void nodeAdded(TreeChangeEvent event) {
- // do nothing
- }
-
- public void nodeRemoved(TreeChangeEvent event) {
- // do nothing
- }
-
- public void treeCleared(TreeChangeEvent event) {
- // do nothing
- }
-
- public void treeChanged(TreeChangeEvent event) {
- // do nothing
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/TreeChangeListener.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/TreeChangeListener.java
deleted file mode 100644
index 7591f9df78..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/listener/TreeChangeListener.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.listener;
-
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-
-/**
- * A "tree change" event gets fired whenever a model changes a "bound"
- * tree. You can register a TreeChangeListener with a source
- * model so as to be notified of any bound tree updates.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface TreeChangeListener extends ChangeListener {
-
- /**
- * This method gets called when a node is added to a bound tree.
- *
- * @param event A TreeChangeEvent describing the event source,
- * the tree that changed, and the path to the node that was added.
- */
- void nodeAdded(TreeChangeEvent event);
-
- /**
- * This method gets called when a node is removed from a bound tree.
- *
- * @param event A TreeChangeEvent describing the event source,
- * the tree that changed, and the path to the node that was removed.
- */
- void nodeRemoved(TreeChangeEvent event);
-
- /**
- * This method gets called when a bound tree is cleared.
- *
- * @param event A TreeChangeEvent describing the event source,
- * the tree that changed, and an empty path.
- */
- void treeCleared(TreeChangeEvent event);
-
- /**
- * This method gets called when a portion of a bound tree is changed in
- * a manner that is not easily characterized by the other methods in this
- * interface.
- *
- * @param event A TreeChangeEvent describing the event source,
- * the tree that changed, and the path to the branch of the
- * tree that changed.
- */
- void treeChanged(TreeChangeEvent event);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/CollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/CollectionValueModel.java
deleted file mode 100644
index dfa8377b3e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/CollectionValueModel.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.value;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * Interface used to abstract collection accessing and
- * change notification and make it more pluggable.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface CollectionValueModel<E>
- extends Model, Iterable<E>
-{
-
- /**
- * Return the collection's values.
- */
- Iterator<E> iterator();
- String VALUES = "values";
-
- /**
- * Return the size of the collection value.
- */
- int size();
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/ListValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/ListValueModel.java
deleted file mode 100644
index 013504fbbb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/ListValueModel.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.value;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * Interface used to abstract list accessing and
- * change notification and make it more pluggable.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ListValueModel<E>
- extends Model, Iterable<E>
-{
- /**
- * Return the list's values.
- */
- Iterator<E> iterator();
- String LIST_VALUES = "list values";
-
- /**
- * Return the list's values.
- */
- ListIterator<E> listIterator();
-
- /**
- * Return the size of the list.
- */
- int size();
-
- /**
- * Return the item at the specified index of the list.
- */
- E get(int index);
-
- /**
- * Return the list's values.
- */
- Object[] toArray();
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/PropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/PropertyValueModel.java
deleted file mode 100644
index 82ee3c0096..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/PropertyValueModel.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.value;
-
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * Interface used to abstract property accessing and
- * change notification and make it more pluggable.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface PropertyValueModel<T>
- extends Model
-{
-
- /**
- * Return the property's value.
- */
- T getValue();
- String VALUE = "value";
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/TreeNodeValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/TreeNodeValueModel.java
deleted file mode 100644
index a6bcea8cdf..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/TreeNodeValueModel.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.value;
-
-/**
- * Extend WritablePropertyValueModel to better support TreeModelAdapter.
- *
- * Implementors of this interface should fire a "state change" event
- * whenever the node's internal state changes in a way that the
- * tree listeners should be notified.
- *
- * Implementors of this interface should also fire a "value property change"
- * event whenever the node's value changes. Typically, only nodes that
- * hold "primitive" data will fire this event.
- *
- * @see org.eclipse.jpt.utility.internal.model.value.AbstractTreeNodeValueModel
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface TreeNodeValueModel<T>
- extends WritablePropertyValueModel<T>
-{
-
- /**
- * Return the node's parent node; null if the node
- * is the root.
- */
- TreeNodeValueModel<T> parent();
-
- /**
- * Return the path to the node.
- */
- TreeNodeValueModel<T>[] path();
-
- /**
- * Return a list value model of the node's child nodes.
- */
- ListValueModel<TreeNodeValueModel<T>> childrenModel();
-
- /**
- * Return the node's child at the specified index.
- */
- TreeNodeValueModel<T> child(int index);
-
- /**
- * Return the size of the node's list of children.
- */
- int childrenSize();
-
- /**
- * Return the index in the node's list of children of the specified child.
- */
- int indexOfChild(TreeNodeValueModel<T> child);
-
- /**
- * Return whether the node is a leaf (i.e. it has no children)
- */
- boolean isLeaf();
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/TreeValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/TreeValueModel.java
deleted file mode 100644
index a76542525a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/TreeValueModel.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.value;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.model.Model;
-
-/**
- * Interface used to abstract tree accessing and
- * change notification and make it more pluggable.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface TreeValueModel<E>
- extends Model
-{
- /**
- * Return the tree's nodes.
- */
- Iterator<E> nodes();
- String NODES = "nodes";
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/WritablePropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/WritablePropertyValueModel.java
deleted file mode 100644
index c2ddacebe4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/model/value/WritablePropertyValueModel.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.model.value;
-
-/**
- * Extend ValueModel to allow the setting of the property's value.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface WritablePropertyValueModel<T>
- extends PropertyValueModel<T>
-{
-
- /**
- * Set the value and fire a property change notification.
- * @see PropertyValueModel#VALUE
- */
- void setValue(T value);
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.classpath b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.classpath
deleted file mode 100644
index 304e86186a..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.cvsignore b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.cvsignore
deleted file mode 100644
index a196dd7686..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.cvsignore
+++ /dev/null
@@ -1,6 +0,0 @@
-bin
-@dot
-temp.folder
-build.xml
-javaCompiler...args
-javaCompiler...args.* \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.project b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.project
deleted file mode 100644
index bb6561e95f..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.core.tests.extension.resource</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.settings/org.eclipse.core.resources.prefs b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 55044aaf02..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Mon Apr 07 14:26:32 EDT 2008
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/META-INF/MANIFEST.MF
deleted file mode 100644
index f4e23a9800..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,25 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.core.tests.extension.resource;singleton:=true
-Bundle-Version: 2.0.0.qualifier
-Bundle-Activator: org.eclipse.jpt.core.tests.extension.resource.ExtensionTestPlugin
-Bundle-Localization: plugin
-Eclipse-LazyStart: true
-Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.jpt.core,
- org.eclipse.jpt.ui,
- org.eclipse.wst.validation,
- org.eclipse.jpt.core,
- org.eclipse.jpt.gen,
- org.eclipse.jface,
- org.eclipse.jpt.db,
- org.eclipse.jdt.core,
- org.eclipse.emf.ecore,
- org.eclipse.jpt.utility,
- org.eclipse.core.resources,
- org.eclipse.ui.navigator;bundle-version="3.3.100",
- org.eclipse.ui.views.properties.tabbed;bundle-version="3.4.0"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.eclipse.jpt.core.tests.extension.resource;x-friends:="org.eclipse.jpt.ui.tests,org.eclipse.jpt.core.tests"
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/build.properties b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/build.properties
deleted file mode 100644
index f5e3f40ad8..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/build.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-javacSource=1.5
-javacTarget=1.5
-source.. = src/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- plugin.xml,\
- plugin.properties
-jars.compile.order = .
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/plugin.properties b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/plugin.properties
deleted file mode 100644
index 83f727f621..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/plugin.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-###############################################################################
-# Copyright (c) 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName = Java Persistence API Tools - ExtensionTestPlugin
-providerName = Eclipse.org
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/plugin.xml b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/plugin.xml
deleted file mode 100644
index e74df7f16b..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/plugin.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.2"?>
-<plugin>
-
- <extension
- point="org.eclipse.jpt.core.jpaPlatform">
-
- <jpaPlatform
- id="core.testJpaPlatform"
- label="Test Jpa Platform"
- class="org.eclipse.jpt.core.tests.extension.resource.TestJpaPlatform"
- default="true">
- </jpaPlatform>
-
- </extension>
-
- <extension
- point="org.eclipse.jpt.ui.jpaPlatform">
-
- <jpaPlatform
- id="core.testJpaPlatform"
- class="org.eclipse.jpt.core.tests.extension.resource.TestJpaPlatformUi">
- </jpaPlatform>
-
- </extension>
-
-</plugin>
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/ExtensionTestPlugin.java b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/ExtensionTestPlugin.java
deleted file mode 100644
index 7a73d2011a..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/ExtensionTestPlugin.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.eclipse.jpt.core.tests.extension.resource;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class ExtensionTestPlugin extends Plugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.jpt.core.tests.extension.resource";
-
- // The shared instance
- private static ExtensionTestPlugin plugin;
-
- /**
- * The constructor
- */
- public ExtensionTestPlugin() {
- }
-
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static ExtensionTestPlugin getDefault() {
- return plugin;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestAttributeMapping.java b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestAttributeMapping.java
deleted file mode 100644
index 5f777f3f54..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestAttributeMapping.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.extension.resource;
-
-import java.util.Iterator;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.java.AbstractJavaAttributeMapping;
-
-public class JavaTestAttributeMapping extends AbstractJavaAttributeMapping
-{
- public static final String TEST_ATTRIBUTE_MAPPING_KEY = "testAttribute";
- public static final String TEST_ATTRIBUTE_ANNOTATION_NAME = "test.TestAttribute";
-
-
- public JavaTestAttributeMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
- public String getKey() {
- return JavaTestAttributeMapping.TEST_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return JavaTestAttributeMapping.TEST_ATTRIBUTE_ANNOTATION_NAME;
- }
-
- public Iterator<String> correspondingAnnotationNames() {
- // TODO Auto-generated method stub
- return null;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestAttributeMappingProvider.java b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestAttributeMappingProvider.java
deleted file mode 100644
index 6d8edbec26..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestAttributeMappingProvider.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.extension.resource;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingProvider;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-
-public class JavaTestAttributeMappingProvider
- implements JavaAttributeMappingProvider
-{
- // singleton
- private static final JavaTestAttributeMappingProvider INSTANCE = new JavaTestAttributeMappingProvider();
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingProvider instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure non-instantiability.
- */
- private JavaTestAttributeMappingProvider() {
- super();
- }
-
- public String getKey() {
- return JavaTestAttributeMapping.TEST_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return JavaTestAttributeMapping.TEST_ATTRIBUTE_ANNOTATION_NAME;
- }
-
- public JavaTestAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return ((TestJpaFactory) factory).buildJavaTestAttributeMapping(parent);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestTypeMapping.java b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestTypeMapping.java
deleted file mode 100644
index 7a7d848fbd..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestTypeMapping.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.extension.resource;
-
-import java.util.Iterator;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.internal.context.java.AbstractJavaTypeMapping;
-
-public class JavaTestTypeMapping extends AbstractJavaTypeMapping
-{
- public static final String TEST_TYPE_MAPPING_KEY = "test";
- public static final String TEST_TYPE_ANNOTATION_NAME = "test.Test";
-
-
- public JavaTestTypeMapping(JavaPersistentType parent) {
- super(parent);
- }
-
- public String getAnnotationName() {
- return TEST_TYPE_ANNOTATION_NAME;
- }
-
- public String getKey() {
- return TEST_TYPE_MAPPING_KEY;
- }
-
- public Iterator<String> correspondingAnnotationNames() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean isMapped() {
- return true;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestTypeMappingProvider.java b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestTypeMappingProvider.java
deleted file mode 100644
index 3bca82aa6d..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/JavaTestTypeMappingProvider.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.extension.resource;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingProvider;
-
-/**
- *
- */
-public class JavaTestTypeMappingProvider
- implements JavaTypeMappingProvider
-{
- // singleton
- private static final JavaTestTypeMappingProvider INSTANCE = new JavaTestTypeMappingProvider();
-
- /**
- * Return the singleton.
- */
- public static JavaTypeMappingProvider instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure non-instantiability.
- */
- private JavaTestTypeMappingProvider() {
- super();
- }
-
- public String getKey() {
- return JavaTestTypeMapping.TEST_TYPE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return JavaTestTypeMapping.TEST_TYPE_ANNOTATION_NAME;
- }
-
- public JavaTestTypeMapping buildMapping(JavaPersistentType parent, JpaFactory factory) {
- return ((TestJpaFactory) factory).buildJavaTestTypeMapping(parent);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJavaBasicMapping.java b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJavaBasicMapping.java
deleted file mode 100644
index ccd2f6ae1d..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJavaBasicMapping.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.extension.resource;
-
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.java.GenericJavaBasicMapping;
-
-public class TestJavaBasicMapping extends GenericJavaBasicMapping
-{
- public TestJavaBasicMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJavaEntity.java b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJavaEntity.java
deleted file mode 100644
index ecffe3a2b6..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJavaEntity.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.extension.resource;
-
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.internal.context.java.GenericJavaEntity;
-
-public class TestJavaEntity extends GenericJavaEntity
-{
- protected TestJavaEntity(JavaPersistentType parent) {
- super(parent);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaFactory.java b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaFactory.java
deleted file mode 100644
index b23aada30d..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaFactory.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0, which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.extension.resource;
-
-import org.eclipse.jpt.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.internal.platform.GenericJpaFactory;
-
-public class TestJpaFactory extends GenericJpaFactory
-{
- @Override
- public JavaEntity buildJavaEntity(JavaPersistentType parent) {
- return new TestJavaEntity(parent);
- }
-
- @Override
- public JavaBasicMapping buildJavaBasicMapping(JavaPersistentAttribute parent) {
- return new TestJavaBasicMapping(parent);
- }
-
- public JavaTestTypeMapping buildJavaTestTypeMapping(JavaPersistentType parent) {
- return new JavaTestTypeMapping(parent);
- }
-
- public JavaTestAttributeMapping buildJavaTestAttributeMapping(JavaPersistentAttribute parent) {
- return new JavaTestAttributeMapping(parent);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaPlatform.java b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaPlatform.java
deleted file mode 100644
index 9aa0335ff1..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaPlatform.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.extension.resource;
-
-import java.util.Collection;
-import org.eclipse.jpt.core.JpaAnnotationProvider;
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingProvider;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingProvider;
-import org.eclipse.jpt.core.internal.platform.GenericJpaPlatform;
-
-public class TestJpaPlatform extends GenericJpaPlatform
-{
- public static final String ID = "core.testJpaPlatform";
-
- @Override
- public String getId() {
- return ID;
- }
-
- @Override
- protected JpaFactory buildJpaFactory() {
- return new TestJpaFactory();
- }
-
- @Override
- public JpaAnnotationProvider getAnnotationProvider() {
- return super.getAnnotationProvider();
- }
-
- @Override
- protected void addJavaTypeMappingProvidersTo(Collection<JavaTypeMappingProvider> providers) {
- super.addJavaTypeMappingProvidersTo(providers);
- providers.add(JavaTestTypeMappingProvider.instance());
- }
-
- @Override
- protected void addJavaAttributeMappingProvidersTo(Collection<JavaAttributeMappingProvider> providers) {
- super.addJavaAttributeMappingProvidersTo(providers);
- providers.add(JavaTestAttributeMappingProvider.instance());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaPlatformUi.java b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaPlatformUi.java
deleted file mode 100644
index d508f79e23..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaPlatformUi.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.extension.resource;
-
-import java.util.List;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.ui.JpaUiFactory;
-import org.eclipse.jpt.ui.details.AttributeMappingUiProvider;
-import org.eclipse.jpt.ui.details.TypeMappingUiProvider;
-import org.eclipse.jpt.ui.internal.platform.base.BaseJpaPlatformUi;
-import org.eclipse.jpt.ui.internal.platform.generic.GenericNavigatorProvider;
-import org.eclipse.jpt.ui.navigator.JpaNavigatorProvider;
-
-public class TestJpaPlatformUi extends BaseJpaPlatformUi
-{
- public TestJpaPlatformUi() {
- super();
- }
-
- public JpaNavigatorProvider buildNavigatorProvider() {
- return new GenericNavigatorProvider();
- }
-
- @Override
- protected JpaUiFactory createJpaUiFactory() {
- return new TestJpaUiFactory();
- }
-
- public void generateDDL(JpaProject project, IStructuredSelection selection) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- protected void addJavaAttributeMappingUiProvidersTo(List<AttributeMappingUiProvider<? extends AttributeMapping>> providers) {
- super.addJavaAttributeMappingUiProvidersTo(providers);
-
- }
-
- @Override
- protected void addJavaTypeMappingUiProvidersTo(List<TypeMappingUiProvider<? extends TypeMapping>> providers) {
- super.addJavaTypeMappingUiProvidersTo(providers);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaUiFactory.java b/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaUiFactory.java
deleted file mode 100644
index 29fa8b4b58..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests.extension.resource/src/org/eclipse/jpt/core/tests/extension/resource/TestJpaUiFactory.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.extension.resource;
-
-import org.eclipse.jpt.ui.internal.BaseJpaUiFactory;
-
-/**
- * The default implementation of the UI factory required to show the information
- * related to a JPA mapping (type or attribute).
- *
- * @see JpaUiFactory
- *
- * @version 1.0
- * @since 1.0
- */
-public class TestJpaUiFactory extends BaseJpaUiFactory
-{
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/.classpath b/jpa/tests/org.eclipse.jpt.core.tests/.classpath
deleted file mode 100644
index 3c0b3a6a9e..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/.classpath
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/wst/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jst/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/core/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/utility/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/.cvsignore b/jpa/tests/org.eclipse.jpt.core.tests/.cvsignore
deleted file mode 100644
index c4ba612bad..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-bin
-@dot
-temp.folder
-build.xml
-javaCompiler...args \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/.project b/jpa/tests/org.eclipse.jpt.core.tests/.project
deleted file mode 100644
index 08395a8e86..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.core.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.core.resources.prefs b/jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index eb348782fa..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tue Jan 15 11:10:55 EST 2008
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.jdt.core.prefs b/jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index a2f6604d54..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Sun May 27 14:58:31 EDT 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index a144b5cb7f..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,40 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.core.tests
-Bundle-Version: 2.0.0
-Bundle-Localization: plugin
-Require-Bundle: org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.emf.ecore;bundle-version="[2.4.0,3.0.0)",
- org.eclipse.emf.ecore.xmi;bundle-version="[2.4.0,3.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jdt.ui;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jem;bundle-version="[2.0.200,3.0.0)",
- org.eclipse.jem.util;bundle-version="[2.0.100,3.0.0)",
- org.eclipse.jpt.core;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jpt.core.tests.extension.resource;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jpt.db;bundle-version="[1.1.1,2.0.0)",
- org.eclipse.jpt.utility;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.jpt.utility.tests;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.wst.common.emf;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.wst.common.emfworkbench.integration;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.wst.common.frameworks;bundle-version="[1.1.200,1.2.0)",
- org.eclipse.wst.common.modulecore;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.wst.common.project.facet.core;bundle-version="[1.3.0,2.0.0)",
- org.junit;bundle-version="[3.8.2,4.0.0)",
- org.eclipse.wst.xml.core;bundle-version="[1.1.300,1.2.0)",
- org.eclipse.wst.validation;bundle-version="[1.2.0,1.3.0)"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.eclipse.jpt.core.tests.internal;x-friends:="org.eclipse.jpt.ui.tests",
- org.eclipse.jpt.core.tests.internal.context;x-internal:=true,
- org.eclipse.jpt.core.tests.internal.context.java;x-internal:=true,
- org.eclipse.jpt.core.tests.internal.context.orm;x-internal:=true,
- org.eclipse.jpt.core.tests.internal.context.persistence;x-internal:=true,
- org.eclipse.jpt.core.tests.internal.model;x-internal:=true,
- org.eclipse.jpt.core.tests.internal.platform;x-internal:=true,
- org.eclipse.jpt.core.tests.internal.projects;x-friends:="org.eclipse.jpt.ui.tests",
- org.eclipse.jpt.core.tests.internal.resource;x-internal:=true,
- org.eclipse.jpt.core.tests.internal.resource.java;x-internal:=true,
- org.eclipse.jpt.core.tests.internal.utility.jdt;x-internal:=true
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/about.html b/jpa/tests/org.eclipse.jpt.core.tests/about.html
deleted file mode 100644
index 9e73bdabb6..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>June 06, 2007</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/build.properties b/jpa/tests/org.eclipse.jpt.core.tests/build.properties
deleted file mode 100644
index 9bf11f791e..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/build.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-javacSource = 1.5
-javacTarget = 1.5
-bin.includes = .,\
- META-INF/,\
- about.html,\
- test.xml,\
- plugin.properties
-source.. = src/
-output.. = bin/
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/plugin.properties b/jpa/tests/org.eclipse.jpt.core.tests/plugin.properties
deleted file mode 100644
index 6ebf8dbed1..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/plugin.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 Oracle. All rights reserved. This
-# program and the accompanying materials are made available under the terms of
-# the Eclipse Public License v1.0 which accompanies this distribution, and is
-# available at http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors: Oracle. - initial API and implementation
-###############################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName=Java Persistence API Core Tests
-providerName=Eclipse.org
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptAllCoreTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptAllCoreTests.java
deleted file mode 100644
index 9b0e632be8..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptAllCoreTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal;
-
-import junit.framework.Test;
-
-/**
- * This test suite is temporary, until jpa.jar can be checked into the CVS
- * repository and used during the nightly builds.
- *
- * Runs ALL JPT Core Tests. Currently we do not have a jpa.jar checked in to CVS.
- * As a result we cannot run any tests that depend on that jar during the build.
- * In our local development environments we should run this suite (JptAllCoreTests)
- * until jpa.jar is checked into CVS.
- * In the nightly build we should continue to run JptCoreTests.
- */
-public class JptAllCoreTests {
-
- public static Test suite() {
- return JptCoreTests.suite(true);
- }
-
- private JptAllCoreTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptCoreTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptCoreTests.java
deleted file mode 100644
index f879593cd6..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptCoreTests.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.core.tests.internal.context.JptCoreContextModelTests;
-import org.eclipse.jpt.core.tests.internal.model.JptCoreModelTests;
-import org.eclipse.jpt.core.tests.internal.resource.JptCoreResourceModelTests;
-import org.eclipse.jpt.core.tests.internal.utility.jdt.JptCoreUtilityJdtTests;
-
-/**
- * Runs MOST JPT Core Tests. Currently we do not have a jpa.jar checked into cvs.
- * As a result we cannot run any tests that depend on that jar during the nightly build.
- * In our development environments we should run JptAllCoreTests (NOT this suite)
- * until jpa.jar is checked into CVS.
- */
-public class JptCoreTests {
-
- public static Test suite() {
- return suite(false);
- }
-
- public static Test suite(boolean all) {
- String quantity = all ? "All" : "Most";
- TestSuite suite = new TestSuite(quantity + " JPT Core Tests");
- suite.addTest(JptCoreUtilityJdtTests.suite(all));
- suite.addTest(JptCoreModelTests.suite(all));
- suite.addTest(JptCoreResourceModelTests.suite(all));
- if (all) {
- suite.addTest(JptCoreContextModelTests.suite(all));
- }
- return suite;
- }
-
- private JptCoreTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/ProjectUtility.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/ProjectUtility.java
deleted file mode 100644
index f4abdb741b..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/ProjectUtility.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import junit.framework.Assert;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.AssertionFailedException;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-
-/**
- * Copied from org.eclipse.wst.common.tests
- */
-public class ProjectUtility {
- public static IProject[] getAllProjects() {
- IProject[] projects = new IProject[0];
- try {
- projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- } catch (AssertionFailedException ex) {
- // Catch Malformed tree exception that occurs from time to time...
- }
- return projects;
- }
- public static boolean projectExists(String projectName) {
- return getProject(projectName) != null;
- }
- public static IProject verifyAndReturnProject(String projectName, boolean exists) {
- IProject project = getProject(projectName);
- if (exists) {
- Assert.assertTrue("Project Does Not Exist:" + projectName, project.exists());
- } else {
- Assert.assertTrue("Project Exists:" + projectName, !project.exists());
- }
- return project;
- }
- public static void verifyProject(String projectName, boolean exists) {
- IProject project = getProject(projectName);
- if (exists) {
- Assert.assertTrue("Project Does Not Exist:" + projectName, project.exists());
- } else {
- Assert.assertTrue("Project Exists:" + projectName, !project.exists());
- }
- }
- public static IProject getProject(String projectName) {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- String pathString = projectName;
- if (!(workspace.getRoot().getProject(pathString) == null))
- return workspace.getRoot().getProject(pathString);
- else
- return null;
- }
- public static void verifyNoProjects() {
- IProject[] projects = getAllProjects();
- String projectNames = "";
- for (int i = 0; i < projects.length; i++) {
- projectNames += " " + projects[i].getName();
- }
- Assert.assertTrue("All projects not deleted" + projectNames, projects.length == 0);
- }
- public static void deleteProjectIfExists(String projectName) {
- if (projectName == null)
- return;
- IProject project = getProject(projectName);
- if (project != null && project.isAccessible()) {
- try {
- project.close(null);
- project.delete(true, true, null);
- ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (Exception e) {
- Assert.fail(e.getMessage());
- }
- }
- }
- public static void deleteAllProjects() throws Exception {
- //closing projects and tread work in here is a hack because of a BeanInfo bug holding
- //onto jars loaded in another VM
-
-// for (int i = 0; i < projects.length; i++) {
-// if (projects[i].exists()) {
-// projects[i].close(null); // This should signal the extra VM to kill itself
-// }
-// }
- // Thread.yield(); // give the VM a chance to die
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
-
- public void run(IProgressMonitor monitor) {
- IProject[] projects = getAllProjects();
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- boolean success = false;
- Exception lastException = null;
- // Don't make 2^12 is about 4 seconds which is the max we
- // will wait for the VM to die
- for (int j = 0; j < 14 && !success; j++) {
- try {
- if (project.exists()) {
- project.delete(true, true, null);
- ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- success = true;
- } catch (Exception ex) {
- lastException = ex;
- if (project.exists()) {
- try {
- project.close(null);
- project.open(null);
- } catch (Exception ex2) {
- // ignore this exception
- }
- }
- try {
- Thread.sleep((int) Math.pow(2, j));
- } catch (InterruptedException ex2) {
- // probably won't happen
- }
- }
- }
- if ( ! success) {
- System.out.println("Problem while deleting: " + project.getName());
- lastException.printStackTrace(System.out);
- }
- }
- }
- };
- try {
- ResourcesPlugin.getWorkspace().run(runnable, null);
- } catch (CoreException ce) {
- }
- //verifyNoProjects();
- }
- /**
- * Return the absolute path Strings to the files based on the fileSuffix and
- * path within the plugin.
- *
- * @param path
- * @param fileSuffix
- * the file ending with the "." if required (the suffix will be
- * used as is)
- * @return
- */
- public static List getSpecificFilesInDirectory(Plugin plugin, String path, final String fileSuffix) {
- URL entry = null;
- entry = plugin.getBundle().getEntry(path);
- List result = null;
- File folder = null;
- if (entry != null) {
- try {
- entry = Platform.asLocalURL(entry);
- folder = new File(new URI(entry.toString()));
- } catch (Exception e1) {
- e1.printStackTrace();
- return Collections.EMPTY_LIST;
- }
- List files = Arrays.asList(folder.list());
- if (!files.isEmpty()) {
- String folderPath = folder.getAbsolutePath() + File.separator;
- result = new ArrayList();
- for (int i = 0; i < files.size(); i++) {
- String fileName = (String) files.get(i);
- if (!fileName.endsWith(fileSuffix))
- continue;
- result.add(folderPath + fileName);
- }
- }
- }
- if (result == null)
- result = Collections.EMPTY_LIST;
- return result;
- }
- public static List getJarsInDirectory(Plugin plugin, String path) {
- return getSpecificFilesInDirectory(plugin, path, ".jar");
- }
- public static List getRarsInDirectory(Plugin plugin, String path) {
- return getSpecificFilesInDirectory(plugin, path, ".rar");
- }
- public static List getEarsInDirectory(Plugin plugin, String path) {
- return getSpecificFilesInDirectory(plugin, path, ".ear");
- }
- public static List getWarsInDirectory(Plugin plugin, String path) {
- return getSpecificFilesInDirectory(plugin, path, ".war");
- }
- public static String getFullFileName(Plugin plugin, String pluginRelativeFileName) throws IOException {
- IPath path = new Path(pluginRelativeFileName);
- if (path.getDevice() != null)
- return pluginRelativeFileName;
- URL url = plugin.getBundle().getEntry(pluginRelativeFileName);
- if (url != null) {
- url = Platform.asLocalURL(url);
- IPath iPath = new Path(url.getPath());
- return iPath.toOSString();
- }
- return null;
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/ContextModelTestCase.java
deleted file mode 100644
index a067b0a21e..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/ContextModelTestCase.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.JpaRootContextNode;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.orm.EntityMappings;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.resource.orm.OrmArtifactEdit;
-import org.eclipse.jpt.core.resource.orm.OrmResource;
-import org.eclipse.jpt.core.resource.persistence.PersistenceArtifactEdit;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.PersistenceResource;
-import org.eclipse.jpt.core.resource.persistence.XmlJavaClassRef;
-import org.eclipse.jpt.core.resource.persistence.XmlPersistence;
-import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject;
-import org.eclipse.jpt.core.tests.internal.projects.TestJpaProject;
-import org.eclipse.jpt.core.tests.internal.utility.jdt.AnnotationTestCase;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper;
-
-public abstract class ContextModelTestCase extends AnnotationTestCase
-{
- protected static final String BASE_PROJECT_NAME = "ContextModelTestProject";
-
- protected PersistenceArtifactEdit persistenceArtifactEdit;
- protected OrmArtifactEdit ormArtifactEdit;
-
-
- protected ContextModelTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.persistenceArtifactEdit = PersistenceArtifactEdit.getArtifactEditForWrite(getJavaProject().getProject());
- this.ormArtifactEdit = OrmArtifactEdit.getArtifactEditForWrite(getJavaProject().getProject());
- waitForWorkspaceJobs();
- }
-
- @Override
- protected void deleteAllProjects() throws Exception{
- //don't delete projects, creating a new one with a new name
- //workspace will be deleted next time tests are run.
- //not saying this is the ultimate solution, but it will work for now
- //until we can figure out how to properly delete projects in tests
- }
-
- @Override
- protected void tearDown() throws Exception {
- //at least delete the project from the workspace since, deleting from the file system doesn't work well.
- //tests run too slow otherwise because so many projects are created in the workspace
- this.persistenceArtifactEdit.dispose();
- this.persistenceArtifactEdit = null;
- this.ormArtifactEdit.dispose();
- this.ormArtifactEdit = null;
- getJavaProject().getProject().delete(false, true, null);
- super.tearDown();
- }
-
- @Override
- protected TestJavaProject buildJavaProject(boolean autoBuild) throws Exception {
- return buildJpaProject(BASE_PROJECT_NAME, autoBuild, null);
- }
-
- protected TestJpaProject buildJpaProject(String projectName, boolean autoBuild, IDataModel jpaConfig)
- throws Exception {
- return TestJpaProject.buildJpaProject(projectName, autoBuild, jpaConfig);
- }
-
- protected JpaProject jpaProject() {
- return getJavaProject().getJpaProject();
- }
-
- protected void waitForWorkspaceJobs() {
- // This job will not finish running until the workspace jobs are done
- Job waitJob = new Job("Wait job") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- return Status.OK_STATUS;
- }
- };
- waitJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
- waitJob.schedule();
- try {
- waitJob.join();
- } catch (InterruptedException ex) {
- // the job thread was interrupted during a wait - ignore
- }
- }
-
- protected PersistenceResource persistenceResource() {
- return this.persistenceArtifactEdit.getResource();
- }
-
- protected OrmResource ormResource() {
- return this.ormArtifactEdit.getResource(JptCorePlugin.getDefaultOrmXmlDeploymentURI(jpaProject().getProject()));
- }
-
- protected XmlPersistence xmlPersistence() {
- return persistenceResource().getPersistence();
- }
-
- protected EntityMappings entityMappings() {
- return persistenceUnit().mappingFileRefs().next().getOrmXml().getEntityMappings();
- }
-
- protected XmlPersistenceUnit xmlPersistenceUnit() {
- return persistenceResource().getPersistence().getPersistenceUnits().get(0);
- }
-
- protected PersistenceUnit persistenceUnit() {
- return rootContext().getPersistenceXml().getPersistence().persistenceUnits().next();
- }
-
- protected ClassRef classRef() {
- return persistenceUnit().specifiedClassRefs().next();
- }
-
- protected JavaPersistentType javaPersistentType() {
- return classRef().getJavaPersistentType();
- }
-
- protected Entity javaEntity() {
- return (Entity) javaPersistentType().getMapping();
- }
-
- protected void addXmlClassRef(String className) {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
-
- XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- xmlClassRef.setJavaClass(className);
- xmlPersistenceUnit.getClasses().add(xmlClassRef);
- }
-
- protected void removeXmlClassRef(String className) {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- XmlJavaClassRef xmlJavaClassRefToRemove = null;
- for (XmlJavaClassRef xmlJavaClassRef : xmlPersistenceUnit.getClasses()) {
- if (xmlJavaClassRef.getJavaClass().equals(className)) {
- xmlJavaClassRefToRemove = xmlJavaClassRef;
- }
- }
- if (xmlJavaClassRefToRemove == null) {
- throw new IllegalArgumentException();
- }
- xmlPersistenceUnit.getClasses().remove(xmlJavaClassRefToRemove);
- }
-
- protected JpaRootContextNode rootContext() {
- return getJavaProject().getJpaProject().getRootContext();
- }
-
- @Override
- protected TestJpaProject getJavaProject() {
- return (TestJpaProject) super.getJavaProject();
- }
-
- protected void deleteResource(Resource resource) throws CoreException {
- System.gc();
- WorkbenchResourceHelper.deleteResource(resource);
- waitForWorkspaceJobs();
- }
-
- protected IType createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- return this.javaProject.createType("javax.persistence", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- protected IType createEnumAndMembers(String enumName, String enumBody) throws Exception {
- return this.javaProject.createType("javax.persistence", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java
deleted file mode 100644
index 37ef707521..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context;
-
-import java.util.Iterator;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JpaFile;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmXml;
-import org.eclipse.jpt.core.context.persistence.MappingFileRef;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JpaFileTests extends ContextModelTestCase
-{
- public JpaFileTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- public void testGetRootStructureNode() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- IFile file = ormResource().getResourceModel().getFile();
- JpaFile ormXmlJpaFile = JptCorePlugin.getJpaFile(file);
-
- assertEquals(entityMappings(), ormXmlJpaFile.rootStructureNodes().next());
-
-
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- //verify the mapping file reference "wins" as the root structure node when both
- //persistence.xml <class> tag and mapping file <entity> tag exist for a particulary java class
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- entityMappings().removeOrmPersistentType(ormPersistentType);
-
- assertEquals(javaEntity().getPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
- }
-
- public void testEntityMappingsRootStructureNodeRemoved() throws Exception {
- IFile file = ormResource().getResourceModel().getFile();
- JpaFile ormXmlJpaFile = JptCorePlugin.getJpaFile(file);
- assertEquals(entityMappings(), ormXmlJpaFile.rootStructureNodes().next());
-
- ((OrmXml) entityMappings().getParent()).removeEntityMappings();
-
- assertFalse(ormXmlJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testImpliedEntityMappingsRootStructureNodeRemoved() throws Exception {
- IFile file = ormResource().getResourceModel().getFile();
- JpaFile ormXmlJpaFile = JptCorePlugin.getJpaFile(file);
-
- assertNull(persistenceUnit().getImpliedMappingFileRef());
-
- xmlPersistenceUnit().getMappingFiles().remove(0);
- assertNotNull(persistenceUnit().getImpliedMappingFileRef());
- assertEquals(persistenceUnit().getImpliedMappingFileRef().getOrmXml().getEntityMappings(), ormXmlJpaFile.rootStructureNodes().next());
-
- persistenceUnit().getImpliedMappingFileRef().getOrmXml().removeEntityMappings();
- assertFalse(ormXmlJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testEntityMappingsRootStructureNodeRemovedFromResourceModel() throws Exception {
- IFile file = ormResource().getResourceModel().getFile();
- JpaFile ormXmlJpaFile = JptCorePlugin.getJpaFile(file);
- assertEquals(entityMappings(), ormXmlJpaFile.rootStructureNodes().next());
-
- ormResource().getContents().remove(ormResource().getEntityMappings());
-
- assertFalse(ormXmlJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testUpdatePersistenceRootStructureNodePersistenceRemoved() throws Exception {
- IFile file = persistenceResource().getResourceModel().getFile();
- JpaFile persistenceXmlJpaFile = JptCorePlugin.getJpaFile(file);
- assertEquals(rootContext().getPersistenceXml().getPersistence(), persistenceXmlJpaFile.rootStructureNodes().next());
-
- rootContext().getPersistenceXml().removePersistence();
- assertFalse(persistenceXmlJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testUpdateOrmJavaRootStructureNodePersistenceRemoved() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- rootContext().getPersistenceXml().removePersistence();
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testUpdateJavaRootStructureNodePersistenceRemoved() throws Exception {
- IType testType = createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(javaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- rootContext().getPersistenceXml().removePersistence();
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testPersistenceRootStructureNodeRemovedFromResourceModel() throws Exception {
- IFile file = persistenceResource().getResourceModel().getFile();
- JpaFile persistenceXmlJpaFile = JptCorePlugin.getJpaFile(file);
- rootContext().getPersistenceXml().getPersistence();
- assertEquals(rootContext().getPersistenceXml().getPersistence(), persistenceXmlJpaFile.rootStructureNodes().next());
-
- persistenceResource().getContents().remove(persistenceResource().getPersistence());
-
- assertFalse(persistenceXmlJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testUpdatePersistenceRootStructureNodePersistenceXmlRemoved() throws Exception {
- IFile file = persistenceResource().getResourceModel().getFile();
- JpaFile persistenceXmlJpaFile = JptCorePlugin.getJpaFile(file);
- assertEquals(rootContext().getPersistenceXml().getPersistence(), persistenceXmlJpaFile.rootStructureNodes().next());
-
- rootContext().removePersistenceXml();
- assertFalse(persistenceXmlJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testUpdateOrmJavaRootStructureNodePersistenceXmlRemoved() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- rootContext().removePersistenceXml();
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testUpdateJavaRootStructureNodePersistenceXmlRemoved() throws Exception {
- IType testType = createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(javaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- rootContext().removePersistenceXml();
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testOrmJavaPersistentTypeRootStructureNodeRemoved() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- entityMappings().removeOrmPersistentType(0);
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testOrmJavaPersistentTypeRootStructureNodeRemovedFromResourceModel() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- ormResource().getEntityMappings().getEntities().remove(0);
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testJavaPersistentTypeRootStructureNodeRemoved() throws Exception {
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- JavaPersistentType javaPersistentType = javaPersistentType();
- assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next());
-
- entityMappings().getPersistenceUnit().removeSpecifiedClassRef(0);
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testJavaPersistentTypeRootStructureNodeRemovedFromResourceModel() throws Exception {
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- JavaPersistentType javaPersistentType = javaPersistentType();
- assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next());
-
- removeXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testImpliedJavaPersistentTypeRootStructureNodeRemoved() throws Exception {
- jpaProject().setDiscoversAnnotatedClasses(true);
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- JavaPersistentType javaPersistentType = persistenceUnit().impliedClassRefs().next().getJavaPersistentType();
- assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next());
-
- javaPersistentType.setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
-
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testJavaRootStructureNodesEntityMappingsRemoved() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- ormResource().getContents().remove(ormResource().getEntityMappings());
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testJavaRootStructureNodesOrmPersistentTypeRemoved() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- entityMappings().removeOrmPersistentType(0);
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testJavaRootStructureNodesOrmTypeMappingMorphed() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- ormPersistentType.setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
- assertEquals(1, javaJpaFile.rootStructureNodesSize());
- assertEquals(entityMappings().ormPersistentTypes().next().getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- entityMappings().removeOrmPersistentType(0);
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- public void testUpdateOrmJavaRootStructureNodeMappingFileRefChanged() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- MappingFileRef mappingFileRef = persistenceUnit().mappingFileRefs().next();
- mappingFileRef.setFileName("foo");
-
- ormPersistentType = persistenceUnit().getImpliedMappingFileRef().getOrmXml().getEntityMappings().ormPersistentTypes().next();
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- IFile file = persistenceResource().getResourceModel().getFile();
- JpaFile ormXmlJpaFile = JptCorePlugin.getJpaFile(file);
-
- assertEquals(1, ormXmlJpaFile.rootStructureNodesSize());
- }
-
- public void testUpdateJavaRootStructureNodeMappingFileRefChanged() throws Exception {
- IType testType = createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(javaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
- MappingFileRef mappingFileRef = persistenceUnit().mappingFileRefs().next();
- mappingFileRef.setFileName("foo");
- assertEquals(javaPersistentType(), javaJpaFile.rootStructureNodes().next());
- }
-
-
- public void testUpdateJavaRootStrucutreNodeDeleteOrmResource() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- IType testType = createTestEntity();
- JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
-
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
-
-
- deleteResource(ormResource());
-
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
- }
-
- //TODO test rootStructureNodes with a static inner class
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JptCoreContextModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JptCoreContextModelTests.java
deleted file mode 100644
index 307e3051db..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JptCoreContextModelTests.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.core.tests.internal.context.java.JptCoreContextJavaModelTests;
-import org.eclipse.jpt.core.tests.internal.context.orm.JptCoreOrmContextModelTests;
-import org.eclipse.jpt.core.tests.internal.context.persistence.JptCorePersistenceContextModelTests;
-
-public class JptCoreContextModelTests extends TestCase
-{
- public static Test suite() {
- return suite(true);
- }
-
- public static Test suite(boolean all) {
- TestSuite suite = new TestSuite(JptCoreContextModelTests.class.getName());
- suite.addTestSuite(JpaFileTests.class);
- suite.addTest(JptCorePersistenceContextModelTests.suite(all));
- suite.addTest(JptCoreOrmContextModelTests.suite(all));
- suite.addTest(JptCoreContextJavaModelTests.suite(all));
- return suite;
- }
-
- private JptCoreContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAssociationOverrideTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAssociationOverrideTests.java
deleted file mode 100644
index 51c4b79b72..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAssociationOverrideTests.java
+++ /dev/null
@@ -1,421 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.AssociationOverride;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaAssociationOverrideTests extends ContextModelTestCase
-{
- private static final String ASSOCIATION_OVERRIDE_NAME = "MY_ASSOCIATION_OVERRIDE_NAME";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createMappedSuperclassAnnotation() throws Exception{
- this.createAnnotationAndMembers("MappedSuperclass", "");
- }
-
- private void createJoinColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("JoinColumn",
- "String name() default \"\";" +
- "String referencedColumnName() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";");
- }
-
- private void createAssociationOverrideAnnotation() throws Exception {
- createJoinColumnAnnotation();
- this.createAnnotationAndMembers("AssociationOverride",
- "String name();" +
- "JoinColumn[] joinColumns();");
- }
-
- private IType createTestMappedSuperclass() throws Exception {
- createMappedSuperclassAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, JPA.ONE_TO_ONE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(" @OneToOne");
- sb.append(CR);
- sb.append(" private int address;").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- private IType createTestEntityWithAssociationOverride() throws Exception {
- createEntityAnnotation();
- createAssociationOverrideAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ASSOCIATION_OVERRIDE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\")");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
-
-
- public JavaAssociationOverrideTests(String name) {
- super(name);
- }
-
- public void testUpdateName() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- AssociationOverride javaAssociationOverride = entity.virtualAssociationOverrides().next();
- javaAssociationOverride = javaAssociationOverride.setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(PACKAGE_NAME + ".AnnotationTestTypeChild");
- AssociationOverrideAnnotation associationOverrideResource = (AssociationOverrideAnnotation) typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- assertEquals("address", javaAssociationOverride.getName());
- assertEquals("address", associationOverrideResource.getName());
- assertTrue(javaEntity().associationOverrides().hasNext());
-
- //set name in the resource model, verify context model updated
- associationOverrideResource.setName("FOO");
- assertEquals("FOO", javaAssociationOverride.getName());
- assertEquals("FOO", associationOverrideResource.getName());
-
- //set name to null in the resource model
- associationOverrideResource.setName(null);
- assertNull(javaAssociationOverride.getName());
- assertNull(associationOverrideResource.getName());
-
- associationOverrideResource.setName("FOO");
- assertEquals("FOO", javaAssociationOverride.getName());
- assertEquals("FOO", associationOverrideResource.getName());
-
- typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- assertFalse(javaEntity().specifiedAssociationOverrides().hasNext());
- assertFalse(typeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).hasNext());
- }
-
- public void testModifyName() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- AssociationOverride javaAssociationOverride = entity.virtualAssociationOverrides().next();
- javaAssociationOverride = javaAssociationOverride.setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(PACKAGE_NAME + ".AnnotationTestTypeChild");
- AssociationOverrideAnnotation associationOverrideResource = (AssociationOverrideAnnotation) typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- assertEquals("address", javaAssociationOverride.getName());
- assertEquals("address", associationOverrideResource.getName());
- assertTrue(javaEntity().associationOverrides().hasNext());
-
- //set name in the context model, verify resource model modified
- javaAssociationOverride.setName("foo");
- assertEquals("foo", javaAssociationOverride.getName());
- assertEquals("foo", associationOverrideResource.getName());
-
- //set name to null in the context model
- javaAssociationOverride.setName(null);
- assertNull(javaAssociationOverride.getName());
- associationOverrideResource = (AssociationOverrideAnnotation) typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
- assertNull(associationOverrideResource.getName());
- }
-
- public void testAddSpecifiedJoinColumn() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- AssociationOverride javaAssociationOverride = entity.virtualAssociationOverrides().next();
- javaAssociationOverride = javaAssociationOverride.setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(PACKAGE_NAME + ".AnnotationTestTypeChild");
- AssociationOverrideAnnotation associationOverrideResource = (AssociationOverrideAnnotation) typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
-
- JoinColumn joinColumn = javaAssociationOverride.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("FOO");
-
- assertEquals("FOO", associationOverrideResource.joinColumnAt(0).getName());
-
- JoinColumn joinColumn2 = javaAssociationOverride.addSpecifiedJoinColumn(0);
- joinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", associationOverrideResource.joinColumnAt(0).getName());
- assertEquals("FOO", associationOverrideResource.joinColumnAt(1).getName());
-
- JoinColumn joinColumn3 = javaAssociationOverride.addSpecifiedJoinColumn(1);
- joinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", associationOverrideResource.joinColumnAt(0).getName());
- assertEquals("BAZ", associationOverrideResource.joinColumnAt(1).getName());
- assertEquals("FOO", associationOverrideResource.joinColumnAt(2).getName());
-
- ListIterator<JoinColumn> joinColumns = javaAssociationOverride.specifiedJoinColumns();
- assertEquals(joinColumn2, joinColumns.next());
- assertEquals(joinColumn3, joinColumns.next());
- assertEquals(joinColumn, joinColumns.next());
-
- joinColumns = javaAssociationOverride.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- }
-
- public void testRemoveSpecifiedJoinColumn() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- AssociationOverride javaAssociationOverride = entity.virtualAssociationOverrides().next();
- javaAssociationOverride = javaAssociationOverride.setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(PACKAGE_NAME + ".AnnotationTestTypeChild");
- AssociationOverrideAnnotation associationOverrideResource = (AssociationOverrideAnnotation) typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- javaAssociationOverride.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- javaAssociationOverride.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- javaAssociationOverride.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- assertEquals(3, associationOverrideResource.joinColumnsSize());
-
- javaAssociationOverride.removeSpecifiedJoinColumn(0);
- assertEquals(2, associationOverrideResource.joinColumnsSize());
- assertEquals("BAR", associationOverrideResource.joinColumnAt(0).getName());
- assertEquals("BAZ", associationOverrideResource.joinColumnAt(1).getName());
-
- javaAssociationOverride.removeSpecifiedJoinColumn(0);
- assertEquals(1, associationOverrideResource.joinColumnsSize());
- assertEquals("BAZ", associationOverrideResource.joinColumnAt(0).getName());
-
- javaAssociationOverride.removeSpecifiedJoinColumn(0);
- assertEquals(0, associationOverrideResource.joinColumnsSize());
- }
-
- public void testMoveSpecifiedJoinColumn() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- AssociationOverride javaAssociationOverride = entity.virtualAssociationOverrides().next();
- javaAssociationOverride = javaAssociationOverride.setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(PACKAGE_NAME + ".AnnotationTestTypeChild");
- AssociationOverrideAnnotation associationOverrideResource = (AssociationOverrideAnnotation) typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- javaAssociationOverride.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- javaAssociationOverride.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- javaAssociationOverride.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- assertEquals(3, associationOverrideResource.joinColumnsSize());
-
-
- javaAssociationOverride.moveSpecifiedJoinColumn(2, 0);
- ListIterator<JoinColumn> joinColumns = javaAssociationOverride.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAR", associationOverrideResource.joinColumnAt(0).getName());
- assertEquals("BAZ", associationOverrideResource.joinColumnAt(1).getName());
- assertEquals("FOO", associationOverrideResource.joinColumnAt(2).getName());
-
-
- javaAssociationOverride.moveSpecifiedJoinColumn(0, 1);
- joinColumns = javaAssociationOverride.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAZ", associationOverrideResource.joinColumnAt(0).getName());
- assertEquals("BAR", associationOverrideResource.joinColumnAt(1).getName());
- assertEquals("FOO", associationOverrideResource.joinColumnAt(2).getName());
- }
-
- public void testUpdateJoinColumns() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- AssociationOverride javaAssociationOverride = entity.virtualAssociationOverrides().next();
- javaAssociationOverride = javaAssociationOverride.setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(PACKAGE_NAME + ".AnnotationTestTypeChild");
- AssociationOverrideAnnotation associationOverrideResource = (AssociationOverrideAnnotation) typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- associationOverrideResource.addJoinColumn(0);
- associationOverrideResource.addJoinColumn(1);
- associationOverrideResource.addJoinColumn(2);
-
- associationOverrideResource.joinColumnAt(0).setName("FOO");
- associationOverrideResource.joinColumnAt(1).setName("BAR");
- associationOverrideResource.joinColumnAt(2).setName("BAZ");
-
- ListIterator<JoinColumn> joinColumns = javaAssociationOverride.specifiedJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- associationOverrideResource.moveJoinColumn(2, 0);
- joinColumns = javaAssociationOverride.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- associationOverrideResource.moveJoinColumn(0, 1);
- joinColumns = javaAssociationOverride.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- associationOverrideResource.removeJoinColumn(1);
- joinColumns = javaAssociationOverride.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- associationOverrideResource.removeJoinColumn(1);
- joinColumns = javaAssociationOverride.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- associationOverrideResource.removeJoinColumn(0);
- assertFalse(javaAssociationOverride.specifiedJoinColumns().hasNext());
- }
-
-
-
-
- public void testGetName() throws Exception {
- createTestEntityWithAssociationOverride();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AssociationOverride specifiedAssociationOverride = javaEntity().specifiedAssociationOverrides().next();
- assertEquals(ASSOCIATION_OVERRIDE_NAME, specifiedAssociationOverride.getName());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- AssociationOverrideAnnotation associationOverrideResource = (AssociationOverrideAnnotation) typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- associationOverrideResource.setName("FOO");
- specifiedAssociationOverride = javaEntity().specifiedAssociationOverrides().next();
- assertEquals("FOO", specifiedAssociationOverride.getName());
- }
-
- public void testSetName() throws Exception {
- createTestEntityWithAssociationOverride();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AssociationOverride specifiedAssociationOverride = javaEntity().specifiedAssociationOverrides().next();
- assertEquals(ASSOCIATION_OVERRIDE_NAME, specifiedAssociationOverride.getName());
-
- specifiedAssociationOverride.setName("FOO");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- AssociationOverrideAnnotation associationOverrideResource = (AssociationOverrideAnnotation) typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- assertEquals("FOO", associationOverrideResource.getName());
- }
-
- public void testDefaultName() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- assertEquals("AnnotationTestTypeChild", entity.getName());
- assertEquals(1, entity.virtualAssociationOverridesSize());
-
- AssociationOverride associationOverride = entity.virtualAssociationOverrides().next();
- assertEquals("address", associationOverride.getName());
- }
-
- public void testIsVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- assertEquals("AnnotationTestTypeChild", entity.getName());
- assertEquals(1, entity.virtualAssociationOverridesSize());
-
- AssociationOverride associationOverride = entity.virtualAssociationOverrides().next();
- assertTrue(associationOverride.isVirtual());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAttributeOverrideTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAttributeOverrideTests.java
deleted file mode 100644
index 96e8302356..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAttributeOverrideTests.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaAttributeOverrideTests extends ContextModelTestCase
-{
- private static final String ATTRIBUTE_OVERRIDE_NAME = "MY_ATTRIBUTE_OVERRIDE_NAME";
- private static final String ATTRIBUTE_OVERRIDE_COLUMN_NAME = "MY_ATTRIBUTE_OVERRIDE_COLUMN_NAME";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createMappedSuperclassAnnotation() throws Exception{
- this.createAnnotationAndMembers("MappedSuperclass", "");
- }
-
- private void createColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("Column",
- "String name() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";" +
- "int length() default 255;" +
- "int precision() default 0;" +
- "int scale() default 0;");
- }
-
- private void createAttributeOverrideAnnotation() throws Exception {
- createColumnAnnotation();
- this.createAnnotationAndMembers("AttributeOverride",
- "String name();" +
- "Column column();");
- }
-
- private IType createTestMappedSuperclass() throws Exception {
- createMappedSuperclassAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass");
- }
- });
- }
-
- private IType createTestEntityWithAttributeOverride() throws Exception {
- createEntityAnnotation();
- createAttributeOverrideAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ATTRIBUTE_OVERRIDE, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\", column=@Column(name=\"" + ATTRIBUTE_OVERRIDE_COLUMN_NAME + "\"))");
- }
- });
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
-
-
- public JavaAttributeOverrideTests(String name) {
- super(name);
- }
-
- public void testGetName() throws Exception {
- createTestEntityWithAttributeOverride();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AttributeOverride specifiedAttributeOverride = javaEntity().specifiedAttributeOverrides().next();
- assertEquals(ATTRIBUTE_OVERRIDE_NAME, specifiedAttributeOverride.getName());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- AttributeOverrideAnnotation attributeOverrideResource = (AttributeOverrideAnnotation) typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
-
- attributeOverrideResource.setName("FOO");
- specifiedAttributeOverride = javaEntity().specifiedAttributeOverrides().next();
- assertEquals("FOO", specifiedAttributeOverride.getName());
- }
-
- public void testSetName() throws Exception {
- createTestEntityWithAttributeOverride();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AttributeOverride specifiedAttributeOverride = javaEntity().specifiedAttributeOverrides().next();
- assertEquals(ATTRIBUTE_OVERRIDE_NAME, specifiedAttributeOverride.getName());
-
- specifiedAttributeOverride.setName("FOO");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- AttributeOverrideAnnotation attributeOverrideResource = (AttributeOverrideAnnotation) typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
-
- assertEquals("FOO", attributeOverrideResource.getName());
- }
-
- public void testColumnGetName() throws Exception {
- createTestEntityWithAttributeOverride();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AttributeOverride specifiedAttributeOverride = javaEntity().specifiedAttributeOverrides().next();
- Column column = specifiedAttributeOverride.getColumn();
- assertEquals(ATTRIBUTE_OVERRIDE_COLUMN_NAME, column.getName());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- AttributeOverrideAnnotation attributeOverrideResource = (AttributeOverrideAnnotation) typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
- ColumnAnnotation columnResource = attributeOverrideResource.getColumn();
- columnResource.setName("FOO");
-
-
- column = javaEntity().specifiedAttributeOverrides().next().getColumn();
- assertEquals("FOO", column.getName());
- }
-
- public void testColumnSetName() throws Exception {
- createTestEntityWithAttributeOverride();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AttributeOverride specifiedAttributeOverride = javaEntity().specifiedAttributeOverrides().next();
- Column column = specifiedAttributeOverride.getColumn();
- assertEquals(ATTRIBUTE_OVERRIDE_COLUMN_NAME, column.getName());
-
- column.setSpecifiedName("FOO");
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- AttributeOverrideAnnotation attributeOverrideResource = (AttributeOverrideAnnotation) typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
- ColumnAnnotation columnResource = attributeOverrideResource.getColumn();
-
- assertEquals("FOO", columnResource.getName());
-
- column.setSpecifiedName(null);
-
- attributeOverrideResource = (AttributeOverrideAnnotation) typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
- assertNull(attributeOverrideResource.getColumn());
- assertNotNull(specifiedAttributeOverride.getColumn());
- }
-
- public void testColumnDefaultName() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- assertEquals("AnnotationTestTypeChild", entity.getName());
- assertEquals(2, entity.virtualAttributeOverridesSize());
-
- AttributeOverride attributeOverride = entity.virtualAttributeOverrides().next();
- assertEquals("id", attributeOverride.getColumn().getDefaultName());
-
-
- JavaPersistentType mappedSuperclass = CollectionTools.list(persistenceUnit().specifiedClassRefs()).get(1).getJavaPersistentType();
- BasicMapping basicMapping = (BasicMapping) mappedSuperclass.getAttributeNamed("id").getMapping();
- basicMapping.getColumn().setSpecifiedName("FOO");
-
- attributeOverride = entity.virtualAttributeOverrides().next();
- assertEquals("FOO", attributeOverride.getColumn().getDefaultName());
- }
-
- public void testColumnDefaultTableName() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- assertEquals("AnnotationTestTypeChild", entity.getName());
- assertEquals(2, entity.virtualAttributeOverridesSize());
-
- AttributeOverride attributeOverride = entity.virtualAttributeOverrides().next();
- assertEquals("AnnotationTestTypeChild", attributeOverride.getColumn().getDefaultTable());
-
-
- JavaPersistentType mappedSuperclass = CollectionTools.list(persistenceUnit().specifiedClassRefs()).get(1).getJavaPersistentType();
- BasicMapping basicMapping = (BasicMapping) mappedSuperclass.getAttributeNamed("id").getMapping();
- basicMapping.getColumn().setSpecifiedTable("BAR");
-
- attributeOverride = entity.virtualAttributeOverrides().next();
- assertEquals("BAR", attributeOverride.getColumn().getDefaultTable());
- }
-
- public void testDefaultName() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- assertEquals("AnnotationTestTypeChild", entity.getName());
- assertEquals(2, entity.virtualAttributeOverridesSize());
-
- AttributeOverride attributeOverride = entity.virtualAttributeOverrides().next();
- assertEquals("id", attributeOverride.getName());
- }
-
- public void testIsVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- assertEquals("AnnotationTestTypeChild", entity.getName());
- assertEquals(2, entity.virtualAttributeOverridesSize());
-
- AttributeOverride attributeOverride = entity.virtualAttributeOverrides().next();
- assertTrue(attributeOverride.isVirtual());
- }
-
- public void testSetColumn() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- AttributeOverride attributeOverride = entity.virtualAttributeOverrides().next();
- attributeOverride = attributeOverride.setVirtual(false);
- attributeOverride.getColumn().setSpecifiedName("FOO");
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(PACKAGE_NAME + ".AnnotationTestTypeChild");
- AttributeOverrideAnnotation attributeOverrideResource = (AttributeOverrideAnnotation) typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
-
- assertEquals("FOO", attributeOverrideResource.getColumn().getName());
- assertEquals("FOO", entity.specifiedAttributeOverrides().next().getColumn().getSpecifiedName());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaBasicMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaBasicMappingTests.java
deleted file mode 100644
index b0c5eb0ff5..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaBasicMappingTests.java
+++ /dev/null
@@ -1,1000 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.EnumType;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.TemporalType;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.LobAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.TemporalAnnotation;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaBasicMappingTests extends ContextModelTestCase
-{
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createBasicAnnotation() throws Exception{
- this.createAnnotationAndMembers("Basic", "FetchType fetch() default EAGER; boolean optional() default true;");
- }
-
- private void createLobAnnotation() throws Exception{
- this.createAnnotationAndMembers("Lob", "");
- }
-
- private void createEnumeratedAnnotation() throws Exception{
- this.createAnnotationAndMembers("Enumerated", "EnumType value() default ORDINAL;");
- }
-
- private void createTemporalAnnotation() throws Exception{
- this.createAnnotationAndMembers("Temporal", "TemporalType value();");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private IType createTestEntityWithBasicMapping() throws Exception {
- createEntityAnnotation();
- createBasicAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic").append(CR);
- }
- });
- }
- private IType createTestEntityWithBasicMappingFetchOptionalSpecified() throws Exception {
- createEntityAnnotation();
- createBasicAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, JPA.FETCH_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic(fetch=FetchType.EAGER, optional=false)").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithLob() throws Exception {
- createEntityAnnotation();
- createLobAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.LOB);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Lob").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithEnumerated() throws Exception {
- createEntityAnnotation();
- createEnumeratedAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ENUMERATED, JPA.ENUM_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Enumerated(EnumType.STRING)").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithTemporal() throws Exception {
- createEntityAnnotation();
- createTemporalAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.TEMPORAL, JPA.TEMPORAL_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Temporal(TemporalType.TIMESTAMP)").append(CR);
- }
- });
- }
-
- public JavaBasicMappingTests(String name) {
- super(name);
- }
-
- public void testDefaultBasicGetDefaultFetch() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertEquals(FetchType.EAGER, basicMapping.getDefaultFetch());
- }
-
- public void testSpecifiedBasicGetDefaultFetch() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
- assertEquals(FetchType.EAGER, basicMapping.getDefaultFetch());
- }
-
- public void testGetFetch() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertEquals(FetchType.EAGER, basicMapping.getFetch());
-
- basicMapping.setSpecifiedFetch(FetchType.LAZY);
- assertEquals(FetchType.LAZY, basicMapping.getFetch());
- }
-
- public void testGetSpecifiedFetch() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(basicMapping.getSpecifiedFetch());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
- basic.setFetch(org.eclipse.jpt.core.resource.java.FetchType.LAZY);
-
- assertEquals(FetchType.LAZY, basicMapping.getSpecifiedFetch());
- }
-
- public void testGetSpecifiedFetch2() throws Exception {
- createTestEntityWithBasicMappingFetchOptionalSpecified();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertEquals(FetchType.EAGER, basicMapping.getSpecifiedFetch());
- }
-
- public void testSetSpecifiedFetch() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
- assertNull(basicMapping.getSpecifiedFetch());
-
- basicMapping.setSpecifiedFetch(FetchType.LAZY);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
-
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, basic.getFetch());
-
- basicMapping.setSpecifiedFetch(null);
- assertNotNull(attributeResource.getMappingAnnotation(JPA.BASIC));
- }
-
- public void testSetSpecifiedFetch2() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- createOrmXmlFile();
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.PROPERTY);
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertNull(basicMapping.getSpecifiedFetch());
- assertTrue(basicMapping.isDefault());
-
- basicMapping.setSpecifiedFetch(FetchType.LAZY);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.properties().next();
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
-
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, basic.getFetch());
-
- basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertEquals(FetchType.LAZY, basicMapping.getSpecifiedFetch());
- assertFalse(basicMapping.isDefault());
-
- basicMapping.setSpecifiedFetch(null);
- assertNotNull(attributeResource.getMappingAnnotation(JPA.BASIC));
-
- basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- }
-
- protected void createOrmXmlFile() throws Exception {
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testSetBasicRemovedFromResourceModel() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setLob(true);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- assertFalse(basicMapping.isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.setMappingAnnotation(null);
-
- assertNotSame(basicMapping, persistentAttribute.getMapping());
-
- basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertTrue(basicMapping.isDefault());
- assertEquals("FOO", basicMapping.getColumn().getSpecifiedName());
-
-
- assertNotNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- }
-
- public void testBasicMorphToDefaultBasic() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setLob(true);
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertEquals("FOO", ((BasicMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
- assertEquals(TemporalType.TIME, ((BasicMapping) persistentAttribute.getMapping()).getTemporal());
- assertTrue(((BasicMapping) persistentAttribute.getMapping()).isLob());
- assertEquals(EnumType.ORDINAL, ((BasicMapping) persistentAttribute.getMapping()).getEnumerated());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(((BasicMapping) persistentAttribute.getMapping()).getSpecifiedFetch());
- assertNull(((BasicMapping) persistentAttribute.getMapping()).getSpecifiedOptional());
- assertNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- }
-
- public void testBasicMorphToId() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setLob(true);
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals("FOO", ((IdMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
- assertEquals(TemporalType.TIME, ((IdMapping) persistentAttribute.getMapping()).getTemporal());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- }
-
- public void testBasicMorphToVersion() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setLob(true);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- assertFalse(basicMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertEquals("FOO", ((VersionMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
- assertEquals(TemporalType.TIME, ((VersionMapping) persistentAttribute.getMapping()).getTemporal());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- }
-
- public void testBasicMorphToEmbedded() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setLob(true);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- assertFalse(basicMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- }
-
- public void testBasicMorphToEmbeddedId() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setLob(true);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- assertFalse(basicMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- }
-
- public void testBasicMorphToTransient() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setLob(true);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- assertFalse(basicMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- }
-
- public void testBasicMorphToOneToOne() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setLob(true);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-//TODO assertEquals(FetchType.EAGER, ((IOneToOneMapping) persistentAttribute.getMapping()).getSpecifiedFetch());
-// assertEquals(Boolean.FALSE, ((IOneToOneMapping) persistentAttribute.getMapping()).getSpecifiedOptional());
- assertNotNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- }
-
- public void testBasicMorphToOneToMany() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setLob(true);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-//TODO assertEquals(FetchType.EAGER, ((IOneToManyMapping) persistentAttribute.getMapping()).getSpecifiedFetch());
-// assertNotNull(attributeResource.mappingAnnotation(OneToMany.ANNOTATION_NAME));
- assertNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- }
- public void testBasicMorphToManyToOne() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setLob(true);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-//TODO assertEquals(FetchType.EAGER, ((IManyToOneMapping) persistentAttribute.getMapping()).getSpecifiedFetch());
-// assertEquals(Boolean.FALSE, ((IManyToOneMapping) persistentAttribute.getMapping()).getSpecifiedOptional());
- assertNotNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- }
-
- public void testBasicMorphToManyToMany() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setLob(true);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-//TODO assertEquals(FetchType.EAGER, ((IManyToManyMapping) persistentAttribute.getMapping()).getSpecifiedFetch());
-// assertNotNull(attributeResource.mappingAnnotation(ManyToMany.ANNOTATION_NAME));
- assertNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- }
-
- public void testDefaultBasicGetDefaultOptional() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertEquals(Boolean.TRUE, basicMapping.getDefaultOptional());
- }
-
- public void testSpecifiedBasicGetDefaultOptional() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
- assertEquals(Boolean.TRUE, basicMapping.getDefaultOptional());
- }
-
- public void testGetOptional() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertEquals(Boolean.TRUE, basicMapping.getOptional());
-
- basicMapping.setSpecifiedOptional(basicMapping.getOptional());
- assertEquals(Boolean.TRUE, basicMapping.getOptional());
- }
-
- public void testGetSpecifiedOptional() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(basicMapping.getSpecifiedOptional());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
- basic.setOptional(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, basicMapping.getSpecifiedOptional());
- }
-
- public void testGetSpecifiedOptional2() throws Exception {
- createTestEntityWithBasicMappingFetchOptionalSpecified();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertEquals(Boolean.FALSE, basicMapping.getSpecifiedOptional());
- }
-
- public void testSetSpecifiedOptional() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
- assertNull(basicMapping.getSpecifiedOptional());
-
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
-
- assertEquals(Boolean.FALSE, basic.getOptional());
-
- basicMapping.setSpecifiedOptional(null);
- assertNotNull(attributeResource.getMappingAnnotation(JPA.BASIC));
- }
-
- public void testSetSpecifiedOptional2() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertNull(basicMapping.getSpecifiedOptional());
- assertTrue(basicMapping.isDefault());
-
- basicMapping.setSpecifiedOptional(Boolean.TRUE);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
-
- assertEquals(Boolean.TRUE, basic.getOptional());
-
- basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertEquals(Boolean.TRUE, basicMapping.getSpecifiedOptional());
- assertFalse(basicMapping.isDefault());
-
- basicMapping.setSpecifiedOptional(null);
- assertNotNull(attributeResource.getMappingAnnotation(JPA.BASIC));
-
- basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- }
-
-
- public void testGetSpecifiedOptionalUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(basicMapping.getSpecifiedOptional());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
- basic.setOptional(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, basicMapping.getSpecifiedOptional());
-
- basic.setOptional(null);
- assertNull(basicMapping.getSpecifiedOptional());
- assertFalse(basicMapping.isDefault());
- assertSame(basicMapping, persistentAttribute.getSpecifiedMapping());
-
- basic.setOptional(Boolean.FALSE);
- attributeResource.setMappingAnnotation(null);
-
- assertNull(persistentAttribute.getSpecifiedMapping());
- assertEquals(Boolean.TRUE, ((BasicMapping) persistentAttribute.getMapping()).getOptional());
- }
-
-
- public void testIsLob() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertFalse(basicMapping.isLob());
- }
-
- public void testIsLob2() throws Exception {
- createTestEntityWithLob();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
-
- assertTrue(basicMapping.isLob());
- }
-
- public void testSetLob() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- basicMapping.setLob(true);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNotNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
-
- basicMapping.setLob(false);
- assertNull(attributeResource.getAnnotation(LobAnnotation.ANNOTATION_NAME));
- }
-
- public void testIsLobUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertFalse(basicMapping.isLob());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(LobAnnotation.ANNOTATION_NAME);
-
- assertTrue(basicMapping.isLob());
-
- attributeResource.removeAnnotation(LobAnnotation.ANNOTATION_NAME);
-
- assertFalse(basicMapping.isLob());
- }
-
- public void testDefaultBasicGetDefaultEnumerated() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertEquals(EnumType.ORDINAL, basicMapping.getDefaultEnumerated());
- }
-
- public void testSpecifiedBasicGetDefaultEnumerated() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
- assertEquals(EnumType.ORDINAL, basicMapping.getDefaultEnumerated());
- }
-
- public void testGetEnumerated() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertEquals(EnumType.ORDINAL, basicMapping.getEnumerated());
-
- basicMapping.setSpecifiedEnumerated(EnumType.STRING);
- assertEquals(EnumType.STRING, basicMapping.getEnumerated());
- }
-
- public void testGetSpecifiedEnumerated() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(basicMapping.getSpecifiedEnumerated());
- }
-
- public void testGetSpecifiedEnumerated2() throws Exception {
- createTestEntityWithEnumerated();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
-
- assertEquals(EnumType.STRING, basicMapping.getSpecifiedEnumerated());
- }
-
- public void testSetSpecifiedEnumerated() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
- assertNull(basicMapping.getSpecifiedEnumerated());
-
- basicMapping.setSpecifiedEnumerated(EnumType.STRING);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- EnumeratedAnnotation enumerated = (EnumeratedAnnotation) attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.core.resource.java.EnumType.STRING, enumerated.getValue());
-
- basicMapping.setSpecifiedEnumerated(null);
- assertNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- }
-
- public void testGetSpecifieEnumeratedUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(basicMapping.getSpecifiedEnumerated());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- EnumeratedAnnotation enumerated = (EnumeratedAnnotation) attributeResource.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME);
- enumerated.setValue(org.eclipse.jpt.core.resource.java.EnumType.STRING);
-
- assertEquals(EnumType.STRING, basicMapping.getSpecifiedEnumerated());
-
- enumerated.setValue(null);
- assertNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
- assertNull(basicMapping.getSpecifiedEnumerated());
- assertFalse(basicMapping.isDefault());
- assertSame(basicMapping, persistentAttribute.getSpecifiedMapping());
- }
-
-
- public void testGetTemporal() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(basicMapping.getTemporal());
- }
-
- public void testGetTemporal2() throws Exception {
- createTestEntityWithTemporal();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
-
- assertEquals(TemporalType.TIMESTAMP, basicMapping.getTemporal());
- }
-
- public void testSetTemporal() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
- assertNull(basicMapping.getTemporal());
-
- basicMapping.setTemporal(TemporalType.TIME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.core.resource.java.TemporalType.TIME, temporal.getValue());
-
- basicMapping.setTemporal(null);
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testGetTemporalUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(basicMapping.getTemporal());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.addAnnotation(TemporalAnnotation.ANNOTATION_NAME);
- temporal.setValue(org.eclipse.jpt.core.resource.java.TemporalType.DATE);
-
- assertEquals(TemporalType.DATE, basicMapping.getTemporal());
-
- attributeResource.removeAnnotation(TemporalAnnotation.ANNOTATION_NAME);
-
- assertNull(basicMapping.getTemporal());
- assertFalse(basicMapping.isDefault());
- assertSame(basicMapping, persistentAttribute.getSpecifiedMapping());
- }
-
- public void testGetColumn() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedName());
- assertEquals("id", basicMapping.getColumn().getName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
- column.setName("foo");
-
- assertEquals("foo", basicMapping.getColumn().getSpecifiedName());
- assertEquals("foo", basicMapping.getColumn().getName());
- assertEquals("id", basicMapping.getColumn().getDefaultName());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaColumnTests.java
deleted file mode 100644
index 427959ac8e..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaColumnTests.java
+++ /dev/null
@@ -1,848 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaColumnTests extends ContextModelTestCase
-{
- private static final String COLUMN_NAME = "MY_COLUMN";
- private static final String TABLE_NAME = "MY_TABLE";
- private static final String COLUMN_DEFINITION = "MY_COLUMN_DEFINITION";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createBasicAnnotation() throws Exception{
- this.createAnnotationAndMembers("Basic", "String name() default \"\";");
- }
-
- private void createColumnAnnotation() throws Exception{
- this.createAnnotationAndMembers("Column",
- "String name() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";" +
- "int length() default 255;" +
- "int precision() default 0;" +
- "int scale() default 0;");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private IType createTestEntityWithDefaultBasicColumn() throws Exception {
- createEntityAnnotation();
- createColumnAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Column(name=\"" + COLUMN_NAME + "\")");
- }
- });
- }
-
- private IType createTestEntityWithBasicColumnTableSet() throws Exception {
- createEntityAnnotation();
- createColumnAnnotation();
- createBasicAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic");
- sb.append("@Column(table=\"" + TABLE_NAME + "\")");
- }
- });
- }
- private IType createTestEntityWithBasicColumnColumnDefinitionSet() throws Exception {
- createEntityAnnotation();
- createColumnAnnotation();
- createBasicAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic");
- sb.append("@Column(columnDefinition=\"" + COLUMN_DEFINITION + "\")");
- }
- });
- }
-
- public JavaColumnTests(String name) {
- super(name);
- }
-
- public void testGetSpecifiedNameNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedName());
- }
-
- public void testGetSpecifiedName() throws Exception {
- createTestEntityWithDefaultBasicColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(COLUMN_NAME, basicMapping.getColumn().getSpecifiedName());
- }
-
- public void testGetDefaultNameSpecifiedNameNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(basicMapping.getPersistentAttribute().getName(), basicMapping.getColumn().getDefaultName());
- assertEquals("id", basicMapping.getColumn().getDefaultName());
- }
-
- public void testGetDefaultName() throws Exception {
- createTestEntityWithDefaultBasicColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
- assertEquals("id", basicMapping.getColumn().getDefaultName());
-
- basicMapping.getColumn().setSpecifiedName("foo");
- assertEquals("id", basicMapping.getColumn().getDefaultName());
- }
-
- public void testGetNameSpecifiedNameNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals("id", basicMapping.getColumn().getName());
- }
-
- public void testGetName() throws Exception {
- createTestEntityWithDefaultBasicColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(COLUMN_NAME, basicMapping.getColumn().getName());
- }
-
- public void testSetSpecifiedName() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- basicMapping.getColumn().setSpecifiedName("foo");
-
- assertEquals("foo", basicMapping.getColumn().getSpecifiedName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals("foo", column.getName());
- }
-
- public void testSetSpecifiedNameNull() throws Exception {
- createTestEntityWithDefaultBasicColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- basicMapping.getColumn().setSpecifiedName(null);
-
- assertNull(basicMapping.getColumn().getSpecifiedName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getAnnotation(JPA.COLUMN));
- }
-
- public void testGetNameUpdatesFromResourceChange() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
-
- column.setName("foo");
- assertEquals("foo", basicMapping.getColumn().getSpecifiedName());
- assertEquals("foo", basicMapping.getColumn().getName());
-
- column.setName(null);
- assertNull(basicMapping.getColumn().getSpecifiedName());
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- public void testGetSpecifiedTableNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedTable());
- }
-
- public void testGetSpecifiedTable() throws Exception {
- createTestEntityWithBasicColumnTableSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(TABLE_NAME, basicMapping.getColumn().getSpecifiedTable());
- }
-
- public void testGetDefaultTableSpecifiedTableNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(((Entity) basicMapping.getTypeMapping()).getName(), basicMapping.getColumn().getDefaultTable());
- assertEquals(TYPE_NAME, basicMapping.getColumn().getDefaultTable());
- }
-
- public void testGetDefaultTable() throws Exception {
- createTestEntityWithDefaultBasicColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
- assertEquals(TYPE_NAME, basicMapping.getColumn().getDefaultTable());
-
- basicMapping.getColumn().setSpecifiedTable("foo");
- assertEquals(TYPE_NAME, basicMapping.getColumn().getDefaultTable());
- }
-
- public void testGetTable() throws Exception {
- createTestEntityWithBasicColumnTableSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(TABLE_NAME, basicMapping.getColumn().getTable());
- }
-
- public void testSetSpecifiedTable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- basicMapping.getColumn().setSpecifiedTable("foo");
-
- assertEquals("foo", basicMapping.getColumn().getSpecifiedTable());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals("foo", column.getTable());
- }
-
- public void testSetSpecifiedTableNull() throws Exception {
- createTestEntityWithBasicColumnTableSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- basicMapping.getColumn().setSpecifiedTable(null);
-
- assertNull(basicMapping.getColumn().getSpecifiedTable());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getAnnotation(JPA.COLUMN));
- }
-
- public void testGetTableUpdatesFromResourceChange() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedTable());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
-
- column.setTable("foo");
- assertEquals("foo", basicMapping.getColumn().getSpecifiedTable());
- assertEquals("foo", basicMapping.getColumn().getTable());
-
- column.setTable(null);
- assertNull(basicMapping.getColumn().getSpecifiedTable());
- }
-
- public void testGetColumnDefinition() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(COLUMN_DEFINITION, basicMapping.getColumn().getColumnDefinition());
- }
-
- public void testSetColumnDefinition() throws Exception {
- createTestEntityWithBasicColumnTableSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- basicMapping.getColumn().setColumnDefinition("foo");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals("foo", column.getColumnDefinition());
-
- basicMapping.getColumn().setColumnDefinition(null);
- assertNull(column.getColumnDefinition());
- }
-
- public void testGetColumnDefinitionUpdatesFromResourceChange() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getColumnDefinition());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
-
- column.setColumnDefinition("foo");
- assertEquals("foo", basicMapping.getColumn().getColumnDefinition());
-
- column.setColumnDefinition(null);
- assertNull(basicMapping.getColumn().getColumnDefinition());
-
- }
-
- public void testGetLength() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(Column.DEFAULT_LENGTH, basicMapping.getColumn().getLength());
- basicMapping.getColumn().setSpecifiedLength(Integer.valueOf(55));
- assertEquals(Integer.valueOf(55), basicMapping.getColumn().getLength());
- }
-
- public void testGetDefaultLength() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(Column.DEFAULT_LENGTH, basicMapping.getColumn().getDefaultLength());
- basicMapping.getColumn().setSpecifiedLength(Integer.valueOf(55));
-
- assertEquals(Column.DEFAULT_LENGTH, basicMapping.getColumn().getDefaultLength());
- }
-
- public void testGetSpecifiedLength() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedLength());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
- column.setLength(Integer.valueOf(66));
-
- assertEquals(Integer.valueOf(66), basicMapping.getColumn().getSpecifiedLength());
- assertEquals(Integer.valueOf(66), basicMapping.getColumn().getLength());
-
- column.setLength(null);
-
- assertNull(attributeResource.getAnnotation(JPA.COLUMN));
- assertNull(basicMapping.getColumn().getSpecifiedLength());
- }
-
- public void testSetSpecifiedLength() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedLength());
-
- basicMapping.getColumn().setSpecifiedLength(Integer.valueOf(100));
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Integer.valueOf(100), column.getLength());
-
- basicMapping.getColumn().setSpecifiedLength(null);
-
- assertNull(column.getLength());
- }
-
- public void testGetPrecision() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(Column.DEFAULT_PRECISION, basicMapping.getColumn().getPrecision());
- basicMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(55));
- assertEquals(Integer.valueOf(55), basicMapping.getColumn().getPrecision());
- }
-
- public void testGetDefaultPrecision() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(Column.DEFAULT_PRECISION, basicMapping.getColumn().getDefaultPrecision());
- basicMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(55));
-
- assertEquals(Column.DEFAULT_PRECISION, basicMapping.getColumn().getDefaultPrecision());
- }
-
- public void testGetSpecifiedPrecision() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedPrecision());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
- column.setPrecision(Integer.valueOf(66));
-
- assertEquals(Integer.valueOf(66), basicMapping.getColumn().getSpecifiedPrecision());
- assertEquals(Integer.valueOf(66), basicMapping.getColumn().getPrecision());
-
- column.setPrecision(null);
-
- assertNull(attributeResource.getAnnotation(JPA.COLUMN));
- assertNull(basicMapping.getColumn().getSpecifiedPrecision());
- }
-
- public void testSetSpecifiedPrecision() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedPrecision());
-
- basicMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(100));
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Integer.valueOf(100), column.getPrecision());
-
- basicMapping.getColumn().setSpecifiedPrecision(null);
-
- assertNull(column.getPrecision());
- }
-
- public void testGetScale() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(Column.DEFAULT_SCALE, basicMapping.getColumn().getScale());
- basicMapping.getColumn().setSpecifiedScale(Integer.valueOf(55));
- assertEquals(Integer.valueOf(55), basicMapping.getColumn().getScale());
- }
-
- public void testGetDefaultScale() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(Column.DEFAULT_SCALE, basicMapping.getColumn().getDefaultScale());
- basicMapping.getColumn().setSpecifiedScale(Integer.valueOf(55));
-
- assertEquals(Column.DEFAULT_SCALE, basicMapping.getColumn().getDefaultScale());
- }
-
- public void testGetSpecifiedScale() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedScale());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
- column.setScale(Integer.valueOf(66));
-
- assertEquals(Integer.valueOf(66), basicMapping.getColumn().getSpecifiedScale());
- assertEquals(Integer.valueOf(66), basicMapping.getColumn().getScale());
-
- column.setScale(null);
-
- assertNull(attributeResource.getAnnotation(JPA.COLUMN));
- assertNull(basicMapping.getColumn().getSpecifiedScale());
- }
-
- public void testSetSpecifiedScale() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedScale());
-
- basicMapping.getColumn().setSpecifiedScale(Integer.valueOf(100));
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Integer.valueOf(100), column.getScale());
-
- basicMapping.getColumn().setSpecifiedScale(null);
-
- assertNull(column.getScale());
- }
-
- public void testGetUnique() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(BaseColumn.DEFAULT_UNIQUE, basicMapping.getColumn().getUnique());
- basicMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- assertEquals(Boolean.TRUE, basicMapping.getColumn().getUnique());
- }
-
- public void testGetDefaultUnique() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(BaseColumn.DEFAULT_UNIQUE, basicMapping.getColumn().getDefaultUnique());
- basicMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
-
- assertEquals(BaseColumn.DEFAULT_UNIQUE, basicMapping.getColumn().getDefaultUnique());
- }
-
- public void testGetSpecifiedUnique() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedUnique());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
- column.setUnique(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, basicMapping.getColumn().getSpecifiedUnique());
- assertEquals(Boolean.TRUE, basicMapping.getColumn().getUnique());
-
- column.setUnique(null);
-
- assertNull(attributeResource.getAnnotation(JPA.COLUMN));
- assertNull(basicMapping.getColumn().getSpecifiedUnique());
- }
-
- public void testSetSpecifiedUnique() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedUnique());
-
- basicMapping.getColumn().setSpecifiedUnique(Boolean.FALSE);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Boolean.FALSE, column.getUnique());
-
- basicMapping.getColumn().setSpecifiedUnique(null);
-
- assertNull(column.getUnique());
- }
-
- public void testGetInsertable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(BaseColumn.DEFAULT_INSERTABLE, basicMapping.getColumn().getInsertable());
- basicMapping.getColumn().setSpecifiedInsertable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, basicMapping.getColumn().getInsertable());
- }
-
- public void testGetDefaultInsertable() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(BaseColumn.DEFAULT_INSERTABLE, basicMapping.getColumn().getDefaultInsertable());
- basicMapping.getColumn().setSpecifiedInsertable(Boolean.TRUE);
-
- assertEquals(BaseColumn.DEFAULT_INSERTABLE, basicMapping.getColumn().getDefaultInsertable());
- }
-
- public void testGetSpecifiedInsertable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedInsertable());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
- column.setInsertable(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, basicMapping.getColumn().getSpecifiedInsertable());
- assertEquals(Boolean.TRUE, basicMapping.getColumn().getInsertable());
-
- column.setInsertable(null);
-
- assertNull(attributeResource.getAnnotation(JPA.COLUMN));
- assertNull(basicMapping.getColumn().getSpecifiedInsertable());
- }
-
- public void testSetSpecifiedInsertable() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedInsertable());
-
- basicMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Boolean.FALSE, column.getInsertable());
-
- basicMapping.getColumn().setSpecifiedInsertable(null);
-
- assertNull(column.getInsertable());
- }
-
- public void testGetNullable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(BaseColumn.DEFAULT_NULLABLE, basicMapping.getColumn().getNullable());
- basicMapping.getColumn().setSpecifiedNullable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, basicMapping.getColumn().getNullable());
- }
-
- public void testGetDefaultNullable() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(BaseColumn.DEFAULT_NULLABLE, basicMapping.getColumn().getDefaultNullable());
- basicMapping.getColumn().setSpecifiedNullable(Boolean.TRUE);
-
- assertEquals(BaseColumn.DEFAULT_NULLABLE, basicMapping.getColumn().getDefaultNullable());
- }
-
- public void testGetSpecifiedNullable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedNullable());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
- column.setNullable(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, basicMapping.getColumn().getSpecifiedNullable());
- assertEquals(Boolean.TRUE, basicMapping.getColumn().getNullable());
-
- column.setNullable(null);
-
- assertNull(attributeResource.getAnnotation(JPA.COLUMN));
- assertNull(basicMapping.getColumn().getSpecifiedNullable());
- }
-
- public void testSetSpecifiedNullable() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedNullable());
-
- basicMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Boolean.FALSE, column.getNullable());
-
- basicMapping.getColumn().setSpecifiedNullable(null);
-
- assertNull(column.getNullable());
- }
-
- public void testGetUpdatable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(BaseColumn.DEFAULT_UPDATABLE, basicMapping.getColumn().getUpdatable());
- basicMapping.getColumn().setSpecifiedUpdatable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, basicMapping.getColumn().getUpdatable());
- }
-
- public void testGetDefaultUpdatable() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertEquals(BaseColumn.DEFAULT_UPDATABLE, basicMapping.getColumn().getDefaultUpdatable());
- basicMapping.getColumn().setSpecifiedUpdatable(Boolean.TRUE);
-
- assertEquals(BaseColumn.DEFAULT_UPDATABLE, basicMapping.getColumn().getDefaultUpdatable());
- }
-
- public void testGetSpecifiedUpdatable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedUpdatable());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
- column.setUpdatable(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, basicMapping.getColumn().getSpecifiedUpdatable());
- assertEquals(Boolean.TRUE, basicMapping.getColumn().getUpdatable());
-
- column.setUpdatable(null);
-
- assertNull(attributeResource.getAnnotation(JPA.COLUMN));
- assertNull(basicMapping.getColumn().getSpecifiedUpdatable());
- }
-
- public void testSetSpecifiedUpdatable() throws Exception {
- createTestEntityWithBasicColumnColumnDefinitionSet();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- BasicMapping basicMapping = (BasicMapping) javaPersistentType().attributes().next().getMapping();
-
- assertNull(basicMapping.getColumn().getSpecifiedUpdatable());
-
- basicMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Boolean.FALSE, column.getUpdatable());
-
- basicMapping.getColumn().setSpecifiedUpdatable(null);
-
- assertNull(column.getUpdatable());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaDiscriminatorColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaDiscriminatorColumnTests.java
deleted file mode 100644
index e40d4e120e..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaDiscriminatorColumnTests.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.DiscriminatorColumn;
-import org.eclipse.jpt.core.context.DiscriminatorType;
-import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaDiscriminatorColumnTests extends ContextModelTestCase
-{
- private static final String DISCRIMINATOR_COLUMN_NAME = "MY_DISCRIMINATOR_COLUMN";
- private static final String COLUMN_DEFINITION = "MY_COLUMN_DEFINITION";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
- private void createDiscriminatorColumnAnnotation() throws Exception{
- this.createAnnotationAndMembers("DiscriminatorColumn",
- "String name() default \"DTYPE\";" +
- "DiscriminatorType discriminatorType() default STRING;" +
- "String columnDefinition() default \"\";" +
- "int length() default 31;");
- }
-
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private IType createTestEntityWithDiscriminatorColumn() throws Exception {
- createEntityAnnotation();
- createDiscriminatorColumnAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.DISCRIMINATOR_COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@DiscriminatorColumn(name=\"" + DISCRIMINATOR_COLUMN_NAME + "\")");
- }
- });
- }
-
-
- public JavaDiscriminatorColumnTests(String name) {
- super(name);
- }
-
- public void testGetSpecifiedNameNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getDiscriminatorColumn().getSpecifiedName());
- }
-
- public void testGetSpecifiedName() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(DISCRIMINATOR_COLUMN_NAME, javaEntity().getDiscriminatorColumn().getSpecifiedName());
- }
-
- public void testGetDefaultNameSpecifiedNameNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals("DTYPE", javaEntity().getDiscriminatorColumn().getDefaultName());
- }
-
- public void testGetDefaultName() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals("DTYPE", javaEntity().getDiscriminatorColumn().getDefaultName());
-
- javaEntity().getDiscriminatorColumn().setSpecifiedName("foo");
- assertEquals("DTYPE", javaEntity().getDiscriminatorColumn().getDefaultName());
- }
-
- public void testGetNameSpecifiedNameNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals("DTYPE", javaEntity().getDiscriminatorColumn().getName());
- }
-
- public void testGetName() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(DISCRIMINATOR_COLUMN_NAME, javaEntity().getDiscriminatorColumn().getName());
- }
-
- public void testSetSpecifiedName() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().getDiscriminatorColumn().setSpecifiedName("foo");
-
- assertEquals("foo", javaEntity().getDiscriminatorColumn().getSpecifiedName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorColumnAnnotation discriminatorColumn = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- assertEquals("foo", discriminatorColumn.getName());
- }
-
- public void testSetSpecifiedNameNull() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().getDiscriminatorColumn().setSpecifiedName(null);
-
- assertNull(javaEntity().getDiscriminatorColumn().getSpecifiedName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorColumnAnnotation discriminatorColumn = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- assertNull(discriminatorColumn);
- }
-
- public void testGetDefaultDiscriminatorType() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(DiscriminatorType.STRING, javaEntity().getDiscriminatorColumn().getDefaultDiscriminatorType());
- }
-
- public void testGetDiscriminatorType() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(DiscriminatorType.STRING, javaEntity().getDiscriminatorColumn().getDiscriminatorType());
-
- javaEntity().getDiscriminatorColumn().setSpecifiedDiscriminatorType(DiscriminatorType.CHAR);
- assertEquals(DiscriminatorType.CHAR, javaEntity().getDiscriminatorColumn().getDiscriminatorType());
- }
-
- public void testGetSpecifiedDiscriminatorType() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getDiscriminatorColumn().getSpecifiedDiscriminatorType());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorColumnAnnotation discriminatorColumn = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
- discriminatorColumn.setDiscriminatorType(org.eclipse.jpt.core.resource.java.DiscriminatorType.CHAR);
-
- assertEquals(DiscriminatorType.CHAR, javaEntity().getDiscriminatorColumn().getSpecifiedDiscriminatorType());
- }
-
- public void testSetSpecifiedDiscriminatorType() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getDiscriminatorColumn().getSpecifiedDiscriminatorType());
-
- javaEntity().getDiscriminatorColumn().setSpecifiedDiscriminatorType(DiscriminatorType.CHAR);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorColumnAnnotation discriminatorColumn = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- assertEquals(org.eclipse.jpt.core.resource.java.DiscriminatorType.CHAR, discriminatorColumn.getDiscriminatorType());
-
- javaEntity().getDiscriminatorColumn().setSpecifiedName(null);
- javaEntity().getDiscriminatorColumn().setSpecifiedDiscriminatorType(null);
- assertNull(typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN));
- }
-
- public void testGetDiscriminatorTypeUpdatesFromResourceChange() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getDiscriminatorColumn().getSpecifiedDiscriminatorType());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.addAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- column.setDiscriminatorType(org.eclipse.jpt.core.resource.java.DiscriminatorType.INTEGER);
- assertEquals(DiscriminatorType.INTEGER, javaEntity().getDiscriminatorColumn().getSpecifiedDiscriminatorType());
- assertEquals(DiscriminatorType.INTEGER, javaEntity().getDiscriminatorColumn().getDiscriminatorType());
-
- column.setDiscriminatorType(null);
- assertNull(javaEntity().getDiscriminatorColumn().getSpecifiedDiscriminatorType());
- assertEquals(DiscriminatorColumn.DEFAULT_DISCRIMINATOR_TYPE, javaEntity().getDiscriminatorColumn().getDiscriminatorType());
- }
-
- public void testGetLength() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(DiscriminatorColumn.DEFAULT_LENGTH, javaEntity().getDiscriminatorColumn().getLength());
- javaEntity().getDiscriminatorColumn().setSpecifiedLength(Integer.valueOf(55));
- assertEquals(Integer.valueOf(55), javaEntity().getDiscriminatorColumn().getLength());
- }
-
- public void testGetDefaultLength() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(DiscriminatorColumn.DEFAULT_LENGTH, javaEntity().getDiscriminatorColumn().getDefaultLength());
- javaEntity().getDiscriminatorColumn().setSpecifiedLength(Integer.valueOf(55));
-
- assertEquals(DiscriminatorColumn.DEFAULT_LENGTH, javaEntity().getDiscriminatorColumn().getDefaultLength());
- }
-
- public void testGetSpecifiedLength() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getDiscriminatorColumn().getSpecifiedLength());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorColumnAnnotation discriminatorColumn = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
- discriminatorColumn.setLength(Integer.valueOf(66));
-
- assertEquals(Integer.valueOf(66), javaEntity().getDiscriminatorColumn().getSpecifiedLength());
- assertEquals(Integer.valueOf(66), javaEntity().getDiscriminatorColumn().getLength());
- discriminatorColumn.setName(null);
- discriminatorColumn.setLength(null);
-
- assertNull(typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN));
- assertNull(javaEntity().getDiscriminatorColumn().getSpecifiedLength());
- }
-
- public void testSetSpecifiedLength() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getDiscriminatorColumn().getSpecifiedLength());
-
- javaEntity().getDiscriminatorColumn().setSpecifiedLength(Integer.valueOf(100));
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorColumnAnnotation discriminatorColumn = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- assertEquals(Integer.valueOf(100), discriminatorColumn.getLength());
-
- javaEntity().getDiscriminatorColumn().setSpecifiedName(null);
- javaEntity().getDiscriminatorColumn().setSpecifiedLength(null);
- assertNull(typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN));
- }
-
- public void testGetLengthUpdatesFromResourceChange() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getDiscriminatorColumn().getSpecifiedLength());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.addAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- column.setLength(Integer.valueOf(78));
- assertEquals(Integer.valueOf(78), javaEntity().getDiscriminatorColumn().getSpecifiedLength());
- assertEquals(Integer.valueOf(78), javaEntity().getDiscriminatorColumn().getLength());
-
- column.setLength(null);
- assertNull(javaEntity().getDiscriminatorColumn().getSpecifiedLength());
- assertEquals(DiscriminatorColumn.DEFAULT_LENGTH, javaEntity().getDiscriminatorColumn().getLength());
- }
-
-
- public void testGetColumnDefinition() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getDiscriminatorColumn().getColumnDefinition());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
- column.setColumnDefinition(COLUMN_DEFINITION);
-
- assertEquals(COLUMN_DEFINITION, javaEntity().getDiscriminatorColumn().getColumnDefinition());
-
- column.setColumnDefinition(null);
-
- assertNull(javaEntity().getDiscriminatorColumn().getColumnDefinition());
-
- typeResource.removeAnnotation(JPA.DISCRIMINATOR_COLUMN);
- }
-
- public void testSetColumnDefinition() throws Exception {
- createTestEntityWithDiscriminatorColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().getDiscriminatorColumn().setColumnDefinition("foo");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- assertEquals("foo", column.getColumnDefinition());
-
- javaEntity().getDiscriminatorColumn().setColumnDefinition(null);
- column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
- assertNull(column.getColumnDefinition());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddableTests.java
deleted file mode 100644
index 2d0be36a34..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddableTests.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.MappedSuperclass;
-import org.eclipse.jpt.core.internal.context.java.JavaNullTypeMapping;
-import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaEmbeddableTests extends ContextModelTestCase
-{
-
- private void createEmbeddableAnnotation() throws Exception {
- this.createAnnotationAndMembers("Embeddable", "");
- }
-
- private IType createTestEmbeddable() throws Exception {
- createEmbeddableAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Embeddable");
- }
- });
- }
-
-
- public JavaEmbeddableTests(String name) {
- super(name);
- }
-
- public void testMorphToEntity() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaPersistentType().setMappingKey(MappingKeys.ENTITY_TYPE_MAPPING_KEY);
- assertTrue(javaPersistentType().getMapping() instanceof Entity);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- assertNull(typeResource.getMappingAnnotation(EmbeddableAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToMappedSuperclass() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaPersistentType().setMappingKey(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY);
- assertTrue(javaPersistentType().getMapping() instanceof MappedSuperclass);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- assertNull(typeResource.getMappingAnnotation(EmbeddableAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToNull() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaPersistentType().setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
- assertTrue(javaPersistentType().getMapping() instanceof JavaNullTypeMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- assertNull(typeResource.getMappingAnnotation(EmbeddableAnnotation.ANNOTATION_NAME));
- }
-
- public void testEmbeddable() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- assertTrue(javaPersistentType().getMapping() instanceof Embeddable);
- }
-
- public void testOverridableAttributeNames() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Embeddable embeddable = (Embeddable) javaPersistentType().getMapping();
- Iterator<String> overridableAttributeNames = embeddable.overridableAttributeNames();
- assertFalse(overridableAttributeNames.hasNext());
- }
-
- public void testOverridableAssociationNames() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Embeddable embeddable = (Embeddable) javaPersistentType().getMapping();
- Iterator<String> overridableAssociationNames = embeddable.overridableAssociationNames();
- assertFalse(overridableAssociationNames.hasNext());
- }
-
- public void testTableNameIsInvalid() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Embeddable embeddable = (Embeddable) javaPersistentType().getMapping();
-
- assertFalse(embeddable.tableNameIsInvalid(FULLY_QUALIFIED_TYPE_NAME));
- assertFalse(embeddable.tableNameIsInvalid("FOO"));
- }
-
- public void testAttributeMappingKeyAllowed() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Embeddable embeddable = (Embeddable) javaPersistentType().getMapping();
- assertTrue(embeddable.attributeMappingKeyAllowed(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY));
- assertTrue(embeddable.attributeMappingKeyAllowed(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY));
- assertFalse(embeddable.attributeMappingKeyAllowed(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY));
- assertFalse(embeddable.attributeMappingKeyAllowed(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY));
- assertFalse(embeddable.attributeMappingKeyAllowed(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY));
- assertFalse(embeddable.attributeMappingKeyAllowed(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY));
- assertFalse(embeddable.attributeMappingKeyAllowed(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- assertFalse(embeddable.attributeMappingKeyAllowed(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- assertFalse(embeddable.attributeMappingKeyAllowed(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY));
- assertFalse(embeddable.attributeMappingKeyAllowed(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY));
- }
-
-
- public void testAssociatedTables() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Embeddable embeddable = (Embeddable) javaPersistentType().getMapping();
-
- assertFalse(embeddable.associatedTables().hasNext());
- }
-
- public void testAssociatedTablesIncludingInherited() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Embeddable embeddable = (Embeddable) javaPersistentType().getMapping();
-
- assertFalse(embeddable.associatedTablesIncludingInherited().hasNext());
- }
-
- public void testAssociatedTableNamesIncludingInherited() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Embeddable embeddable = (Embeddable) javaPersistentType().getMapping();
-
- assertFalse(embeddable.associatedTableNamesIncludingInherited().hasNext());
- }
-
- public void testAllOverridableAttributeNames() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Embeddable embeddable = (Embeddable) javaPersistentType().getMapping();
- Iterator<String> overridableAttributeNames = embeddable.overridableAttributeNames();
- assertFalse(overridableAttributeNames.hasNext());
- }
-
- //TODO need to create a subclass mappedSuperclass and test this
- public void testAllOverridableAssociationNames() throws Exception {
- createTestEmbeddable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Embeddable embeddable = (Embeddable) javaPersistentType().getMapping();
- Iterator<String> overridableAssociationNames = embeddable.overridableAssociationNames();
- assertFalse(overridableAssociationNames.hasNext());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java
deleted file mode 100644
index eb16d4896f..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java
+++ /dev/null
@@ -1,605 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.internal.context.java.GenericJavaNullAttributeMapping;
-import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.AttributeOverridesAnnotation;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaEmbeddedIdMappingTests extends ContextModelTestCase
-{
-
- public static final String EMBEDDABLE_TYPE_NAME = "MyEmbeddable";
- public static final String FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME = PACKAGE_NAME + "." + EMBEDDABLE_TYPE_NAME;
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createEmbeddableAnnotation() throws Exception{
- this.createAnnotationAndMembers("Embeddable", "");
- }
-
- private void createEmbeddedIdAnnotation() throws Exception{
- this.createAnnotationAndMembers("EmbeddedId", "");
- }
-
- private IType createTestEntityWithEmbeddedIdMapping() throws Exception {
- createEntityAnnotation();
- createEmbeddedIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.EMBEDDED_ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@EmbeddedId").append(CR);
- sb.append(CR);
- sb.append(" private " + EMBEDDABLE_TYPE_NAME +" myEmbeddedId;").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private IType createEmbeddableType() throws Exception {
- createEmbeddableAnnotation();
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.EMBEDDABLE);
- sb.append(";");
- sb.append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append(EMBEDDABLE_TYPE_NAME).append(" {");
- sb.append(CR);
- sb.append(" private String city;").append(CR);
- sb.append(CR);
- sb.append(" private String state;").append(CR);
- sb.append(CR);
- sb.append(" ");
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, EMBEDDABLE_TYPE_NAME + ".java", sourceWriter);
- }
-
-
- public JavaEmbeddedIdMappingTests(String name) {
- super(name);
- }
-
- public void testMorphToBasicMapping() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedIdMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToDefault() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedIdMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertTrue(((EmbeddedMapping) persistentAttribute.getMapping()).attributeOverrides().hasNext());
- assertTrue(persistentAttribute.getMapping().isDefault());
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testDefaultEmbeddedIdMapping() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
- assertFalse(embeddedIdMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof GenericJavaNullAttributeMapping);
- assertTrue(persistentAttribute.getMapping().isDefault());
-
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertTrue(persistentAttribute.getMapping().isDefault());
- }
-
- public void testMorphToVersionMapping() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedIdMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToTransientMapping() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedIdMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToIdMapping() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedIdMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedMapping() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedIdMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToOneMapping() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedIdMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToManyMapping() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedIdMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToOneMapping() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedIdMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToManyMapping() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedIdMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testSpecifiedAttributeOverrides() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) javaPersistentType().getAttributeNamed("myEmbeddedId").getMapping();
-
- ListIterator<JavaAttributeOverride> specifiedAttributeOverrides = embeddedIdMapping.specifiedAttributeOverrides();
-
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- specifiedAttributeOverrides = embeddedIdMapping.specifiedAttributeOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- specifiedAttributeOverrides = embeddedIdMapping.specifiedAttributeOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAZ");
- specifiedAttributeOverrides = embeddedIdMapping.specifiedAttributeOverrides();
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- attributeResource.move(1, 0, JPA.ATTRIBUTE_OVERRIDES);
- specifiedAttributeOverrides = embeddedIdMapping.specifiedAttributeOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- specifiedAttributeOverrides = embeddedIdMapping.specifiedAttributeOverrides();
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- specifiedAttributeOverrides = embeddedIdMapping.specifiedAttributeOverrides();
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- specifiedAttributeOverrides = embeddedIdMapping.specifiedAttributeOverrides();
- assertFalse(specifiedAttributeOverrides.hasNext());
- }
-
- public void testDefaultAttributeOverrides() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) javaPersistentType().getAttributeNamed("myEmbeddedId").getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertEquals("myEmbeddedId", attributeResource.getName());
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(2, embeddedIdMapping.virtualAttributeOverridesSize());
- AttributeOverride defaultAttributeOverride = embeddedIdMapping.virtualAttributeOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("city", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME, defaultAttributeOverride.getColumn().getTable());
-
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- Embeddable embeddable = (Embeddable) classRefs.next().getJavaPersistentType().getMapping();
-
- BasicMapping cityMapping = (BasicMapping) embeddable.getPersistentType().getAttributeNamed("city").getMapping();
- cityMapping.getColumn().setSpecifiedName("FOO");
- cityMapping.getColumn().setSpecifiedTable("BAR");
-
- assertEquals(2, embeddedIdMapping.virtualAttributeOverridesSize());
- defaultAttributeOverride = embeddedIdMapping.virtualAttributeOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("FOO", defaultAttributeOverride.getColumn().getName());
- assertEquals("BAR", defaultAttributeOverride.getColumn().getTable());
-
- cityMapping.getColumn().setSpecifiedName(null);
- cityMapping.getColumn().setSpecifiedTable(null);
- defaultAttributeOverride = embeddedIdMapping.virtualAttributeOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("city", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME, defaultAttributeOverride.getColumn().getTable());
-
- AttributeOverrideAnnotation annotation = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- annotation.setName("city");
- assertEquals(1, embeddedIdMapping.virtualAttributeOverridesSize());
- }
-
- public void testSpecifiedAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) javaPersistentType().getAttributeNamed("myEmbeddedId").getMapping();
- assertEquals(0, embeddedIdMapping.specifiedAttributeOverridesSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
-
- assertEquals(2, embeddedIdMapping.specifiedAttributeOverridesSize());
- }
-
- public void testAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) javaPersistentType().getAttributeNamed("myEmbeddedId").getMapping();
- assertEquals(2, embeddedIdMapping.attributeOverridesSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
-
- assertEquals(4, embeddedIdMapping.attributeOverridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("city");
- assertEquals(4, embeddedIdMapping.attributeOverridesSize());
- }
-
- public void testVirtualAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) javaPersistentType().getAttributeNamed("myEmbeddedId").getMapping();
- assertEquals(2, embeddedIdMapping.virtualAttributeOverridesSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
-
- assertEquals(2, embeddedIdMapping.virtualAttributeOverridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("city");
- assertEquals(1, embeddedIdMapping.virtualAttributeOverridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("state");
- assertEquals(0, embeddedIdMapping.virtualAttributeOverridesSize());
- }
-
- public void testAttributeOverrideSetVirtual() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) javaPersistentType().getAttributeNamed("myEmbeddedId").getMapping();
- embeddedIdMapping.virtualAttributeOverrides().next().setVirtual(false);
- embeddedIdMapping.virtualAttributeOverrides().next().setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- Iterator<JavaResourceNode> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("state", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- embeddedIdMapping.specifiedAttributeOverrides().next().setVirtual(true);
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("state", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- assertEquals("city", embeddedIdMapping.virtualAttributeOverrides().next().getName());
- assertEquals(1, embeddedIdMapping.virtualAttributeOverridesSize());
-
- embeddedIdMapping.specifiedAttributeOverrides().next().setVirtual(true);
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertFalse(attributeOverrides.hasNext());
-
- Iterator<AttributeOverride> virtualAttributeOverrides = embeddedIdMapping.virtualAttributeOverrides();
- assertEquals("city", virtualAttributeOverrides.next().getName());
- assertEquals("state", virtualAttributeOverrides.next().getName());
- assertEquals(2, embeddedIdMapping.virtualAttributeOverridesSize());
- }
-
- public void testAttributeOverrideSetVirtual2() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) javaPersistentType().getAttributeNamed("myEmbeddedId").getMapping();
- ListIterator<AttributeOverride> virtualAttributeOverrides = embeddedIdMapping.virtualAttributeOverrides();
- virtualAttributeOverrides.next();
- virtualAttributeOverrides.next().setVirtual(false);
- embeddedIdMapping.virtualAttributeOverrides().next().setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- Iterator<JavaResourceNode> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("state", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
- }
-
-
- public void testMoveSpecifiedAttributeOverride() throws Exception {
- createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) javaPersistentType().getAttributeNamed("myEmbeddedId").getMapping();
- embeddedIdMapping.virtualAttributeOverrides().next().setVirtual(false);
- embeddedIdMapping.virtualAttributeOverrides().next().setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- attributeResource.move(1, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- Iterator<JavaResourceNode> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("state", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java
deleted file mode 100644
index b68b5623db..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java
+++ /dev/null
@@ -1,607 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.internal.context.java.GenericJavaNullAttributeMapping;
-import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.AttributeOverridesAnnotation;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaEmbeddedMappingTests extends ContextModelTestCase
-{
-
- public static final String EMBEDDABLE_TYPE_NAME = "MyEmbeddable";
- public static final String FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME = PACKAGE_NAME + "." + EMBEDDABLE_TYPE_NAME;
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createEmbeddableAnnotation() throws Exception{
- this.createAnnotationAndMembers("Embeddable", "");
- }
-
- private void createEmbeddedAnnotation() throws Exception{
- this.createAnnotationAndMembers("Embedded", "");
- }
-
- private IType createTestEntityWithEmbeddedMapping() throws Exception {
- createEntityAnnotation();
- createEmbeddedAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.EMBEDDED);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Embedded").append(CR);
- sb.append(" private " + EMBEDDABLE_TYPE_NAME + " myEmbedded;").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private IType createEmbeddableType() throws Exception {
- createEmbeddableAnnotation();
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.EMBEDDABLE);
- sb.append(";");
- sb.append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append(EMBEDDABLE_TYPE_NAME).append(" {");
- sb.append(CR);
- sb.append(" private String city;").append(CR);
- sb.append(CR);
- sb.append(" private String state;").append(CR);
- sb.append(CR);
- sb.append(" ");
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, EMBEDDABLE_TYPE_NAME + ".java", sourceWriter);
- }
-
-
- public JavaEmbeddedMappingTests(String name) {
- super(name);
- }
-
- public void testMorphToBasicMapping() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) persistentAttribute.getMapping();
- assertFalse(embeddedMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToDefault() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertTrue(((EmbeddedMapping) persistentAttribute.getMapping()).attributeOverrides().hasNext());
- assertTrue(persistentAttribute.getMapping().isDefault());
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testDefaultEmbeddedMapping() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) persistentAttribute.getMapping();
- assertFalse(embeddedMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof GenericJavaNullAttributeMapping);
- assertTrue(persistentAttribute.getMapping().isDefault());
-
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertTrue(persistentAttribute.getMapping().isDefault());
- }
-
- public void testMorphToVersionMapping() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToTransientMapping() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToIdMapping() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToOneMapping() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToManyMapping() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToOneMapping() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToManyMapping() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) persistentAttribute.getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertFalse(embeddedMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
-
- assertNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- }
-
- public void testSpecifiedAttributeOverrides() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) javaPersistentType().getAttributeNamed("myEmbedded").getMapping();
-
- ListIterator<JavaAttributeOverride> specifiedAttributeOverrides = embeddedMapping.specifiedAttributeOverrides();
-
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- specifiedAttributeOverrides = embeddedMapping.specifiedAttributeOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- specifiedAttributeOverrides = embeddedMapping.specifiedAttributeOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAZ");
- specifiedAttributeOverrides = embeddedMapping.specifiedAttributeOverrides();
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- attributeResource.move(1, 0, JPA.ATTRIBUTE_OVERRIDES);
- specifiedAttributeOverrides = embeddedMapping.specifiedAttributeOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- specifiedAttributeOverrides = embeddedMapping.specifiedAttributeOverrides();
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- specifiedAttributeOverrides = embeddedMapping.specifiedAttributeOverrides();
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- specifiedAttributeOverrides = embeddedMapping.specifiedAttributeOverrides();
- assertFalse(specifiedAttributeOverrides.hasNext());
- }
-
- public void testVirtualAttributeOverrides() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) javaPersistentType().getAttributeNamed("myEmbedded").getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertEquals("myEmbedded", attributeResource.getName());
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(2, embeddedMapping.virtualAttributeOverridesSize());
- AttributeOverride defaultAttributeOverride = embeddedMapping.virtualAttributeOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("city", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME, defaultAttributeOverride.getColumn().getTable());
-
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- Embeddable embeddable = (Embeddable) classRefs.next().getJavaPersistentType().getMapping();
-
- BasicMapping cityMapping = (BasicMapping) embeddable.getPersistentType().getAttributeNamed("city").getMapping();
- cityMapping.getColumn().setSpecifiedName("FOO");
- cityMapping.getColumn().setSpecifiedTable("BAR");
-
- assertEquals("myEmbedded", attributeResource.getName());
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(2, embeddedMapping.virtualAttributeOverridesSize());
- defaultAttributeOverride = embeddedMapping.virtualAttributeOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("FOO", defaultAttributeOverride.getColumn().getName());
- assertEquals("BAR", defaultAttributeOverride.getColumn().getTable());
-
- cityMapping.getColumn().setSpecifiedName(null);
- cityMapping.getColumn().setSpecifiedTable(null);
- defaultAttributeOverride = embeddedMapping.virtualAttributeOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("city", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME, defaultAttributeOverride.getColumn().getTable());
-
- AttributeOverrideAnnotation annotation = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- annotation.setName("city");
- assertEquals(1, embeddedMapping.virtualAttributeOverridesSize());
- }
-
- public void testSpecifiedAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) javaPersistentType().getAttributeNamed("myEmbedded").getMapping();
- assertEquals(0, embeddedMapping.specifiedAttributeOverridesSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
-
- assertEquals(2, embeddedMapping.specifiedAttributeOverridesSize());
- }
-
- public void testAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) javaPersistentType().getAttributeNamed("myEmbedded").getMapping();
- assertEquals(2, embeddedMapping.attributeOverridesSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
-
- assertEquals(4, embeddedMapping.attributeOverridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("city");
- assertEquals(4, embeddedMapping.attributeOverridesSize());
- }
-
- public void testVirtualAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) javaPersistentType().getAttributeNamed("myEmbedded").getMapping();
- assertEquals(2, embeddedMapping.virtualAttributeOverridesSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
-
- assertEquals(2, embeddedMapping.virtualAttributeOverridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("city");
- assertEquals(1, embeddedMapping.virtualAttributeOverridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("state");
- assertEquals(0, embeddedMapping.virtualAttributeOverridesSize());
- }
-
- public void testAttributeOverrideSetVirtual() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) javaPersistentType().getAttributeNamed("myEmbedded").getMapping();
- embeddedMapping.virtualAttributeOverrides().next().setVirtual(false);
- embeddedMapping.virtualAttributeOverrides().next().setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- Iterator<JavaResourceNode> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("state", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- embeddedMapping.specifiedAttributeOverrides().next().setVirtual(true);
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("state", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- assertEquals("city", embeddedMapping.virtualAttributeOverrides().next().getName());
- assertEquals(1, embeddedMapping.virtualAttributeOverridesSize());
-
- embeddedMapping.specifiedAttributeOverrides().next().setVirtual(true);
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertFalse(attributeOverrides.hasNext());
-
- Iterator<AttributeOverride> virtualAttributeOverrides = embeddedMapping.virtualAttributeOverrides();
- assertEquals("city", virtualAttributeOverrides.next().getName());
- assertEquals("state", virtualAttributeOverrides.next().getName());
- assertEquals(2, embeddedMapping.virtualAttributeOverridesSize());
- }
-
- public void testAttributeOverrideSetVirtual2() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) javaPersistentType().getAttributeNamed("myEmbedded").getMapping();
- ListIterator<AttributeOverride> virtualAttributeOverrides = embeddedMapping.virtualAttributeOverrides();
- virtualAttributeOverrides.next();
- virtualAttributeOverrides.next().setVirtual(false);
- embeddedMapping.virtualAttributeOverrides().next().setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- Iterator<JavaResourceNode> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("state", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
- }
-
- public void testMoveSpecifiedAttributeOverride() throws Exception {
- createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) javaPersistentType().getAttributeNamed("myEmbedded").getMapping();
- embeddedMapping.virtualAttributeOverrides().next().setVirtual(false);
- embeddedMapping.virtualAttributeOverrides().next().setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- attributeResource.move(1, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- Iterator<JavaResourceNode> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("state", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java
deleted file mode 100644
index 7b57b25965..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java
+++ /dev/null
@@ -1,2902 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.AssociationOverride;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.DiscriminatorType;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.InheritanceType;
-import org.eclipse.jpt.core.context.MappedSuperclass;
-import org.eclipse.jpt.core.context.NamedNativeQuery;
-import org.eclipse.jpt.core.context.NamedQuery;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.SecondaryTable;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.java.JavaAssociationOverride;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaSecondaryTable;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.internal.context.java.JavaNullTypeMapping;
-import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.AssociationOverridesAnnotation;
-import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.AttributeOverridesAnnotation;
-import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation;
-import org.eclipse.jpt.core.resource.java.EntityAnnotation;
-import org.eclipse.jpt.core.resource.java.IdClassAnnotation;
-import org.eclipse.jpt.core.resource.java.InheritanceAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.NamedNativeQueriesAnnotation;
-import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation;
-import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation;
-import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumns;
-import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation;
-import org.eclipse.jpt.core.resource.java.SecondaryTablesAnnotation;
-import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation;
-import org.eclipse.jpt.core.resource.java.TableAnnotation;
-import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaEntityTests extends ContextModelTestCase
-{
- private static final String ENTITY_NAME = "entityName";
- private static final String TABLE_NAME = "MY_TABLE";
- private static final String DISCRIMINATOR_VALUE = "MY_DISCRIMINATOR_VALUE";
- protected static final String SUB_TYPE_NAME = "AnnotationTestTypeChild";
- protected static final String FULLY_QUALIFIED_SUB_TYPE_NAME = PACKAGE_NAME + "." + SUB_TYPE_NAME;
-
-
- public JavaEntityTests(String name) {
- super(name);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- }
-
- private void createMappedSuperclassAnnotation() throws Exception{
- this.createAnnotationAndMembers("MappedSuperclass", "");
- }
-
- private void createTableAnnotation() throws Exception {
- this.createAnnotationAndMembers("Table", "String name() default \"\";");
- }
-
- private void createInheritanceAnnotation() throws Exception {
- createInheritanceTypeEnum();
- this.createAnnotationAndMembers("Inheritance", "InheritanceType strategy() default SINGLE_TABLE;");
- }
-
- private void createInheritanceTypeEnum() throws Exception {
- this.createEnumAndMembers("InheritanceType", "SINGLE_TABLE, JOINED, TABLE_PER_CLASS");
- }
-
- private void createDiscriminatorValueAnnotation() throws Exception {
- this.createAnnotationAndMembers("DiscriminatorValue", "String value();");
- }
-
- private void createSecondaryTableAnnotation() throws Exception {
- this.createAnnotationAndMembers("SecondaryTable",
- "String name(); " +
- "String catalog() default \"\"; " +
- "String schema() default \"\"; ");
-// PrimaryKeyJoinColumn[] pkJoinColumns() default {};
-// UniqueConstraint[] uniqueConstraints() default {};
- }
-
- private void createSecondaryTablesAnnotation() throws Exception {
- createSecondaryTableAnnotation();
- this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value();");
- }
-
- private void createPrimaryKeyJoinColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("PrimaryKeyJoinColumn",
- "String name(); " +
- "String referencedColumnName() default \"\"; " +
- "String columnDefinition() default \"\"; ");
- }
-
- private void createPrimaryKeyJoinColumnsAnnotation() throws Exception {
- createPrimaryKeyJoinColumnAnnotation();
- this.createAnnotationAndMembers("PrimaryKeyJoinColumns", "PrimaryKeyJoinColumn[] value();");
- }
-
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private IType createTestEntityAnnotationOnProperty() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestMappedSuperclass() throws Exception {
- createMappedSuperclassAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, JPA.ONE_TO_ONE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("private String foo;").append(CR);
- sb.append(CR);
- sb.append(" @OneToOne");
- sb.append(CR);
- sb.append(" private int address;").append(CR);
- sb.append(CR);
- sb.append(" @OneToOne");
- sb.append(CR);
- sb.append(" private int address2;").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- private IType createTestEntityWithName() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity(name=\"" + ENTITY_NAME + "\")");
- }
- });
- }
-
- private IType createTestEntityWithTable() throws Exception {
- createEntityAnnotation();
- createTableAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@Table(name=\"" + TABLE_NAME + "\")");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- private IType createTestEntityWithInheritance() throws Exception {
- createEntityAnnotation();
- createInheritanceAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.INHERITANCE, JPA.INHERITANCE_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithDiscriminatorValue() throws Exception {
- createEntityAnnotation();
- createDiscriminatorValueAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.DISCRIMINATOR_VALUE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@DiscriminatorValue(value=\"" + DISCRIMINATOR_VALUE + "\")");
- }
- });
- }
-
- private IType createTestEntityWithSecondaryTable() throws Exception {
- createEntityAnnotation();
- createSecondaryTableAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.SECONDARY_TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@SecondaryTable(name=\"foo\")");
- }
- });
- }
-
- private IType createTestEntityWithSecondaryTables() throws Exception {
- createEntityAnnotation();
- createSecondaryTablesAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@SecondaryTables({@SecondaryTable(name=\"foo\"), @SecondaryTable(name=\"bar\")})");
- }
- });
- }
-
- public void testMorphToMappedSuperclass() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = (Entity) javaPersistentType().getMapping();
- entity.getTable().setSpecifiedName("FOO");
- entity.addSpecifiedSecondaryTable(0);
- entity.addSpecifiedPrimaryKeyJoinColumn(0);
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- entity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- entity.setSpecifiedDiscriminatorValue("asdf");
- entity.getDiscriminatorColumn().setSpecifiedName("BAR");
- entity.addTableGenerator();
- entity.addSequenceGenerator();
- entity.setIdClass("myIdClass");
- entity.addNamedNativeQuery(0);
- entity.addNamedQuery(0);
-
- javaPersistentType().setMappingKey(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY);
- assertTrue(javaPersistentType().getMapping() instanceof MappedSuperclass);
-
- assertNull(typeResource.getMappingAnnotation(EntityAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(TableAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(SecondaryTableAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AssociationOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(InheritanceAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(DiscriminatorColumnAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNotNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = (Entity) javaPersistentType().getMapping();
- entity.getTable().setSpecifiedName("FOO");
- entity.addSpecifiedSecondaryTable(0);
- entity.addSpecifiedPrimaryKeyJoinColumn(0);
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- entity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- entity.setSpecifiedDiscriminatorValue("asdf");
- entity.getDiscriminatorColumn().setSpecifiedName("BAR");
- entity.addTableGenerator();
- entity.addSequenceGenerator();
- entity.setIdClass("myIdClass");
- entity.addNamedNativeQuery(0);
- entity.addNamedQuery(0);
-
- javaPersistentType().setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
- assertTrue(javaPersistentType().getMapping() instanceof Embeddable);
-
- assertNull(typeResource.getMappingAnnotation(EntityAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(TableAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(SecondaryTableAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AssociationOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(InheritanceAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(DiscriminatorColumnAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = (Entity) javaPersistentType().getMapping();
- entity.getTable().setSpecifiedName("FOO");
- entity.addSpecifiedSecondaryTable(0);
- entity.addSpecifiedPrimaryKeyJoinColumn(0);
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- entity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- entity.setSpecifiedDiscriminatorValue("asdf");
- entity.getDiscriminatorColumn().setSpecifiedName("BAR");
- entity.addTableGenerator();
- entity.addSequenceGenerator();
- entity.setIdClass("myIdClass");
- entity.addNamedNativeQuery(0);
- entity.addNamedQuery(0);
-
- javaPersistentType().setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
- assertTrue(javaPersistentType().getMapping() instanceof JavaNullTypeMapping);
-
- assertNull(typeResource.getMappingAnnotation(EntityAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(TableAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(SecondaryTableAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AssociationOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(InheritanceAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(DiscriminatorColumnAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME));
- }
-
- public void testAccessNoAnnotations() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- assertEquals(AccessType.FIELD, javaPersistentType().getAccess());
- }
-
- public void testAccessAnnotationsOnParent() throws Exception {
- createTestEntityAnnotationOnProperty();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
-
- JavaPersistentType childPersistentType = javaPersistentType();
- PersistentType parentPersistentType = childPersistentType.getParentPersistentType();
-
- assertEquals(AccessType.PROPERTY, parentPersistentType.getAccess());
- assertEquals(AccessType.PROPERTY, childPersistentType.getAccess());
-
- ((IdMapping) parentPersistentType.getAttributeNamed("id").getMapping()).getColumn().setSpecifiedName("FOO");
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.properties().next().setMappingAnnotation(null);
- //no mapping(Id) annotation, but still a Column annotation, so access should still be property
- assertEquals(AccessType.PROPERTY, parentPersistentType.getAccess());
- assertEquals(AccessType.PROPERTY, childPersistentType.getAccess());
-
- ((BasicMapping) parentPersistentType.getAttributeNamed("id").getMapping()).getColumn().setSpecifiedName(null);
- assertEquals(AccessType.FIELD, parentPersistentType.getAccess());
- assertEquals(AccessType.FIELD, childPersistentType.getAccess());
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, parentPersistentType.getAccess());
- assertEquals(AccessType.PROPERTY, childPersistentType.getAccess());
-
- entityMappings().setSpecifiedAccess(AccessType.FIELD);
- //still accessType of PROPERTY because the java class is not specified in this orm.xml
- assertEquals(AccessType.PROPERTY, parentPersistentType.getAccess());
- assertEquals(AccessType.PROPERTY, childPersistentType.getAccess());
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- removeXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- //only parent specified in orm.xml, i think this outcome is right??
- assertEquals(AccessType.FIELD, ormPersistentType.getJavaPersistentType().getAccess());
- assertEquals(AccessType.FIELD, childPersistentType.getAccess());
-
- OrmPersistentType childOrmPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
- removeXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- //both parent and child specified in orm.xml
- assertEquals(AccessType.FIELD, ormPersistentType.getJavaPersistentType().getAccess());
- assertEquals(AccessType.FIELD, childOrmPersistentType.getJavaPersistentType().getAccess());
- }
-
- public void testAccessWithXmlSettings() throws Exception {
- createTestEntityAnnotationOnProperty();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
-
- assertEquals(AccessType.PROPERTY, javaPersistentType().getAccess());
-
- ((IdMapping) javaPersistentType().getAttributeNamed("id").getMapping()).getColumn().setSpecifiedName("FOO");
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.properties().next().setMappingAnnotation(null);
- //no mapping(Id) annotation, but still a Column annotation, so access should still be property
- assertEquals(AccessType.PROPERTY, javaPersistentType().getAccess());
-
- ((BasicMapping) javaPersistentType().getAttributeNamed("id").getMapping()).getColumn().setSpecifiedName(null);
- assertEquals(AccessType.FIELD, javaPersistentType().getAccess());
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, javaPersistentType().getAccess());
-
- entityMappings().setSpecifiedAccess(AccessType.FIELD);
- //still accessType of PROPERTY because the java class is not specified in this orm.xml
- assertEquals(AccessType.PROPERTY, javaPersistentType().getAccess());
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- //now class is specified in orm.xml, so entityMappings access setting wins over persistence-unit-defaults
- assertEquals(AccessType.FIELD, ormPersistentType.getJavaPersistentType().getAccess());
-
- ((OrmEntity) ormPersistentType.getMapping()).setSpecifiedAccess(AccessType.PROPERTY);
-
- //accessType should be PROPERTY now, java gets the access from xml entity if it is specified
- assertEquals(AccessType.PROPERTY, ormPersistentType.getJavaPersistentType().getAccess());
- }
-
- public void testGetSpecifiedNameNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getSpecifiedName());
- }
-
- public void testGetSpecifiedName() throws Exception {
- createTestEntityWithName();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(ENTITY_NAME, javaEntity().getSpecifiedName());
- }
-
- public void testGetDefaultNameSpecifiedNameNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(TYPE_NAME, javaEntity().getDefaultName());
- }
-
- public void testGetDefaultName() throws Exception {
- createTestEntityWithName();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(TYPE_NAME, javaEntity().getDefaultName());
- }
-
- public void testGetNameSpecifiedNameNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(TYPE_NAME, javaEntity().getName());
- }
-
- public void testGetName() throws Exception {
- createTestEntityWithName();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(ENTITY_NAME, javaEntity().getName());
- }
-
- public void testSetSpecifiedName() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().setSpecifiedName("foo");
-
- assertEquals("foo", javaEntity().getSpecifiedName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals("foo", ((EntityAnnotation) typeResource.getMappingAnnotation()).getName());
- }
-
- public void testSetSpecifiedNameNull() throws Exception {
- createTestEntityWithName();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().setSpecifiedName(null);
-
- assertNull(javaEntity().getSpecifiedName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(((EntityAnnotation) typeResource.getMappingAnnotation()).getName());
- }
-
- public void testUpdateFromSpecifiedNameChangeInResourceModel() throws Exception {
- createTestEntityWithName();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- EntityAnnotation entity = (EntityAnnotation) typeResource.getMappingAnnotation();
- entity.setName("foo");
-
- assertEquals("foo", javaEntity().getSpecifiedName());
- }
-
- public void testGetTableName() throws Exception {
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- createTestEntityWithName();
-
- assertEquals(ENTITY_NAME, javaEntity().getTableName());
- }
-
- public void testGetTableName2() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(TYPE_NAME, javaEntity().getTableName());
- }
-
- public void testGetTableName3() throws Exception {
- createTestEntityWithTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(TABLE_NAME, javaEntity().getTableName());
- }
-
- public void testSetTableNameWithNullTable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Table table = javaEntity().getTable();
- assertEquals(TYPE_NAME, table.getName());
- assertSourceDoesNotContain("@Table");
-
- table.setSpecifiedName(TABLE_NAME);
- assertSourceContains("@Table(name=\"" + TABLE_NAME + "\")");
-
- assertEquals(TABLE_NAME, javaEntity().getTableName());
- assertEquals(TABLE_NAME, table.getName());
-
- table.setSpecifiedCatalog(TABLE_NAME);
- }
-
- public void testGetInheritanceStrategy() throws Exception {
- createTestEntityWithInheritance();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(InheritanceType.TABLE_PER_CLASS, javaEntity().getInheritanceStrategy());
- }
-
- public void testGetDefaultInheritanceStrategy() throws Exception {
- createTestEntity();
- createTestSubType();
-
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNotSame(javaEntity(), javaEntity().getRootEntity());
- assertEquals(InheritanceType.SINGLE_TABLE, javaEntity().getDefaultInheritanceStrategy());
-
- //change root inheritance strategy, verify default is changed for child entity
- javaEntity().getRootEntity().setSpecifiedInheritanceStrategy(InheritanceType.TABLE_PER_CLASS);
-
- assertEquals(InheritanceType.SINGLE_TABLE, javaEntity().getRootEntity().getDefaultInheritanceStrategy());
- assertEquals(InheritanceType.TABLE_PER_CLASS, javaEntity().getDefaultInheritanceStrategy());
- assertEquals(InheritanceType.TABLE_PER_CLASS, javaEntity().getInheritanceStrategy());
- assertNull(javaEntity().getSpecifiedInheritanceStrategy());
- }
-
- public void testGetSpecifiedInheritanceStrategy() throws Exception {
- createTestEntityWithInheritance();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(InheritanceType.TABLE_PER_CLASS, javaEntity().getSpecifiedInheritanceStrategy());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- InheritanceAnnotation inheritance = (InheritanceAnnotation) typeResource.getAnnotation(InheritanceAnnotation.ANNOTATION_NAME);
-
- inheritance.setStrategy(org.eclipse.jpt.core.resource.java.InheritanceType.JOINED);
-
- assertEquals(InheritanceType.JOINED, javaEntity().getSpecifiedInheritanceStrategy());
-
- inheritance.setStrategy(null);
-
- assertNull(javaEntity().getSpecifiedInheritanceStrategy());
- }
-
- public void testSetSpecifiedInheritanceStrategy() throws Exception {
- createTestEntityWithInheritance();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- assertEquals(InheritanceType.TABLE_PER_CLASS, javaEntity().getSpecifiedInheritanceStrategy());
-
- javaEntity().setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
-
- assertEquals(InheritanceType.JOINED, javaEntity().getSpecifiedInheritanceStrategy());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- InheritanceAnnotation inheritance = (InheritanceAnnotation) typeResource.getAnnotation(InheritanceAnnotation.ANNOTATION_NAME);
- assertEquals(org.eclipse.jpt.core.resource.java.InheritanceType.JOINED, inheritance.getStrategy());
-
- }
-
- public void testGetDiscriminatorValue() throws Exception {
- createTestEntityWithDiscriminatorValue();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(DISCRIMINATOR_VALUE, javaEntity().getDiscriminatorValue());
- }
-
- public void testGetDefaultDiscriminatorValue() throws Exception {
- createTestEntityWithDiscriminatorValue();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(javaEntity().getName(), javaEntity().getDefaultDiscriminatorValue());
-
- javaEntity().getDiscriminatorColumn().setSpecifiedDiscriminatorType(DiscriminatorType.INTEGER);
- assertNull(javaEntity().getDefaultDiscriminatorValue());
- }
-
- public void testGetSpecifiedDiscriminatorValue() throws Exception {
- createTestEntityWithDiscriminatorValue();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(DISCRIMINATOR_VALUE, javaEntity().getSpecifiedDiscriminatorValue());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorValueAnnotation discriminatorValue = (DiscriminatorValueAnnotation) typeResource.getAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME);
-
- discriminatorValue.setValue("foo");
-
- assertEquals("foo", javaEntity().getSpecifiedDiscriminatorValue());
-
- discriminatorValue.setValue(null);
-
- assertNull(javaEntity().getSpecifiedDiscriminatorValue());
- assertNull(typeResource.getAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME));
- }
-
- public void testSetSpecifiedDiscriminatorValue() throws Exception {
- createTestEntityWithDiscriminatorValue();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- assertEquals(DISCRIMINATOR_VALUE, javaEntity().getSpecifiedDiscriminatorValue());
-
- javaEntity().setSpecifiedDiscriminatorValue("foo");
-
- assertEquals("foo", javaEntity().getSpecifiedDiscriminatorValue());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorValueAnnotation discriminatorValue = (DiscriminatorValueAnnotation) typeResource.getAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME);
- assertEquals("foo", discriminatorValue.getValue());
- }
-
- public void testSecondaryTables() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- ListIterator<JavaSecondaryTable> secondaryTables = javaEntity().secondaryTables();
-
- assertTrue(secondaryTables.hasNext());
- assertEquals("foo", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
- }
-
- public void testSecondaryTablesSize() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(0, entity.secondaryTablesSize());
-
- ((SecondaryTableAnnotation) typeResource.addAnnotation(0, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((SecondaryTableAnnotation) typeResource.addAnnotation(1, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((SecondaryTableAnnotation) typeResource.addAnnotation(2, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)).setName("BAZ");
-
- assertEquals(3, entity.secondaryTablesSize());
- }
-
- public void testSpecifiedSecondaryTables() throws Exception {
- createTestEntityWithSecondaryTables();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- ListIterator<JavaSecondaryTable> specifiedSecondaryTables = javaEntity().specifiedSecondaryTables();
-
- assertTrue(specifiedSecondaryTables.hasNext());
- assertEquals("foo", specifiedSecondaryTables.next().getName());
- assertEquals("bar", specifiedSecondaryTables.next().getName());
- assertFalse(specifiedSecondaryTables.hasNext());
- }
-
- public void testSpecifiedSecondaryTablesSize() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(0, entity.specifiedSecondaryTablesSize());
-
- ((SecondaryTableAnnotation) typeResource.addAnnotation(0, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((SecondaryTableAnnotation) typeResource.addAnnotation(1, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((SecondaryTableAnnotation) typeResource.addAnnotation(2, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)).setName("BAZ");
-
- assertEquals(3, entity.specifiedSecondaryTablesSize());
- }
-
- public void testAddSpecifiedSecondaryTable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().addSpecifiedSecondaryTable(0).setSpecifiedName("FOO");
- javaEntity().addSpecifiedSecondaryTable(0).setSpecifiedName("BAR");
- javaEntity().addSpecifiedSecondaryTable(0).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- Iterator<JavaResourceNode> secondaryTables = typeResource.annotations(SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
-
- assertEquals("BAZ", ((SecondaryTableAnnotation) secondaryTables.next()).getName());
- assertEquals("BAR", ((SecondaryTableAnnotation) secondaryTables.next()).getName());
- assertEquals("FOO", ((SecondaryTableAnnotation) secondaryTables.next()).getName());
- assertFalse(secondaryTables.hasNext());
- }
-
- public void testAddSpecifiedSecondaryTable2() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().addSpecifiedSecondaryTable(0).setSpecifiedName("FOO");
- javaEntity().addSpecifiedSecondaryTable(1).setSpecifiedName("BAR");
- javaEntity().addSpecifiedSecondaryTable(0).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- Iterator<JavaResourceNode> secondaryTables = typeResource.annotations(SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
-
- assertEquals("BAZ", ((SecondaryTableAnnotation) secondaryTables.next()).getName());
- assertEquals("FOO", ((SecondaryTableAnnotation) secondaryTables.next()).getName());
- assertEquals("BAR", ((SecondaryTableAnnotation) secondaryTables.next()).getName());
- assertFalse(secondaryTables.hasNext());
- }
-
- public void testAddSpecifiedSecondaryTablePreservePkJoinColumns() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable specifiedSecondaryTable = javaEntity().addSpecifiedSecondaryTable(0);
- specifiedSecondaryTable.setSpecifiedName("FOO");
- specifiedSecondaryTable.setSpecifiedCatalog("CATALOG");
- specifiedSecondaryTable.setSpecifiedSchema("SCHEMA");
- specifiedSecondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("PK_NAME");
-
- //add another specified secondary table, pkJoinColumns from first should be saved.
- SecondaryTable specifiedSecondaryTable2 = javaEntity().addSpecifiedSecondaryTable(1);
- specifiedSecondaryTable2.setSpecifiedName("BAR");
-
-
- Iterator<SecondaryTable> secondaryTables = javaEntity().secondaryTables();
- SecondaryTable secondaryTable = secondaryTables.next();
- assertEquals(secondaryTable, specifiedSecondaryTable);
- assertEquals("FOO", secondaryTable.getName());
- assertEquals("CATALOG", secondaryTable.getCatalog());
- assertEquals("SCHEMA", secondaryTable.getSchema());
- assertEquals(1, secondaryTable.specifiedPrimaryKeyJoinColumnsSize());
- PrimaryKeyJoinColumn pkJoinColumn = secondaryTable.specifiedPrimaryKeyJoinColumns().next();
- assertEquals("PK_NAME", pkJoinColumn.getName());
-
- secondaryTable = secondaryTables.next();
- assertEquals(secondaryTable, specifiedSecondaryTable2);
- assertEquals("BAR", secondaryTable.getName());
- assertEquals(0, secondaryTable.specifiedPrimaryKeyJoinColumnsSize());
-
- }
-
- public void testRemoveSpecifiedSecondaryTable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().addSpecifiedSecondaryTable(0).setSpecifiedName("FOO");
- javaEntity().addSpecifiedSecondaryTable(1).setSpecifiedName("BAR");
- javaEntity().addSpecifiedSecondaryTable(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(3, CollectionTools.size(typeResource.annotations(SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)));
-
- javaEntity().removeSpecifiedSecondaryTable(1);
-
- Iterator<JavaResourceNode> secondaryTableResources = typeResource.annotations(SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- assertEquals("FOO", ((SecondaryTableAnnotation) secondaryTableResources.next()).getName());
- assertEquals("BAZ", ((SecondaryTableAnnotation) secondaryTableResources.next()).getName());
- assertFalse(secondaryTableResources.hasNext());
-
- Iterator<SecondaryTable> secondaryTables = javaEntity().secondaryTables();
- assertEquals("FOO", secondaryTables.next().getName());
- assertEquals("BAZ", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
-
-
- javaEntity().removeSpecifiedSecondaryTable(1);
- secondaryTableResources = typeResource.annotations(SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- assertEquals("FOO", ((SecondaryTableAnnotation) secondaryTableResources.next()).getName());
- assertFalse(secondaryTableResources.hasNext());
-
- secondaryTables = javaEntity().secondaryTables();
- assertEquals("FOO", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
-
-
- javaEntity().removeSpecifiedSecondaryTable(0);
- secondaryTableResources = typeResource.annotations(SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- assertFalse(secondaryTableResources.hasNext());
- secondaryTables = javaEntity().secondaryTables();
- assertFalse(secondaryTables.hasNext());
-
- assertNull(typeResource.getAnnotation(SecondaryTablesAnnotation.ANNOTATION_NAME));
- }
-
- public void testMoveSpecifiedSecondaryTable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- entity.addSpecifiedSecondaryTable(0).setSpecifiedName("FOO");
- entity.addSpecifiedSecondaryTable(1).setSpecifiedName("BAR");
- entity.addSpecifiedSecondaryTable(2).setSpecifiedName("BAZ");
-
- ListIterator<SecondaryTableAnnotation> javaSecondaryTables = typeResource.annotations(SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- assertEquals(3, CollectionTools.size(javaSecondaryTables));
-
-
- entity.moveSpecifiedSecondaryTable(2, 0);
- ListIterator<SecondaryTable> secondaryTables = entity.specifiedSecondaryTables();
- assertEquals("BAR", secondaryTables.next().getSpecifiedName());
- assertEquals("BAZ", secondaryTables.next().getSpecifiedName());
- assertEquals("FOO", secondaryTables.next().getSpecifiedName());
-
- javaSecondaryTables = typeResource.annotations(SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", javaSecondaryTables.next().getName());
- assertEquals("BAZ", javaSecondaryTables.next().getName());
- assertEquals("FOO", javaSecondaryTables.next().getName());
-
-
- entity.moveSpecifiedSecondaryTable(0, 1);
- secondaryTables = entity.specifiedSecondaryTables();
- assertEquals("BAZ", secondaryTables.next().getSpecifiedName());
- assertEquals("BAR", secondaryTables.next().getSpecifiedName());
- assertEquals("FOO", secondaryTables.next().getSpecifiedName());
-
- javaSecondaryTables = typeResource.annotations(SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- assertEquals("BAZ", javaSecondaryTables.next().getName());
- assertEquals("BAR", javaSecondaryTables.next().getName());
- assertEquals("FOO", javaSecondaryTables.next().getName());
- }
-
- public void testUpdateSpecifiedSecondaryTables() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- ((SecondaryTableAnnotation) typeResource.addAnnotation(0, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((SecondaryTableAnnotation) typeResource.addAnnotation(1, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((SecondaryTableAnnotation) typeResource.addAnnotation(2, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)).setName("BAZ");
-
- ListIterator<SecondaryTable> secondaryTables = entity.specifiedSecondaryTables();
- assertEquals("FOO", secondaryTables.next().getName());
- assertEquals("BAR", secondaryTables.next().getName());
- assertEquals("BAZ", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
-
- typeResource.move(2, 0, SecondaryTablesAnnotation.ANNOTATION_NAME);
- secondaryTables = entity.specifiedSecondaryTables();
- assertEquals("BAR", secondaryTables.next().getName());
- assertEquals("BAZ", secondaryTables.next().getName());
- assertEquals("FOO", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
-
- typeResource.move(0, 1, SecondaryTablesAnnotation.ANNOTATION_NAME);
- secondaryTables = entity.specifiedSecondaryTables();
- assertEquals("BAZ", secondaryTables.next().getName());
- assertEquals("BAR", secondaryTables.next().getName());
- assertEquals("FOO", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
-
- typeResource.removeAnnotation(1, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- secondaryTables = entity.specifiedSecondaryTables();
- assertEquals("BAZ", secondaryTables.next().getName());
- assertEquals("FOO", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
-
- typeResource.removeAnnotation(1, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- secondaryTables = entity.specifiedSecondaryTables();
- assertEquals("BAZ", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
-
- typeResource.removeAnnotation(0, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- secondaryTables = entity.specifiedSecondaryTables();
- assertFalse(secondaryTables.hasNext());
- }
-
- public void testAssociatedTables() throws Exception {
- createTestEntityWithSecondaryTables();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(3, CollectionTools.size(javaEntity().associatedTables()));
- Iterator<Table> associatedTables = javaEntity().associatedTables();
- Table table1 = associatedTables.next();
- SecondaryTable table2 = (SecondaryTable) associatedTables.next();
- SecondaryTable table3 = (SecondaryTable) associatedTables.next();
- assertEquals(TYPE_NAME, table1.getName());
- assertEquals("foo", table2.getName());
- assertEquals("bar", table3.getName());
- }
-
- public void testAssociatedTablesIncludingInherited() throws Exception {
- createTestEntityWithSecondaryTables();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity parentEntity = javaEntity().getRootEntity();
- assertEquals(3, CollectionTools.size(parentEntity.associatedTablesIncludingInherited()));
- Iterator<Table> associatedTables = parentEntity.associatedTablesIncludingInherited();
- Table table1 = associatedTables.next();
- SecondaryTable table2 = (SecondaryTable) associatedTables.next();
- SecondaryTable table3 = (SecondaryTable) associatedTables.next();
- assertEquals(TYPE_NAME, table1.getName());
- assertEquals("foo", table2.getName());
- assertEquals("bar", table3.getName());
-
- Entity childEntity = javaEntity();
- //TODO probably want this to be 3, since in this case the child descriptor really uses the
- //parent table because it is single table inheritance strategy. Not sure yet how to deal with this.
- assertEquals(4, CollectionTools.size(childEntity.associatedTablesIncludingInherited()));
- }
-
- public void testAssociatedTableNamesIncludingInherited() throws Exception {
- createTestEntityWithSecondaryTables();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity parentEntity = javaEntity().getRootEntity();
- assertEquals(3, CollectionTools.size(parentEntity.associatedTableNamesIncludingInherited()));
- Iterator<String> associatedTables = parentEntity.associatedTableNamesIncludingInherited();
- String table1 = associatedTables.next();
- String table2 = associatedTables.next();
- String table3 = associatedTables.next();
- assertEquals(TYPE_NAME, table1);
- assertEquals("foo", table2);
- assertEquals("bar", table3);
-
- Entity childEntity = javaEntity();
- //TODO probably want this to be 3, since in this case the child descriptor really uses the
- //parent table because it is single table inheritance strategy. Not sure yet how to deal with this.
- assertEquals(4, CollectionTools.size(childEntity.associatedTableNamesIncludingInherited()));
- }
-
- public void testAddSecondaryTableToResourceModel() throws Exception {
- createTestEntityWithName();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTable.setName("FOO");
-
- assertEquals(1, javaEntity().secondaryTablesSize());
- assertEquals("FOO", javaEntity().secondaryTables().next().getSpecifiedName());
- assertEquals("FOO", javaEntity().secondaryTables().next().getName());
-
- SecondaryTableAnnotation secondaryTable2 = (SecondaryTableAnnotation) typeResource.addAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTable2.setName("BAR");
-
- assertEquals(2, javaEntity().secondaryTablesSize());
- ListIterator<SecondaryTable> secondaryTables = javaEntity().secondaryTables();
- assertEquals("FOO", secondaryTables.next().getSpecifiedName());
- assertEquals("BAR", secondaryTables.next().getSpecifiedName());
-
- SecondaryTableAnnotation secondaryTable3 = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTable3.setName("BAZ");
-
- assertEquals(3, javaEntity().secondaryTablesSize());
- secondaryTables = javaEntity().secondaryTables();
- assertEquals("BAZ", secondaryTables.next().getSpecifiedName());
- assertEquals("FOO", secondaryTables.next().getSpecifiedName());
- assertEquals("BAR", secondaryTables.next().getSpecifiedName());
- }
-
- public void testRemoveSecondaryTableFromResourceModel() throws Exception {
- createTestEntityWithSecondaryTables();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().addSpecifiedSecondaryTable(2).setSpecifiedName("baz");
- ListIterator<SecondaryTable> secondaryTables = javaEntity().secondaryTables();
-
- assertEquals(3, javaEntity().secondaryTablesSize());
- assertEquals("foo", secondaryTables.next().getSpecifiedName());
- assertEquals("bar", secondaryTables.next().getSpecifiedName());
- assertEquals("baz", secondaryTables.next().getSpecifiedName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.removeAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
-
- secondaryTables = javaEntity().secondaryTables();
- assertEquals(2, javaEntity().secondaryTablesSize());
- assertEquals("bar", secondaryTables.next().getSpecifiedName());
- assertEquals("baz", secondaryTables.next().getSpecifiedName());
-
- typeResource.removeAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
-
- secondaryTables = javaEntity().secondaryTables();
- assertEquals(1, javaEntity().secondaryTablesSize());
- assertEquals("baz", secondaryTables.next().getSpecifiedName());
-
-
- typeResource.removeAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
-
- secondaryTables = javaEntity().secondaryTables();
- assertEquals(0, javaEntity().secondaryTablesSize());
- assertFalse(secondaryTables.hasNext());
- }
-
- public void testGetSequenceGenerator() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getSequenceGenerator());
- assertEquals(0, CollectionTools.size(javaEntity().getPersistenceUnit().allGenerators()));
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.addAnnotation(JPA.SEQUENCE_GENERATOR);
-
- assertNotNull(javaEntity().getSequenceGenerator());
- assertEquals(1, typeResource.annotationsSize());
- assertEquals(1, CollectionTools.size(javaEntity().getPersistenceUnit().allGenerators()));
-
- javaEntity().getSequenceGenerator().setName("foo");
- assertEquals(1, CollectionTools.size(javaEntity().getPersistenceUnit().allGenerators()));
- }
-
- public void testAddSequenceGenerator() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getSequenceGenerator());
-
- javaEntity().addSequenceGenerator();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNotNull(typeResource.getAnnotation(JPA.SEQUENCE_GENERATOR));
- assertNotNull(javaEntity().getSequenceGenerator());
-
- //try adding another sequence generator, should get an IllegalStateException
- try {
- javaEntity().addSequenceGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testRemoveSequenceGenerator() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.addAnnotation(JPA.SEQUENCE_GENERATOR);
-
- javaEntity().removeSequenceGenerator();
-
- assertNull(javaEntity().getSequenceGenerator());
- assertNull(typeResource.getAnnotation(JPA.SEQUENCE_GENERATOR));
-
- //try removing the sequence generator again, should get an IllegalStateException
- try {
- javaEntity().removeSequenceGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testGetTableGenerator() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getTableGenerator());
- assertEquals(0, CollectionTools.size(javaEntity().getPersistenceUnit().allGenerators()));
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.addAnnotation(JPA.TABLE_GENERATOR);
-
- assertNotNull(javaEntity().getTableGenerator());
- assertEquals(1, typeResource.annotationsSize());
- assertEquals(1, CollectionTools.size(javaEntity().getPersistenceUnit().allGenerators()));
-
- javaEntity().getTableGenerator().setName("foo");
- assertEquals(1, CollectionTools.size(javaEntity().getPersistenceUnit().allGenerators()));
- }
-
- public void testAddTableGenerator() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getTableGenerator());
-
- javaEntity().addTableGenerator();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNotNull(typeResource.getAnnotation(JPA.TABLE_GENERATOR));
- assertNotNull(javaEntity().getTableGenerator());
-
- //try adding another table generator, should get an IllegalStateException
- try {
- javaEntity().addTableGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testRemoveTableGenerator() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.addAnnotation(JPA.TABLE_GENERATOR);
-
- javaEntity().removeTableGenerator();
-
- assertNull(javaEntity().getTableGenerator());
- assertNull(typeResource.getAnnotation(JPA.TABLE_GENERATOR));
-
- //try removing the table generator again, should get an IllegalStateException
- try {
- javaEntity().removeTableGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testGetDiscriminatorColumn() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNotNull(javaEntity().getDiscriminatorColumn());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.addAnnotation(JPA.DISCRIMINATOR_COLUMN);
- column.setName("foo");
-
- assertEquals("foo", javaEntity().getDiscriminatorColumn().getSpecifiedName());
-
- column.setName(null);
-
- assertNull(javaEntity().getDiscriminatorColumn().getSpecifiedName());
-
- typeResource.removeAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- assertNotNull(javaEntity().getDiscriminatorColumn());
- }
-
- public void testSpecifiedPrimaryKeyJoinColumns() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- ListIterator<JavaPrimaryKeyJoinColumn> specifiedPkJoinColumns = javaEntity().specifiedPrimaryKeyJoinColumns();
-
- assertFalse(specifiedPkJoinColumns.hasNext());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- //add an annotation to the resource model and verify the context model is updated
- PrimaryKeyJoinColumnAnnotation pkJoinColumn = (PrimaryKeyJoinColumnAnnotation) typeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- pkJoinColumn.setName("FOO");
- specifiedPkJoinColumns = javaEntity().specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", specifiedPkJoinColumns.next().getName());
- assertFalse(specifiedPkJoinColumns.hasNext());
-
- pkJoinColumn = (PrimaryKeyJoinColumnAnnotation) typeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- pkJoinColumn.setName("BAR");
- specifiedPkJoinColumns = javaEntity().specifiedPrimaryKeyJoinColumns();
- assertEquals("BAR", specifiedPkJoinColumns.next().getName());
- assertEquals("FOO", specifiedPkJoinColumns.next().getName());
- assertFalse(specifiedPkJoinColumns.hasNext());
-
-
- pkJoinColumn = (PrimaryKeyJoinColumnAnnotation) typeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- pkJoinColumn.setName("BAZ");
- specifiedPkJoinColumns = javaEntity().specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", specifiedPkJoinColumns.next().getName());
- assertEquals("BAR", specifiedPkJoinColumns.next().getName());
- assertEquals("FOO", specifiedPkJoinColumns.next().getName());
- assertFalse(specifiedPkJoinColumns.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- typeResource.move(1, 0, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- specifiedPkJoinColumns = javaEntity().specifiedPrimaryKeyJoinColumns();
- assertEquals("BAR", specifiedPkJoinColumns.next().getName());
- assertEquals("BAZ", specifiedPkJoinColumns.next().getName());
- assertEquals("FOO", specifiedPkJoinColumns.next().getName());
- assertFalse(specifiedPkJoinColumns.hasNext());
-
- typeResource.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- specifiedPkJoinColumns = javaEntity().specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", specifiedPkJoinColumns.next().getName());
- assertEquals("FOO", specifiedPkJoinColumns.next().getName());
- assertFalse(specifiedPkJoinColumns.hasNext());
-
- typeResource.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- specifiedPkJoinColumns = javaEntity().specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", specifiedPkJoinColumns.next().getName());
- assertFalse(specifiedPkJoinColumns.hasNext());
-
-
- typeResource.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- specifiedPkJoinColumns = javaEntity().specifiedPrimaryKeyJoinColumns();
- assertFalse(specifiedPkJoinColumns.hasNext());
- }
-
- public void testSpecifiedPrimaryKeyJoinColumnsSize() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(0, javaEntity().specifiedPrimaryKeyJoinColumnsSize());
-
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAR");
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAZ");
-
- assertEquals(3, javaEntity().specifiedPrimaryKeyJoinColumnsSize());
- }
-
- public void testPrimaryKeyJoinColumnsSize() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- //just the default pkJoinColumn, so 1
- assertEquals(1, javaEntity().primaryKeyJoinColumnsSize());
-
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAR");
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAZ");
-
- //only the specified pkJoinColumns, 3
- assertEquals(3, javaEntity().primaryKeyJoinColumnsSize());
- }
-
- public void testGetDefaultPrimaryKeyJoinColumn() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNotNull(javaEntity().getDefaultPrimaryKeyJoinColumn());
-
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAR");
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAZ");
-
- assertNull(javaEntity().getDefaultPrimaryKeyJoinColumn());
- }
-
- public void testAddSpecifiedPrimaryKeyJoinColumn() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAR");
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- Iterator<JavaResourceNode> pkJoinColumns = typeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
-
- assertEquals("BAZ", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumns.next()).getName());
- assertEquals("BAR", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumns.next()).getName());
- assertEquals("FOO", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumns.next()).getName());
- assertFalse(pkJoinColumns.hasNext());
- }
-
- public void testAddSpecifiedPrimaryKeyJoinColumn2() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- Iterator<JavaResourceNode> pkJoinColumns = typeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
-
- assertEquals("FOO", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumns.next()).getName());
- assertEquals("BAR", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumns.next()).getName());
- assertEquals("BAZ", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumns.next()).getName());
- assertFalse(pkJoinColumns.hasNext());
- }
- public void testRemoveSpecifiedPrimaryKeyJoinColumn() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(3, CollectionTools.size(typeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME)));
-
- javaEntity().removeSpecifiedPrimaryKeyJoinColumn(1);
-
- Iterator<JavaResourceNode> pkJoinColumnResources = typeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- assertEquals("FOO", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumnResources.next()).getName());
- assertEquals("BAZ", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumnResources.next()).getName());
- assertFalse(pkJoinColumnResources.hasNext());
-
- Iterator<PrimaryKeyJoinColumn> pkJoinColumns = javaEntity().specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", pkJoinColumns.next().getName());
- assertEquals("BAZ", pkJoinColumns.next().getName());
- assertFalse(pkJoinColumns.hasNext());
-
-
- javaEntity().removeSpecifiedPrimaryKeyJoinColumn(1);
- pkJoinColumnResources = typeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- assertEquals("FOO", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumnResources.next()).getName());
- assertFalse(pkJoinColumnResources.hasNext());
-
- pkJoinColumns = javaEntity().specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", pkJoinColumns.next().getName());
- assertFalse(pkJoinColumns.hasNext());
-
-
- javaEntity().removeSpecifiedPrimaryKeyJoinColumn(0);
- pkJoinColumnResources = typeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- assertFalse(pkJoinColumnResources.hasNext());
- pkJoinColumns = javaEntity().specifiedPrimaryKeyJoinColumns();
- assertFalse(pkJoinColumns.hasNext());
-
- assertNull(typeResource.getAnnotation(PrimaryKeyJoinColumns.ANNOTATION_NAME));
- }
-
- public void testMoveSpecifiedPrimaryKeyJoinColumn() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- entity.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- entity.addSpecifiedPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- entity.addSpecifiedPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- ListIterator<PrimaryKeyJoinColumnAnnotation> javaPrimaryKeyJoinColumns = typeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- assertEquals(3, CollectionTools.size(javaPrimaryKeyJoinColumns));
-
-
- entity.moveSpecifiedPrimaryKeyJoinColumn(2, 0);
- ListIterator<PrimaryKeyJoinColumn> primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getSpecifiedName());
-
- javaPrimaryKeyJoinColumns = typeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- assertEquals("BAR", javaPrimaryKeyJoinColumns.next().getName());
- assertEquals("BAZ", javaPrimaryKeyJoinColumns.next().getName());
- assertEquals("FOO", javaPrimaryKeyJoinColumns.next().getName());
-
-
- entity.moveSpecifiedPrimaryKeyJoinColumn(0, 1);
- primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getSpecifiedName());
-
- javaPrimaryKeyJoinColumns = typeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- assertEquals("BAZ", javaPrimaryKeyJoinColumns.next().getName());
- assertEquals("BAR", javaPrimaryKeyJoinColumns.next().getName());
- assertEquals("FOO", javaPrimaryKeyJoinColumns.next().getName());
- }
-
- public void testUpdateSpecifiedPrimaryKeyJoinColumns() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- ((PrimaryKeyJoinColumnAnnotation) typeResource.addAnnotation(0, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME)).setName("FOO");
- ((PrimaryKeyJoinColumnAnnotation) typeResource.addAnnotation(1, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME)).setName("BAR");
- ((PrimaryKeyJoinColumnAnnotation) typeResource.addAnnotation(2, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME)).setName("BAZ");
-
- ListIterator<PrimaryKeyJoinColumn> primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- typeResource.move(2, 0, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- typeResource.move(0, 1, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- typeResource.removeAnnotation(1, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- typeResource.removeAnnotation(1, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- typeResource.removeAnnotation(0, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns();
- assertFalse(primaryKeyJoinColumns.hasNext());
- }
-
- public void testPrimaryKeyJoinColumnIsVirtual() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertTrue(javaEntity().getDefaultPrimaryKeyJoinColumn().isVirtual());
-
- javaEntity().addSpecifiedPrimaryKeyJoinColumn(0);
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertFalse(specifiedPkJoinColumn.isVirtual());
-
- assertNull(javaEntity().getDefaultPrimaryKeyJoinColumn());
- }
-
- public void testTableNameIsInvalid() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertFalse(javaEntity().tableNameIsInvalid(TYPE_NAME));
- assertTrue(javaEntity().tableNameIsInvalid("FOO"));
-
- javaEntity().addSpecifiedSecondaryTable(0).setSpecifiedName("BAR");
-
- assertFalse(javaEntity().tableNameIsInvalid("BAR"));
- }
-
- public void testAttributeMappingKeyAllowed() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = (Entity) javaPersistentType().getMapping();
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY));
- }
-
- public void testOverridableAttributes() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<PersistentAttribute> overridableAttributes = javaEntity().overridableAttributes();
- assertFalse(overridableAttributes.hasNext());
- }
-
- public void testOverridableAttributeNames() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAttributeNames = javaEntity().overridableAttributeNames();
- assertFalse(overridableAttributeNames.hasNext());
- }
-
- public void testAllOverridableAttributes() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<PersistentAttribute> overridableAttributes = javaEntity().allOverridableAttributes();
- assertEquals("id", overridableAttributes.next().getName());
- assertEquals("name", overridableAttributes.next().getName());
- assertEquals("foo", overridableAttributes.next().getName());
- assertFalse(overridableAttributes.hasNext());
- }
-
- public void testAllOverridableAttributesMappedSuperclassInOrmXml() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<PersistentAttribute> overridableAttributes = javaEntity().allOverridableAttributes();
- assertEquals("id", overridableAttributes.next().getName());
- assertEquals("name", overridableAttributes.next().getName());
- assertEquals("foo", overridableAttributes.next().getName());
- assertFalse(overridableAttributes.hasNext());
- }
-
- public void testAllOverridableAttributeNames() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAttributeNames = javaEntity().allOverridableAttributeNames();
- assertEquals("id", overridableAttributeNames.next());
- assertEquals("name", overridableAttributeNames.next());
- assertEquals("foo", overridableAttributeNames.next());
- assertFalse(overridableAttributeNames.hasNext());
- }
-
- public void testSpecifiedAttributeOverrides() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- ListIterator<JavaAttributeOverride> specifiedAttributeOverrides = javaEntity().specifiedAttributeOverrides();
-
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- specifiedAttributeOverrides = javaEntity().specifiedAttributeOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- specifiedAttributeOverrides = javaEntity().specifiedAttributeOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
-
- attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAZ");
- specifiedAttributeOverrides = javaEntity().specifiedAttributeOverrides();
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- typeResource.move(1, 0, JPA.ATTRIBUTE_OVERRIDES);
- specifiedAttributeOverrides = javaEntity().specifiedAttributeOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- specifiedAttributeOverrides = javaEntity().specifiedAttributeOverrides();
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- specifiedAttributeOverrides = javaEntity().specifiedAttributeOverrides();
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
-
- typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- specifiedAttributeOverrides = javaEntity().specifiedAttributeOverrides();
- assertFalse(specifiedAttributeOverrides.hasNext());
- }
-
- public void testDefaultAttributeOverrides() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- JavaEntity javaEntity = (JavaEntity) classRefs.next().getJavaPersistentType().getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_SUB_TYPE_NAME);
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(3, javaEntity.virtualAttributeOverridesSize());
- AttributeOverride virtualAttributeOverride = javaEntity.virtualAttributeOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("id", virtualAttributeOverride.getColumn().getName());
- assertEquals(SUB_TYPE_NAME, virtualAttributeOverride.getColumn().getTable());
-
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
-
- BasicMapping idMapping = (BasicMapping) mappedSuperclass.getPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.getColumn().setSpecifiedTable("BAR");
-
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(3, javaEntity.virtualAttributeOverridesSize());
- virtualAttributeOverride = javaEntity.virtualAttributeOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("FOO", virtualAttributeOverride.getColumn().getName());
- assertEquals("BAR", virtualAttributeOverride.getColumn().getTable());
-
- idMapping.getColumn().setSpecifiedName(null);
- idMapping.getColumn().setSpecifiedTable(null);
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- virtualAttributeOverride = javaEntity.virtualAttributeOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("id", virtualAttributeOverride.getColumn().getName());
- assertEquals(SUB_TYPE_NAME, virtualAttributeOverride.getColumn().getTable());
-
- virtualAttributeOverride = virtualAttributeOverride.setVirtual(false);
- assertEquals(2, javaEntity.virtualAttributeOverridesSize());
- }
-
- public void testSpecifiedAttributeOverridesSize() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(0, javaEntity().specifiedAttributeOverridesSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
-
- assertEquals(2, javaEntity().specifiedAttributeOverridesSize());
- }
-
- public void testDefaultAttributeOverridesSize() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity javaEntity = javaEntity();
-
- assertEquals(3, javaEntity.virtualAttributeOverridesSize());
-
- javaEntity.virtualAttributeOverrides().next().setVirtual(false);
- assertEquals(2, javaEntity.virtualAttributeOverridesSize());
-
- javaEntity.virtualAttributeOverrides().next().setVirtual(false);
- assertEquals(1, javaEntity.virtualAttributeOverridesSize());
-
- javaEntity.virtualAttributeOverrides().next().setVirtual(false);
- assertEquals(0, javaEntity.virtualAttributeOverridesSize());
- }
-
- public void testAttributeOverridesSize() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity javaEntity = javaEntity();
-
- assertEquals(3, javaEntity.attributeOverridesSize());
-
- javaEntity.virtualAttributeOverrides().next().setVirtual(false);
- assertEquals(3, javaEntity.attributeOverridesSize());
-
- javaEntity.virtualAttributeOverrides().next().setVirtual(false);
- assertEquals(3, javaEntity.attributeOverridesSize());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_SUB_TYPE_NAME);
- AttributeOverrideAnnotation annotation = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- annotation.setName("bar");
- assertEquals(4, javaEntity.attributeOverridesSize());
- }
-
- public void testAttributeOverrideSetVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().virtualAttributeOverrides().next().setVirtual(false);
- javaEntity().virtualAttributeOverrides().next().setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_SUB_TYPE_NAME);
- Iterator<JavaResourceNode> attributeOverrides = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("id", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
- }
-
- public void testAttributeOverrideSetVirtual2() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- ListIterator<JavaAttributeOverride> virtualAttributeOverrides = javaEntity().virtualAttributeOverrides();
- virtualAttributeOverrides.next();
- virtualAttributeOverrides.next().setVirtual(false);
- javaEntity().virtualAttributeOverrides().next().setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_SUB_TYPE_NAME);
- Iterator<JavaResourceNode> attributeOverrides = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("id", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
- }
-
- public void testAttributeOverrideSetVirtualTrue() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().virtualAttributeOverrides().next().setVirtual(false);
- javaEntity().virtualAttributeOverrides().next().setVirtual(false);
- javaEntity().virtualAttributeOverrides().next().setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_SUB_TYPE_NAME);
- assertEquals(3, CollectionTools.size(typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)));
-
- javaEntity().specifiedAttributeOverrides().next().setVirtual(true);
-
- Iterator<JavaResourceNode> attributeOverrideResources = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("name", ((AttributeOverrideAnnotation) attributeOverrideResources.next()).getName());
- assertEquals("foo", ((AttributeOverrideAnnotation) attributeOverrideResources.next()).getName());
- assertFalse(attributeOverrideResources.hasNext());
-
- Iterator<AttributeOverride> attributeOverrides = javaEntity().specifiedAttributeOverrides();
- assertEquals("name", attributeOverrides.next().getName());
- assertEquals("foo", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
-
- javaEntity().specifiedAttributeOverrides().next().setVirtual(true);
- attributeOverrideResources = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("foo", ((AttributeOverrideAnnotation) attributeOverrideResources.next()).getName());
- assertFalse(attributeOverrideResources.hasNext());
-
- attributeOverrides = javaEntity().specifiedAttributeOverrides();
- assertEquals("foo", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
-
- javaEntity().specifiedAttributeOverrides().next().setVirtual(true);
- attributeOverrideResources = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertFalse(attributeOverrideResources.hasNext());
- attributeOverrides = javaEntity().specifiedAttributeOverrides();
- assertFalse(attributeOverrides.hasNext());
-
- assertNull(typeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
- }
-
- public void testMoveSpecifiedAttributeOverride() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- javaEntity().virtualAttributeOverrides().next().setVirtual(false);
- javaEntity().virtualAttributeOverrides().next().setVirtual(false);
- javaEntity().virtualAttributeOverrides().next().setVirtual(false);
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_SUB_TYPE_NAME);
-
- ListIterator<AttributeOverrideAnnotation> javaAttributeOverrides = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals(3, CollectionTools.size(javaAttributeOverrides));
-
-
- entity.moveSpecifiedAttributeOverride(2, 0);
- ListIterator<AttributeOverride> attributeOverrides = entity.specifiedAttributeOverrides();
- assertEquals("name", attributeOverrides.next().getName());
- assertEquals("foo", attributeOverrides.next().getName());
- assertEquals("id", attributeOverrides.next().getName());
-
- javaAttributeOverrides = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("name", javaAttributeOverrides.next().getName());
- assertEquals("foo", javaAttributeOverrides.next().getName());
- assertEquals("id", javaAttributeOverrides.next().getName());
-
-
- entity.moveSpecifiedAttributeOverride(0, 1);
- attributeOverrides = entity.specifiedAttributeOverrides();
- assertEquals("foo", attributeOverrides.next().getName());
- assertEquals("name", attributeOverrides.next().getName());
- assertEquals("id", attributeOverrides.next().getName());
-
- javaAttributeOverrides = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("foo", javaAttributeOverrides.next().getName());
- assertEquals("name", javaAttributeOverrides.next().getName());
- assertEquals("id", javaAttributeOverrides.next().getName());
- }
-//
- public void testUpdateSpecifiedAttributeOverrides() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- ((AttributeOverrideAnnotation) typeResource.addAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((AttributeOverrideAnnotation) typeResource.addAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((AttributeOverrideAnnotation) typeResource.addAnnotation(2, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("BAZ");
-
- ListIterator<AttributeOverride> attributeOverrides = entity.specifiedAttributeOverrides();
- assertEquals("FOO", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- typeResource.move(2, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
- attributeOverrides = entity.specifiedAttributeOverrides();
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- typeResource.move(0, 1, AttributeOverridesAnnotation.ANNOTATION_NAME);
- attributeOverrides = entity.specifiedAttributeOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- typeResource.removeAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- attributeOverrides = entity.specifiedAttributeOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- typeResource.removeAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- attributeOverrides = entity.specifiedAttributeOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- typeResource.removeAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- attributeOverrides = entity.specifiedAttributeOverrides();
- assertFalse(attributeOverrides.hasNext());
- }
-
- public void testAttributeOverrideIsVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- ListIterator<AttributeOverride> virtualAttributeOverrides = javaEntity().virtualAttributeOverrides();
- AttributeOverride virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
-
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("name", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
-
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("foo", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
- assertFalse(virtualAttributeOverrides.hasNext());
-
- javaEntity().virtualAttributeOverrides().next().setVirtual(false);
- AttributeOverride specifiedAttributeOverride = javaEntity().specifiedAttributeOverrides().next();
- assertFalse(specifiedAttributeOverride.isVirtual());
-
-
- virtualAttributeOverrides = javaEntity().virtualAttributeOverrides();
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("name", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
-
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("foo", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
- assertFalse(virtualAttributeOverrides.hasNext());
- }
-
-
- public void testOverridableAssociations() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<PersistentAttribute> overridableAssociations = javaEntity().overridableAssociations();
- assertFalse(overridableAssociations.hasNext());
- }
-
- public void testOverridableAssociationNames() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAssociationNames = javaEntity().overridableAssociationNames();
- assertFalse(overridableAssociationNames.hasNext());
- }
-
-// //TODO add all mapping types to the mapped superclass to test which ones are overridable
- public void testAllOverridableAssociationNames() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAssociationNames = javaEntity().allOverridableAssociationNames();
- assertEquals("address", overridableAssociationNames.next());
- assertEquals("address2", overridableAssociationNames.next());
- assertFalse(overridableAssociationNames.hasNext());
- }
-
- public void testAllOverridableAssociations() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<PersistentAttribute> overridableAssociations = javaEntity().allOverridableAssociations();
- assertEquals("address", overridableAssociations.next().getName());
- assertEquals("address2", overridableAssociations.next().getName());
- assertFalse(overridableAssociations.hasNext());
- }
-
- public void testAllOverridableAssociationsMappedSuperclassInOrmXml() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<PersistentAttribute> overridableAssociations = javaEntity().allOverridableAssociations();
- assertEquals("address", overridableAssociations.next().getName());
- assertEquals("address2", overridableAssociations.next().getName());
- assertFalse(overridableAssociations.hasNext());
- }
-
- public void testSpecifiedAssociationOverrides() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- ListIterator<JavaAssociationOverride> specifiedAssociationOverrides = javaEntity().specifiedAssociationOverrides();
-
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- //add an annotation to the resource model and verify the context model is updated
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("FOO");
- specifiedAssociationOverrides = javaEntity().specifiedAssociationOverrides();
- assertEquals("FOO", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("BAR");
- specifiedAssociationOverrides = javaEntity().specifiedAssociationOverrides();
- assertEquals("FOO", specifiedAssociationOverrides.next().getName());
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
-
- associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("BAZ");
- specifiedAssociationOverrides = javaEntity().specifiedAssociationOverrides();
- assertEquals("BAZ", specifiedAssociationOverrides.next().getName());
- assertEquals("FOO", specifiedAssociationOverrides.next().getName());
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- typeResource.move(1, 0, JPA.ASSOCIATION_OVERRIDES);
- specifiedAssociationOverrides = javaEntity().specifiedAssociationOverrides();
- assertEquals("FOO", specifiedAssociationOverrides.next().getName());
- assertEquals("BAZ", specifiedAssociationOverrides.next().getName());
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- specifiedAssociationOverrides = javaEntity().specifiedAssociationOverrides();
- assertEquals("BAZ", specifiedAssociationOverrides.next().getName());
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- specifiedAssociationOverrides = javaEntity().specifiedAssociationOverrides();
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
-
- typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- specifiedAssociationOverrides = javaEntity().specifiedAssociationOverrides();
- assertFalse(specifiedAssociationOverrides.hasNext());
- }
-
- public void testDefaultAssociationOverrides() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- JavaEntity javaEntity = (JavaEntity) classRefs.next().getJavaPersistentType().getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_SUB_TYPE_NAME);
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AssociationOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AssociationOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(2, javaEntity.virtualAssociationOverridesSize());
- AssociationOverride virtualAssociationOverride = javaEntity.virtualAssociationOverrides().next();
- assertEquals("address", virtualAssociationOverride.getName());
-
-
- //MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
- //BasicMapping idMapping = (BasicMapping) mappedSuperclass.persistentType().attributeNamed("id").getMapping();
- //idMapping.getColumn().setSpecifiedName("FOO");
- //idMapping.getColumn().setSpecifiedTable("BAR");
-
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AssociationOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AssociationOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(2, javaEntity.virtualAssociationOverridesSize());
- virtualAssociationOverride = javaEntity.virtualAssociationOverrides().next();
- assertEquals("address", virtualAssociationOverride.getName());
-
- //idMapping.getColumn().setSpecifiedName(null);
- //idMapping.getColumn().setSpecifiedTable(null);
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AssociationOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AssociationOverridesAnnotation.ANNOTATION_NAME));
-
- virtualAssociationOverride = javaEntity.virtualAssociationOverrides().next();
- assertEquals("address", virtualAssociationOverride.getName());
-
- virtualAssociationOverride = virtualAssociationOverride.setVirtual(false);
- assertEquals(1, javaEntity.virtualAssociationOverridesSize());
-
-
-
-// //TODO joinColumns for default association overrides
-//// IJoinColumn defaultJoinColumn = defaultAssociationOverride.joinColumns().next();
-//// assertEquals("address", defaultJoinColumn.getName());
-//// assertEquals("address", defaultJoinColumn.getReferencedColumnName());
-//// assertEquals(SUB_TYPE_NAME, defaultJoinColumn.getTable());
-////
-////
-//// IMappedSuperclass mappedSuperclass = (IMappedSuperclass) javaPersistentType().getMapping();
-////
-//// IOneToOneMapping addressMapping = (IOneToOneMapping) mappedSuperclass.persistentType().attributeNamed("address").getMapping();
-//// IJoinColumn joinColumn = addressMapping.addSpecifiedJoinColumn(0);
-//// joinColumn.setSpecifiedName("FOO");
-//// joinColumn.setSpecifiedReferencedColumnName("BAR");
-//// joinColumn.setSpecifiedTable("BAZ");
-////
-//// assertEquals(SUB_TYPE_NAME, typeResource.getName());
-//// assertNull(typeResource.annotation(AssociationOverride.ANNOTATION_NAME));
-//// assertNull(typeResource.annotation(AssociationOverrides.ANNOTATION_NAME));
-////
-//// assertEquals(1, CollectionTools.size(javaEntity.defaultAssociationOverrides()));
-//// defaultAssociationOverride = javaEntity.defaultAssociationOverrides().next();
-//// assertEquals("address", defaultAssociationOverride.getName());
-//// assertEquals("FOO", defaultJoinColumn.getName());
-//// assertEquals("BAR", defaultJoinColumn.getReferencedColumnName());
-//// assertEquals("BAZ", defaultJoinColumn.getTable());
-////
-//// joinColumn.setSpecifiedName(null);
-//// joinColumn.setSpecifiedReferencedColumnName(null);
-//// joinColumn.setSpecifiedTable(null);
-//// assertEquals(SUB_TYPE_NAME, typeResource.getName());
-//// assertNull(typeResource.annotation(AssociationOverride.ANNOTATION_NAME));
-//// assertNull(typeResource.annotation(AssociationOverrides.ANNOTATION_NAME));
-////
-//// defaultAssociationOverride = javaEntity.defaultAssociationOverrides().next();
-//// assertEquals("address", defaultJoinColumn.getName());
-//// assertEquals("address", defaultJoinColumn.getReferencedColumnName());
-//// assertEquals(SUB_TYPE_NAME, defaultJoinColumn.getTable());
-////
-//// javaEntity.addSpecifiedAssociationOverride(0).setName("address");
-//// assertEquals(0, CollectionTools.size(javaEntity.defaultAssociationOverrides()));
-
- }
-
- public void testSpecifiedAssociationOverridesSize() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(0, javaEntity().specifiedAssociationOverridesSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- //add an annotation to the resource model and verify the context model is updated
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("FOO");
- associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("BAR");
-
- assertEquals(2, javaEntity().specifiedAssociationOverridesSize());
- }
-
- public void testDefaultAssociationOverridesSize() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity javaEntity = javaEntity();
-
- assertEquals(2, javaEntity.virtualAssociationOverridesSize());
-
- javaEntity.virtualAssociationOverrides().next().setVirtual(false);
- assertEquals(1, javaEntity.virtualAssociationOverridesSize());
-
- javaEntity.virtualAssociationOverrides().next().setVirtual(false);
- assertEquals(0, javaEntity.virtualAssociationOverridesSize());
- }
-
- public void testAssociationOverridesSize() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity javaEntity = javaEntity();
-
- assertEquals(2, javaEntity.associationOverridesSize());
-
- javaEntity.virtualAssociationOverrides().next().setVirtual(false);
- assertEquals(2, javaEntity.associationOverridesSize());
-
- javaEntity.virtualAssociationOverrides().next().setVirtual(false);
- assertEquals(2, javaEntity.associationOverridesSize());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_SUB_TYPE_NAME);
- AssociationOverrideAnnotation annotation = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- annotation.setName("bar");
- assertEquals(3, javaEntity.associationOverridesSize());
- }
-
- public void testAssociationOverrideSetVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().virtualAssociationOverrides().next().setVirtual(false);
- javaEntity().virtualAssociationOverrides().next().setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_SUB_TYPE_NAME);
- Iterator<JavaResourceNode> associationOverrides = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("address", ((AssociationOverrideAnnotation) associationOverrides.next()).getName());
- assertEquals("address2", ((AssociationOverrideAnnotation) associationOverrides.next()).getName());
- assertFalse(associationOverrides.hasNext());
- }
-
- public void testAssociationOverrideSetVirtual2() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- ListIterator<JavaAssociationOverride> virtualAssociationOverrides = javaEntity().virtualAssociationOverrides();
- virtualAssociationOverrides.next();
- virtualAssociationOverrides.next().setVirtual(false);
- javaEntity().virtualAssociationOverrides().next().setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_SUB_TYPE_NAME);
- Iterator<JavaResourceNode> associationOverrides = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("address2", ((AssociationOverrideAnnotation) associationOverrides.next()).getName());
- assertEquals("address", ((AssociationOverrideAnnotation) associationOverrides.next()).getName());
- assertFalse(associationOverrides.hasNext());
- }
-
- public void testAssociationOverrideSetVirtualTrue() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().virtualAssociationOverrides().next().setVirtual(false);
- javaEntity().virtualAssociationOverrides().next().setVirtual(false);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_SUB_TYPE_NAME);
- assertEquals(2, CollectionTools.size(typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)));
-
- javaEntity().specifiedAssociationOverrides().next().setVirtual(true);
-
- Iterator<JavaResourceNode> associationOverrideResources = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("address2", ((AssociationOverrideAnnotation) associationOverrideResources.next()).getName());
- assertFalse(associationOverrideResources.hasNext());
-
- Iterator<AssociationOverride> associationOverrides = javaEntity().specifiedAssociationOverrides();
- assertEquals("address2", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
-
- javaEntity().specifiedAssociationOverrides().next().setVirtual(true);
- associationOverrideResources = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- assertFalse(associationOverrideResources.hasNext());
- associationOverrides = javaEntity().specifiedAssociationOverrides();
- assertFalse(associationOverrides.hasNext());
-
- assertNull(typeResource.getAnnotation(AssociationOverridesAnnotation.ANNOTATION_NAME));
- }
-
- public void testMoveSpecifiedAssociationOverride() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- javaEntity().virtualAssociationOverrides().next().setVirtual(false);
- javaEntity().virtualAssociationOverrides().next().setVirtual(false);
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_SUB_TYPE_NAME);
-
- ListIterator<AssociationOverrideAnnotation> javaAssociationOverrides = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- assertEquals(2, CollectionTools.size(javaAssociationOverrides));
-
-
- entity.moveSpecifiedAssociationOverride(1, 0);
- ListIterator<AssociationOverride> associationOverrides = entity.specifiedAssociationOverrides();
- assertEquals("address2", associationOverrides.next().getName());
- assertEquals("address", associationOverrides.next().getName());
-
- javaAssociationOverrides = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("address2", javaAssociationOverrides.next().getName());
- assertEquals("address", javaAssociationOverrides.next().getName());
-
-
- entity.moveSpecifiedAssociationOverride(0, 1);
- associationOverrides = entity.specifiedAssociationOverrides();
- assertEquals("address", associationOverrides.next().getName());
- assertEquals("address2", associationOverrides.next().getName());
-
- javaAssociationOverrides = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("address", javaAssociationOverrides.next().getName());
- assertEquals("address2", javaAssociationOverrides.next().getName());
- }
-
- public void testUpdateSpecifiedAssociationOverrides() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- ((AssociationOverrideAnnotation) typeResource.addAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((AssociationOverrideAnnotation) typeResource.addAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((AssociationOverrideAnnotation) typeResource.addAnnotation(2, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("BAZ");
-
- ListIterator<AssociationOverride> associationOverrides = entity.specifiedAssociationOverrides();
- assertEquals("FOO", associationOverrides.next().getName());
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("BAZ", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- typeResource.move(2, 0, AssociationOverridesAnnotation.ANNOTATION_NAME);
- associationOverrides = entity.specifiedAssociationOverrides();
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- typeResource.move(0, 1, AssociationOverridesAnnotation.ANNOTATION_NAME);
- associationOverrides = entity.specifiedAssociationOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- typeResource.removeAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- associationOverrides = entity.specifiedAssociationOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- typeResource.removeAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- associationOverrides = entity.specifiedAssociationOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- typeResource.removeAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- associationOverrides = entity.specifiedAssociationOverrides();
- assertFalse(associationOverrides.hasNext());
- }
-
- public void testAssociationOverrideIsVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- ListIterator<AssociationOverride> virtualAssociationOverrides = javaEntity().virtualAssociationOverrides();
- AssociationOverride virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
-
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address2", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
- assertFalse(virtualAssociationOverrides.hasNext());
-
- javaEntity().virtualAssociationOverrides().next().setVirtual(false);
- AssociationOverride specifiedAssociationOverride = javaEntity().specifiedAssociationOverrides().next();
- assertFalse(specifiedAssociationOverride.isVirtual());
-
-
- virtualAssociationOverrides = javaEntity().virtualAssociationOverrides();
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address2", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
- assertFalse(virtualAssociationOverrides.hasNext());
- }
-
- public void testAddNamedQuery() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- NamedQuery namedQuery = entity.addNamedQuery(0);
- namedQuery.setName("FOO");
-
- ListIterator<NamedQueryAnnotation> javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("FOO", javaNamedQueries.next().getName());
-
- NamedQuery namedQuery2 = entity.addNamedQuery(0);
- namedQuery2.setName("BAR");
-
- javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", javaNamedQueries.next().getName());
- assertEquals("FOO", javaNamedQueries.next().getName());
-
- NamedQuery namedQuery3 = entity.addNamedQuery(1);
- namedQuery3.setName("BAZ");
-
- javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", javaNamedQueries.next().getName());
- assertEquals("BAZ", javaNamedQueries.next().getName());
- assertEquals("FOO", javaNamedQueries.next().getName());
-
- ListIterator<NamedQuery> namedQueries = entity.namedQueries();
- assertEquals(namedQuery2, namedQueries.next());
- assertEquals(namedQuery3, namedQueries.next());
- assertEquals(namedQuery, namedQueries.next());
-
- namedQueries = entity.namedQueries();
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
-
- entity.addNamedNativeQuery(0).setName("foo");
- }
-
- public void testRemoveNamedQuery() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- entity.addNamedQuery(0).setName("FOO");
- entity.addNamedQuery(1).setName("BAR");
- entity.addNamedQuery(2).setName("BAZ");
-
- ListIterator<NamedQueryAnnotation> javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- assertEquals(3, CollectionTools.size(javaNamedQueries));
-
- entity.removeNamedQuery(0);
- javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- assertEquals(2, CollectionTools.size(javaNamedQueries));
- javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", javaNamedQueries.next().getName());
- assertEquals("BAZ", javaNamedQueries.next().getName());
-
- entity.removeNamedQuery(0);
- javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- assertEquals(1, CollectionTools.size(javaNamedQueries));
- javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("BAZ", javaNamedQueries.next().getName());
-
- entity.removeNamedQuery(0);
- javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- assertEquals(0, CollectionTools.size(javaNamedQueries));
- }
-
- public void testAddNamedNativeQueryWithNamedQuery() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- entity.addNamedQuery(0).setName("FOO");
-
-
- NamedNativeQueryAnnotation nativeQuery = (NamedNativeQueryAnnotation) typeResource.addAnnotation(0, JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES);
- nativeQuery.setName("BAR");
-
- assertEquals(1, entity.namedNativeQueriesSize());
- assertEquals("BAR", entity.namedNativeQueries().next().getName());
- }
-
- public void testAddNamedQueryWithNamedNativeQuery() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- entity.addNamedNativeQuery(0).setName("FOO");
-
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.addAnnotation(0, JPA.NAMED_QUERY, JPA.NAMED_QUERIES);
- namedQuery.setName("BAR");
-
- assertEquals(1, entity.namedQueriesSize());
- assertEquals("BAR", entity.namedQueries().next().getName());
- }
-
- public void testMoveNamedQuery() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- entity.addNamedQuery(0).setName("FOO");
- entity.addNamedQuery(1).setName("BAR");
- entity.addNamedQuery(2).setName("BAZ");
-
- ListIterator<NamedQueryAnnotation> javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- assertEquals(3, CollectionTools.size(javaNamedQueries));
-
-
- entity.moveNamedQuery(2, 0);
- ListIterator<NamedQuery> namedQueries = entity.namedQueries();
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
-
- javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", javaNamedQueries.next().getName());
- assertEquals("BAZ", javaNamedQueries.next().getName());
- assertEquals("FOO", javaNamedQueries.next().getName());
-
-
- entity.moveNamedQuery(0, 1);
- namedQueries = entity.namedQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
-
- javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("BAZ", javaNamedQueries.next().getName());
- assertEquals("BAR", javaNamedQueries.next().getName());
- assertEquals("FOO", javaNamedQueries.next().getName());
- }
-
- public void testUpdateNamedQueries() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(0, CollectionTools.size(entity.getPersistenceUnit().allQueries()));
-
- ((NamedQueryAnnotation) typeResource.addAnnotation(0, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((NamedQueryAnnotation) typeResource.addAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((NamedQueryAnnotation) typeResource.addAnnotation(2, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("BAZ");
- ListIterator<NamedQuery> namedQueries = entity.namedQueries();
- assertEquals("FOO", namedQueries.next().getName());
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
- assertEquals(3, CollectionTools.size(entity.getPersistenceUnit().allQueries()));
-
- typeResource.move(2, 0, NamedQueriesAnnotation.ANNOTATION_NAME);
- namedQueries = entity.namedQueries();
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
-
- typeResource.move(0, 1, NamedQueriesAnnotation.ANNOTATION_NAME);
- namedQueries = entity.namedQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
-
- typeResource.removeAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- namedQueries = entity.namedQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
- assertEquals(2, CollectionTools.size(entity.getPersistenceUnit().allQueries()));
-
- typeResource.removeAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- namedQueries = entity.namedQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
- assertEquals(1, CollectionTools.size(entity.getPersistenceUnit().allQueries()));
-
- typeResource.removeAnnotation(0, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
- namedQueries = entity.namedQueries();
- assertFalse(namedQueries.hasNext());
- assertEquals(0, CollectionTools.size(entity.getPersistenceUnit().allQueries()));
- }
-
- public void testNamedQueriesSize() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(0, entity.namedQueriesSize());
-
- ((NamedQueryAnnotation) typeResource.addAnnotation(0, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((NamedQueryAnnotation) typeResource.addAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((NamedQueryAnnotation) typeResource.addAnnotation(2, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("BAZ");
-
- assertEquals(3, entity.namedQueriesSize());
- }
-
- public void testAddNamedNativeQuery() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- NamedNativeQuery namedNativeQuery = entity.addNamedNativeQuery(0);
- namedNativeQuery.setName("FOO");
-
- ListIterator<NamedNativeQueryAnnotation> javaNamedQueries = typeResource.annotations(NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("FOO", javaNamedQueries.next().getName());
-
- NamedNativeQuery namedNativeQuery2 = entity.addNamedNativeQuery(0);
- namedNativeQuery2.setName("BAR");
-
- javaNamedQueries = typeResource.annotations(NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", javaNamedQueries.next().getName());
- assertEquals("FOO", javaNamedQueries.next().getName());
-
- NamedNativeQuery namedNativeQuery3 = entity.addNamedNativeQuery(1);
- namedNativeQuery3.setName("BAZ");
-
- javaNamedQueries = typeResource.annotations(NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", javaNamedQueries.next().getName());
- assertEquals("BAZ", javaNamedQueries.next().getName());
- assertEquals("FOO", javaNamedQueries.next().getName());
-
- ListIterator<NamedNativeQuery> namedQueries = entity.namedNativeQueries();
- assertEquals(namedNativeQuery2, namedQueries.next());
- assertEquals(namedNativeQuery3, namedQueries.next());
- assertEquals(namedNativeQuery, namedQueries.next());
-
- namedQueries = entity.namedNativeQueries();
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- }
-
- public void testRemoveNamedNativeQuery() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- entity.addNamedNativeQuery(0).setName("FOO");
- entity.addNamedNativeQuery(1).setName("BAR");
- entity.addNamedNativeQuery(2).setName("BAZ");
-
- ListIterator<NamedNativeQueryAnnotation> javaNamedQueries = typeResource.annotations(NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- assertEquals(3, CollectionTools.size(javaNamedQueries));
-
- entity.removeNamedNativeQuery(0);
- javaNamedQueries = typeResource.annotations(NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- assertEquals(2, CollectionTools.size(javaNamedQueries));
- javaNamedQueries = typeResource.annotations(NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", javaNamedQueries.next().getName());
- assertEquals("BAZ", javaNamedQueries.next().getName());
-
- entity.removeNamedNativeQuery(0);
- javaNamedQueries = typeResource.annotations(NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- assertEquals(1, CollectionTools.size(javaNamedQueries));
- javaNamedQueries = typeResource.annotations(NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("BAZ", javaNamedQueries.next().getName());
-
- entity.removeNamedNativeQuery(0);
- javaNamedQueries = typeResource.annotations(NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- assertEquals(0, CollectionTools.size(javaNamedQueries));
- }
-
- public void testMoveNamedNativeQuery() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- entity.addNamedNativeQuery(0).setName("FOO");
- entity.addNamedNativeQuery(1).setName("BAR");
- entity.addNamedNativeQuery(2).setName("BAZ");
-
- ListIterator<NamedNativeQueryAnnotation> javaNamedQueries = typeResource.annotations(NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- assertEquals(3, CollectionTools.size(javaNamedQueries));
-
-
- entity.moveNamedNativeQuery(2, 0);
- ListIterator<NamedNativeQuery> namedQueries = entity.namedNativeQueries();
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
-
- javaNamedQueries = typeResource.annotations(NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", javaNamedQueries.next().getName());
- assertEquals("BAZ", javaNamedQueries.next().getName());
- assertEquals("FOO", javaNamedQueries.next().getName());
-
-
- entity.moveNamedNativeQuery(0, 1);
- namedQueries = entity.namedNativeQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
-
- javaNamedQueries = typeResource.annotations(NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- assertEquals("BAZ", javaNamedQueries.next().getName());
- assertEquals("BAR", javaNamedQueries.next().getName());
- assertEquals("FOO", javaNamedQueries.next().getName());
- }
-
- public void testUpdateNamedNativeQueries() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(0, CollectionTools.size(entity.getPersistenceUnit().allQueries()));
-
- ((NamedNativeQueryAnnotation) typeResource.addAnnotation(0, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((NamedNativeQueryAnnotation) typeResource.addAnnotation(1, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((NamedNativeQueryAnnotation) typeResource.addAnnotation(2, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME)).setName("BAZ");
- ListIterator<NamedNativeQuery> namedQueries = entity.namedNativeQueries();
- assertEquals("FOO", namedQueries.next().getName());
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
- assertEquals(3, CollectionTools.size(entity.getPersistenceUnit().allQueries()));
-
- typeResource.move(2, 0, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- namedQueries = entity.namedNativeQueries();
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
-
- typeResource.move(0, 1, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- namedQueries = entity.namedNativeQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
-
- typeResource.removeAnnotation(1, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- namedQueries = entity.namedNativeQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
- assertEquals(2, CollectionTools.size(entity.getPersistenceUnit().allQueries()));
-
- typeResource.removeAnnotation(1, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- namedQueries = entity.namedNativeQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
- assertEquals(1, CollectionTools.size(entity.getPersistenceUnit().allQueries()));
-
- typeResource.removeAnnotation(0, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME);
- namedQueries = entity.namedNativeQueries();
- assertFalse(namedQueries.hasNext());
- assertEquals(0, CollectionTools.size(entity.getPersistenceUnit().allQueries()));
- }
-
- public void testNamedNativeQueriesSize() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(0, entity.namedNativeQueriesSize());
-
- ((NamedNativeQueryAnnotation) typeResource.addAnnotation(0, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((NamedNativeQueryAnnotation) typeResource.addAnnotation(1, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((NamedNativeQueryAnnotation) typeResource.addAnnotation(2, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME)).setName("BAZ");
-
- assertEquals(3, entity.namedNativeQueriesSize());
- }
-
- public void testUpdateIdClass() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getIdClass());
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
-
- IdClassAnnotation idClass = (IdClassAnnotation) typeResource.addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- assertNull(javaEntity().getIdClass());
- assertNotNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
-
- idClass.setValue("model.Foo");
- assertEquals("model.Foo", javaEntity().getIdClass());
- assertEquals("model.Foo", ((IdClassAnnotation) typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME)).getValue());
-
- //test setting @IdClass value to null, IdClass annotation is removed
- idClass.setValue(null);
- assertNull(javaEntity().getIdClass());
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
-
- //reset @IdClass value and then remove @IdClass
- idClass = (IdClassAnnotation) typeResource.addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- idClass.setValue("model.Foo");
- typeResource.removeAnnotation(IdClassAnnotation.ANNOTATION_NAME);
-
- assertNull(javaEntity().getIdClass());
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifyIdClass() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getIdClass());
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
-
- javaEntity().setIdClass("model.Foo");
- assertEquals("model.Foo", ((IdClassAnnotation) typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME)).getValue());
- assertEquals("model.Foo", javaEntity().getIdClass());
-
- javaEntity().setIdClass(null);
- assertNull(javaEntity().getIdClass());
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaGeneratedValueTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaGeneratedValueTests.java
deleted file mode 100644
index 3c5e75c373..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaGeneratedValueTests.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.GeneratedValue;
-import org.eclipse.jpt.core.context.GenerationType;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaGeneratedValueTests extends ContextModelTestCase
-{
- private static final String GENERATOR = "MY_GENERATOR";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createGeneratedValueAnnotation() throws Exception{
- this.createAnnotationAndMembers("GeneratedValue",
- "GenerationType strategy() default;" +
- "String generator() default \"\"; ");
- }
-
- private IType createTestEntityWithGeneratedValue() throws Exception {
- createEntityAnnotation();
- createGeneratedValueAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.GENERATED_VALUE, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id").append(CR);
- sb.append("@GeneratedValue(generator=\"" + GENERATOR + "\")");
- }
- });
- }
-
- public JavaGeneratedValueTests(String name) {
- super(name);
- }
-
- public void testGetGenerator() throws Exception {
- createTestEntityWithGeneratedValue();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- assertEquals(GENERATOR, idMapping.getGeneratedValue().getGenerator());
-
- //change resource model sequenceGenerator name, verify the context model is updated
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE);
-
- generatedValue.setGenerator("foo");
-
- assertEquals("foo", idMapping.getGeneratedValue().getGenerator());
- }
-
- public void testSetSpecifiedGenerator() throws Exception {
- createTestEntityWithGeneratedValue();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- assertEquals(GENERATOR, idMapping.getGeneratedValue().getGenerator());
-
- idMapping.getGeneratedValue().setSpecifiedGenerator("foo");
-
- assertEquals("foo", idMapping.getGeneratedValue().getGenerator());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE);
-
- assertEquals("foo", generatedValue.getGenerator());
- }
-
- public void testSetSpecifiedNameNull() throws Exception {
- createTestEntityWithGeneratedValue();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- assertEquals(GENERATOR, idMapping.getGeneratedValue().getGenerator());
-
- idMapping.getGeneratedValue().setSpecifiedGenerator(null);
-
- assertNotNull(idMapping.getGeneratedValue());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE);
-
- assertNotNull(generatedValue);
- }
-
- public void testGetStrategy() throws Exception {
- createTestEntityWithGeneratedValue();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- assertEquals(GeneratedValue.DEFAULT_STRATEGY, idMapping.getGeneratedValue().getStrategy());
-
- //change resource model sequenceGenerator name, verify the context model is updated
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE);
-
- generatedValue.setStrategy(org.eclipse.jpt.core.resource.java.GenerationType.IDENTITY);
-
- assertEquals(GenerationType.IDENTITY, idMapping.getGeneratedValue().getStrategy());
- assertEquals(GeneratedValue.DEFAULT_STRATEGY, idMapping.getGeneratedValue().getDefaultStrategy());
- }
-
- public void testSetSpecifiedStrategy() throws Exception {
- createTestEntityWithGeneratedValue();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- assertEquals(GeneratedValue.DEFAULT_STRATEGY, idMapping.getGeneratedValue().getStrategy());
-
- idMapping.getGeneratedValue().setSpecifiedStrategy(GenerationType.IDENTITY);
-
- assertEquals(GenerationType.IDENTITY, idMapping.getGeneratedValue().getStrategy());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE);
-
- assertEquals(org.eclipse.jpt.core.resource.java.GenerationType.IDENTITY, generatedValue.getStrategy());
-
- idMapping.getGeneratedValue().setSpecifiedStrategy(null);
-
- assertEquals(GeneratedValue.DEFAULT_STRATEGY, idMapping.getGeneratedValue().getStrategy());
- generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE);
- assertNotNull(generatedValue);
- assertNull(generatedValue.getStrategy());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaIdMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaIdMappingTests.java
deleted file mode 100644
index 4353f16716..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaIdMappingTests.java
+++ /dev/null
@@ -1,730 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.TemporalType;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation;
-import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation;
-import org.eclipse.jpt.core.resource.java.TemporalAnnotation;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaIdMappingTests extends ContextModelTestCase
-{
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception{
- this.createAnnotationAndMembers("Id", "");
- }
-
- private void createGeneratedValueAnnotation() throws Exception{
- this.createAnnotationAndMembers("GeneratedValue", "");
- }
-
- private void createTemporalAnnotation() throws Exception{
- this.createAnnotationAndMembers("Temporal", "TemporalType value();");
- }
-
- private IType createTestEntityWithIdMapping() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithTemporal() throws Exception {
- createEntityAnnotation();
- createTemporalAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.TEMPORAL, JPA.TEMPORAL_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id").append(CR);
- sb.append("@Temporal(TemporalType.TIMESTAMP)").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithIdMappingGeneratedValue() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
- createGeneratedValueAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.GENERATED_VALUE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id").append(CR);
- sb.append("@GeneratedValue").append(CR);
- }
- });
- }
-
- public JavaIdMappingTests(String name) {
- super(name);
- }
-
- public void testMorphToBasicMapping() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- idMapping.addGeneratedValue();
- idMapping.addTableGenerator();
- idMapping.addSequenceGenerator();
- assertFalse(idMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertEquals("FOO", ((BasicMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
- assertEquals(TemporalType.TIME, ((BasicMapping) persistentAttribute.getMapping()).getTemporal());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToDefault() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- idMapping.addGeneratedValue();
- idMapping.addTableGenerator();
- idMapping.addSequenceGenerator();
- assertFalse(idMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertEquals("FOO", ((BasicMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
- assertEquals(TemporalType.TIME, ((BasicMapping) persistentAttribute.getMapping()).getTemporal());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToVersionMapping() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- idMapping.addGeneratedValue();
- idMapping.addTableGenerator();
- idMapping.addSequenceGenerator();
- assertFalse(idMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertEquals("FOO", ((VersionMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
- assertEquals(TemporalType.TIME, ((VersionMapping) persistentAttribute.getMapping()).getTemporal());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedMapping() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- idMapping.addGeneratedValue();
- idMapping.addTableGenerator();
- idMapping.addSequenceGenerator();
- assertFalse(idMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToTransientMapping() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- idMapping.addGeneratedValue();
- idMapping.addTableGenerator();
- idMapping.addSequenceGenerator();
- assertFalse(idMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- idMapping.addGeneratedValue();
- idMapping.addTableGenerator();
- idMapping.addSequenceGenerator();
- assertFalse(idMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToOneMapping() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- idMapping.addGeneratedValue();
- idMapping.addTableGenerator();
- idMapping.addSequenceGenerator();
- assertFalse(idMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToManyMapping() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- idMapping.addGeneratedValue();
- idMapping.addTableGenerator();
- idMapping.addSequenceGenerator();
- assertFalse(idMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToOneMapping() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- idMapping.addGeneratedValue();
- idMapping.addTableGenerator();
- idMapping.addSequenceGenerator();
- assertFalse(idMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToManyMapping() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- idMapping.addGeneratedValue();
- idMapping.addTableGenerator();
- idMapping.addSequenceGenerator();
- assertFalse(idMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
- }
-
- public void testGetTemporal() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(idMapping.getTemporal());
- }
-
- public void testGetTemporal2() throws Exception {
- createTestEntityWithTemporal();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
-
- assertEquals(TemporalType.TIMESTAMP, idMapping.getTemporal());
- }
-
- public void testSetTemporal() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
- assertNull(idMapping.getTemporal());
-
- idMapping.setTemporal(TemporalType.TIME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.core.resource.java.TemporalType.TIME, temporal.getValue());
-
- idMapping.setTemporal(null);
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testGetTemporalUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(idMapping.getTemporal());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.addAnnotation(TemporalAnnotation.ANNOTATION_NAME);
- temporal.setValue(org.eclipse.jpt.core.resource.java.TemporalType.DATE);
-
- assertEquals(TemporalType.DATE, idMapping.getTemporal());
-
- attributeResource.removeAnnotation(TemporalAnnotation.ANNOTATION_NAME);
-
- assertNull(idMapping.getTemporal());
- assertFalse(idMapping.isDefault());
- assertSame(idMapping, persistentAttribute.getSpecifiedMapping());
- }
-
- public void testGetColumn() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(idMapping.getColumn().getSpecifiedName());
- assertEquals("id", idMapping.getColumn().getName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
- column.setName("foo");
-
- assertEquals("foo", idMapping.getColumn().getSpecifiedName());
- assertEquals("foo", idMapping.getColumn().getName());
- assertEquals("id", idMapping.getColumn().getDefaultName());
- }
-
- public void testGetSequenceGenerator() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
- assertNull(idMapping.getSequenceGenerator());
- assertEquals(0, CollectionTools.size(idMapping.getPersistenceUnit().allGenerators()));
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(JPA.SEQUENCE_GENERATOR);
- assertNotNull(idMapping.getSequenceGenerator());
- assertEquals(1, attributeResource.annotationsSize());
- assertEquals(1, CollectionTools.size(idMapping.getPersistenceUnit().allGenerators()));
-
- idMapping.getSequenceGenerator().setName("foo");
- assertEquals(1, CollectionTools.size(idMapping.getPersistenceUnit().allGenerators()));
- }
-
- public void testAddSequenceGenerator() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(idMapping.getSequenceGenerator());
-
- idMapping.addSequenceGenerator();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertNotNull(attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR));
- assertNotNull(idMapping.getSequenceGenerator());
-
- //try adding another sequence generator, should get an IllegalStateException
- try {
- idMapping.addSequenceGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testRemoveSequenceGenerator() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(JPA.SEQUENCE_GENERATOR);
-
-
- idMapping.removeSequenceGenerator();
-
- assertNull(idMapping.getSequenceGenerator());
- assertNull(attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR));
-
- //try removing the sequence generator again, should get an IllegalStateException
- try {
- idMapping.removeSequenceGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testGetTableGenerator() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
- assertNull(idMapping.getTableGenerator());
- assertEquals(0, CollectionTools.size(idMapping.getPersistenceUnit().allGenerators()));
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(JPA.TABLE_GENERATOR);
- assertNotNull(idMapping.getTableGenerator());
- assertEquals(1, attributeResource.annotationsSize());
- assertEquals(1, CollectionTools.size(idMapping.getPersistenceUnit().allGenerators()));
-
- idMapping.getTableGenerator().setName("foo");
- assertEquals(1, CollectionTools.size(idMapping.getPersistenceUnit().allGenerators()));
- }
-
- public void testAddTableGenerator() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(idMapping.getTableGenerator());
-
- idMapping.addTableGenerator();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertNotNull(attributeResource.getAnnotation(JPA.TABLE_GENERATOR));
- assertNotNull(idMapping.getTableGenerator());
-
- //try adding another table generator, should get an IllegalStateException
- try {
- idMapping.addTableGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testRemoveTableGenerator() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(JPA.TABLE_GENERATOR);
-
-
- idMapping.removeTableGenerator();
-
- assertNull(idMapping.getTableGenerator());
- assertNull(attributeResource.getAnnotation(JPA.TABLE_GENERATOR));
-
- //try removing the table generator again, should get an IllegalStateException
- try {
- idMapping.removeTableGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testGetGeneratedValue() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(idMapping.getGeneratedValue());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(JPA.GENERATED_VALUE);
-
- assertNotNull(idMapping.getGeneratedValue());
- assertEquals(1, attributeResource.annotationsSize());
- }
-
- public void testGetGeneratedValue2() throws Exception {
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- createTestEntityWithIdMappingGeneratedValue();
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertNotNull(idMapping.getGeneratedValue());
- assertEquals(1, attributeResource.annotationsSize());
- }
-
- public void testAddGeneratedValue() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(idMapping.getGeneratedValue());
-
- idMapping.addGeneratedValue();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertNotNull(attributeResource.getAnnotation(JPA.GENERATED_VALUE));
- assertNotNull(idMapping.getGeneratedValue());
-
- //try adding another generated value, should get an IllegalStateException
- try {
- idMapping.addGeneratedValue();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testRemoveGeneratedValue() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.addAnnotation(JPA.GENERATED_VALUE);
-
-
- idMapping.removeGeneratedValue();
-
- assertNull(idMapping.getGeneratedValue());
- assertNull(attributeResource.getAnnotation(JPA.GENERATED_VALUE));
-
- //try removing the generatedValue again, should get an IllegalStateException
- try {
- idMapping.removeGeneratedValue();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java
deleted file mode 100644
index c43524f623..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java
+++ /dev/null
@@ -1,541 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaOneToOneMapping;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaJoinColumnTests extends ContextModelTestCase
-{
- public JavaJoinColumnTests(String name) {
- super(name);
- }
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createOneToOneAnnotation() throws Exception{
- this.createAnnotationAndMembers("OneToOne", "");
- }
-
- private void createJoinColumnAnnotation() throws Exception{
- this.createAnnotationAndMembers("JoinColumn",
- "String name() default \"\"; " +
- "String referencedColumnName() default \"\"; " +
- "boolean unique() default false; " +
- "boolean nullable() default true; " +
- "boolean insertable() default true; " +
- "boolean updatable() default true; " +
- "String columnDefinition() default \"\"; " +
- "String table() default \"\";");
- }
-
-
- private IType createTestEntityWithOneToOne() throws Exception {
- createEntityAnnotation();
- createOneToOneAnnotation();
- createJoinColumnAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithValidOneToOne() throws Exception {
- createEntityAnnotation();
- createOneToOneAnnotation();
- createJoinColumnAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne").append(CR);
- sb.append(" private Project project;").append(CR);
- }
- });
- }
-
- private IType createTargetEntity() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class Project {").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int proj_id;").append(CR);
- sb.append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "Project.java", sourceWriter);
- }
-
- public void testUpdateSpecifiedName() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
-
- assertEquals(0, oneToOneMapping.specifiedJoinColumnsSize());
- assertNull(javaJoinColumn);
-
-
- //set name in the resource model, verify context model updated
- javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- javaJoinColumn.setName("FOO");
- JavaJoinColumn joinColumn = oneToOneMapping.specifiedJoinColumns().next();
- assertEquals("FOO", joinColumn.getSpecifiedName());
- assertEquals("FOO", javaJoinColumn.getName());
-
- //set name to null in the resource model, annotation removed, specified join column removed
- javaJoinColumn.setName(null);
- assertEquals(0, oneToOneMapping.specifiedJoinColumnsSize());
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifySpecifiedName() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
-
- JavaJoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- //set name in the context model, verify resource model modified
- joinColumn.setSpecifiedName("foo");
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- assertEquals("foo", joinColumn.getSpecifiedName());
- assertEquals("foo", javaJoinColumn.getName());
-
- //set name to null in the context model
- joinColumn.setSpecifiedName(null);
- assertNull(joinColumn.getSpecifiedName());
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- // <attribute name>_<referenced column name>
- // or
- // <target entity name>_<referenced column name>
- public void testDefaultName() throws Exception {
- createTestEntityWithValidOneToOne();
- createTargetEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
- JavaJoinColumn defaultJavaJoinColumn = oneToOneMapping.getDefaultJoinColumn();
-
- assertNull(defaultJavaJoinColumn.getDefaultName());
-//TODO test default join column name
-// //add target entity to the persistence unit, now join table name is [table name]_[target table name]
-// addXmlClassRef(PACKAGE_NAME + ".Project");
-// assertEquals(TYPE_NAME + "_Project", joinTable.getDefaultName());
-//
-// JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
-// JavaPersistentAttributeResource attributeResource = typeResource.attributes().next();
-// assertNull(attributeResource.annotation(JoinTable.ANNOTATION_NAME));
-//
-// //target entity does not resolve, default name is null
-// manyToManyMapping.setSpecifiedTargetEntity("Foo");
-// assertNull(joinTable.getDefaultName());
-//
-// //default target entity does resolve, so default name is again [table name]_[target table name]
-// manyToManyMapping.setSpecifiedTargetEntity(null);
-// assertEquals(TYPE_NAME + "_Project", joinTable.getDefaultName());
-//
-// //add the join table annotation, verify default join table name is the same
-// attributeResource.addAnnotation(JoinTable.ANNOTATION_NAME);
-// assertEquals(TYPE_NAME + "_Project", joinTable.getDefaultName());
-// assertNotNull(attributeResource.annotation(JoinTable.ANNOTATION_NAME));
-//
-// //set a table on the target entity, very default join table name updates
-// manyToManyMapping.getResolvedTargetEntity().getTable().setSpecifiedName("FOO");
-// assertEquals(TYPE_NAME + "_FOO", joinTable.getDefaultName());
-//
-// //set a table on the owning entity, very default join table name updates
-// javaEntity().getTable().setSpecifiedName("BAR");
-// assertEquals("BAR_FOO", joinTable.getDefaultName());
- }
-
- public void testUpdateSpecifiedReferencedColumnName() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
-
- assertEquals(0, oneToOneMapping.specifiedJoinColumnsSize());
- assertNull(javaJoinColumn);
-
-
- //set referenced column name in the resource model, verify context model updated
- javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- javaJoinColumn.setName("FOO");
- javaJoinColumn.setReferencedColumnName("BAR");
- JavaJoinColumn joinColumn = oneToOneMapping.specifiedJoinColumns().next();
- assertEquals("BAR", joinColumn.getSpecifiedReferencedColumnName());
- assertEquals("BAR", javaJoinColumn.getReferencedColumnName());
-
- //set referenced column name to null in the resource model,
- javaJoinColumn.setReferencedColumnName(null);
- assertNull(joinColumn.getSpecifiedReferencedColumnName());
- assertNull("BAR", javaJoinColumn.getReferencedColumnName());
- }
-
- public void testModifySpecifiedReferencedColumnName() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
-
- JavaJoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- //set referenced column name in the context model, verify resource model modified
- joinColumn.setSpecifiedName("foo");
- joinColumn.setSpecifiedReferencedColumnName("BAR");
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", joinColumn.getSpecifiedReferencedColumnName());
- assertEquals("BAR", javaJoinColumn.getReferencedColumnName());
-
- //set referenced column name to null in the context model
- joinColumn.setSpecifiedReferencedColumnName(null);
- assertNull(joinColumn.getSpecifiedReferencedColumnName());
- assertNull(javaJoinColumn.getReferencedColumnName());
- }
-
- public void testDefaultReferencedColumnName() throws Exception {
- //TODO test default join column referenced column name
-
- }
-
- public void testUpdateTable() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
-
- assertEquals(0, oneToOneMapping.specifiedJoinColumnsSize());
- assertNull(javaJoinColumn);
-
-
- //set table in the resource model, verify context model updated
- javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- javaJoinColumn.setName("FOO");
- javaJoinColumn.setTable("BAR");
- JavaJoinColumn joinColumn = oneToOneMapping.specifiedJoinColumns().next();
- assertEquals("BAR", joinColumn.getSpecifiedTable());
- assertEquals("BAR", javaJoinColumn.getTable());
-
- //set table to null in the resource model,
- javaJoinColumn.setTable(null);
- assertNull(joinColumn.getSpecifiedTable());
- assertNull("BAR", javaJoinColumn.getTable());
- }
-
- public void testModifyTable() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
-
- JavaJoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- //set table in the context model, verify resource model modified
- joinColumn.setSpecifiedName("foo");
- joinColumn.setSpecifiedTable("BAR");
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", joinColumn.getSpecifiedTable());
- assertEquals("BAR", javaJoinColumn.getTable());
-
- //set table to null in the context model
- joinColumn.setSpecifiedTable(null);
- assertNull(joinColumn.getSpecifiedTable());
- assertNull(javaJoinColumn.getTable());
- }
-
- public void testDefaultTable() throws Exception {
- //TODO test default join column table
-
- }
-
- public void testUpdateUnique() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
-
- assertEquals(0, oneToOneMapping.specifiedJoinColumnsSize());
- assertNull(javaJoinColumn);
-
-
- //set unique in the resource model, verify context model updated
- javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- javaJoinColumn.setName("FOO");
- javaJoinColumn.setUnique(Boolean.TRUE);
- JavaJoinColumn joinColumn = oneToOneMapping.specifiedJoinColumns().next();
- assertEquals(Boolean.TRUE, joinColumn.getSpecifiedUnique());
- assertEquals(Boolean.TRUE, javaJoinColumn.getUnique());
-
- //set unique to null in the resource model,
- javaJoinColumn.setUnique(null);
- assertNull(joinColumn.getSpecifiedUnique());
- assertNull(javaJoinColumn.getUnique());
- }
-
- public void testModifyUnique() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
-
- JavaJoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- //set unique in the context model, verify resource model modified
- joinColumn.setSpecifiedName("foo");
- joinColumn.setSpecifiedUnique(Boolean.TRUE);
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- assertEquals(Boolean.TRUE, joinColumn.getSpecifiedUnique());
- assertEquals(Boolean.TRUE, javaJoinColumn.getUnique());
-
- //set unique to null in the context model
- joinColumn.setSpecifiedUnique(null);
- assertNull(joinColumn.getSpecifiedUnique());
- assertNull(javaJoinColumn.getUnique());
- }
-
- public void testUpdateNullable() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
-
- assertEquals(0, oneToOneMapping.specifiedJoinColumnsSize());
- assertNull(javaJoinColumn);
-
-
- //set nullable in the resource model, verify context model updated
- javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- javaJoinColumn.setName("FOO");
- javaJoinColumn.setNullable(Boolean.FALSE);
- JavaJoinColumn joinColumn = oneToOneMapping.specifiedJoinColumns().next();
- assertEquals(Boolean.FALSE, joinColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, javaJoinColumn.getNullable());
-
- //set nullable to null in the resource model,
- javaJoinColumn.setNullable(null);
- assertNull(joinColumn.getSpecifiedNullable());
- assertNull(javaJoinColumn.getNullable());
- }
-
- public void testModifyNullable() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
-
- JavaJoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- //set nullable in the context model, verify resource model modified
- joinColumn.setSpecifiedName("foo");
- joinColumn.setSpecifiedNullable(Boolean.FALSE);
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- assertEquals(Boolean.FALSE, joinColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, javaJoinColumn.getNullable());
-
- //set nullable to null in the context model
- joinColumn.setSpecifiedNullable(null);
- assertNull(joinColumn.getSpecifiedNullable());
- assertNull(javaJoinColumn.getNullable());
- }
-
- public void testUpdateInsertable() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
-
- assertEquals(0, oneToOneMapping.specifiedJoinColumnsSize());
- assertNull(javaJoinColumn);
-
-
- //set insertable in the resource model, verify context model updated
- javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- javaJoinColumn.setName("FOO");
- javaJoinColumn.setInsertable(Boolean.FALSE);
- JavaJoinColumn joinColumn = oneToOneMapping.specifiedJoinColumns().next();
- assertEquals(Boolean.FALSE, joinColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, javaJoinColumn.getInsertable());
-
- //set insertable to null in the resource model,
- javaJoinColumn.setInsertable(null);
- assertNull(joinColumn.getSpecifiedInsertable());
- assertNull(javaJoinColumn.getInsertable());
- }
-
- public void testModifyInsertable() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
-
- JavaJoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- //set insertable in the context model, verify resource model modified
- joinColumn.setSpecifiedName("foo");
- joinColumn.setSpecifiedInsertable(Boolean.FALSE);
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- assertEquals(Boolean.FALSE, joinColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, javaJoinColumn.getInsertable());
-
- //set insertable to null in the context model
- joinColumn.setSpecifiedInsertable(null);
- assertNull(joinColumn.getSpecifiedInsertable());
- assertNull(javaJoinColumn.getInsertable());
- }
-
- public void testUpdateUpdatable() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
-
- assertEquals(0, oneToOneMapping.specifiedJoinColumnsSize());
- assertNull(javaJoinColumn);
-
-
- //set updatable in the resource model, verify context model updated
- javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- javaJoinColumn.setName("FOO");
- javaJoinColumn.setUpdatable(Boolean.FALSE);
- JavaJoinColumn joinColumn = oneToOneMapping.specifiedJoinColumns().next();
- assertEquals(Boolean.FALSE, joinColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.FALSE, javaJoinColumn.getUpdatable());
-
- //set updatable to null in the resource model,
- javaJoinColumn.setUpdatable(null);
- assertNull(joinColumn.getSpecifiedUpdatable());
- assertNull(javaJoinColumn.getUpdatable());
- }
-
- public void testModifyUpdatable() throws Exception {
- createTestEntityWithOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
-
- JavaJoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- //set updatable in the context model, verify resource model modified
- joinColumn.setSpecifiedName("foo");
- joinColumn.setSpecifiedUpdatable(Boolean.FALSE);
-
- JoinColumnAnnotation javaJoinColumn = (JoinColumnAnnotation) attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
- assertEquals(Boolean.FALSE, joinColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.FALSE, javaJoinColumn.getUpdatable());
-
- //set updatable to null in the context model
- joinColumn.setSpecifiedUpdatable(null);
- assertNull(joinColumn.getSpecifiedUpdatable());
- assertNull(javaJoinColumn.getUpdatable());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java
deleted file mode 100644
index bf23e9e2d0..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java
+++ /dev/null
@@ -1,1000 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.UniqueConstraint;
-import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
-import org.eclipse.jpt.core.context.java.JavaUniqueConstraint;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaJoinTableTests extends ContextModelTestCase
-{
- public JavaJoinTableTests(String name) {
- super(name);
- }
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createManyToManyAnnotation() throws Exception{
- this.createAnnotationAndMembers("ManyToMany", "");
- }
-
- private void createJoinTableAnnotation() throws Exception{
- //TODO
- this.createAnnotationAndMembers("JoinTable",
- "String name() default \"\"; " +
- "String catalog() default \"\"; " +
- "String schema() default \"\";");
- }
-
- private void createUniqueConstraintAnnotation() throws Exception{
- this.createAnnotationAndMembers("UniqueConstraint",
- "String[] columnNames(); ");
- }
-
- private IType createTestEntityWithManyToMany() throws Exception {
- createEntityAnnotation();
- createManyToManyAnnotation();
- createJoinTableAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithValidManyToMany() throws Exception {
- createEntityAnnotation();
- createManyToManyAnnotation();
- createJoinTableAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany").append(CR);
- sb.append(" private Collection<Project> projects;").append(CR);
- }
- });
- }
-
- private IType createTargetEntity() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class Project {").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int proj_id;").append(CR);
- sb.append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "Project.java", sourceWriter);
- }
- public void testUpdateSpecifiedName() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinTableAnnotation javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- assertNull(joinTable.getSpecifiedName());
- assertNull(javaJoinTable);
-
-
- //set name in the resource model, verify context model updated
- attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- javaJoinTable.setName("FOO");
- assertEquals("FOO", joinTable.getSpecifiedName());
- assertEquals("FOO", javaJoinTable.getName());
-
- //set name to null in the resource model
- javaJoinTable.setName(null);
- assertNull(joinTable.getSpecifiedName());
- assertNull(javaJoinTable.getName());
-
- javaJoinTable.setName("FOO");
- assertEquals("FOO", joinTable.getSpecifiedName());
- assertEquals("FOO", javaJoinTable.getName());
-
- attributeResource.removeAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- assertNull(joinTable.getSpecifiedName());
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifySpecifiedName() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinTableAnnotation javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- assertNull(joinTable.getSpecifiedName());
- assertNull(javaJoinTable);
-
- //set name in the context model, verify resource model modified
- joinTable.setSpecifiedName("foo");
- javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- assertEquals("foo", joinTable.getSpecifiedName());
- assertEquals("foo", javaJoinTable.getName());
-
- //set name to null in the context model
- joinTable.setSpecifiedName(null);
- assertNull(joinTable.getSpecifiedName());
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- }
-
- public void testDefaultName() throws Exception {
- createTestEntityWithValidManyToMany();
- createTargetEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- //joinTable default name is null because targetEntity is not in the persistence unit
- assertNull(joinTable.getDefaultName());
-
- //add target entity to the persistence unit, now join table name is [table name]_[target table name]
- addXmlClassRef(PACKAGE_NAME + ".Project");
- assertEquals(TYPE_NAME + "_Project", joinTable.getDefaultName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
-
- //target entity does not resolve, default name is null
- manyToManyMapping.setSpecifiedTargetEntity("Foo");
- assertNull(joinTable.getDefaultName());
-
- //default target entity does resolve, so default name is again [table name]_[target table name]
- manyToManyMapping.setSpecifiedTargetEntity(null);
- assertEquals(TYPE_NAME + "_Project", joinTable.getDefaultName());
-
- //add the join table annotation, verify default join table name is the same
- attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- assertEquals(TYPE_NAME + "_Project", joinTable.getDefaultName());
- assertNotNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
-
- //set a table on the target entity, very default join table name updates
- manyToManyMapping.getResolvedTargetEntity().getTable().setSpecifiedName("FOO");
- assertEquals(TYPE_NAME + "_FOO", joinTable.getDefaultName());
-
- //set a table on the owning entity, very default join table name updates
- javaEntity().getTable().setSpecifiedName("BAR");
- assertEquals("BAR_FOO", joinTable.getDefaultName());
- }
-
- public void testUpdateSpecifiedSchema() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinTableAnnotation javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- assertNull(joinTable.getSpecifiedSchema());
- assertNull(javaJoinTable);
-
-
- //set schema in the resource model, verify context model updated
- attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- javaJoinTable.setSchema("FOO");
- assertEquals("FOO", joinTable.getSpecifiedSchema());
- assertEquals("FOO", javaJoinTable.getSchema());
-
- //set schema to null in the resource model
- javaJoinTable.setSchema(null);
- assertNull(joinTable.getSpecifiedSchema());
- assertNull(javaJoinTable.getSchema());
-
- javaJoinTable.setSchema("FOO");
- assertEquals("FOO", joinTable.getSpecifiedSchema());
- assertEquals("FOO", javaJoinTable.getSchema());
-
- attributeResource.removeAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- assertNull(joinTable.getSpecifiedSchema());
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifySpecifiedSchema() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinTableAnnotation javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- assertNull(joinTable.getSpecifiedSchema());
- assertNull(javaJoinTable);
-
- //set schema in the context model, verify resource model modified
- joinTable.setSpecifiedSchema("foo");
- javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- assertEquals("foo", joinTable.getSpecifiedSchema());
- assertEquals("foo", javaJoinTable.getSchema());
-
- //set schema to null in the context model
- joinTable.setSpecifiedSchema(null);
- assertNull(joinTable.getSpecifiedSchema());
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- }
-
- public void testUpdateSpecifiedCatalog() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinTableAnnotation javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- assertNull(joinTable.getSpecifiedCatalog());
- assertNull(javaJoinTable);
-
-
- //set catalog in the resource model, verify context model updated
- attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- javaJoinTable.setCatalog("FOO");
- assertEquals("FOO", joinTable.getSpecifiedCatalog());
- assertEquals("FOO", javaJoinTable.getCatalog());
-
- //set catalog to null in the resource model
- javaJoinTable.setCatalog(null);
- assertNull(joinTable.getSpecifiedCatalog());
- assertNull(javaJoinTable.getCatalog());
-
- javaJoinTable.setCatalog("FOO");
- assertEquals("FOO", joinTable.getSpecifiedCatalog());
- assertEquals("FOO", javaJoinTable.getCatalog());
-
- attributeResource.removeAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- assertNull(joinTable.getSpecifiedCatalog());
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifySpecifiedCatalog() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinTableAnnotation javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- assertNull(joinTable.getSpecifiedCatalog());
- assertNull(javaJoinTable);
-
- //set catalog in the context model, verify resource model modified
- joinTable.setSpecifiedCatalog("foo");
- javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- assertEquals("foo", joinTable.getSpecifiedCatalog());
- assertEquals("foo", javaJoinTable.getCatalog());
-
- //set catalog to null in the context model
- joinTable.setSpecifiedCatalog(null);
- assertNull(joinTable.getSpecifiedCatalog());
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- }
-
- public void testAddSpecifiedJoinColumn() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
-
- JoinColumn joinColumn = joinTable.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("FOO");
-
- JoinTableAnnotation joinTableResource = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- assertEquals("FOO", joinTableResource.joinColumnAt(0).getName());
-
- JoinColumn joinColumn2 = joinTable.addSpecifiedJoinColumn(0);
- joinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", joinTableResource.joinColumnAt(0).getName());
- assertEquals("FOO", joinTableResource.joinColumnAt(1).getName());
-
- JoinColumn joinColumn3 = joinTable.addSpecifiedJoinColumn(1);
- joinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", joinTableResource.joinColumnAt(0).getName());
- assertEquals("BAZ", joinTableResource.joinColumnAt(1).getName());
- assertEquals("FOO", joinTableResource.joinColumnAt(2).getName());
-
- ListIterator<JoinColumn> joinColumns = joinTable.specifiedJoinColumns();
- assertEquals(joinColumn2, joinColumns.next());
- assertEquals(joinColumn3, joinColumns.next());
- assertEquals(joinColumn, joinColumns.next());
-
- joinColumns = joinTable.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- }
-
- public void testRemoveSpecifiedJoinColumn() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- joinTable.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- joinTable.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- joinTable.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- JoinTableAnnotation joinTableResource = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- assertEquals(3, joinTableResource.joinColumnsSize());
-
- joinTable.removeSpecifiedJoinColumn(0);
- assertEquals(2, joinTableResource.joinColumnsSize());
- assertEquals("BAR", joinTableResource.joinColumnAt(0).getName());
- assertEquals("BAZ", joinTableResource.joinColumnAt(1).getName());
-
- joinTable.removeSpecifiedJoinColumn(0);
- assertEquals(1, joinTableResource.joinColumnsSize());
- assertEquals("BAZ", joinTableResource.joinColumnAt(0).getName());
-
- joinTable.removeSpecifiedJoinColumn(0);
- assertEquals(0, joinTableResource.joinColumnsSize());
- }
-
- public void testMoveSpecifiedJoinColumn() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- joinTable.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- joinTable.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- joinTable.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- JoinTableAnnotation joinTableResource = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- assertEquals(3, joinTableResource.joinColumnsSize());
-
-
- joinTable.moveSpecifiedJoinColumn(2, 0);
- ListIterator<JoinColumn> joinColumns = joinTable.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAR", joinTableResource.joinColumnAt(0).getName());
- assertEquals("BAZ", joinTableResource.joinColumnAt(1).getName());
- assertEquals("FOO", joinTableResource.joinColumnAt(2).getName());
-
-
- joinTable.moveSpecifiedJoinColumn(0, 1);
- joinColumns = joinTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAZ", joinTableResource.joinColumnAt(0).getName());
- assertEquals("BAR", joinTableResource.joinColumnAt(1).getName());
- assertEquals("FOO", joinTableResource.joinColumnAt(2).getName());
- }
-
- public void testUpdateJoinColumns() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinTableAnnotation joinTableResource = (JoinTableAnnotation) attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- joinTableResource.addJoinColumn(0);
- joinTableResource.addJoinColumn(1);
- joinTableResource.addJoinColumn(2);
-
- joinTableResource.joinColumnAt(0).setName("FOO");
- joinTableResource.joinColumnAt(1).setName("BAR");
- joinTableResource.joinColumnAt(2).setName("BAZ");
-
- ListIterator<JoinColumn> joinColumns = joinTable.specifiedJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.moveJoinColumn(2, 0);
- joinColumns = joinTable.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.moveJoinColumn(0, 1);
- joinColumns = joinTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.removeJoinColumn(1);
- joinColumns = joinTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.removeJoinColumn(1);
- joinColumns = joinTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.removeJoinColumn(0);
- assertFalse(joinTable.specifiedJoinColumns().hasNext());
- }
-
- public void testGetDefaultJoinColumn() {
- //TODO
- }
-
- public void testSpecifiedJoinColumnsSize() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- assertEquals(0, joinTable.specifiedJoinColumnsSize());
-
- joinTable.addSpecifiedJoinColumn(0);
- assertEquals(1, joinTable.specifiedJoinColumnsSize());
-
- joinTable.removeSpecifiedJoinColumn(0);
- assertEquals(0, joinTable.specifiedJoinColumnsSize());
- }
-
- public void testJoinColumnsSize() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- assertEquals(1, joinTable.joinColumnsSize());
-
- joinTable.addSpecifiedJoinColumn(0);
- assertEquals(1, joinTable.joinColumnsSize());
-
- joinTable.addSpecifiedJoinColumn(0);
- assertEquals(2, joinTable.joinColumnsSize());
-
- joinTable.removeSpecifiedJoinColumn(0);
- joinTable.removeSpecifiedJoinColumn(0);
- assertEquals(1, joinTable.joinColumnsSize());
-
- //if non-owning side of the relationship then no default join column
- manyToManyMapping.setMappedBy("foo");
- assertEquals(0, joinTable.joinColumnsSize());
- }
-
- public void testAddSpecifiedInverseJoinColumn() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
-
- JoinColumn inverseJoinColumn = joinTable.addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("FOO");
-
- JoinTableAnnotation joinTableResource = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- assertEquals("FOO", joinTableResource.inverseJoinColumnAt(0).getName());
-
- JoinColumn inverseJoinColumn2 = joinTable.addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", joinTableResource.inverseJoinColumnAt(0).getName());
- assertEquals("FOO", joinTableResource.inverseJoinColumnAt(1).getName());
-
- JoinColumn inverseJoinColumn3 = joinTable.addSpecifiedInverseJoinColumn(1);
- inverseJoinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", joinTableResource.inverseJoinColumnAt(0).getName());
- assertEquals("BAZ", joinTableResource.inverseJoinColumnAt(1).getName());
- assertEquals("FOO", joinTableResource.inverseJoinColumnAt(2).getName());
-
- ListIterator<JoinColumn> inverseJoinColumns = joinTable.specifiedInverseJoinColumns();
- assertEquals(inverseJoinColumn2, inverseJoinColumns.next());
- assertEquals(inverseJoinColumn3, inverseJoinColumns.next());
- assertEquals(inverseJoinColumn, inverseJoinColumns.next());
-
- inverseJoinColumns = joinTable.specifiedInverseJoinColumns();
- assertEquals("BAR", inverseJoinColumns.next().getName());
- assertEquals("BAZ", inverseJoinColumns.next().getName());
- assertEquals("FOO", inverseJoinColumns.next().getName());
- }
-
- public void testRemoveSpecifiedInverseJoinColumn() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- joinTable.addSpecifiedInverseJoinColumn(0).setSpecifiedName("FOO");
- joinTable.addSpecifiedInverseJoinColumn(1).setSpecifiedName("BAR");
- joinTable.addSpecifiedInverseJoinColumn(2).setSpecifiedName("BAZ");
-
- JoinTableAnnotation joinTableResource = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- assertEquals(3, joinTableResource.inverseJoinColumnsSize());
-
- joinTable.removeSpecifiedInverseJoinColumn(0);
- assertEquals(2, joinTableResource.inverseJoinColumnsSize());
- assertEquals("BAR", joinTableResource.inverseJoinColumnAt(0).getName());
- assertEquals("BAZ", joinTableResource.inverseJoinColumnAt(1).getName());
-
- joinTable.removeSpecifiedInverseJoinColumn(0);
- assertEquals(1, joinTableResource.inverseJoinColumnsSize());
- assertEquals("BAZ", joinTableResource.inverseJoinColumnAt(0).getName());
-
- joinTable.removeSpecifiedInverseJoinColumn(0);
- assertEquals(0, joinTableResource.inverseJoinColumnsSize());
- }
-
- public void testMoveSpecifiedInverseJoinColumn() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- joinTable.addSpecifiedInverseJoinColumn(0).setSpecifiedName("FOO");
- joinTable.addSpecifiedInverseJoinColumn(1).setSpecifiedName("BAR");
- joinTable.addSpecifiedInverseJoinColumn(2).setSpecifiedName("BAZ");
-
- JoinTableAnnotation joinTableResource = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- assertEquals(3, joinTableResource.inverseJoinColumnsSize());
-
-
- joinTable.moveSpecifiedInverseJoinColumn(2, 0);
- ListIterator<JoinColumn> inverseJoinColumns = joinTable.specifiedInverseJoinColumns();
- assertEquals("BAR", inverseJoinColumns.next().getName());
- assertEquals("BAZ", inverseJoinColumns.next().getName());
- assertEquals("FOO", inverseJoinColumns.next().getName());
-
- assertEquals("BAR", joinTableResource.inverseJoinColumnAt(0).getName());
- assertEquals("BAZ", joinTableResource.inverseJoinColumnAt(1).getName());
- assertEquals("FOO", joinTableResource.inverseJoinColumnAt(2).getName());
-
-
- joinTable.moveSpecifiedInverseJoinColumn(0, 1);
- inverseJoinColumns = joinTable.specifiedInverseJoinColumns();
- assertEquals("BAZ", inverseJoinColumns.next().getName());
- assertEquals("BAR", inverseJoinColumns.next().getName());
- assertEquals("FOO", inverseJoinColumns.next().getName());
-
- assertEquals("BAZ", joinTableResource.inverseJoinColumnAt(0).getName());
- assertEquals("BAR", joinTableResource.inverseJoinColumnAt(1).getName());
- assertEquals("FOO", joinTableResource.inverseJoinColumnAt(2).getName());
- }
-
- public void testUpdateInverseJoinColumns() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- JoinTableAnnotation joinTableResource = (JoinTableAnnotation) attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- joinTableResource.addInverseJoinColumn(0);
- joinTableResource.addInverseJoinColumn(1);
- joinTableResource.addInverseJoinColumn(2);
-
- joinTableResource.inverseJoinColumnAt(0).setName("FOO");
- joinTableResource.inverseJoinColumnAt(1).setName("BAR");
- joinTableResource.inverseJoinColumnAt(2).setName("BAZ");
-
- ListIterator<JoinColumn> inverseJoinColumns = joinTable.specifiedInverseJoinColumns();
- assertEquals("FOO", inverseJoinColumns.next().getName());
- assertEquals("BAR", inverseJoinColumns.next().getName());
- assertEquals("BAZ", inverseJoinColumns.next().getName());
- assertFalse(inverseJoinColumns.hasNext());
-
- joinTableResource.moveInverseJoinColumn(2, 0);
- inverseJoinColumns = joinTable.specifiedInverseJoinColumns();
- assertEquals("BAR", inverseJoinColumns.next().getName());
- assertEquals("BAZ", inverseJoinColumns.next().getName());
- assertEquals("FOO", inverseJoinColumns.next().getName());
- assertFalse(inverseJoinColumns.hasNext());
-
- joinTableResource.moveInverseJoinColumn(0, 1);
- inverseJoinColumns = joinTable.specifiedInverseJoinColumns();
- assertEquals("BAZ", inverseJoinColumns.next().getName());
- assertEquals("BAR", inverseJoinColumns.next().getName());
- assertEquals("FOO", inverseJoinColumns.next().getName());
- assertFalse(inverseJoinColumns.hasNext());
-
- joinTableResource.removeInverseJoinColumn(1);
- inverseJoinColumns = joinTable.specifiedInverseJoinColumns();
- assertEquals("BAZ", inverseJoinColumns.next().getName());
- assertEquals("FOO", inverseJoinColumns.next().getName());
- assertFalse(inverseJoinColumns.hasNext());
-
- joinTableResource.removeInverseJoinColumn(1);
- inverseJoinColumns = joinTable.specifiedInverseJoinColumns();
- assertEquals("BAZ", inverseJoinColumns.next().getName());
- assertFalse(inverseJoinColumns.hasNext());
-
- joinTableResource.removeInverseJoinColumn(0);
- assertFalse(joinTable.specifiedInverseJoinColumns().hasNext());
- }
-
- public void testGetDefaultInverseJoinColumn() {
- //TODO
- }
-
- public void testSpecifiedInverseJoinColumnsSize() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- assertEquals(0, joinTable.specifiedInverseJoinColumnsSize());
-
- joinTable.addSpecifiedInverseJoinColumn(0);
- assertEquals(1, joinTable.specifiedInverseJoinColumnsSize());
-
- joinTable.removeSpecifiedInverseJoinColumn(0);
- assertEquals(0, joinTable.specifiedInverseJoinColumnsSize());
- }
-
- public void testInverseJoinColumnsSize() throws Exception {
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaManyToManyMapping manyToManyMapping = (JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping();
- JoinTable joinTable = manyToManyMapping.getJoinTable();
-
- assertEquals(1, joinTable.inverseJoinColumnsSize());
-
- joinTable.addSpecifiedInverseJoinColumn(0);
- assertEquals(1, joinTable.inverseJoinColumnsSize());
-
- joinTable.addSpecifiedInverseJoinColumn(0);
- assertEquals(2, joinTable.inverseJoinColumnsSize());
-
- joinTable.removeSpecifiedInverseJoinColumn(0);
- joinTable.removeSpecifiedInverseJoinColumn(0);
- assertEquals(1, joinTable.inverseJoinColumnsSize());
-
- //if non-owning side of the relationship then no default join column
- manyToManyMapping.setMappedBy("foo");
- assertEquals(0, joinTable.inverseJoinColumnsSize());
- }
-
- public void testUniqueConstraints() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JoinTable joinTable = ((JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping()).getJoinTable();
-
- ListIterator<JavaUniqueConstraint> uniqueConstraints = joinTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- JoinTableAnnotation joinTableAnnotation = (JoinTableAnnotation) attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- joinTableAnnotation.addUniqueConstraint(0).addColumnName(0, "foo");
- joinTableAnnotation.addUniqueConstraint(0).addColumnName(0, "bar");
-
- uniqueConstraints = joinTable.uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("bar", uniqueConstraints.next().columnNames().next());
- assertEquals("foo", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testUniqueConstraintsSize() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JoinTable joinTable = ((JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping()).getJoinTable();
-
- assertEquals(0, joinTable.uniqueConstraintsSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- JoinTableAnnotation joinTableAnnotation = (JoinTableAnnotation) attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- joinTableAnnotation.addUniqueConstraint(0).addColumnName(0, "foo");
- joinTableAnnotation.addUniqueConstraint(1).addColumnName(0, "bar");
-
- assertEquals(2, joinTable.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JoinTable joinTable = ((JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping()).getJoinTable();
- joinTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- joinTable.addUniqueConstraint(0).addColumnName(0, "BAR");
- joinTable.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- JoinTableAnnotation joinTableAnnotation = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- ListIterator<UniqueConstraintAnnotation> uniqueConstraints = joinTableAnnotation.uniqueConstraints();
-
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testAddUniqueConstraint2() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JoinTable joinTable = ((JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping()).getJoinTable();
- joinTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- joinTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- joinTable.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- JoinTableAnnotation joinTableAnnotation = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- ListIterator<UniqueConstraintAnnotation> uniqueConstraints = joinTableAnnotation.uniqueConstraints();
-
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JoinTable joinTable = ((JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping()).getJoinTable();
- joinTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- joinTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- joinTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- JoinTableAnnotation joinTableAnnotation = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- assertEquals(3, joinTableAnnotation.uniqueConstraintsSize());
-
- joinTable.removeUniqueConstraint(1);
-
- ListIterator<UniqueConstraintAnnotation> uniqueConstraintAnnotations = joinTableAnnotation.uniqueConstraints();
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertFalse(uniqueConstraintAnnotations.hasNext());
-
- Iterator<UniqueConstraint> uniqueConstraints = joinTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- joinTable.removeUniqueConstraint(1);
- uniqueConstraintAnnotations = joinTableAnnotation.uniqueConstraints();
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- assertFalse(uniqueConstraintAnnotations.hasNext());
-
- uniqueConstraints = joinTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- joinTable.removeUniqueConstraint(0);
- uniqueConstraintAnnotations = joinTableAnnotation.uniqueConstraints();
- assertFalse(uniqueConstraintAnnotations.hasNext());
- uniqueConstraints = joinTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JoinTable joinTable = ((JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping()).getJoinTable();
- joinTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- joinTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- joinTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- JoinTableAnnotation joinTableAnnotation = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- assertEquals(3, joinTableAnnotation.uniqueConstraintsSize());
-
-
- joinTable.moveUniqueConstraint(2, 0);
- ListIterator<UniqueConstraint> uniqueConstraints = joinTable.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- ListIterator<UniqueConstraintAnnotation> uniqueConstraintAnnotations = joinTableAnnotation.uniqueConstraints();
- assertEquals("BAR", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
-
-
- joinTable.moveUniqueConstraint(0, 1);
- uniqueConstraints = joinTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- uniqueConstraintAnnotations = joinTableAnnotation.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAR", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- }
-
- public void testUpdateUniqueConstraints() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JoinTable joinTable = ((JavaManyToManyMapping) javaPersistentType().attributes().next().getMapping()).getJoinTable();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- JoinTableAnnotation joinTableAnnotation = (JoinTableAnnotation) attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
-
- joinTableAnnotation.addUniqueConstraint(0).addColumnName("FOO");
- joinTableAnnotation.addUniqueConstraint(1).addColumnName("BAR");
- joinTableAnnotation.addUniqueConstraint(2).addColumnName("BAZ");
-
-
- ListIterator<UniqueConstraint> uniqueConstraints = joinTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableAnnotation.moveUniqueConstraint(2, 0);
- uniqueConstraints = joinTable.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableAnnotation.moveUniqueConstraint(0, 1);
- uniqueConstraints = joinTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableAnnotation.removeUniqueConstraint(1);
- uniqueConstraints = joinTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableAnnotation.removeUniqueConstraint(1);
- uniqueConstraints = joinTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableAnnotation.removeUniqueConstraint(0);
- uniqueConstraints = joinTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java
deleted file mode 100644
index fe413a26fc..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java
+++ /dev/null
@@ -1,923 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.OrderByAnnotation;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaManyToManyMappingTests extends ContextModelTestCase
-{
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createManyToManyAnnotation() throws Exception{
- this.createAnnotationAndMembers("ManyToMany", "");
- }
-
- private IType createTestTargetEntityAddress() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int id;").append(CR);
- sb.append(CR);
- sb.append(" private String city;").append(CR);
- sb.append(CR);
- sb.append(" private String state;").append(CR);
- sb.append(CR);
- sb.append(" private int zip;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter);
- }
-
- private IType createTestEntityWithManyToManyMapping() throws Exception {
- createEntityAnnotation();
- createManyToManyAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithValidManyToManyMapping() throws Exception {
- createEntityAnnotation();
- createManyToManyAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToMany").append(CR);
- sb.append(" private Collection<Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
- private IType createTestEntityWithCollectionManyToManyMapping() throws Exception {
- createEntityAnnotation();
- createManyToManyAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToMany").append(CR);
- sb.append(" private Collection addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
- private IType createTestEntityWithNonCollectionManyToManyMapping() throws Exception {
- createEntityAnnotation();
- createManyToManyAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToMany").append(CR);
- sb.append(" private Address addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- public JavaManyToManyMappingTests(String name) {
- super(name);
- }
-
- public void testMorphToBasicMapping() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
- manyToManyMapping.setOrderBy("asdf");
- manyToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(manyToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToDefault() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
- manyToManyMapping.setOrderBy("asdf");
- manyToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(manyToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertNull(persistentAttribute.getSpecifiedMapping());
- assertTrue(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToVersionMapping() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
- manyToManyMapping.setOrderBy("asdf");
- manyToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(manyToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToIdMapping() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
- manyToManyMapping.setOrderBy("asdf");
- manyToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(manyToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedMapping() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
- manyToManyMapping.setOrderBy("asdf");
- manyToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(manyToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
- manyToManyMapping.setOrderBy("asdf");
- manyToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(manyToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToTransientMapping() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
- manyToManyMapping.setOrderBy("asdf");
- manyToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(manyToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToOneMapping() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
- manyToManyMapping.setOrderBy("asdf");
- manyToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(manyToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToManyMapping() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
- manyToManyMapping.setOrderBy("asdf");
- manyToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(manyToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToOneMapping() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
- manyToManyMapping.setOrderBy("asdf");
- manyToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(manyToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testUpdateSpecifiedTargetEntity() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(manyToManyMapping.getSpecifiedTargetEntity());
- assertNull(manyToMany.getTargetEntity());
-
- //set target entity in the resource model, verify context model updated
- manyToMany.setTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", manyToManyMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", manyToMany.getTargetEntity());
-
- //set target entity to null in the resource model
- manyToMany.setTargetEntity(null);
- assertNull(manyToManyMapping.getSpecifiedTargetEntity());
- assertNull(manyToMany.getTargetEntity());
- }
-
- public void testModifySpecifiedTargetEntity() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(manyToManyMapping.getSpecifiedTargetEntity());
- assertNull(manyToMany.getTargetEntity());
-
- //set target entity in the context model, verify resource model updated
- manyToManyMapping.setSpecifiedTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", manyToManyMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", manyToMany.getTargetEntity());
-
- //set target entity to null in the context model
- manyToManyMapping.setSpecifiedTargetEntity(null);
- assertNull(manyToManyMapping.getSpecifiedTargetEntity());
- assertNull(manyToMany.getTargetEntity());
- }
-
- public void testUpdateSpecifiedFetch() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(manyToManyMapping.getSpecifiedFetch());
- assertNull(manyToMany.getFetch());
-
- //set fetch in the resource model, verify context model updated
- manyToMany.setFetch(org.eclipse.jpt.core.resource.java.FetchType.EAGER);
- assertEquals(FetchType.EAGER, manyToManyMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.EAGER, manyToMany.getFetch());
-
- manyToMany.setFetch(org.eclipse.jpt.core.resource.java.FetchType.LAZY);
- assertEquals(FetchType.LAZY, manyToManyMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, manyToMany.getFetch());
-
-
- //set fetch to null in the resource model
- manyToMany.setFetch(null);
- assertNull(manyToManyMapping.getSpecifiedFetch());
- assertNull(manyToMany.getFetch());
- }
-
- public void testModifySpecifiedFetch() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(manyToManyMapping.getSpecifiedFetch());
- assertNull(manyToMany.getFetch());
-
- //set fetch in the context model, verify resource model updated
- manyToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- assertEquals(FetchType.EAGER, manyToManyMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.EAGER, manyToMany.getFetch());
-
- manyToManyMapping.setSpecifiedFetch(FetchType.LAZY);
- assertEquals(FetchType.LAZY, manyToManyMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, manyToMany.getFetch());
-
-
- //set fetch to null in the context model
- manyToManyMapping.setSpecifiedFetch(null);
- assertNull(manyToManyMapping.getSpecifiedFetch());
- assertNull(manyToMany.getFetch());
- }
-
- public void testUpdateMappedBy() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(manyToManyMapping.getMappedBy());
- assertNull(manyToMany.getMappedBy());
-
- //set mappedBy in the resource model, verify context model updated
- manyToMany.setMappedBy("newMappedBy");
- assertEquals("newMappedBy", manyToManyMapping.getMappedBy());
- assertEquals("newMappedBy", manyToMany.getMappedBy());
-
- //set mappedBy to null in the resource model
- manyToMany.setMappedBy(null);
- assertNull(manyToManyMapping.getMappedBy());
- assertNull(manyToMany.getMappedBy());
- }
-
- public void testModifyMappedBy() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(manyToManyMapping.getMappedBy());
- assertNull(manyToMany.getMappedBy());
-
- //set mappedBy in the context model, verify resource model updated
- manyToManyMapping.setMappedBy("newTargetEntity");
- assertEquals("newTargetEntity", manyToManyMapping.getMappedBy());
- assertEquals("newTargetEntity", manyToMany.getMappedBy());
-
- //set mappedBy to null in the context model
- manyToManyMapping.setMappedBy(null);
- assertNull(manyToManyMapping.getMappedBy());
- assertNull(manyToMany.getMappedBy());
- }
-
-
- public void testCandidateMappedByAttributeNames() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- Iterator<String> attributeNames = manyToManyMapping.candidateMappedByAttributeNames();
- assertEquals("id", attributeNames.next());
- assertEquals("city", attributeNames.next());
- assertEquals("state", attributeNames.next());
- assertEquals("zip", attributeNames.next());
- assertFalse(attributeNames.hasNext());
-
- manyToManyMapping.setSpecifiedTargetEntity("foo");
- attributeNames = manyToManyMapping.candidateMappedByAttributeNames();
- assertFalse(attributeNames.hasNext());
-
- manyToManyMapping.setSpecifiedTargetEntity(null);
- attributeNames = manyToManyMapping.candidateMappedByAttributeNames();
- assertEquals("id", attributeNames.next());
- assertEquals("city", attributeNames.next());
- assertEquals("state", attributeNames.next());
- assertEquals("zip", attributeNames.next());
- assertFalse(attributeNames.hasNext());
- }
-
- public void testDefaultTargetEntity() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- //targetEntity not in the persistence unit, default still set, handled by validation
- assertEquals(PACKAGE_NAME + ".Address", manyToManyMapping.getDefaultTargetEntity());
-
- //add targetEntity to the persistence unit
- addXmlClassRef(PACKAGE_NAME + ".Address");
- assertEquals(PACKAGE_NAME + ".Address", manyToManyMapping.getDefaultTargetEntity());
-
- //test default still the same when specified target entity it set
- manyToManyMapping.setSpecifiedTargetEntity("foo");
- assertEquals(PACKAGE_NAME + ".Address", manyToManyMapping.getDefaultTargetEntity());
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef addressClassRef = classRefs.next();
- JavaPersistentType addressPersistentType = addressClassRef.getJavaPersistentType();
-
- //test target is not an Entity, default target entity still exists, this case handled with validation
- addressPersistentType.setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
- assertEquals(PACKAGE_NAME + ".Address", manyToManyMapping.getDefaultTargetEntity());
- }
-
- public void testDefaultTargetEntityCollectionType() throws Exception {
- createTestEntityWithCollectionManyToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- assertNull(manyToManyMapping.getDefaultTargetEntity());
- }
-
- public void testDefaultTargetEntityNonCollectionType() throws Exception {
- createTestEntityWithNonCollectionManyToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- assertNull(manyToManyMapping.getDefaultTargetEntity());
- }
-
- public void testTargetEntity() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- assertEquals(PACKAGE_NAME + ".Address", manyToManyMapping.getTargetEntity());
-
- manyToManyMapping.setSpecifiedTargetEntity("foo");
- assertEquals("foo", manyToManyMapping.getTargetEntity());
-
- manyToManyMapping.setSpecifiedTargetEntity(null);
- assertEquals(PACKAGE_NAME + ".Address", manyToManyMapping.getTargetEntity());
- }
-
- public void testResolvedTargetEntity() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- //targetEntity not in the persistence unit
- assertNull(manyToManyMapping.getResolvedTargetEntity());
-
- //add targetEntity to the persistence unit, now target entity should resolve
- addXmlClassRef(PACKAGE_NAME + ".Address");
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef addressClassRef = classRefs.next();
- TypeMapping addressTypeMapping = addressClassRef.getJavaPersistentType().getMapping();
- assertEquals(addressTypeMapping, manyToManyMapping.getResolvedTargetEntity());
-
- //test default still the same when specified target entity it set
- manyToManyMapping.setSpecifiedTargetEntity("foo");
- assertNull(manyToManyMapping.getResolvedTargetEntity());
-
-
- manyToManyMapping.setSpecifiedTargetEntity(PACKAGE_NAME + ".Address");
- assertEquals(addressTypeMapping, manyToManyMapping.getResolvedTargetEntity());
-
-
- manyToManyMapping.setSpecifiedTargetEntity(null);
- assertEquals(addressTypeMapping, manyToManyMapping.getResolvedTargetEntity());
- }
-
-
- public void testUpdateMapKey() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertNull(manyToManyMapping.getMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
-
- //set mapKey in the resource model, verify context model does not change
- attributeResource.addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNull(manyToManyMapping.getMapKey());
- MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNotNull(mapKey);
-
- //set mapKey name in the resource model, verify context model updated
- mapKey.setName("myMapKey");
- assertEquals("myMapKey", manyToManyMapping.getMapKey());
- assertEquals("myMapKey", mapKey.getName());
-
- //set mapKey name to null in the resource model
- mapKey.setName(null);
- assertNull(manyToManyMapping.getMapKey());
- assertNull(mapKey.getName());
-
- mapKey.setName("myMapKey");
- attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNull(manyToManyMapping.getMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifyMapKey() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertNull(manyToManyMapping.getMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
-
- //set mapKey in the context model, verify resource model updated
- manyToManyMapping.setMapKey("myMapKey");
- MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertEquals("myMapKey", manyToManyMapping.getMapKey());
- assertEquals("myMapKey", mapKey.getName());
-
- //set mapKey to null in the context model
- manyToManyMapping.setMapKey(null);
- assertNull(manyToManyMapping.getMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
- }
-
- public void testUpdateOrderBy() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertNull(manyToManyMapping.getOrderBy());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
-
- //set orderBy in the resource model, verify context model updated
- attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- orderBy.setValue("newOrderBy");
- assertEquals("newOrderBy", manyToManyMapping.getOrderBy());
- assertEquals("newOrderBy", orderBy.getValue());
-
- //set orderBy to null in the resource model
- attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertNull(manyToManyMapping.getOrderBy());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifyOrderBy() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertNull(manyToManyMapping.getOrderBy());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
-
- //set mappedBy in the context model, verify resource model updated
- manyToManyMapping.setOrderBy("newOrderBy");
- assertEquals("newOrderBy", manyToManyMapping.getOrderBy());
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertEquals("newOrderBy", orderBy.getValue());
-
- //set mappedBy to null in the context model
- manyToManyMapping.setOrderBy(null);
- assertNull(manyToManyMapping.getOrderBy());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testUpdateNoOrdering() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertTrue(manyToManyMapping.isNoOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
-
- //set orderBy in the resource model, verify context model updated
- attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertFalse(manyToManyMapping.isNoOrdering());
-
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- orderBy.setValue("newOrderBy");
- assertFalse(manyToManyMapping.isNoOrdering());
-
- //set orderBy to null in the resource model
- attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertTrue(manyToManyMapping.isNoOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifyNoOrdering() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertTrue(manyToManyMapping.isNoOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
-
-// manyToManyMapping.setNoOrdering(false); //this does nothing
-// //set mappedBy in the context model, verify resource model updated
-// manyToManyMapping.setOrderBy("newOrderBy");
-// assertEquals("newOrderBy", manyToManyMapping.getOrderBy());
-// OrderBy orderBy = (OrderBy) attributeResource.annotation(OrderBy.ANNOTATION_NAME);
-// assertEquals("newOrderBy", orderBy.getValue());
-//
-// //set mappedBy to null in the context model
-// manyToManyMapping.setOrderBy(null);
-// assertNull(manyToManyMapping.getOrderBy());
-// assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
- }
-
- public void testUpdatePkOrdering() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertFalse(manyToManyMapping.isPkOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
-
- //set orderBy in the resource model, verify context model updated
- attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertTrue(manyToManyMapping.isPkOrdering());
-
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- orderBy.setValue("newOrderBy");
- assertFalse(manyToManyMapping.isPkOrdering());
-
- //set orderBy to null in the resource model
- attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertFalse(manyToManyMapping.isPkOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testUpdateCustomOrdering() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertFalse(manyToManyMapping.isCustomOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
-
- //set orderBy in the resource model, verify context model updated
- attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertFalse(manyToManyMapping.isCustomOrdering());
-
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- orderBy.setValue("newOrderBy");
- assertTrue(manyToManyMapping.isCustomOrdering());
-
- //set orderBy to null in the resource model
- attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertFalse(manyToManyMapping.isCustomOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java
deleted file mode 100644
index 34257f9919..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java
+++ /dev/null
@@ -1,905 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JoinColumnsAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaManyToOneMappingTests extends ContextModelTestCase
-{
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createManyToOneAnnotation() throws Exception{
- this.createAnnotationAndMembers("ManyToOne", "");
- }
-
- private IType createTestTargetEntityAddress() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int id;").append(CR);
- sb.append(CR);
- sb.append(" private String city;").append(CR);
- sb.append(CR);
- sb.append(" private String state;").append(CR);
- sb.append(CR);
- sb.append(" private int zip;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter);
- }
-
- private IType createTestEntityWithManyToOneMapping() throws Exception {
- createEntityAnnotation();
- createManyToOneAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_ONE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToOne").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithValidManyToOneMapping() throws Exception {
- createEntityAnnotation();
- createManyToOneAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_ONE, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToOne").append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithCollectionManyToOneMapping() throws Exception {
- createEntityAnnotation();
- createManyToOneAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_ONE, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToOne").append(CR);
- sb.append(" private Collection address;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithGenericizedCollectionManyToOneMapping() throws Exception {
- createEntityAnnotation();
- createManyToOneAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_ONE, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToOne").append(CR);
- sb.append(" private Collection<Address> address;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- public JavaManyToOneMappingTests(String name) {
- super(name);
- }
-
- public void testMorphToBasicMapping() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(manyToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToDefault() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(manyToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertNull(persistentAttribute.getSpecifiedMapping());
- assertTrue(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToVersionMapping() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(manyToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToIdMapping() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(manyToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedMapping() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(manyToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(manyToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToTransientMapping() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(manyToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToOneMapping() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(manyToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToManyMapping() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(manyToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToManyMapping() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(manyToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testUpdateSpecifiedTargetEntity() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(manyToOneMapping.getSpecifiedTargetEntity());
- assertNull(manyToOne.getTargetEntity());
-
- //set target entity in the resource model, verify context model updated
- manyToOne.setTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", manyToOneMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", manyToOne.getTargetEntity());
-
- //set target entity to null in the resource model
- manyToOne.setTargetEntity(null);
- assertNull(manyToOneMapping.getSpecifiedTargetEntity());
- assertNull(manyToOne.getTargetEntity());
- }
-
- public void testModifySpecifiedTargetEntity() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(manyToOneMapping.getSpecifiedTargetEntity());
- assertNull(manyToOne.getTargetEntity());
-
- //set target entity in the context model, verify resource model updated
- manyToOneMapping.setSpecifiedTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", manyToOneMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", manyToOne.getTargetEntity());
-
- //set target entity to null in the context model
- manyToOneMapping.setSpecifiedTargetEntity(null);
- assertNull(manyToOneMapping.getSpecifiedTargetEntity());
- assertNull(manyToOne.getTargetEntity());
- }
-
- public void testUpdateSpecifiedOptional() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(manyToOneMapping.getSpecifiedOptional());
- assertNull(manyToOne.getOptional());
-
- //set optional in the resource model, verify context model updated
- manyToOne.setOptional(Boolean.TRUE);
- assertEquals(Boolean.TRUE, manyToOneMapping.getSpecifiedOptional());
- assertEquals(Boolean.TRUE, manyToOne.getOptional());
-
- manyToOne.setOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, manyToOneMapping.getSpecifiedOptional());
- assertEquals(Boolean.FALSE, manyToOne.getOptional());
-
-
- //set optional to null in the resource model
- manyToOne.setOptional(null);
- assertNull(manyToOneMapping.getSpecifiedOptional());
- assertNull(manyToOne.getOptional());
- }
-
- public void testModifySpecifiedOptional() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(manyToOneMapping.getSpecifiedOptional());
- assertNull(manyToOne.getOptional());
-
- //set optional in the context model, verify resource model updated
- manyToOneMapping.setSpecifiedOptional(Boolean.TRUE);
- assertEquals(Boolean.TRUE, manyToOneMapping.getSpecifiedOptional());
- assertEquals(Boolean.TRUE, manyToOne.getOptional());
-
- manyToOneMapping.setSpecifiedOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, manyToOneMapping.getSpecifiedOptional());
- assertEquals(Boolean.FALSE, manyToOne.getOptional());
-
-
- //set optional to null in the context model
- manyToOneMapping.setSpecifiedOptional(null);
- assertNull(manyToOneMapping.getSpecifiedOptional());
- assertNull(manyToOne.getOptional());
- }
-
-
- public void testSpecifiedJoinColumns() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- ListIterator<JavaJoinColumn> specifiedJoinColumns = manyToOneMapping.specifiedJoinColumns();
-
- assertFalse(specifiedJoinColumns.hasNext());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- JoinColumnAnnotation joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- joinColumn.setName("FOO");
- specifiedJoinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("FOO", specifiedJoinColumns.next().getName());
- assertFalse(specifiedJoinColumns.hasNext());
-
- joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- joinColumn.setName("BAR");
- specifiedJoinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("BAR", specifiedJoinColumns.next().getName());
- assertEquals("FOO", specifiedJoinColumns.next().getName());
- assertFalse(specifiedJoinColumns.hasNext());
-
-
- joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- joinColumn.setName("BAZ");
- specifiedJoinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", specifiedJoinColumns.next().getName());
- assertEquals("BAR", specifiedJoinColumns.next().getName());
- assertEquals("FOO", specifiedJoinColumns.next().getName());
- assertFalse(specifiedJoinColumns.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- attributeResource.move(1, 0, JPA.JOIN_COLUMNS);
- specifiedJoinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("BAR", specifiedJoinColumns.next().getName());
- assertEquals("BAZ", specifiedJoinColumns.next().getName());
- assertEquals("FOO", specifiedJoinColumns.next().getName());
- assertFalse(specifiedJoinColumns.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- specifiedJoinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", specifiedJoinColumns.next().getName());
- assertEquals("FOO", specifiedJoinColumns.next().getName());
- assertFalse(specifiedJoinColumns.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- specifiedJoinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("FOO", specifiedJoinColumns.next().getName());
- assertFalse(specifiedJoinColumns.hasNext());
-
-
- attributeResource.removeAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- specifiedJoinColumns = manyToOneMapping.specifiedJoinColumns();
- assertFalse(specifiedJoinColumns.hasNext());
- }
-
- public void testGetDefaultJoin() {
- //TODO
- }
-
- public void testSpecifiedJoinColumnsSize() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- assertEquals(0, manyToOneMapping.specifiedJoinColumnsSize());
-
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertEquals(1, manyToOneMapping.specifiedJoinColumnsSize());
-
- manyToOneMapping.removeSpecifiedJoinColumn(0);
- assertEquals(0, manyToOneMapping.specifiedJoinColumnsSize());
- }
-
- public void testJoinColumnsSize() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- assertEquals(1, manyToOneMapping.joinColumnsSize());
-
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertEquals(1, manyToOneMapping.joinColumnsSize());
-
- manyToOneMapping.addSpecifiedJoinColumn(0);
- assertEquals(2, manyToOneMapping.joinColumnsSize());
-
- manyToOneMapping.removeSpecifiedJoinColumn(0);
- manyToOneMapping.removeSpecifiedJoinColumn(0);
- assertEquals(1, manyToOneMapping.joinColumnsSize());
- }
-
- public void testAddSpecifiedJoinColumn() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- manyToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- manyToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("BAR");
- manyToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- Iterator<JavaResourceNode> joinColumns = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
-
- assertEquals("BAZ", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("BAR", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("FOO", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertFalse(joinColumns.hasNext());
- }
-
- public void testAddSpecifiedJoinColumn2() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- manyToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- manyToOneMapping.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- manyToOneMapping.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- Iterator<JavaResourceNode> joinColumns = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
-
- assertEquals("FOO", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("BAR", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("BAZ", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertFalse(joinColumns.hasNext());
- }
- public void testRemoveSpecifiedJoinColumn() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- manyToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- manyToOneMapping.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- manyToOneMapping.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertEquals(3, CollectionTools.size(attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)));
-
- manyToOneMapping.removeSpecifiedJoinColumn(1);
-
- Iterator<JavaResourceNode> joinColumnResources = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- assertEquals("FOO", ((JoinColumnAnnotation) joinColumnResources.next()).getName());
- assertEquals("BAZ", ((JoinColumnAnnotation) joinColumnResources.next()).getName());
- assertFalse(joinColumnResources.hasNext());
-
- Iterator<JoinColumn> joinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
-
- manyToOneMapping.removeSpecifiedJoinColumn(1);
- joinColumnResources = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- assertEquals("FOO", ((JoinColumnAnnotation) joinColumnResources.next()).getName());
- assertFalse(joinColumnResources.hasNext());
-
- joinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
-
- manyToOneMapping.removeSpecifiedJoinColumn(0);
- joinColumnResources = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- assertFalse(joinColumnResources.hasNext());
- joinColumns = manyToOneMapping.specifiedJoinColumns();
- assertFalse(joinColumns.hasNext());
-
- assertNull(attributeResource.getAnnotation(JoinColumnsAnnotation.ANNOTATION_NAME));
- }
-
- public void testMoveSpecifiedJoinColumn() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- manyToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- manyToOneMapping.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- manyToOneMapping.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentAttribute attributeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME).attributes().next();
-
- ListIterator<JoinColumnAnnotation> javaJoinColumns = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- assertEquals(3, CollectionTools.size(javaJoinColumns));
-
-
- manyToOneMapping.moveSpecifiedJoinColumn(2, 0);
- ListIterator<JoinColumn> primaryKeyJoinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getSpecifiedName());
-
- javaJoinColumns = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", javaJoinColumns.next().getName());
- assertEquals("BAZ", javaJoinColumns.next().getName());
- assertEquals("FOO", javaJoinColumns.next().getName());
-
-
- manyToOneMapping.moveSpecifiedJoinColumn(0, 1);
- primaryKeyJoinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getSpecifiedName());
-
- javaJoinColumns = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- assertEquals("BAZ", javaJoinColumns.next().getName());
- assertEquals("BAR", javaJoinColumns.next().getName());
- assertEquals("FOO", javaJoinColumns.next().getName());
- }
-
- public void testUpdateSpecifiedJoinColumns() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
- JavaResourcePersistentAttribute attributeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME).attributes().next();
-
- ((JoinColumnAnnotation) attributeResource.addAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((JoinColumnAnnotation) attributeResource.addAnnotation(1, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((JoinColumnAnnotation) attributeResource.addAnnotation(2, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)).setName("BAZ");
-
- ListIterator<JoinColumn> joinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.move(2, 0, JoinColumnsAnnotation.ANNOTATION_NAME);
- joinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.move(0, 1, JoinColumnsAnnotation.ANNOTATION_NAME);
- joinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.removeAnnotation(1, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- joinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.removeAnnotation(1, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- joinColumns = manyToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.removeAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- joinColumns = manyToOneMapping.specifiedJoinColumns();
- assertFalse(joinColumns.hasNext());
- }
- public void testJoinColumnIsVirtual() throws Exception {
- createTestEntityWithManyToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- assertTrue(manyToOneMapping.getDefaultJoinColumn().isVirtual());
-
- manyToOneMapping.addSpecifiedJoinColumn(0);
- JoinColumn specifiedJoinColumn = manyToOneMapping.specifiedJoinColumns().next();
- assertFalse(specifiedJoinColumn.isVirtual());
-
- assertNull(manyToOneMapping.getDefaultJoinColumn());
- }
-
- public void testDefaultTargetEntity() throws Exception {
- createTestEntityWithValidManyToOneMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- //targetEntity not in the persistence unit, default still set, handled by validation
- assertEquals(PACKAGE_NAME + ".Address", manyToOneMapping.getDefaultTargetEntity());
-
- //add targetEntity to the persistence unit
- addXmlClassRef(PACKAGE_NAME + ".Address");
- assertEquals(PACKAGE_NAME + ".Address", manyToOneMapping.getDefaultTargetEntity());
-
- //test default still the same when specified target entity it set
- manyToOneMapping.setSpecifiedTargetEntity("foo");
- assertEquals(PACKAGE_NAME + ".Address", manyToOneMapping.getDefaultTargetEntity());
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef addressClassRef = classRefs.next();
- JavaPersistentType addressPersistentType = addressClassRef.getJavaPersistentType();
-
- //test target is not an Entity, default target entity still exists, this case handled with validation
- addressPersistentType.setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
- assertEquals(PACKAGE_NAME + ".Address", manyToOneMapping.getDefaultTargetEntity());
- }
-
- public void testDefaultTargetEntityCollectionType() throws Exception {
- createTestEntityWithCollectionManyToOneMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- assertNull(manyToOneMapping.getDefaultTargetEntity());
- }
-
- public void testDefaultTargetEntityGenericizedCollectionType() throws Exception {
- createTestEntityWithGenericizedCollectionManyToOneMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- assertNull(manyToOneMapping.getDefaultTargetEntity());
- }
-
- public void testTargetEntity() throws Exception {
- createTestEntityWithValidManyToOneMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- assertEquals(PACKAGE_NAME + ".Address", manyToOneMapping.getTargetEntity());
-
- manyToOneMapping.setSpecifiedTargetEntity("foo");
- assertEquals("foo", manyToOneMapping.getTargetEntity());
-
- manyToOneMapping.setSpecifiedTargetEntity(null);
- assertEquals(PACKAGE_NAME + ".Address", manyToOneMapping.getTargetEntity());
- }
-
- public void testResolvedTargetEntity() throws Exception {
- createTestEntityWithValidManyToOneMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
-
- //targetEntity not in the persistence unit
- assertNull(manyToOneMapping.getResolvedTargetEntity());
-
- //add targetEntity to the persistence unit, now target entity should resolve
- addXmlClassRef(PACKAGE_NAME + ".Address");
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef addressClassRef = classRefs.next();
- TypeMapping addressTypeMapping = addressClassRef.getJavaPersistentType().getMapping();
- assertEquals(addressTypeMapping, manyToOneMapping.getResolvedTargetEntity());
-
- //test default still the same when specified target entity it set
- manyToOneMapping.setSpecifiedTargetEntity("foo");
- assertNull(manyToOneMapping.getResolvedTargetEntity());
-
-
- manyToOneMapping.setSpecifiedTargetEntity(PACKAGE_NAME + ".Address");
- assertEquals(addressTypeMapping, manyToOneMapping.getResolvedTargetEntity());
-
-
- manyToOneMapping.setSpecifiedTargetEntity(null);
- assertEquals(addressTypeMapping, manyToOneMapping.getResolvedTargetEntity());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaMappedSuperclassTests.java
deleted file mode 100644
index 3bd2e944ea..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaMappedSuperclassTests.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.MappedSuperclass;
-import org.eclipse.jpt.core.internal.context.java.JavaNullTypeMapping;
-import org.eclipse.jpt.core.resource.java.IdClassAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaMappedSuperclassTests extends ContextModelTestCase
-{
-
- private void createMappedSuperclassAnnotation() throws Exception {
- this.createAnnotationAndMembers("MappedSuperclass", "");
- }
-
- private IType createTestMappedSuperclass() throws Exception {
- createMappedSuperclassAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass");
- }
- });
- }
-
-
- public JavaMappedSuperclassTests(String name) {
- super(name);
- }
-
- public void testMorphToEntity() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
- mappedSuperclass.setIdClass("myIdClass");
-
- javaPersistentType().setMappingKey(MappingKeys.ENTITY_TYPE_MAPPING_KEY);
- assertTrue(javaPersistentType().getMapping() instanceof Entity);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- assertNull(typeResource.getMappingAnnotation(MappedSuperclassAnnotation.ANNOTATION_NAME));
- assertNotNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddable() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
- mappedSuperclass.setIdClass("myIdClass");
-
- javaPersistentType().setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
- assertTrue(javaPersistentType().getMapping() instanceof Embeddable);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- assertNull(typeResource.getMappingAnnotation(MappedSuperclassAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToNull() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
- mappedSuperclass.setIdClass("myIdClass");
-
- javaPersistentType().setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
- assertTrue(javaPersistentType().getMapping() instanceof JavaNullTypeMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- assertNull(typeResource.getMappingAnnotation(MappedSuperclassAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
- }
-
-
- public void testMappedSuperclass() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- assertTrue(javaPersistentType().getMapping() instanceof MappedSuperclass);
- }
-
- public void testOverridableAttributeNames() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
- Iterator<String> overridableAttributeNames = mappedSuperclass.overridableAttributeNames();
- assertEquals("id", overridableAttributeNames.next());
- assertEquals("name", overridableAttributeNames.next());
- assertFalse(overridableAttributeNames.hasNext());
- }
-
- public void testOverridableAssociationNames() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
- Iterator<String> overridableAssociationNames = mappedSuperclass.overridableAssociationNames();
- assertFalse(overridableAssociationNames.hasNext());
- }
-
- public void testTableNameIsInvalid() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
-
- assertFalse(mappedSuperclass.tableNameIsInvalid(FULLY_QUALIFIED_TYPE_NAME));
- assertFalse(mappedSuperclass.tableNameIsInvalid("FOO"));
- }
-
- public void testAssociatedTables() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
-
- assertFalse(mappedSuperclass.associatedTables().hasNext());
- }
-
- public void testAssociatedTablesIncludingInherited() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
-
- assertFalse(mappedSuperclass.associatedTablesIncludingInherited().hasNext());
- }
-
- public void testAssociatedTableNamesIncludingInherited() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
-
- assertFalse(mappedSuperclass.associatedTableNamesIncludingInherited().hasNext());
- }
-
- public void testAllOverridableAttributeNames() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
- Iterator<String> overridableAttributeNames = mappedSuperclass.overridableAttributeNames();
- assertEquals("id", overridableAttributeNames.next());
- assertEquals("name", overridableAttributeNames.next());
- assertFalse(overridableAttributeNames.hasNext());
- }
-
- //TODO need to create a subclass mappedSuperclass and test this
- public void testAllOverridableAssociationNames() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
- Iterator<String> overridableAssociationNames = mappedSuperclass.overridableAssociationNames();
- assertFalse(overridableAssociationNames.hasNext());
- }
-
- public void testAttributeMappingKeyAllowed() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
- assertTrue(mappedSuperclass.attributeMappingKeyAllowed(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY));
- assertTrue(mappedSuperclass.attributeMappingKeyAllowed(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY));
- assertTrue(mappedSuperclass.attributeMappingKeyAllowed(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY));
- assertTrue(mappedSuperclass.attributeMappingKeyAllowed(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY));
- assertTrue(mappedSuperclass.attributeMappingKeyAllowed(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY));
- assertTrue(mappedSuperclass.attributeMappingKeyAllowed(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY));
- assertTrue(mappedSuperclass.attributeMappingKeyAllowed(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- assertTrue(mappedSuperclass.attributeMappingKeyAllowed(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- assertTrue(mappedSuperclass.attributeMappingKeyAllowed(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY));
- assertTrue(mappedSuperclass.attributeMappingKeyAllowed(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY));
- }
-
- public void testUpdateIdClass() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
-
- assertNull(mappedSuperclass.getIdClass());
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
-
- IdClassAnnotation idClass = (IdClassAnnotation) typeResource.addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- assertNull(mappedSuperclass.getIdClass());
- assertNotNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
-
- idClass.setValue("model.Foo");
- assertEquals("model.Foo", mappedSuperclass.getIdClass());
- assertEquals("model.Foo", ((IdClassAnnotation) typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME)).getValue());
-
- //test setting @IdClass value to null, IdClass annotation is removed
- idClass.setValue(null);
- assertNull(mappedSuperclass.getIdClass());
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
-
- //reset @IdClass value and then remove @IdClass
- idClass = (IdClassAnnotation) typeResource.addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- idClass.setValue("model.Foo");
- typeResource.removeAnnotation(IdClassAnnotation.ANNOTATION_NAME);
-
- assertNull(mappedSuperclass.getIdClass());
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifyIdClass() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
-
- assertNull(mappedSuperclass.getIdClass());
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
-
- mappedSuperclass.setIdClass("model.Foo");
- assertEquals("model.Foo", ((IdClassAnnotation) typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME)).getValue());
- assertEquals("model.Foo", mappedSuperclass.getIdClass());
-
- mappedSuperclass.setIdClass(null);
- assertNull(mappedSuperclass.getIdClass());
- assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedNativeQueryTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedNativeQueryTests.java
deleted file mode 100644
index dee49a631b..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedNativeQueryTests.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.NamedNativeQuery;
-import org.eclipse.jpt.core.context.QueryHint;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaNamedNativeQueryTests extends ContextModelTestCase
-{
- private static final String QUERY_NAME = "QUERY_NAME";
- private static final String QUERY_QUERY = "MY_QUERY";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createNamedNativeQueryAnnotation() throws Exception {
- createQueryHintAnnotation();
- this.createAnnotationAndMembers("NamedNativeQuery",
- "String name();" +
- "String query();" +
- "QueryHint[] hints() default {};");
- }
-
- private void createQueryHintAnnotation() throws Exception {
- this.createAnnotationAndMembers("QueryHint",
- "String name();" +
- "String value();");
- }
-
- private IType createTestEntityWithNamedNativeQuery() throws Exception {
- createEntityAnnotation();
- createNamedNativeQueryAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.NAMED_NATIVE_QUERY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@NamedNativeQuery(name=\"" + QUERY_NAME + "\", query=\"" + QUERY_QUERY + "\")");
- }
- });
- }
-
-
-
- public JavaNamedNativeQueryTests(String name) {
- super(name);
- }
-
- public void testUpdateName() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
- assertEquals(QUERY_NAME, javaNamedNativeQuery.getName());
- assertEquals(QUERY_NAME, namedNativeQuery.getName());
-
- //set name to null in the resource model
- javaNamedNativeQuery.setName(null);
- assertNull(javaNamedNativeQuery.getName());
- assertNull(namedNativeQuery.getName());
-
- //set name in the resource model, verify context model updated
- javaNamedNativeQuery.setName("foo");
- assertEquals("foo", javaNamedNativeQuery.getName());
- assertEquals("foo", namedNativeQuery.getName());
- }
-
- public void testModifyName() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
- assertEquals(QUERY_NAME, javaNamedNativeQuery.getName());
- assertEquals(QUERY_NAME, namedNativeQuery.getName());
-
- //set name to null in the context model
- namedNativeQuery.setName(null);
- assertNull(javaNamedNativeQuery.getName());
- assertNull(namedNativeQuery.getName());
-
- //set name in the context model, verify resource model updated
- namedNativeQuery.setName("foo");
- assertEquals("foo", javaNamedNativeQuery.getName());
- assertEquals("foo", namedNativeQuery.getName());
- }
-
- public void testUpdateQuery() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
- assertEquals(QUERY_QUERY, javaNamedNativeQuery.getQuery());
- assertEquals(QUERY_QUERY, namedNativeQuery.getQuery());
-
- //set name to null in the resource model
- javaNamedNativeQuery.setQuery(null);
- assertNull(javaNamedNativeQuery.getQuery());
- assertNull(namedNativeQuery.getQuery());
-
- //set name in the resource model, verify context model updated
- javaNamedNativeQuery.setQuery("foo");
- assertEquals("foo", javaNamedNativeQuery.getQuery());
- assertEquals("foo", namedNativeQuery.getQuery());
- }
-
- public void testModifyQuery() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
- assertEquals(QUERY_QUERY, javaNamedNativeQuery.getQuery());
- assertEquals(QUERY_QUERY, namedNativeQuery.getQuery());
-
- //set name to null in the context model
- namedNativeQuery.setQuery(null);
- assertNull(javaNamedNativeQuery.getQuery());
- assertNull(namedNativeQuery.getQuery());
-
- //set name in the context model, verify resource model updated
- namedNativeQuery.setQuery("foo");
- assertEquals("foo", javaNamedNativeQuery.getQuery());
- assertEquals("foo", namedNativeQuery.getQuery());
- }
-
-
- public void testAddHint() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
-
- QueryHint queryHint = namedNativeQuery.addHint(0);
- ormResource().save(null);
- queryHint.setName("FOO");
- ormResource().save(null);
-
- assertEquals("FOO", javaNamedNativeQuery.hintAt(0).getName());
-
- QueryHint queryHint2 = namedNativeQuery.addHint(0);
- ormResource().save(null);
- queryHint2.setName("BAR");
- ormResource().save(null);
-
- assertEquals("BAR", javaNamedNativeQuery.hintAt(0).getName());
- assertEquals("FOO", javaNamedNativeQuery.hintAt(1).getName());
-
- QueryHint queryHint3 = namedNativeQuery.addHint(1);
- ormResource().save(null);
- queryHint3.setName("BAZ");
- ormResource().save(null);
-
- assertEquals("BAR", javaNamedNativeQuery.hintAt(0).getName());
- assertEquals("BAZ", javaNamedNativeQuery.hintAt(1).getName());
- assertEquals("FOO", javaNamedNativeQuery.hintAt(2).getName());
-
- ListIterator<QueryHint> hints = namedNativeQuery.hints();
- assertEquals(queryHint2, hints.next());
- assertEquals(queryHint3, hints.next());
- assertEquals(queryHint, hints.next());
-
- hints = namedNativeQuery.hints();
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- }
-
- public void testRemoveHint() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
- namedNativeQuery.addHint(0).setName("FOO");
- namedNativeQuery.addHint(1).setName("BAR");
- namedNativeQuery.addHint(2).setName("BAZ");
-
- assertEquals(3, javaNamedNativeQuery.hintsSize());
-
- namedNativeQuery.removeHint(0);
- assertEquals(2, javaNamedNativeQuery.hintsSize());
- assertEquals("BAR", javaNamedNativeQuery.hintAt(0).getName());
- assertEquals("BAZ", javaNamedNativeQuery.hintAt(1).getName());
-
- namedNativeQuery.removeHint(0);
- assertEquals(1, javaNamedNativeQuery.hintsSize());
- assertEquals("BAZ", javaNamedNativeQuery.hintAt(0).getName());
-
- namedNativeQuery.removeHint(0);
- assertEquals(0, javaNamedNativeQuery.hintsSize());
- }
-
- public void testMoveHint() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
- namedNativeQuery.addHint(0).setName("FOO");
- namedNativeQuery.addHint(1).setName("BAR");
- namedNativeQuery.addHint(2).setName("BAZ");
-
- assertEquals(3, javaNamedNativeQuery.hintsSize());
-
-
- namedNativeQuery.moveHint(2, 0);
- ListIterator<QueryHint> hints = namedNativeQuery.hints();
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
-
- assertEquals("BAR", javaNamedNativeQuery.hintAt(0).getName());
- assertEquals("BAZ", javaNamedNativeQuery.hintAt(1).getName());
- assertEquals("FOO", javaNamedNativeQuery.hintAt(2).getName());
-
-
- namedNativeQuery.moveHint(0, 1);
- hints = namedNativeQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertEquals("BAR", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
-
- assertEquals("BAZ", javaNamedNativeQuery.hintAt(0).getName());
- assertEquals("BAR", javaNamedNativeQuery.hintAt(1).getName());
- assertEquals("FOO", javaNamedNativeQuery.hintAt(2).getName());
- }
-
- public void testUpdateHints() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
- javaNamedNativeQuery.addHint(0);
- javaNamedNativeQuery.addHint(1);
- javaNamedNativeQuery.addHint(2);
-
- javaNamedNativeQuery.hintAt(0).setName("FOO");
- javaNamedNativeQuery.hintAt(1).setName("BAR");
- javaNamedNativeQuery.hintAt(2).setName("BAZ");
-
- ListIterator<QueryHint> hints = namedNativeQuery.hints();
- assertEquals("FOO", hints.next().getName());
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertFalse(hints.hasNext());
-
- javaNamedNativeQuery.moveHint(2, 0);
- hints = namedNativeQuery.hints();
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- assertFalse(hints.hasNext());
-
- javaNamedNativeQuery.moveHint(0, 1);
- hints = namedNativeQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertEquals("BAR", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- assertFalse(hints.hasNext());
-
- javaNamedNativeQuery.removeHint(1);
- hints = namedNativeQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- assertFalse(hints.hasNext());
-
- javaNamedNativeQuery.removeHint(1);
- hints = namedNativeQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertFalse(hints.hasNext());
-
- javaNamedNativeQuery.removeHint(0);
- assertFalse(namedNativeQuery.hints().hasNext());
- }
-
- public void testHintsSize() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
-
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
- assertEquals(0, namedNativeQuery.hintsSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
-
- javaNamedNativeQuery.addHint(0);
- assertEquals(1, namedNativeQuery.hintsSize());
-
- javaNamedNativeQuery.addHint(0);
- assertEquals(2, namedNativeQuery.hintsSize());
-
- javaNamedNativeQuery.removeHint(0);
- javaNamedNativeQuery.removeHint(0);
- assertEquals(0, namedNativeQuery.hintsSize());
- }
-
- public void testUpdateResultClass() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
- assertEquals(null, javaNamedNativeQuery.getResultClass());
- assertEquals(null, namedNativeQuery.getResultClass());
-
- //set name in the resource model, verify context model updated
- javaNamedNativeQuery.setResultClass("foo");
- assertEquals("foo", javaNamedNativeQuery.getResultClass());
- assertEquals("foo", namedNativeQuery.getResultClass());
-
- //set name to null in the resource model
- javaNamedNativeQuery.setResultClass(null);
- assertNull(javaNamedNativeQuery.getResultClass());
- assertNull(namedNativeQuery.getResultClass());
- }
-
- public void testModifyResultClass() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
- assertEquals(null, javaNamedNativeQuery.getResultClass());
- assertEquals(null, namedNativeQuery.getResultClass());
-
- //set name in the context model, verify resource model updated
- namedNativeQuery.setResultClass("foo");
- assertEquals("foo", javaNamedNativeQuery.getResultClass());
- assertEquals("foo", namedNativeQuery.getResultClass());
-
- //set name to null in the context model
- namedNativeQuery.setResultClass(null);
- assertNull(javaNamedNativeQuery.getResultClass());
- assertNull(namedNativeQuery.getResultClass());
- }
-
- public void testUpdateResultSetMapping() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
- assertEquals(null, javaNamedNativeQuery.getResultSetMapping());
- assertEquals(null, namedNativeQuery.getResultSetMapping());
-
- //set name in the resource model, verify context model updated
- javaNamedNativeQuery.setResultSetMapping("foo");
- assertEquals("foo", javaNamedNativeQuery.getResultSetMapping());
- assertEquals("foo", namedNativeQuery.getResultSetMapping());
-
- //set name to null in the resource model
- javaNamedNativeQuery.setResultSetMapping(null);
- assertNull(javaNamedNativeQuery.getResultSetMapping());
- assertNull(namedNativeQuery.getResultSetMapping());
- }
-
- public void testModifyResultSetMapping() throws Exception {
- createTestEntityWithNamedNativeQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedNativeQuery namedNativeQuery = entity.namedNativeQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedNativeQueryAnnotation javaNamedNativeQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(NamedNativeQueryAnnotation.ANNOTATION_NAME);
-
- assertEquals(null, javaNamedNativeQuery.getResultSetMapping());
- assertEquals(null, namedNativeQuery.getResultSetMapping());
-
- //set name in the context model, verify resource model updated
- namedNativeQuery.setResultSetMapping("foo");
- assertEquals("foo", javaNamedNativeQuery.getResultSetMapping());
- assertEquals("foo", namedNativeQuery.getResultSetMapping());
-
- //set name to null in the context model
- namedNativeQuery.setResultSetMapping(null);
- assertNull(javaNamedNativeQuery.getResultSetMapping());
- assertNull(namedNativeQuery.getResultSetMapping());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedQueryTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedQueryTests.java
deleted file mode 100644
index 106df282b7..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedQueryTests.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.NamedQuery;
-import org.eclipse.jpt.core.context.QueryHint;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaNamedQueryTests extends ContextModelTestCase
-{
- private static final String QUERY_NAME = "QUERY_NAME";
- private static final String QUERY_QUERY = "MY_QUERY";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createNamedQueryAnnotation() throws Exception {
- createQueryHintAnnotation();
- this.createAnnotationAndMembers("NamedQuery",
- "String name();" +
- "String query();" +
- "QueryHint[] hints() default {};");
- }
-
- private void createQueryHintAnnotation() throws Exception {
- this.createAnnotationAndMembers("QueryHint",
- "String name();" +
- "String value();");
- }
-
- private IType createTestEntityWithNamedQuery() throws Exception {
- createEntityAnnotation();
- createNamedQueryAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.NAMED_QUERY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@NamedQuery(name=\"" + QUERY_NAME + "\", query=\"" + QUERY_QUERY + "\")");
- }
- });
- }
-
-
-
- public JavaNamedQueryTests(String name) {
- super(name);
- }
-
- public void testUpdateName() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- NamedQuery namedQuery = entity.namedQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedQueryAnnotation javaNamedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME);
-
- assertEquals(QUERY_NAME, javaNamedQuery.getName());
- assertEquals(QUERY_NAME, namedQuery.getName());
-
- //set name to null in the resource model
- javaNamedQuery.setName(null);
- assertNull(javaNamedQuery.getName());
- assertNull(namedQuery.getName());
-
- //set name in the resource model, verify context model updated
- javaNamedQuery.setName("foo");
- assertEquals("foo", javaNamedQuery.getName());
- assertEquals("foo", namedQuery.getName());
- }
-
- public void testModifyName() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedQuery namedQuery = entity.namedQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedQueryAnnotation javaNamedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME);
-
- assertEquals(QUERY_NAME, javaNamedQuery.getName());
- assertEquals(QUERY_NAME, namedQuery.getName());
-
- //set name to null in the context model
- namedQuery.setName(null);
- assertNull(javaNamedQuery.getName());
- assertNull(namedQuery.getName());
-
- //set name in the context model, verify resource model updated
- namedQuery.setName("foo");
- assertEquals("foo", javaNamedQuery.getName());
- assertEquals("foo", namedQuery.getName());
- }
-
- public void testUpdateQuery() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- NamedQuery namedQuery = entity.namedQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedQueryAnnotation javaNamedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME);
-
- assertEquals(QUERY_QUERY, javaNamedQuery.getQuery());
- assertEquals(QUERY_QUERY, namedQuery.getQuery());
-
- //set name to null in the resource model
- javaNamedQuery.setQuery(null);
- assertNull(javaNamedQuery.getQuery());
- assertNull(namedQuery.getQuery());
-
- //set name in the resource model, verify context model updated
- javaNamedQuery.setQuery("foo");
- assertEquals("foo", javaNamedQuery.getQuery());
- assertEquals("foo", namedQuery.getQuery());
- }
-
- public void testModifyQuery() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedQuery namedQuery = entity.namedQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedQueryAnnotation javaNamedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME);
-
- assertEquals(QUERY_QUERY, javaNamedQuery.getQuery());
- assertEquals(QUERY_QUERY, namedQuery.getQuery());
-
- //set name to null in the context model
- namedQuery.setQuery(null);
- assertNull(javaNamedQuery.getQuery());
- assertNull(namedQuery.getQuery());
-
- //set name in the context model, verify resource model updated
- namedQuery.setQuery("foo");
- assertEquals("foo", javaNamedQuery.getQuery());
- assertEquals("foo", namedQuery.getQuery());
- }
-
-
- public void testAddHint() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedQuery namedQuery = entity.namedQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedQueryAnnotation javaNamedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME);
-
-
- QueryHint queryHint = namedQuery.addHint(0);
- queryHint.setName("FOO");
-
- assertEquals("FOO", javaNamedQuery.hintAt(0).getName());
-
- QueryHint queryHint2 = namedQuery.addHint(0);
- queryHint2.setName("BAR");
-
- assertEquals("BAR", javaNamedQuery.hintAt(0).getName());
- assertEquals("FOO", javaNamedQuery.hintAt(1).getName());
-
- QueryHint queryHint3 = namedQuery.addHint(1);
- queryHint3.setName("BAZ");
-
- assertEquals("BAR", javaNamedQuery.hintAt(0).getName());
- assertEquals("BAZ", javaNamedQuery.hintAt(1).getName());
- assertEquals("FOO", javaNamedQuery.hintAt(2).getName());
-
- ListIterator<QueryHint> hints = namedQuery.hints();
- assertEquals(queryHint2, hints.next());
- assertEquals(queryHint3, hints.next());
- assertEquals(queryHint, hints.next());
-
- hints = namedQuery.hints();
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- }
-
- public void testRemoveHint() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedQuery namedQuery = entity.namedQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedQueryAnnotation javaNamedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME);
-
- namedQuery.addHint(0).setName("FOO");
- namedQuery.addHint(1).setName("BAR");
- namedQuery.addHint(2).setName("BAZ");
-
- assertEquals(3, javaNamedQuery.hintsSize());
-
- namedQuery.removeHint(0);
- assertEquals(2, javaNamedQuery.hintsSize());
- assertEquals("BAR", javaNamedQuery.hintAt(0).getName());
- assertEquals("BAZ", javaNamedQuery.hintAt(1).getName());
-
- namedQuery.removeHint(0);
- assertEquals(1, javaNamedQuery.hintsSize());
- assertEquals("BAZ", javaNamedQuery.hintAt(0).getName());
-
- namedQuery.removeHint(0);
- assertEquals(0, javaNamedQuery.hintsSize());
- }
-
- public void testMoveHint() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedQuery namedQuery = entity.namedQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedQueryAnnotation javaNamedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME);
-
- namedQuery.addHint(0).setName("FOO");
- namedQuery.addHint(1).setName("BAR");
- namedQuery.addHint(2).setName("BAZ");
-
- assertEquals(3, javaNamedQuery.hintsSize());
-
-
- namedQuery.moveHint(2, 0);
- ListIterator<QueryHint> hints = namedQuery.hints();
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
-
- assertEquals("BAR", javaNamedQuery.hintAt(0).getName());
- assertEquals("BAZ", javaNamedQuery.hintAt(1).getName());
- assertEquals("FOO", javaNamedQuery.hintAt(2).getName());
-
-
- namedQuery.moveHint(0, 1);
- hints = namedQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertEquals("BAR", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
-
- assertEquals("BAZ", javaNamedQuery.hintAt(0).getName());
- assertEquals("BAR", javaNamedQuery.hintAt(1).getName());
- assertEquals("FOO", javaNamedQuery.hintAt(2).getName());
- }
-
- public void testUpdateHints() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
- NamedQuery namedQuery = entity.namedQueries().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedQueryAnnotation javaNamedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME);
-
- javaNamedQuery.addHint(0);
- javaNamedQuery.addHint(1);
- javaNamedQuery.addHint(2);
-
- javaNamedQuery.hintAt(0).setName("FOO");
- javaNamedQuery.hintAt(1).setName("BAR");
- javaNamedQuery.hintAt(2).setName("BAZ");
-
- ListIterator<QueryHint> hints = namedQuery.hints();
- assertEquals("FOO", hints.next().getName());
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertFalse(hints.hasNext());
-
- javaNamedQuery.moveHint(2, 0);
- hints = namedQuery.hints();
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- assertFalse(hints.hasNext());
-
- javaNamedQuery.moveHint(0, 1);
- hints = namedQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertEquals("BAR", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- assertFalse(hints.hasNext());
-
- javaNamedQuery.removeHint(1);
- hints = namedQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- assertFalse(hints.hasNext());
-
- javaNamedQuery.removeHint(1);
- hints = namedQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertFalse(hints.hasNext());
-
- javaNamedQuery.removeHint(0);
- assertFalse(namedQuery.hints().hasNext());
- }
-
- public void testHintsSize() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Entity entity = javaEntity();
-
- NamedQuery namedQuery = entity.namedQueries().next();
- assertEquals(0, namedQuery.hintsSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- NamedQueryAnnotation javaNamedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME);
-
-
- javaNamedQuery.addHint(0);
- assertEquals(1, namedQuery.hintsSize());
-
- javaNamedQuery.addHint(0);
- assertEquals(2, namedQuery.hintsSize());
-
- javaNamedQuery.removeHint(0);
- javaNamedQuery.removeHint(0);
- assertEquals(0, namedQuery.hintsSize());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java
deleted file mode 100644
index 64e638cca9..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java
+++ /dev/null
@@ -1,899 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.OrderByAnnotation;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaOneToManyMappingTests extends ContextModelTestCase
-{
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createOneToManyAnnotation() throws Exception{
- this.createAnnotationAndMembers("OneToMany", "");
- }
-
- private IType createTestTargetEntityAddress() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int id;").append(CR);
- sb.append(CR);
- sb.append(" private String city;").append(CR);
- sb.append(CR);
- sb.append(" private String state;").append(CR);
- sb.append(CR);
- sb.append(" private int zip;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter);
- }
-
- private IType createTestEntityWithOneToManyMapping() throws Exception {
- createEntityAnnotation();
- createOneToManyAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithValidOneToManyMapping() throws Exception {
- createEntityAnnotation();
- createOneToManyAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private Collection<Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithCollectionOneToManyMapping() throws Exception {
- createEntityAnnotation();
- createOneToManyAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private Collection addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
- private IType createTestEntityWithNonCollectionOneToManyMapping() throws Exception {
- createEntityAnnotation();
- createOneToManyAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private Address addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
-
- public JavaOneToManyMappingTests(String name) {
- super(name);
- }
-
- public void testMorphToBasicMapping() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.setOrderBy("asdf");
- oneToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(oneToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToDefault() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.setOrderBy("asdf");
- oneToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(oneToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertNull(persistentAttribute.getSpecifiedMapping());
- assertTrue(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToVersionMapping() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.setOrderBy("asdf");
- oneToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(oneToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToIdMapping() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.setOrderBy("asdf");
- oneToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(oneToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedMapping() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.setOrderBy("asdf");
- oneToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(oneToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.setOrderBy("asdf");
- oneToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(oneToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToTransientMapping() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.setOrderBy("asdf");
- oneToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(oneToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToOneMapping() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.setOrderBy("asdf");
- oneToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(oneToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToManyMapping() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.setOrderBy("asdf");
- oneToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(oneToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToOneMapping() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.setOrderBy("asdf");
- oneToManyMapping.getJoinTable().setSpecifiedName("FOO");
- assertFalse(oneToManyMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
-
- public void testUpdateSpecifiedTargetEntity() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToManyMapping.getSpecifiedTargetEntity());
- assertNull(oneToMany.getTargetEntity());
-
- //set target entity in the resource model, verify context model updated
- oneToMany.setTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", oneToManyMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", oneToMany.getTargetEntity());
-
- //set target entity to null in the resource model
- oneToMany.setTargetEntity(null);
- assertNull(oneToManyMapping.getSpecifiedTargetEntity());
- assertNull(oneToMany.getTargetEntity());
- }
-
- public void testModifySpecifiedTargetEntity() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToManyMapping.getSpecifiedTargetEntity());
- assertNull(oneToMany.getTargetEntity());
-
- //set target entity in the context model, verify resource model updated
- oneToManyMapping.setSpecifiedTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", oneToManyMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", oneToMany.getTargetEntity());
-
- //set target entity to null in the context model
- oneToManyMapping.setSpecifiedTargetEntity(null);
- assertNull(oneToManyMapping.getSpecifiedTargetEntity());
- assertNull(oneToMany.getTargetEntity());
- }
-
- public void testUpdateSpecifiedFetch() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToManyMapping.getSpecifiedFetch());
- assertNull(oneToMany.getFetch());
-
- //set fetch in the resource model, verify context model updated
- oneToMany.setFetch(org.eclipse.jpt.core.resource.java.FetchType.EAGER);
- assertEquals(FetchType.EAGER, oneToManyMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.EAGER, oneToMany.getFetch());
-
- oneToMany.setFetch(org.eclipse.jpt.core.resource.java.FetchType.LAZY);
- assertEquals(FetchType.LAZY, oneToManyMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, oneToMany.getFetch());
-
-
- //set fetch to null in the resource model
- oneToMany.setFetch(null);
- assertNull(oneToManyMapping.getSpecifiedFetch());
- assertNull(oneToMany.getFetch());
- }
-
- public void testModifySpecifiedFetch() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToManyMapping.getSpecifiedFetch());
- assertNull(oneToMany.getFetch());
-
- //set fetch in the context model, verify resource model updated
- oneToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- assertEquals(FetchType.EAGER, oneToManyMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.EAGER, oneToMany.getFetch());
-
- oneToManyMapping.setSpecifiedFetch(FetchType.LAZY);
- assertEquals(FetchType.LAZY, oneToManyMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, oneToMany.getFetch());
-
-
- //set fetch to null in the context model
- oneToManyMapping.setSpecifiedFetch(null);
- assertNull(oneToManyMapping.getSpecifiedFetch());
- assertNull(oneToMany.getFetch());
- }
-
- public void testUpdateMappedBy() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToManyMapping.getMappedBy());
- assertNull(oneToMany.getMappedBy());
-
- //set mappedBy in the resource model, verify context model updated
- oneToMany.setMappedBy("newMappedBy");
- assertEquals("newMappedBy", oneToManyMapping.getMappedBy());
- assertEquals("newMappedBy", oneToMany.getMappedBy());
-
- //set mappedBy to null in the resource model
- oneToMany.setMappedBy(null);
- assertNull(oneToManyMapping.getMappedBy());
- assertNull(oneToMany.getMappedBy());
- }
-
- public void testModifyMappedBy() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToManyMapping.getMappedBy());
- assertNull(oneToMany.getMappedBy());
-
- //set mappedBy in the context model, verify resource model updated
- oneToManyMapping.setMappedBy("newTargetEntity");
- assertEquals("newTargetEntity", oneToManyMapping.getMappedBy());
- assertEquals("newTargetEntity", oneToMany.getMappedBy());
-
- //set mappedBy to null in the context model
- oneToManyMapping.setMappedBy(null);
- assertNull(oneToManyMapping.getMappedBy());
- assertNull(oneToMany.getMappedBy());
- }
-
-
- public void testCandidateMappedByAttributeNames() throws Exception {
- createTestEntityWithValidOneToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- Iterator<String> attributeNames = oneToManyMapping.candidateMappedByAttributeNames();
- assertEquals("id", attributeNames.next());
- assertEquals("city", attributeNames.next());
- assertEquals("state", attributeNames.next());
- assertEquals("zip", attributeNames.next());
- assertFalse(attributeNames.hasNext());
-
- oneToManyMapping.setSpecifiedTargetEntity("foo");
- attributeNames = oneToManyMapping.candidateMappedByAttributeNames();
- assertFalse(attributeNames.hasNext());
-
- oneToManyMapping.setSpecifiedTargetEntity(null);
- attributeNames = oneToManyMapping.candidateMappedByAttributeNames();
- assertEquals("id", attributeNames.next());
- assertEquals("city", attributeNames.next());
- assertEquals("state", attributeNames.next());
- assertEquals("zip", attributeNames.next());
- assertFalse(attributeNames.hasNext());
- }
-
- public void testDefaultTargetEntity() throws Exception {
- createTestEntityWithValidOneToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- //targetEntity not in the persistence unit, default still set, handled by validation
- assertEquals(PACKAGE_NAME + ".Address", oneToManyMapping.getDefaultTargetEntity());
-
- //add targetEntity to the persistence unit
- addXmlClassRef(PACKAGE_NAME + ".Address");
- assertEquals(PACKAGE_NAME + ".Address", oneToManyMapping.getDefaultTargetEntity());
-
- //test default still the same when specified target entity it set
- oneToManyMapping.setSpecifiedTargetEntity("foo");
- assertEquals(PACKAGE_NAME + ".Address", oneToManyMapping.getDefaultTargetEntity());
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef addressClassRef = classRefs.next();
- JavaPersistentType addressPersistentType = addressClassRef.getJavaPersistentType();
-
- //test target is not an Entity, default target entity still exists, this case handled with validation
- addressPersistentType.setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
- assertEquals(PACKAGE_NAME + ".Address", oneToManyMapping.getDefaultTargetEntity());
- }
-
- public void testDefaultTargetEntityCollectionType() throws Exception {
- createTestEntityWithCollectionOneToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- assertNull(oneToManyMapping.getDefaultTargetEntity());
- }
-
- public void testDefaultTargetEntityNonCollectionType() throws Exception {
- createTestEntityWithNonCollectionOneToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- assertNull(oneToManyMapping.getDefaultTargetEntity());
- }
-
- public void testTargetEntity() throws Exception {
- createTestEntityWithValidOneToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- assertEquals(PACKAGE_NAME + ".Address", oneToManyMapping.getTargetEntity());
-
- oneToManyMapping.setSpecifiedTargetEntity("foo");
- assertEquals("foo", oneToManyMapping.getTargetEntity());
-
- oneToManyMapping.setSpecifiedTargetEntity(null);
- assertEquals(PACKAGE_NAME + ".Address", oneToManyMapping.getTargetEntity());
- }
-
- public void testResolvedTargetEntity() throws Exception {
- createTestEntityWithValidOneToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- //targetEntity not in the persistence unit
- assertNull(oneToManyMapping.getResolvedTargetEntity());
-
- //add targetEntity to the persistence unit, now target entity should resolve
- addXmlClassRef(PACKAGE_NAME + ".Address");
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef addressClassRef = classRefs.next();
- TypeMapping addressTypeMapping = addressClassRef.getJavaPersistentType().getMapping();
- assertEquals(addressTypeMapping, oneToManyMapping.getResolvedTargetEntity());
-
- //test default still the same when specified target entity it set
- oneToManyMapping.setSpecifiedTargetEntity("foo");
- assertNull(oneToManyMapping.getResolvedTargetEntity());
-
-
- oneToManyMapping.setSpecifiedTargetEntity(PACKAGE_NAME + ".Address");
- assertEquals(addressTypeMapping, oneToManyMapping.getResolvedTargetEntity());
-
-
- oneToManyMapping.setSpecifiedTargetEntity(null);
- assertEquals(addressTypeMapping, oneToManyMapping.getResolvedTargetEntity());
- }
-
-
- public void testUpdateMapKey() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertNull(oneToManyMapping.getMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
-
- //set mapKey in the resource model, verify context model does not change
- attributeResource.addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNull(oneToManyMapping.getMapKey());
- MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNotNull(mapKey);
-
- //set mapKey name in the resource model, verify context model updated
- mapKey.setName("myMapKey");
- assertEquals("myMapKey", oneToManyMapping.getMapKey());
- assertEquals("myMapKey", mapKey.getName());
-
- //set mapKey name to null in the resource model
- mapKey.setName(null);
- assertNull(oneToManyMapping.getMapKey());
- assertNull(mapKey.getName());
-
- mapKey.setName("myMapKey");
- attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNull(oneToManyMapping.getMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifyMapKey() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertNull(oneToManyMapping.getMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
-
- //set mapKey in the context model, verify resource model updated
- oneToManyMapping.setMapKey("myMapKey");
- MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertEquals("myMapKey", oneToManyMapping.getMapKey());
- assertEquals("myMapKey", mapKey.getName());
-
- //set mapKey to null in the context model
- oneToManyMapping.setMapKey(null);
- assertNull(oneToManyMapping.getMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
- }
-
- public void testUpdateOrderBy() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertNull(oneToManyMapping.getOrderBy());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
-
- //set orderBy in the resource model, verify context model updated
- attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- orderBy.setValue("newOrderBy");
- assertEquals("newOrderBy", oneToManyMapping.getOrderBy());
- assertEquals("newOrderBy", orderBy.getValue());
-
- //set orderBy to null in the resource model
- attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertNull(oneToManyMapping.getOrderBy());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifyOrderBy() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertNull(oneToManyMapping.getOrderBy());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
-
- //set mappedBy in the context model, verify resource model updated
- oneToManyMapping.setOrderBy("newOrderBy");
- assertEquals("newOrderBy", oneToManyMapping.getOrderBy());
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertEquals("newOrderBy", orderBy.getValue());
-
- //set mappedBy to null in the context model
- oneToManyMapping.setOrderBy(null);
- assertNull(oneToManyMapping.getOrderBy());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testUpdateNoOrdering() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertTrue(oneToManyMapping.isNoOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
-
- //set orderBy in the resource model, verify context model updated
- attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertFalse(oneToManyMapping.isNoOrdering());
-
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- orderBy.setValue("newOrderBy");
- assertFalse(oneToManyMapping.isNoOrdering());
-
- //set orderBy to null in the resource model
- attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertTrue(oneToManyMapping.isNoOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testUpdatePkOrdering() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertFalse(oneToManyMapping.isPkOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
-
- //set orderBy in the resource model, verify context model updated
- attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertTrue(oneToManyMapping.isPkOrdering());
-
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- orderBy.setValue("newOrderBy");
- assertFalse(oneToManyMapping.isPkOrdering());
-
- //set orderBy to null in the resource model
- attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertFalse(oneToManyMapping.isPkOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-
- public void testUpdateCustomOrdering() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertFalse(oneToManyMapping.isCustomOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
-
- //set orderBy in the resource model, verify context model updated
- attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertFalse(oneToManyMapping.isCustomOrdering());
-
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- orderBy.setValue("newOrderBy");
- assertTrue(oneToManyMapping.isCustomOrdering());
-
- //set orderBy to null in the resource model
- attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME);
- assertFalse(oneToManyMapping.isCustomOrdering());
- assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java
deleted file mode 100644
index f30f1d4620..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java
+++ /dev/null
@@ -1,1311 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JoinColumnsAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumns;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaOneToOneMappingTests extends ContextModelTestCase
-{
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createOneToOneAnnotation() throws Exception{
- this.createAnnotationAndMembers("OneToOne", "");
- }
-
- private IType createTestTargetEntityAddress() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int id;").append(CR);
- sb.append(CR);
- sb.append(" private String city;").append(CR);
- sb.append(CR);
- sb.append(" private String state;").append(CR);
- sb.append(CR);
- sb.append(" private int zip;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter);
- }
-
-
- private IType createTestEntityWithOneToOneMapping() throws Exception {
- createEntityAnnotation();
- createOneToOneAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithValidOneToOneMapping() throws Exception {
- createEntityAnnotation();
- createOneToOneAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToOne").append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithCollectionOneToOneMapping() throws Exception {
- createEntityAnnotation();
- createOneToOneAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToOne").append(CR);
- sb.append(" private Collection address;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithGenericizedCollectionOneToOneMapping() throws Exception {
- createEntityAnnotation();
- createOneToOneAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToOne").append(CR);
- sb.append(" private Collection<Address> address;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- public JavaOneToOneMappingTests(String name) {
- super(name);
- }
-
- public void testMorphToBasicMapping() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(oneToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToDefault() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(oneToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertNull(persistentAttribute.getSpecifiedMapping());
- assertTrue(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToVersionMapping() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(oneToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToIdMapping() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(oneToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedMapping() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(oneToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(oneToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToTransientMapping() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(oneToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToOneMapping() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(oneToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToManyMapping() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(oneToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToManyMapping() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertFalse(oneToOneMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME));
- }
-
-
- public void testUpdateSpecifiedTargetEntity() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToOneMapping.getSpecifiedTargetEntity());
- assertNull(oneToOne.getTargetEntity());
-
- //set target entity in the resource model, verify context model updated
- oneToOne.setTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", oneToOneMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", oneToOne.getTargetEntity());
-
- //set target entity to null in the resource model
- oneToOne.setTargetEntity(null);
- assertNull(oneToOneMapping.getSpecifiedTargetEntity());
- assertNull(oneToOne.getTargetEntity());
- }
-
- public void testModifySpecifiedTargetEntity() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToOneMapping.getSpecifiedTargetEntity());
- assertNull(oneToOne.getTargetEntity());
-
- //set target entity in the context model, verify resource model updated
- oneToOneMapping.setSpecifiedTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", oneToOneMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", oneToOne.getTargetEntity());
-
- //set target entity to null in the context model
- oneToOneMapping.setSpecifiedTargetEntity(null);
- assertNull(oneToOneMapping.getSpecifiedTargetEntity());
- assertNull(oneToOne.getTargetEntity());
- }
-
- public void testUpdateMappedBy() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToOneMapping.getMappedBy());
- assertNull(oneToOne.getMappedBy());
-
- //set mappedBy in the resource model, verify context model updated
- oneToOne.setMappedBy("newMappedBy");
- assertEquals("newMappedBy", oneToOneMapping.getMappedBy());
- assertEquals("newMappedBy", oneToOne.getMappedBy());
-
- //set mappedBy to null in the resource model
- oneToOne.setMappedBy(null);
- assertNull(oneToOneMapping.getMappedBy());
- assertNull(oneToOne.getMappedBy());
- }
-
- public void testModifyMappedBy() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToOneMapping.getMappedBy());
- assertNull(oneToOne.getMappedBy());
-
- //set mappedBy in the context model, verify resource model updated
- oneToOneMapping.setMappedBy("newTargetEntity");
- assertEquals("newTargetEntity", oneToOneMapping.getMappedBy());
- assertEquals("newTargetEntity", oneToOne.getMappedBy());
-
- //set mappedBy to null in the context model
- oneToOneMapping.setMappedBy(null);
- assertNull(oneToOneMapping.getMappedBy());
- assertNull(oneToOne.getMappedBy());
- }
-
- public void testUpdateSpecifiedOptional() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToOneMapping.getSpecifiedOptional());
- assertNull(oneToOne.getOptional());
-
- //set optional in the resource model, verify context model updated
- oneToOne.setOptional(Boolean.TRUE);
- assertEquals(Boolean.TRUE, oneToOneMapping.getSpecifiedOptional());
- assertEquals(Boolean.TRUE, oneToOne.getOptional());
-
- oneToOne.setOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, oneToOneMapping.getSpecifiedOptional());
- assertEquals(Boolean.FALSE, oneToOne.getOptional());
-
-
- //set optional to null in the resource model
- oneToOne.setOptional(null);
- assertNull(oneToOneMapping.getSpecifiedOptional());
- assertNull(oneToOne.getOptional());
- }
-
- public void testModifySpecifiedOptional() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToOneMapping.getSpecifiedOptional());
- assertNull(oneToOne.getOptional());
-
- //set optional in the context model, verify resource model updated
- oneToOneMapping.setSpecifiedOptional(Boolean.TRUE);
- assertEquals(Boolean.TRUE, oneToOneMapping.getSpecifiedOptional());
- assertEquals(Boolean.TRUE, oneToOne.getOptional());
-
- oneToOneMapping.setSpecifiedOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, oneToOneMapping.getSpecifiedOptional());
- assertEquals(Boolean.FALSE, oneToOne.getOptional());
-
-
- //set optional to null in the context model
- oneToOneMapping.setSpecifiedOptional(null);
- assertNull(oneToOneMapping.getSpecifiedOptional());
- assertNull(oneToOne.getOptional());
- }
-
- public void testUpdateSpecifiedFetch() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToOneMapping.getSpecifiedFetch());
- assertNull(oneToOne.getFetch());
-
- //set fetch in the resource model, verify context model updated
- oneToOne.setFetch(org.eclipse.jpt.core.resource.java.FetchType.EAGER);
- assertEquals(FetchType.EAGER, oneToOneMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.EAGER, oneToOne.getFetch());
-
- oneToOne.setFetch(org.eclipse.jpt.core.resource.java.FetchType.LAZY);
- assertEquals(FetchType.LAZY, oneToOneMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, oneToOne.getFetch());
-
-
- //set fetch to null in the resource model
- oneToOne.setFetch(null);
- assertNull(oneToOneMapping.getSpecifiedFetch());
- assertNull(oneToOne.getFetch());
- }
-
- public void testModifySpecifiedFetch() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation();
-
- assertNull(oneToOneMapping.getSpecifiedFetch());
- assertNull(oneToOne.getFetch());
-
- //set fetch in the context model, verify resource model updated
- oneToOneMapping.setSpecifiedFetch(FetchType.EAGER);
- assertEquals(FetchType.EAGER, oneToOneMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.EAGER, oneToOne.getFetch());
-
- oneToOneMapping.setSpecifiedFetch(FetchType.LAZY);
- assertEquals(FetchType.LAZY, oneToOneMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, oneToOne.getFetch());
-
-
- //set fetch to null in the context model
- oneToOneMapping.setSpecifiedFetch(null);
- assertNull(oneToOneMapping.getSpecifiedFetch());
- assertNull(oneToOne.getFetch());
- }
-
- public void testSpecifiedJoinColumns() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- ListIterator<JavaJoinColumn> specifiedJoinColumns = oneToOneMapping.specifiedJoinColumns();
-
- assertFalse(specifiedJoinColumns.hasNext());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- JoinColumnAnnotation joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- joinColumn.setName("FOO");
- specifiedJoinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("FOO", specifiedJoinColumns.next().getName());
- assertFalse(specifiedJoinColumns.hasNext());
-
- joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- joinColumn.setName("BAR");
- specifiedJoinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("BAR", specifiedJoinColumns.next().getName());
- assertEquals("FOO", specifiedJoinColumns.next().getName());
- assertFalse(specifiedJoinColumns.hasNext());
-
-
- joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- joinColumn.setName("BAZ");
- specifiedJoinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", specifiedJoinColumns.next().getName());
- assertEquals("BAR", specifiedJoinColumns.next().getName());
- assertEquals("FOO", specifiedJoinColumns.next().getName());
- assertFalse(specifiedJoinColumns.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- attributeResource.move(1, 0, JPA.JOIN_COLUMNS);
- specifiedJoinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("BAR", specifiedJoinColumns.next().getName());
- assertEquals("BAZ", specifiedJoinColumns.next().getName());
- assertEquals("FOO", specifiedJoinColumns.next().getName());
- assertFalse(specifiedJoinColumns.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- specifiedJoinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", specifiedJoinColumns.next().getName());
- assertEquals("FOO", specifiedJoinColumns.next().getName());
- assertFalse(specifiedJoinColumns.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- specifiedJoinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("FOO", specifiedJoinColumns.next().getName());
- assertFalse(specifiedJoinColumns.hasNext());
-
-
- attributeResource.removeAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- specifiedJoinColumns = oneToOneMapping.specifiedJoinColumns();
- assertFalse(specifiedJoinColumns.hasNext());
- }
-
- public void testGetDefaultJoin() {
- //TODO
- }
-
- public void testSpecifiedJoinColumnsSize() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- assertEquals(0, oneToOneMapping.specifiedJoinColumnsSize());
-
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertEquals(1, oneToOneMapping.specifiedJoinColumnsSize());
-
- oneToOneMapping.removeSpecifiedJoinColumn(0);
- assertEquals(0, oneToOneMapping.specifiedJoinColumnsSize());
- }
-
- public void testJoinColumnsSize() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- assertEquals(1, oneToOneMapping.joinColumnsSize());
-
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertEquals(1, oneToOneMapping.joinColumnsSize());
-
- oneToOneMapping.addSpecifiedJoinColumn(0);
- assertEquals(2, oneToOneMapping.joinColumnsSize());
-
- oneToOneMapping.removeSpecifiedJoinColumn(0);
- oneToOneMapping.removeSpecifiedJoinColumn(0);
- assertEquals(1, oneToOneMapping.joinColumnsSize());
-
- //if non-owning side of the relationship then no default join column
- oneToOneMapping.setMappedBy("foo");
- assertEquals(0, oneToOneMapping.joinColumnsSize());
- }
-
- public void testAddSpecifiedJoinColumn() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- oneToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- oneToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("BAR");
- oneToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- Iterator<JavaResourceNode> joinColumns = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
-
- assertEquals("BAZ", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("BAR", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("FOO", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertFalse(joinColumns.hasNext());
- }
-
- public void testAddSpecifiedJoinColumn2() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- oneToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- oneToOneMapping.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- oneToOneMapping.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- Iterator<JavaResourceNode> joinColumns = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
-
- assertEquals("FOO", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("BAR", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("BAZ", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertFalse(joinColumns.hasNext());
- }
- public void testRemoveSpecifiedJoinColumn() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- oneToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- oneToOneMapping.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- oneToOneMapping.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertEquals(3, CollectionTools.size(attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)));
-
- oneToOneMapping.removeSpecifiedJoinColumn(1);
-
- Iterator<JavaResourceNode> joinColumnResources = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- assertEquals("FOO", ((JoinColumnAnnotation) joinColumnResources.next()).getName());
- assertEquals("BAZ", ((JoinColumnAnnotation) joinColumnResources.next()).getName());
- assertFalse(joinColumnResources.hasNext());
-
- Iterator<JoinColumn> joinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
-
- oneToOneMapping.removeSpecifiedJoinColumn(1);
- joinColumnResources = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- assertEquals("FOO", ((JoinColumnAnnotation) joinColumnResources.next()).getName());
- assertFalse(joinColumnResources.hasNext());
-
- joinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
-
- oneToOneMapping.removeSpecifiedJoinColumn(0);
- joinColumnResources = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- assertFalse(joinColumnResources.hasNext());
- joinColumns = oneToOneMapping.specifiedJoinColumns();
- assertFalse(joinColumns.hasNext());
-
- assertNull(attributeResource.getAnnotation(JoinColumnsAnnotation.ANNOTATION_NAME));
- }
-
- public void testMoveSpecifiedJoinColumn() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- oneToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- oneToOneMapping.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- oneToOneMapping.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentAttribute attributeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME).attributes().next();
-
- ListIterator<JoinColumnAnnotation> javaJoinColumns = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- assertEquals(3, CollectionTools.size(javaJoinColumns));
-
-
- oneToOneMapping.moveSpecifiedJoinColumn(2, 0);
- ListIterator<JoinColumn> primaryKeyJoinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getSpecifiedName());
-
- javaJoinColumns = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- assertEquals("BAR", javaJoinColumns.next().getName());
- assertEquals("BAZ", javaJoinColumns.next().getName());
- assertEquals("FOO", javaJoinColumns.next().getName());
-
-
- oneToOneMapping.moveSpecifiedJoinColumn(0, 1);
- primaryKeyJoinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getSpecifiedName());
-
- javaJoinColumns = attributeResource.annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- assertEquals("BAZ", javaJoinColumns.next().getName());
- assertEquals("BAR", javaJoinColumns.next().getName());
- assertEquals("FOO", javaJoinColumns.next().getName());
- }
-
- public void testUpdateSpecifiedJoinColumns() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
- JavaResourcePersistentAttribute attributeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME).attributes().next();
-
- ((JoinColumnAnnotation) attributeResource.addAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((JoinColumnAnnotation) attributeResource.addAnnotation(1, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((JoinColumnAnnotation) attributeResource.addAnnotation(2, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)).setName("BAZ");
-
- ListIterator<JoinColumn> joinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.move(2, 0, JoinColumnsAnnotation.ANNOTATION_NAME);
- joinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.move(0, 1, JoinColumnsAnnotation.ANNOTATION_NAME);
- joinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.removeAnnotation(1, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- joinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.removeAnnotation(1, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- joinColumns = oneToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.removeAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- joinColumns = oneToOneMapping.specifiedJoinColumns();
- assertFalse(joinColumns.hasNext());
- }
-
- public void testJoinColumnIsVirtual() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- assertTrue(oneToOneMapping.getDefaultJoinColumn().isVirtual());
-
- oneToOneMapping.addSpecifiedJoinColumn(0);
- JoinColumn specifiedJoinColumn = oneToOneMapping.specifiedJoinColumns().next();
- assertFalse(specifiedJoinColumn.isVirtual());
-
- assertNull(oneToOneMapping.getDefaultJoinColumn());
- }
-
- public void testCandidateMappedByAttributeNames() throws Exception {
- createTestEntityWithValidOneToOneMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- Iterator<String> attributeNames = oneToOneMapping.candidateMappedByAttributeNames();
- assertEquals("id", attributeNames.next());
- assertEquals("city", attributeNames.next());
- assertEquals("state", attributeNames.next());
- assertEquals("zip", attributeNames.next());
- assertFalse(attributeNames.hasNext());
-
- oneToOneMapping.setSpecifiedTargetEntity("foo");
- attributeNames = oneToOneMapping.candidateMappedByAttributeNames();
- assertFalse(attributeNames.hasNext());
-
- oneToOneMapping.setSpecifiedTargetEntity(null);
- attributeNames = oneToOneMapping.candidateMappedByAttributeNames();
- assertEquals("id", attributeNames.next());
- assertEquals("city", attributeNames.next());
- assertEquals("state", attributeNames.next());
- assertEquals("zip", attributeNames.next());
- assertFalse(attributeNames.hasNext());
- }
-
- public void testDefaultTargetEntity() throws Exception {
- createTestEntityWithValidOneToOneMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- //targetEntity not in the persistence unit, default still set, handled by validation
- assertEquals(PACKAGE_NAME + ".Address", oneToOneMapping.getDefaultTargetEntity());
-
- //add targetEntity to the persistence unit
- addXmlClassRef(PACKAGE_NAME + ".Address");
- assertEquals(PACKAGE_NAME + ".Address", oneToOneMapping.getDefaultTargetEntity());
-
- //test default still the same when specified target entity it set
- oneToOneMapping.setSpecifiedTargetEntity("foo");
- assertEquals(PACKAGE_NAME + ".Address", oneToOneMapping.getDefaultTargetEntity());
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef addressClassRef = classRefs.next();
- JavaPersistentType addressPersistentType = addressClassRef.getJavaPersistentType();
-
- //test target is not an Entity, default target entity still exists, this case handled with validation
- addressPersistentType.setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
- assertEquals(PACKAGE_NAME + ".Address", oneToOneMapping.getDefaultTargetEntity());
- }
-
- public void testDefaultTargetEntityCollectionType() throws Exception {
- createTestEntityWithCollectionOneToOneMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- assertNull(oneToOneMapping.getDefaultTargetEntity());
- }
-
- public void testDefaultTargetEntityGenericizedCollectionType() throws Exception {
- createTestEntityWithGenericizedCollectionOneToOneMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- assertNull(oneToOneMapping.getDefaultTargetEntity());
- }
-
- public void testTargetEntity() throws Exception {
- createTestEntityWithValidOneToOneMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- assertEquals(PACKAGE_NAME + ".Address", oneToOneMapping.getTargetEntity());
-
- oneToOneMapping.setSpecifiedTargetEntity("foo");
- assertEquals("foo", oneToOneMapping.getTargetEntity());
-
- oneToOneMapping.setSpecifiedTargetEntity(null);
- assertEquals(PACKAGE_NAME + ".Address", oneToOneMapping.getTargetEntity());
- }
-
- public void testResolvedTargetEntity() throws Exception {
- createTestEntityWithValidOneToOneMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- //targetEntity not in the persistence unit
- assertNull(oneToOneMapping.getResolvedTargetEntity());
-
- //add targetEntity to the persistence unit, now target entity should resolve
- addXmlClassRef(PACKAGE_NAME + ".Address");
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef addressClassRef = classRefs.next();
- TypeMapping addressTypeMapping = addressClassRef.getJavaPersistentType().getMapping();
- assertEquals(addressTypeMapping, oneToOneMapping.getResolvedTargetEntity());
-
- //test default still the same when specified target entity it set
- oneToOneMapping.setSpecifiedTargetEntity("foo");
- assertNull(oneToOneMapping.getResolvedTargetEntity());
-
-
- oneToOneMapping.setSpecifiedTargetEntity(PACKAGE_NAME + ".Address");
- assertEquals(addressTypeMapping, oneToOneMapping.getResolvedTargetEntity());
-
-
- oneToOneMapping.setSpecifiedTargetEntity(null);
- assertEquals(addressTypeMapping, oneToOneMapping.getResolvedTargetEntity());
- }
-
- public void testPrimaryKeyJoinColumns() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- ListIterator<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns = oneToOneMapping.primaryKeyJoinColumns();
-
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- PrimaryKeyJoinColumnAnnotation joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- joinColumn.setName("FOO");
- primaryKeyJoinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- joinColumn.setName("BAR");
- primaryKeyJoinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
-
- joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- joinColumn.setName("BAZ");
- primaryKeyJoinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- attributeResource.move(1, 0, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- primaryKeyJoinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- primaryKeyJoinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- primaryKeyJoinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
-
- attributeResource.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- primaryKeyJoinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertFalse(primaryKeyJoinColumns.hasNext());
- }
-
- public void testPrimaryKeyJoinColumnsSize() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- assertEquals(0, oneToOneMapping.primaryKeyJoinColumnsSize());
-
- oneToOneMapping.addPrimaryKeyJoinColumn(0);
- assertEquals(1, oneToOneMapping.primaryKeyJoinColumnsSize());
-
- oneToOneMapping.removePrimaryKeyJoinColumn(0);
- assertEquals(0, oneToOneMapping.primaryKeyJoinColumnsSize());
- }
-
- public void testAddPrimaryKeyJoinColumn() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- oneToOneMapping.addPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- oneToOneMapping.addPrimaryKeyJoinColumn(0).setSpecifiedName("BAR");
- oneToOneMapping.addPrimaryKeyJoinColumn(0).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- Iterator<JavaResourceNode> joinColumns = attributeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
-
- assertEquals("BAZ", ((PrimaryKeyJoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("BAR", ((PrimaryKeyJoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("FOO", ((PrimaryKeyJoinColumnAnnotation) joinColumns.next()).getName());
- assertFalse(joinColumns.hasNext());
- }
-
- public void testAddPrimaryKeyJoinColumn2() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- oneToOneMapping.addPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- oneToOneMapping.addPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- oneToOneMapping.addPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- Iterator<JavaResourceNode> joinColumns = attributeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
-
- assertEquals("FOO", ((PrimaryKeyJoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("BAR", ((PrimaryKeyJoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("BAZ", ((PrimaryKeyJoinColumnAnnotation) joinColumns.next()).getName());
- assertFalse(joinColumns.hasNext());
- }
-
- public void testRemovePrimaryKeyJoinColumn() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- oneToOneMapping.addPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- oneToOneMapping.addPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- oneToOneMapping.addPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
-
- assertEquals(3, CollectionTools.size(attributeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME)));
-
- oneToOneMapping.removePrimaryKeyJoinColumn(1);
-
- Iterator<JavaResourceNode> joinColumnResources = attributeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- assertEquals("FOO", ((PrimaryKeyJoinColumnAnnotation) joinColumnResources.next()).getName());
- assertEquals("BAZ", ((PrimaryKeyJoinColumnAnnotation) joinColumnResources.next()).getName());
- assertFalse(joinColumnResources.hasNext());
-
- Iterator<PrimaryKeyJoinColumn> joinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
-
- oneToOneMapping.removePrimaryKeyJoinColumn(1);
- joinColumnResources = attributeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- assertEquals("FOO", ((PrimaryKeyJoinColumnAnnotation) joinColumnResources.next()).getName());
- assertFalse(joinColumnResources.hasNext());
-
- joinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
-
- oneToOneMapping.removePrimaryKeyJoinColumn(0);
- joinColumnResources = attributeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- assertFalse(joinColumnResources.hasNext());
- joinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertFalse(joinColumns.hasNext());
-
- assertNull(attributeResource.getAnnotation(PrimaryKeyJoinColumns.ANNOTATION_NAME));
- }
-
- public void testMovePrimaryKeyJoinColumn() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
-
- oneToOneMapping.addPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- oneToOneMapping.addPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- oneToOneMapping.addPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentAttribute attributeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME).attributes().next();
-
- ListIterator<PrimaryKeyJoinColumnAnnotation> javaJoinColumns = attributeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- assertEquals(3, CollectionTools.size(javaJoinColumns));
-
-
- oneToOneMapping.movePrimaryKeyJoinColumn(2, 0);
- ListIterator<PrimaryKeyJoinColumn> primaryKeyJoinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getSpecifiedName());
-
- javaJoinColumns = attributeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- assertEquals("BAR", javaJoinColumns.next().getName());
- assertEquals("BAZ", javaJoinColumns.next().getName());
- assertEquals("FOO", javaJoinColumns.next().getName());
-
-
- oneToOneMapping.movePrimaryKeyJoinColumn(0, 1);
- primaryKeyJoinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getSpecifiedName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getSpecifiedName());
-
- javaJoinColumns = attributeResource.annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- assertEquals("BAZ", javaJoinColumns.next().getName());
- assertEquals("BAR", javaJoinColumns.next().getName());
- assertEquals("FOO", javaJoinColumns.next().getName());
- }
-
- public void testUpdatePrimaryKeyJoinColumns() throws Exception {
- createTestEntityWithOneToOneMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
- JavaResourcePersistentAttribute attributeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME).attributes().next();
-
- ((PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(0, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME)).setName("FOO");
- ((PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(1, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME)).setName("BAR");
- ((PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(2, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME)).setName("BAZ");
-
- ListIterator<PrimaryKeyJoinColumn> joinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.move(2, 0, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- joinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.move(0, 1, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- joinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.removeAnnotation(1, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- joinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.removeAnnotation(1, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- joinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- attributeResource.removeAnnotation(0, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumns.ANNOTATION_NAME);
- joinColumns = oneToOneMapping.primaryKeyJoinColumns();
- assertFalse(joinColumns.hasNext());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentAttributeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentAttributeTests.java
deleted file mode 100644
index 17f39f6873..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentAttributeTests.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.core.context.java.JavaEmbeddedMapping;
-import org.eclipse.jpt.core.context.java.JavaIdMapping;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaPersistentAttributeTests extends ContextModelTestCase
-{
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
-
- private IType createTestEntityAnnotatedField() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Id", "");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestEntityAnnotatedMethod() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Id", "");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
-
- public JavaPersistentAttributeTests(String name) {
- super(name);
- }
-
- public void testGetName() throws Exception {
- createTestType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
-
- assertEquals("id", persistentAttribute.getName());
- }
-
- public void testGetMapping() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- assertTrue(persistentAttribute.getMapping() instanceof JavaIdMapping);
-
- persistentAttribute.setSpecifiedMappingKey(null);
- assertTrue(persistentAttribute.getMapping() instanceof JavaBasicMapping);
- }
-
- public void testGetSpecifiedMapping() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- assertTrue(persistentAttribute.getSpecifiedMapping() instanceof JavaIdMapping);
-
- persistentAttribute.setSpecifiedMappingKey(null);
- assertNull(persistentAttribute.getSpecifiedMapping());
- }
-
- public void testGetSpecifiedMappingNull() throws Exception {
- createTestType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
-
- assertNull(persistentAttribute.getSpecifiedMapping());
- assertNotNull(persistentAttribute.getMapping());
- }
-
- public void testMappingKey() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
-
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMappingKey());
-
- persistentAttribute.setSpecifiedMappingKey(null);
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMappingKey());
- }
-
- public void testDefaultMappingKey() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
-
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMappingKey());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
- }
-
- public void testSetSpecifiedMappingKey() throws Exception {
- createTestType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- assertNull(persistentAttribute.getSpecifiedMapping());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNotNull(attributeResource.getMappingAnnotation());
- assertTrue(attributeResource.getMappingAnnotation() instanceof EmbeddedAnnotation);
-
- assertEquals(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMappingKey());
- assertTrue(persistentAttribute.getSpecifiedMapping() instanceof JavaEmbeddedMapping);
- }
-
- public void testSetSpecifiedMappingKey2() throws Exception {
- createTestEntityAnnotatedField();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMappingKey());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNotNull(attributeResource.getMappingAnnotation());
- assertTrue(attributeResource.getMappingAnnotation() instanceof EmbeddedAnnotation);
-
- assertEquals(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMappingKey());
- assertTrue(persistentAttribute.getSpecifiedMapping() instanceof JavaEmbeddedMapping);
- }
-
- public void testSetSpecifiedMappingKeyNull() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMappingKey());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation());
- assertNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
-
- assertNull(persistentAttribute.getSpecifiedMapping());
- }
-
- public void testGetMappingKeyMappingChangeInResourceModel() throws Exception {
- createTestEntityAnnotatedField();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMappingKey());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.setMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME);
-
- assertEquals(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMappingKey());
- }
-
- public void testGetMappingKeyMappingChangeInResourceModel2() throws Exception {
- createTestType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- assertNull(persistentAttribute.getSpecifiedMapping());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- attributeResource.setMappingAnnotation(BasicAnnotation.ANNOTATION_NAME);
-
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getSpecifiedMapping().getKey());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java
deleted file mode 100644
index 64096c7805..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java
+++ /dev/null
@@ -1,701 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation;
-import org.eclipse.jpt.core.resource.java.EntityAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaPersistentTypeTests extends ContextModelTestCase
-{
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private IType createTestEntityAnnotatedField() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Id", "");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestEntityAnnotatedMethod() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Id", "");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
- private IType createTestEntityAnnotatedFieldAndMethod() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Id", "");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- return this.createTestType(PACKAGE_NAME, "AnnotationTestTypeChild.java", "AnnotationTestTypeChild", new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendExtendsImplementsTo(StringBuilder sb) {
- sb.append("extends " + TYPE_NAME + " ");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- });
- }
-
- private IType createTestSubTypeWithFieldAnnotation() throws Exception {
- return this.createTestType(PACKAGE_NAME, "AnnotationTestTypeChild.java", "AnnotationTestTypeChild", new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendExtendsImplementsTo(StringBuilder sb) {
- sb.append("extends " + TYPE_NAME + " ");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestSubTypeWithMethodAnnotation() throws Exception {
- return this.createTestType(PACKAGE_NAME, "AnnotationTestTypeChild.java", "AnnotationTestTypeChild", new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendExtendsImplementsTo(StringBuilder sb) {
- sb.append("extends " + TYPE_NAME + " ");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestSubTypeNonPersistent() throws Exception {
- return this.createTestType(PACKAGE_NAME, "AnnotationTestTypeChild.java", "AnnotationTestTypeChild", new DefaultAnnotationWriter() {
- @Override
- public void appendExtendsImplementsTo(StringBuilder sb) {
- sb.append("extends " + TYPE_NAME + " ");
- }
- });
- }
-
- private IType createTestSubTypePersistentExtendsNonPersistent() throws Exception {
- return this.createTestType(PACKAGE_NAME, "AnnotationTestTypeChild2.java", "AnnotationTestTypeChild2", new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendExtendsImplementsTo(StringBuilder sb) {
- sb.append("extends AnnotationTestTypeChild ");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- public JavaPersistentTypeTests(String name) {
- super(name);
- }
-
- public void testGetName() throws Exception {
- createTestType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, javaPersistentType().getName());
- }
-
- public void testGetAccessNothingAnnotated() throws Exception {
- createTestType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(AccessType.FIELD, javaPersistentType().getAccess());
- }
-
- public void testAccessField() throws Exception {
- createTestEntityAnnotatedField();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(AccessType.FIELD, javaPersistentType().getAccess());
- }
-
- public void testAccessProperty() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(AccessType.PROPERTY, javaPersistentType().getAccess());
- }
-
- public void testAccessFieldAndMethodAnnotated() throws Exception {
- createTestEntityAnnotatedFieldAndMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(AccessType.FIELD, javaPersistentType().getAccess());
- }
-
- public void testAccessInheritance() throws Exception {
- createTestEntityAnnotatedMethod();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef classRef = classRefs.next();
-
- JavaPersistentType javaPersistentType = classRef.getJavaPersistentType();
- assertEquals(PACKAGE_NAME + ".AnnotationTestTypeChild", javaPersistentType.getName());
-
- assertEquals(AccessType.PROPERTY, javaPersistentType.getAccess());
- }
-
- public void testAccessInheritance2() throws Exception {
- createTestEntityAnnotatedField();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef classRef = classRefs.next();
-
- JavaPersistentType javaPersistentType = classRef.getJavaPersistentType();
- assertEquals(PACKAGE_NAME + ".AnnotationTestTypeChild", javaPersistentType.getName());
-
- assertEquals(AccessType.FIELD, javaPersistentType.getAccess());
- }
-
- public void testAccessInheritance3() throws Exception {
- createTestEntityAnnotatedField();
- createTestSubTypeWithMethodAnnotation();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef classRef = classRefs.next();
-
- JavaPersistentType javaPersistentType = classRef.getJavaPersistentType();
- assertEquals(PACKAGE_NAME + ".AnnotationTestTypeChild", javaPersistentType.getName());
-
- assertEquals(AccessType.PROPERTY, javaPersistentType.getAccess());
- }
-
- public void testAccessInheritance4() throws Exception {
- createTestEntityAnnotatedMethod();
- createTestSubTypeWithFieldAnnotation();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef classRef = classRefs.next();
- JavaPersistentType javaPersistentType = classRef.getJavaPersistentType();
-
- assertEquals(PACKAGE_NAME + ".AnnotationTestTypeChild", javaPersistentType.getName());
-
- assertEquals(AccessType.FIELD, javaPersistentType.getAccess());
- }
-
- //inherited class having annotations set wins over the default access set on persistence-unit-defaults
- public void testAccessInheritancePersistenceUnitDefaultAccess() throws Exception {
- createTestEntityAnnotatedMethod();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.FIELD);
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef classRef = classRefs.next();
- JavaPersistentType javaPersistentType = classRef.getJavaPersistentType();
-
- assertEquals(PACKAGE_NAME + ".AnnotationTestTypeChild", javaPersistentType.getName());
-
- assertEquals(AccessType.PROPERTY, javaPersistentType.getAccess());
- }
-
- public void testAccessXmlNoAccessNoAnnotations() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- createTestEntity();
-
- JavaPersistentType javaPersistentType = entityPersistentType.getJavaPersistentType();
- assertEquals(AccessType.FIELD, javaPersistentType.getAccess());
- }
-
- public void testAccessXmlEntityAccessNoAnnotations() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- createTestEntity();
- JavaPersistentType javaPersistentType = entityPersistentType.getJavaPersistentType();
-
- entityPersistentType.getMapping().setSpecifiedAccess(AccessType.FIELD);
- assertEquals(AccessType.FIELD, javaPersistentType.getAccess());
-
- entityPersistentType.getMapping().setSpecifiedAccess(AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, javaPersistentType.getAccess());
- }
-
- public void testAccessXmlPersistenceUnitDefaultsAccessNoAnnotations() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- createTestEntity();
- JavaPersistentType javaPersistentType = entityPersistentType.getJavaPersistentType();
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.FIELD);
- assertEquals(AccessType.FIELD, javaPersistentType.getAccess());
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, javaPersistentType.getAccess());
- }
-
- public void testAccessXmlEntityPropertyAccessAndFieldAnnotations() throws Exception {
- //xml access set to property, field annotations, JavaPersistentType access is property
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- createTestEntityAnnotatedField();
- JavaPersistentType javaPersistentType = entityPersistentType.getJavaPersistentType();
-
- entityPersistentType.getMapping().setSpecifiedAccess(AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, javaPersistentType.getAccess());
- }
-
- public void testAccessXmlEntityFieldAccessAndPropertyAnnotations() throws Exception {
- //xml access set to field, property annotations, JavaPersistentType access is field
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- createTestEntityAnnotatedMethod();
- JavaPersistentType javaPersistentType = entityPersistentType.getJavaPersistentType();
-
- entityPersistentType.getMapping().setSpecifiedAccess(AccessType.FIELD);
- assertEquals(AccessType.FIELD, javaPersistentType.getAccess());
- }
-
- public void testAccessXmlPersistenceUnitDefaultsAccessFieldAnnotations() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- createTestEntityAnnotatedField();
- JavaPersistentType javaPersistentType = entityPersistentType.getJavaPersistentType();
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.PROPERTY);
- assertEquals(AccessType.FIELD, javaPersistentType.getAccess());
- }
-
- //inheritance wins over entity-mappings specified access
- public void testAccessXmlEntityMappingsAccessWithInheritance() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentType childEntityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
-
- createTestEntityAnnotatedMethod();
- createTestSubType();
- JavaPersistentType childJavaPersistentType = childEntityPersistentType.getJavaPersistentType();
-
- entityMappings().setSpecifiedAccess(AccessType.FIELD);
- assertEquals(AccessType.PROPERTY, entityPersistentType.getJavaPersistentType().getAccess());
- assertEquals(AccessType.PROPERTY, childJavaPersistentType.getAccess());
- }
-
- public void testAccessXmlMetadataCompleteFieldAnnotations() throws Exception {
- //xml access set to property, so even though there are field annotations, JavaPersistentType
- //access should be property
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- createTestEntityAnnotatedField();
- JavaPersistentType javaPersistentType = entityPersistentType.getJavaPersistentType();
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.PROPERTY);
- entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertEquals(AccessType.PROPERTY, javaPersistentType.getAccess());
-
- }
-
- public void testAccessNoXmlAccessXmlMetdataCompletePropertyAnnotations() throws Exception {
- //xml access not set, metadata complete set. JavaPersistentType access
- //is field??
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- createTestEntityAnnotatedMethod();
- JavaPersistentType javaPersistentType = entityPersistentType.getJavaPersistentType();
-
- entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertEquals(AccessType.FIELD, javaPersistentType.getAccess());
- }
-
- public void testParentPersistentType() throws Exception {
- createTestEntityAnnotatedMethod();
- createTestSubTypeWithFieldAnnotation();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- ClassRef classRef = classRefs.next();
- JavaPersistentType rootJavaPersistentType = classRef.getJavaPersistentType();
-
- classRef = classRefs.next();
- JavaPersistentType childJavaPersistentType = classRef.getJavaPersistentType();
-
- assertEquals(rootJavaPersistentType, childJavaPersistentType.getParentPersistentType());
- assertNull(rootJavaPersistentType.getParentPersistentType());
- }
-
- public void testParentPersistentType2() throws Exception {
- createTestEntityAnnotatedMethod();
- createTestSubTypeWithFieldAnnotation();
-
- //parent is not added to the persistenceUnit, so even though it has an Entity
- //annotation it should not be found as the parentPersistentType
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- JavaPersistentType javaPersistentType = classRefs.next().getJavaPersistentType();
-
- assertNull(javaPersistentType.getParentPersistentType());
- }
-
- //Entity extends Non-Entity extends Entity
- public void testParentPersistentType3() throws Exception {
- createTestEntityAnnotatedMethod();
- createTestSubTypeNonPersistent();
- createTestSubTypePersistentExtendsNonPersistent();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild2");
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- ClassRef classRef = classRefs.next();
- JavaPersistentType rootJavaPersistentType = classRef.getJavaPersistentType();
-
- classRef = classRefs.next();
- JavaPersistentType childJavaPersistentType = classRef.getJavaPersistentType();
-
- assertEquals(rootJavaPersistentType, childJavaPersistentType.getParentPersistentType());
- assertNull(rootJavaPersistentType.getParentPersistentType());
- }
-
- public void testInheritanceHierarchy() throws Exception {
- createTestEntityAnnotatedMethod();
- createTestSubTypeNonPersistent();
- createTestSubTypePersistentExtendsNonPersistent();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild2");
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- JavaPersistentType rootJavaPersistentType = classRefs.next().getJavaPersistentType();
- JavaPersistentType childJavaPersistentType = classRefs.next().getJavaPersistentType();
-
- Iterator<PersistentType> inheritanceHierarchy = childJavaPersistentType.inheritanceHierarchy();
-
- assertEquals(childJavaPersistentType, inheritanceHierarchy.next());
- assertEquals(rootJavaPersistentType, inheritanceHierarchy.next());
- }
-
- public void testInheritanceHierarchy2() throws Exception {
- createTestEntityAnnotatedMethod();
- createTestSubTypeNonPersistent();
- createTestSubTypePersistentExtendsNonPersistent();
-
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild2");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
- JavaPersistentType childJavaPersistentType = classRefs.next().getJavaPersistentType();
- JavaPersistentType rootJavaPersistentType = classRefs.next().getJavaPersistentType();
-
- Iterator<PersistentType> inheritanceHierarchy = childJavaPersistentType.inheritanceHierarchy();
-
- assertEquals(childJavaPersistentType, inheritanceHierarchy.next());
- assertEquals(rootJavaPersistentType, inheritanceHierarchy.next());
- }
-
- public void testGetMapping() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, javaPersistentType().getMapping().getKey());
- }
-
- public void testGetMappingNull() throws Exception {
- createTestType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(MappingKeys.NULL_TYPE_MAPPING_KEY, javaPersistentType().getMapping().getKey());
- }
-
- public void testMappingKey() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, javaPersistentType().getMappingKey());
- }
-
- public void testMappingKeyNull() throws Exception {
- createTestType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(MappingKeys.NULL_TYPE_MAPPING_KEY, javaPersistentType().getMappingKey());
- }
-
- public void testSetMappingKey() throws Exception {
- createTestType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(MappingKeys.NULL_TYPE_MAPPING_KEY, javaPersistentType().getMappingKey());
-
- javaPersistentType().setMappingKey(MappingKeys.ENTITY_TYPE_MAPPING_KEY);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- assertNotNull(typeResource.getMappingAnnotation());
- assertTrue(typeResource.getMappingAnnotation() instanceof EntityAnnotation);
-
- assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, javaPersistentType().getMappingKey());
- }
-
- public void testSetMappingKey2() throws Exception {
- createTestEntityAnnotatedField();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, javaPersistentType().getMappingKey());
-
- javaPersistentType().setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- assertNotNull(typeResource.getMappingAnnotation());
- assertTrue(typeResource.getMappingAnnotation() instanceof EmbeddableAnnotation);
-
- assertEquals(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, javaPersistentType().getMappingKey());
- }
-
- public void testSetMappingKeyNull() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, javaPersistentType().getMappingKey());
-
- javaPersistentType().setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- assertNull(typeResource.getMappingAnnotation());
- assertNull(typeResource.getMappingAnnotation(EntityAnnotation.ANNOTATION_NAME));
-
- assertEquals(MappingKeys.NULL_TYPE_MAPPING_KEY, javaPersistentType().getMappingKey());
- }
-
- public void testGetMappingKeyMappingChangeInResourceModel() throws Exception {
- createTestEntityAnnotatedField();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, javaPersistentType().getMappingKey());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.setMappingAnnotation(EmbeddableAnnotation.ANNOTATION_NAME);
-
- assertEquals(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, javaPersistentType().getMappingKey());
- }
-
- public void testGetMappingKeyMappingChangeInResourceModel2() throws Exception {
- createTestType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(MappingKeys.NULL_TYPE_MAPPING_KEY, javaPersistentType().getMappingKey());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.setMappingAnnotation(EntityAnnotation.ANNOTATION_NAME);
-
- assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, javaPersistentType().getMappingKey());
- }
-
- public void testIsMapped() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertTrue(javaPersistentType().isMapped());
-
- javaPersistentType().setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
- assertFalse(javaPersistentType().isMapped());
- }
-
- public void testAttributes() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- ListIterator<JavaPersistentAttribute> attributes = javaPersistentType().attributes();
-
- assertEquals("id", attributes.next().getName());
- assertFalse(attributes.hasNext());
- }
-
- public void testAttributes2() throws Exception {
- createTestEntityAnnotatedFieldAndMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- ListIterator<JavaPersistentAttribute> attributes = javaPersistentType().attributes();
-
- assertEquals("id", attributes.next().getName());
- assertEquals("name", attributes.next().getName());
- assertFalse(attributes.hasNext());
- }
-
- public void testAttributesSize() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(1, javaPersistentType().attributesSize());
- }
-
- public void testAttributesSize2() throws Exception {
- createTestEntityAnnotatedFieldAndMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(2, javaPersistentType().attributesSize());
- }
-
- public void testAttributeNamed() throws Exception {
- createTestEntityAnnotatedMethod();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute attribute = javaPersistentType().getAttributeNamed("id");
-
- assertEquals("id", attribute.getName());
- assertNull(javaPersistentType().getAttributeNamed("name"));
- assertNull(javaPersistentType().getAttributeNamed("foo"));
- }
-
- public void testAttributeNamed2() throws Exception {
- createTestEntityAnnotatedField();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute attribute = javaPersistentType().getAttributeNamed("name");
-
- assertEquals("name", attribute.getName());
-
- assertNull(javaPersistentType().getAttributeNamed("foo"));
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPrimaryKeyJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPrimaryKeyJoinColumnTests.java
deleted file mode 100644
index 57f27f280e..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPrimaryKeyJoinColumnTests.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaPrimaryKeyJoinColumnTests extends ContextModelTestCase
-{
- private static final String PRIMARY_KEY_JOIN_COLUMN_NAME = "MY_PRIMARY_KEY_JOIN_COLUMN";
- private static final String COLUMN_DEFINITION = "MY_COLUMN_DEFINITION";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception{
- this.createAnnotationAndMembers("Id", "");
- }
-
- private void createPrimaryKeyJoinColumnAnnotation() throws Exception{
- this.createAnnotationAndMembers("PrimaryKeyJoinColumn",
- "String name() default \"\";" +
- "String referencedColumnName() default \"\";" +
- "String columnDefinition() default \"\";");
- }
-
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestEntityWithPrimaryKeyJoinColumn() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
- createPrimaryKeyJoinColumnAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.PRIMARY_KEY_JOIN_COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@PrimaryKeyJoinColumn(name=\"" + PRIMARY_KEY_JOIN_COLUMN_NAME + "\")");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
-
- public JavaPrimaryKeyJoinColumnTests(String name) {
- super(name);
- }
-
- public void testGetSpecifiedName() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertEquals(PRIMARY_KEY_JOIN_COLUMN_NAME, specifiedPkJoinColumn.getSpecifiedName());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- PrimaryKeyJoinColumnAnnotation pkJoinColumnResource = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
-
- pkJoinColumnResource.setName("FOO");
- specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertEquals("FOO", specifiedPkJoinColumn.getName());
- }
-
- public void testGetDefaultNameNoSpecifiedPrimaryKeyJoinColumns() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn pkJoinColumn = javaEntity().getDefaultPrimaryKeyJoinColumn();
- assertEquals("id", pkJoinColumn.getDefaultName());
- }
-
- public void testGetDefaultName() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getDefaultPrimaryKeyJoinColumn());
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertEquals("id", specifiedPkJoinColumn.getDefaultName());
-
- //remove @Id annotation
- PersistentAttribute idAttribute = javaPersistentType().getAttributeNamed("id");
- idAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
-
- assertNull(specifiedPkJoinColumn.getDefaultName());
- }
-
- public void testGetName() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertEquals(PRIMARY_KEY_JOIN_COLUMN_NAME, specifiedPkJoinColumn.getName());
- }
-
- public void testSetSpecifiedName() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
-
- specifiedPkJoinColumn.setSpecifiedName("foo");
- assertEquals("foo", specifiedPkJoinColumn.getSpecifiedName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- PrimaryKeyJoinColumnAnnotation pkJoinColumn = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
-
- assertEquals("foo", pkJoinColumn.getName());
-
- specifiedPkJoinColumn.setSpecifiedName(null);
- assertNull(specifiedPkJoinColumn.getSpecifiedName());
- pkJoinColumn = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
- assertNull(pkJoinColumn);
- }
-
- public void testGetColumnDefinition() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertNull(specifiedPkJoinColumn.getColumnDefinition());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
- column.setColumnDefinition(COLUMN_DEFINITION);
-
- assertEquals(COLUMN_DEFINITION, specifiedPkJoinColumn.getColumnDefinition());
-
- column.setColumnDefinition(null);
-
- assertNull(specifiedPkJoinColumn.getColumnDefinition());
-
- typeResource.removeAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
-
- assertEquals(0, javaEntity().specifiedPrimaryKeyJoinColumnsSize());
- }
-
- public void testSetColumnDefinition() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- specifiedPkJoinColumn.setColumnDefinition("foo");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
-
- assertEquals("foo", column.getColumnDefinition());
-
- specifiedPkJoinColumn.setColumnDefinition(null);
- column = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
- assertNull(column.getColumnDefinition());
- }
-
- public void testGetSpecifiedReferencedColumnName() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertNull(specifiedPkJoinColumn.getSpecifiedReferencedColumnName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- PrimaryKeyJoinColumnAnnotation pkJoinColumnResource = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
-
- pkJoinColumnResource.setReferencedColumnName("FOO");
- specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertEquals("FOO", specifiedPkJoinColumn.getSpecifiedReferencedColumnName());
- }
-
- public void testGetDefaultReferencedColumnNameNoSpecifiedPrimaryKeyJoinColumns() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn pkJoinColumn = javaEntity().getDefaultPrimaryKeyJoinColumn();
- assertEquals("id", pkJoinColumn.getDefaultReferencedColumnName());
- }
-
- public void testGetDefaultReferencedColumnName() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getDefaultPrimaryKeyJoinColumn());
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertEquals("id", specifiedPkJoinColumn.getDefaultReferencedColumnName());
-
-
- //remove @Id annotation
- PersistentAttribute idAttribute = javaPersistentType().getAttributeNamed("id");
- idAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
-
- assertNull(specifiedPkJoinColumn.getDefaultReferencedColumnName());
- }
-
- public void testGetReferencedColumnName() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- PrimaryKeyJoinColumnAnnotation pkJoinColumnResource = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
-
- pkJoinColumnResource.setReferencedColumnName("FOO");
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertEquals("FOO", specifiedPkJoinColumn.getReferencedColumnName());
- }
-
- public void testSetSpecifiedReferencedColumnName() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
-
- specifiedPkJoinColumn.setSpecifiedReferencedColumnName("foo");
- assertEquals("foo", specifiedPkJoinColumn.getSpecifiedReferencedColumnName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- PrimaryKeyJoinColumnAnnotation pkJoinColumn = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
-
- assertEquals("foo", pkJoinColumn.getReferencedColumnName());
-
- specifiedPkJoinColumn.setSpecifiedName(null);
- specifiedPkJoinColumn.setSpecifiedReferencedColumnName(null);
- assertNull(specifiedPkJoinColumn.getSpecifiedReferencedColumnName());
- pkJoinColumn = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
- assertNull(pkJoinColumn);
- }
-
- public void testIsVirtual() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertFalse(specifiedPkJoinColumn.isVirtual());
-
- assertNull(javaEntity().getDefaultPrimaryKeyJoinColumn());
- javaEntity().removeSpecifiedPrimaryKeyJoinColumn(0);
- assertTrue(javaEntity().getDefaultPrimaryKeyJoinColumn().isVirtual());
- }
-
- public void testIsReferencedColumnResolved() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertFalse(specifiedPkJoinColumn.isReferencedColumnResolved());
- }
-
- public void testDbColumn() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertNull(specifiedPkJoinColumn.getDbColumn());
- }
-
- public void testDbReferencedColumn() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertNull(specifiedPkJoinColumn.getDbReferencedColumn());
- }
-
- public void testDbTable() throws Exception {
- createTestEntityWithPrimaryKeyJoinColumn();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PrimaryKeyJoinColumn specifiedPkJoinColumn = javaEntity().specifiedPrimaryKeyJoinColumns().next();
- assertNull(specifiedPkJoinColumn.getDbTable());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaQueryHintTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaQueryHintTests.java
deleted file mode 100644
index 3e4be05d01..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaQueryHintTests.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.QueryHint;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
-import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaQueryHintTests extends ContextModelTestCase
-{
- private static final String QUERY_NAME = "QUERY_NAME";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createNamedQueryAnnotation() throws Exception {
- createQueryHintAnnotation();
- this.createAnnotationAndMembers("NamedQuery",
- "String name();" +
- "String query();" +
- "QueryHint[] hints() default {};");
- }
-
- private void createQueryHintAnnotation() throws Exception {
- this.createAnnotationAndMembers("QueryHint",
- "String name();" +
- "String value();");
- }
-
- private IType createTestEntityWithNamedQuery() throws Exception {
- createEntityAnnotation();
- createNamedQueryAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.NAMED_QUERY, JPA.QUERY_HINT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@NamedQuery(name=\"" + QUERY_NAME + "\", hints=@QueryHint())");
- }
- });
- }
-
-
-
- public JavaQueryHintTests(String name) {
- super(name);
- }
-
- public void testUpdateName() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- QueryHint queryHint = entity.namedQueries().next().hints().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- QueryHintAnnotation javaQueryHint = ((NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME)).hints().next();
-
- assertNull(javaQueryHint.getName());
- assertNull(queryHint.getName());
-
- //set name in the resource model, verify context model updated
- javaQueryHint.setName("foo");
- assertEquals("foo", javaQueryHint.getName());
- assertEquals("foo", queryHint.getName());
-
- //set name to null in the resource model
- javaQueryHint.setName(null);
- assertNull(javaQueryHint.getName());
- assertEquals(0, entity.namedQueries().next().hintsSize());
- }
-
- public void testModifyName() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- QueryHint queryHint = entity.namedQueries().next().hints().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- QueryHintAnnotation javaQueryhint = ((NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME)).hints().next();
-
- assertNull(javaQueryhint.getName());
- assertNull(queryHint.getName());
-
- //set name in the context model, verify resource model updated
- queryHint.setName("foo");
- assertEquals("foo", javaQueryhint.getName());
- assertEquals("foo", queryHint.getName());
-
- //set name to null in the context model
- queryHint.setName(null);
- assertNull(javaQueryhint.getName());
- assertNull(queryHint.getName());
- }
-
- public void testUpdateValue() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- QueryHint queryHint = entity.namedQueries().next().hints().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- QueryHintAnnotation javaQueryhint = ((NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME)).hints().next();
-
- assertNull(javaQueryhint.getValue());
- assertNull(queryHint.getValue());
-
- //set name in the resource model, verify context model updated
- javaQueryhint.setValue("foo");
- assertEquals("foo", javaQueryhint.getValue());
- assertEquals("foo", queryHint.getValue());
-
- //set name to null in the resource model
- javaQueryhint.setValue(null);
- assertNull(javaQueryhint.getValue());
- assertEquals(0, entity.namedQueries().next().hintsSize());
- }
-
- public void testModifyValue() throws Exception {
- createTestEntityWithNamedQuery();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = javaEntity();
- QueryHint queryHint = entity.namedQueries().next().hints().next();
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- QueryHintAnnotation javaQueryhint = ((NamedQueryAnnotation) typeResource.getAnnotation(NamedQueryAnnotation.ANNOTATION_NAME)).hints().next();
-
- assertNull(javaQueryhint.getValue());
- assertNull(queryHint.getValue());
-
- //set name in the context model, verify resource model updated
- queryHint.setValue("foo");
- assertEquals("foo", javaQueryhint.getValue());
- assertEquals("foo", queryHint.getValue());
-
- //set name to null in the context model
- queryHint.setValue(null);
- assertNull(javaQueryhint.getValue());
- assertNull(queryHint.getValue());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSecondaryTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSecondaryTableTests.java
deleted file mode 100644
index 6204905c39..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSecondaryTableTests.java
+++ /dev/null
@@ -1,759 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.SecondaryTable;
-import org.eclipse.jpt.core.context.UniqueConstraint;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaUniqueConstraint;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation;
-import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaSecondaryTableTests extends ContextModelTestCase
-{
- private static final String TABLE_NAME = "MY_TABLE";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception{
- this.createAnnotationAndMembers("Id", "");
- }
-
- private void createSecondaryTableAnnotation() throws Exception{
- this.createAnnotationAndMembers("SecondaryTable",
- "String name() default \"\"; " +
- "String catalog() default \"\"; " +
- "String schema() default \"\";");
- }
-
- private void createSecondaryTablesAnnotation() throws Exception {
- createSecondaryTableAnnotation();
- this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value();");
- }
-
- private IType createTestEntityWithSecondaryTable() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
- createSecondaryTableAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.SECONDARY_TABLE, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@SecondaryTable(name=\"" + TABLE_NAME + "\")");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestEntityWithSecondaryTables() throws Exception {
- createEntityAnnotation();
- createSecondaryTablesAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@SecondaryTables({@SecondaryTable(name=\"foo\"), @SecondaryTable(name=\"bar\")})");
- }
- });
- }
-
-
-
-
- public JavaSecondaryTableTests(String name) {
- super(name);
- }
-
- public void testGetSpecifiedName() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().secondaryTables().next();
- assertEquals(TABLE_NAME, secondaryTable.getSpecifiedName());
- }
-
- public void testGetDefaultNameNull() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().secondaryTables().next();
- assertNull(secondaryTable.getDefaultName());
- }
-
- public void testGetName() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().secondaryTables().next();
- assertEquals(TABLE_NAME, secondaryTable.getName());
- }
-
- public void testSetSpecifiedName() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().secondaryTables().next();
- secondaryTable.setSpecifiedName("foo");
-
- assertEquals("foo", javaEntity().secondaryTables().next().getSpecifiedName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals("foo", table.getName());
- }
-
- public void testSetSpecifiedNameNull() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().secondaryTables().next();
- secondaryTable.setSpecifiedName(null);
-
- assertEquals(0, javaEntity().secondaryTablesSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE));
- }
-
- public void testUpdateFromSpecifiedNameChangeInResourceModel() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- table.setName("foo");
-
- assertEquals("foo", javaEntity().secondaryTables().next().getSpecifiedName());
- }
-
- public void testUpdateFromSpecifiedCatalogChangeInResourceModel() throws Exception {
- createTestEntityWithSecondaryTables();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- ListIterator<SecondaryTableAnnotation> secondaryTableResources = typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTableResources.next().setCatalog("foo");
- secondaryTableResources.next().setCatalog("bar");
-
- ListIterator<SecondaryTable> secondaryTsbles = javaEntity().secondaryTables();
- assertEquals("foo", secondaryTsbles.next().getSpecifiedCatalog());
- assertEquals("bar", secondaryTsbles.next().getSpecifiedCatalog());
- }
-
- public void testUpdateFromSpecifiedSchemaChangeInResourceModel() throws Exception {
- createTestEntityWithSecondaryTables();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- ListIterator<SecondaryTableAnnotation> secondaryTableResources = typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTableResources.next().setSchema("foo");
- secondaryTableResources.next().setSchema("bar");
-
- ListIterator<SecondaryTable> secondaryTsbles = javaEntity().secondaryTables();
- assertEquals("foo", secondaryTsbles.next().getSpecifiedSchema());
- assertEquals("bar", secondaryTsbles.next().getSpecifiedSchema());
- }
-
- public void testGetCatalog() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- table.setCatalog("myCatalog");
-
- assertEquals("myCatalog", javaEntity().secondaryTables().next().getSpecifiedCatalog());
- assertEquals("myCatalog", javaEntity().secondaryTables().next().getCatalog());
- }
-
- public void testGetDefaultCatalog() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().secondaryTables().next().getDefaultCatalog());
-
- javaEntity().secondaryTables().next().setSpecifiedCatalog("myCatalog");
-
- assertNull(javaEntity().secondaryTables().next().getDefaultCatalog());
- }
-
- public void testSetSpecifiedCatalog() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTable table = javaEntity().secondaryTables().next();
- table.setSpecifiedCatalog("myCatalog");
- table.setSpecifiedName(null);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation tableResource = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals("myCatalog", tableResource.getCatalog());
-
- table.setSpecifiedCatalog(null);
- assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE));
- }
-
- public void testGetSchema() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation tableResource = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- tableResource.setSchema("mySchema");
-
- assertEquals("mySchema", javaEntity().secondaryTables().next().getSpecifiedSchema());
- assertEquals("mySchema", javaEntity().secondaryTables().next().getSchema());
- }
-
- public void testGetDefaultSchema() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().secondaryTables().next().getDefaultSchema());
-
- javaEntity().secondaryTables().next().setSpecifiedSchema("mySchema");
-
- assertNull(javaEntity().secondaryTables().next().getDefaultSchema());
- }
-
- public void testSetSpecifiedSchema() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTable table = javaEntity().secondaryTables().next();
- table.setSpecifiedSchema("mySchema");
- table.setSpecifiedName(null);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation tableResource = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals("mySchema", tableResource.getSchema());
-
- table.setSpecifiedSchema(null);
- assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE));
- }
-
- public void testSpecifiedPrimaryKeyJoinColumns() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- ListIterator<JavaPrimaryKeyJoinColumn> specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns();
-
- assertFalse(specifiedPkJoinColumns.hasNext());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation tableResource = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- //add an annotation to the resource model and verify the context model is updated
- PrimaryKeyJoinColumnAnnotation pkJoinColumn = tableResource.addPkJoinColumn(0);
- pkJoinColumn.setName("FOO");
- specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", specifiedPkJoinColumns.next().getName());
- assertFalse(specifiedPkJoinColumns.hasNext());
-
- pkJoinColumn = tableResource.addPkJoinColumn(0);
- pkJoinColumn.setName("BAR");
- specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAR", specifiedPkJoinColumns.next().getName());
- assertEquals("FOO", specifiedPkJoinColumns.next().getName());
- assertFalse(specifiedPkJoinColumns.hasNext());
-
-
- //move an annotation to the resource model and verify the context model is updated
- tableResource.movePkJoinColumn(1, 0);
- specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", specifiedPkJoinColumns.next().getName());
- assertEquals("BAR", specifiedPkJoinColumns.next().getName());
- assertFalse(specifiedPkJoinColumns.hasNext());
-
- tableResource.removePkJoinColumn(0);
- specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAR", specifiedPkJoinColumns.next().getName());
- assertFalse(specifiedPkJoinColumns.hasNext());
-
- tableResource.removePkJoinColumn(0);
- specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns();
- assertFalse(specifiedPkJoinColumns.hasNext());
- }
-
- public void testSpecifiedPrimaryKeyJoinColumnsSize() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- assertEquals(0, secondaryTable.specifiedPrimaryKeyJoinColumnsSize());
-
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAR");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAZ");
-
- assertEquals(3, secondaryTable.specifiedPrimaryKeyJoinColumnsSize());
- }
-
- public void testPrimaryKeyJoinColumnsSize() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- //just the default pkJoinColumn, so 1
- assertEquals(1, secondaryTable.primaryKeyJoinColumnsSize());
-
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAR");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAZ");
-
- //only the specified pkJoinColumns, 3
- assertEquals(3, secondaryTable.primaryKeyJoinColumnsSize());
- }
-
- public void testGetDefaultPrimaryKeyJoinColumn() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- assertNotNull(secondaryTable.getDefaultPrimaryKeyJoinColumn());
-
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAR");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAZ");
-
- assertNull(secondaryTable.getDefaultPrimaryKeyJoinColumn());
- }
-
- public void testPrimaryKeyJoinColumnDefaults() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- PrimaryKeyJoinColumn defaultPkJoinColumn = secondaryTable.getDefaultPrimaryKeyJoinColumn();
- assertNotNull(defaultPkJoinColumn);
- assertEquals("id", defaultPkJoinColumn.getDefaultName());
- assertEquals("id", defaultPkJoinColumn.getDefaultReferencedColumnName());
-
-
- IdMapping idMapping = (IdMapping) javaEntity().getPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getColumn().setSpecifiedName("FOO");
- assertEquals("FOO", defaultPkJoinColumn.getDefaultName());
- assertEquals("FOO", defaultPkJoinColumn.getDefaultReferencedColumnName());
-
- idMapping.getColumn().setSpecifiedName(null);
- assertEquals("id", defaultPkJoinColumn.getDefaultName());
- assertEquals("id", defaultPkJoinColumn.getDefaultReferencedColumnName());
- }
-
- public void testAddSpecifiedPrimaryKeyJoinColumn() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAR");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("BAZ");
-
- Iterator<PrimaryKeyJoinColumn> specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", specifiedPkJoinColumns.next().getName());
- assertEquals("BAR", specifiedPkJoinColumns.next().getName());
- assertEquals("FOO", specifiedPkJoinColumns.next().getName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation tableResource = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- Iterator<PrimaryKeyJoinColumnAnnotation> pkJoinColumns = tableResource.pkJoinColumns();
-
- assertEquals("BAZ", pkJoinColumns.next().getName());
- assertEquals("BAR", pkJoinColumns.next().getName());
- assertEquals("FOO", pkJoinColumns.next().getName());
- assertFalse(pkJoinColumns.hasNext());
- }
-
- public void testAddSpecifiedPrimaryKeyJoinColumn2() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
-
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- Iterator<PrimaryKeyJoinColumn> specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", specifiedPkJoinColumns.next().getName());
- assertEquals("BAR", specifiedPkJoinColumns.next().getName());
- assertEquals("BAZ", specifiedPkJoinColumns.next().getName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation tableResource = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- Iterator<PrimaryKeyJoinColumnAnnotation> pkJoinColumns = tableResource.pkJoinColumns();
-
- assertEquals("FOO", pkJoinColumns.next().getName());
- assertEquals("BAR", pkJoinColumns.next().getName());
- assertEquals("BAZ", pkJoinColumns.next().getName());
- assertFalse(pkJoinColumns.hasNext());
- }
- public void testRemoveSpecifiedPrimaryKeyJoinColumn() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
-
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation tableResource = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals(3, tableResource.pkJoinColumnsSize());
-
- secondaryTable.removeSpecifiedPrimaryKeyJoinColumn(1);
-
- Iterator<PrimaryKeyJoinColumnAnnotation> pkJoinColumnResources = tableResource.pkJoinColumns();
- assertEquals("FOO", pkJoinColumnResources.next().getName());
- assertEquals("BAZ", pkJoinColumnResources.next().getName());
- assertFalse(pkJoinColumnResources.hasNext());
-
- Iterator<PrimaryKeyJoinColumn> pkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", pkJoinColumns.next().getName());
- assertEquals("BAZ", pkJoinColumns.next().getName());
- assertFalse(pkJoinColumns.hasNext());
-
-
- secondaryTable.removeSpecifiedPrimaryKeyJoinColumn(1);
- pkJoinColumnResources = tableResource.pkJoinColumns();
- assertEquals("FOO", pkJoinColumnResources.next().getName());
- assertFalse(pkJoinColumnResources.hasNext());
-
- pkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", pkJoinColumns.next().getName());
- assertFalse(pkJoinColumns.hasNext());
-
-
- secondaryTable.removeSpecifiedPrimaryKeyJoinColumn(0);
- pkJoinColumnResources = tableResource.pkJoinColumns();
- assertFalse(pkJoinColumnResources.hasNext());
- pkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns();
- assertFalse(pkJoinColumns.hasNext());
-
- assertEquals(0, tableResource.pkJoinColumnsSize());
- }
-
- public void testMoveSpecifiedPrimaryKeyJoinColumn() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- Iterator<PrimaryKeyJoinColumn> specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", specifiedPkJoinColumns.next().getName());
- assertEquals("BAR", specifiedPkJoinColumns.next().getName());
- assertEquals("BAZ", specifiedPkJoinColumns.next().getName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation tableResource = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- Iterator<PrimaryKeyJoinColumnAnnotation> pkJoinColumns = tableResource.pkJoinColumns();
-
- assertEquals("FOO", pkJoinColumns.next().getName());
- assertEquals("BAR", pkJoinColumns.next().getName());
- assertEquals("BAZ", pkJoinColumns.next().getName());
-
-
- secondaryTable.moveSpecifiedPrimaryKeyJoinColumn(2, 0);
- pkJoinColumns = tableResource.pkJoinColumns();
-
- assertEquals("BAR", pkJoinColumns.next().getName());
- assertEquals("BAZ", pkJoinColumns.next().getName());
- assertEquals("FOO", pkJoinColumns.next().getName());
- }
-
- public void testPrimaryKeyJoinColumnGetDefaultName() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- PrimaryKeyJoinColumn defaultPkJoinColumn = secondaryTable.getDefaultPrimaryKeyJoinColumn();
- assertEquals("id", defaultPkJoinColumn.getDefaultName());
-
-
- //remove @Id annotation
- PersistentAttribute idAttribute = javaPersistentType().getAttributeNamed("id");
- idAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
-
- assertNull(defaultPkJoinColumn.getDefaultName());
- }
- public void testPrimaryKeyJoinColumnGetDefaultReferencedColumnName() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- PrimaryKeyJoinColumn defaultPkJoinColumn = secondaryTable.getDefaultPrimaryKeyJoinColumn();
- assertEquals("id", defaultPkJoinColumn.getDefaultReferencedColumnName());
-
- //remove @Id annotation
- PersistentAttribute idAttribute = javaPersistentType().getAttributeNamed("id");
- idAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
-
- assertNull(defaultPkJoinColumn.getDefaultReferencedColumnName());
- }
-
- public void testPrimaryKeyJoinColumnIsVirtual() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
-
- assertTrue(secondaryTable.getDefaultPrimaryKeyJoinColumn().isVirtual());
-
- secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0);
- PrimaryKeyJoinColumn specifiedPkJoinColumn = secondaryTable.specifiedPrimaryKeyJoinColumns().next();
- assertFalse(specifiedPkJoinColumn.isVirtual());
-
- assertNull(secondaryTable.getDefaultPrimaryKeyJoinColumn());
- }
-
-
- public void testUniqueConstraints() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
-
- ListIterator<JavaUniqueConstraint> uniqueConstraints = secondaryTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
- JavaResourcePersistentType resourcePersistentType = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation secondaryTableAnnotation = (SecondaryTableAnnotation) resourcePersistentType.getAnnotation(JPA.SECONDARY_TABLE);
- secondaryTableAnnotation.addUniqueConstraint(0).addColumnName(0, "foo");
- secondaryTableAnnotation.addUniqueConstraint(0).addColumnName(0, "bar");
-
- uniqueConstraints = secondaryTable.uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("bar", uniqueConstraints.next().columnNames().next());
- assertEquals("foo", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testUniqueConstraintsSize() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
-
- assertEquals(0, secondaryTable.uniqueConstraintsSize());
-
- JavaResourcePersistentType resourcePersistentType = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation secondaryTableAnnotation = (SecondaryTableAnnotation) resourcePersistentType.getAnnotation(JPA.SECONDARY_TABLE);
- secondaryTableAnnotation.addUniqueConstraint(0).addColumnName(0, "foo");
- secondaryTableAnnotation.addUniqueConstraint(1).addColumnName(0, "bar");
-
- assertEquals(2, secondaryTable.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- secondaryTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- secondaryTable.addUniqueConstraint(0).addColumnName(0, "BAR");
- secondaryTable.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType resourcePersistentType = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation secondaryTableAnnotation = (SecondaryTableAnnotation) resourcePersistentType.getAnnotation(JPA.SECONDARY_TABLE);
- ListIterator<UniqueConstraintAnnotation> uniqueConstraints = secondaryTableAnnotation.uniqueConstraints();
-
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testAddUniqueConstraint2() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- secondaryTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- secondaryTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- secondaryTable.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType resourcePersistentType = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation secondaryTableAnnotation = (SecondaryTableAnnotation) resourcePersistentType.getAnnotation(JPA.SECONDARY_TABLE);
- ListIterator<UniqueConstraintAnnotation> uniqueConstraints = secondaryTableAnnotation.uniqueConstraints();
-
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- secondaryTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- secondaryTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- secondaryTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType resourcePersistentType = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation secondaryTableAnnotation = (SecondaryTableAnnotation) resourcePersistentType.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals(3, secondaryTableAnnotation.uniqueConstraintsSize());
-
- secondaryTable.removeUniqueConstraint(1);
-
- ListIterator<UniqueConstraintAnnotation> uniqueConstraintAnnotations = secondaryTableAnnotation.uniqueConstraints();
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertFalse(uniqueConstraintAnnotations.hasNext());
-
- Iterator<UniqueConstraint> uniqueConstraints = secondaryTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- secondaryTable.removeUniqueConstraint(1);
- uniqueConstraintAnnotations = secondaryTableAnnotation.uniqueConstraints();
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- assertFalse(uniqueConstraintAnnotations.hasNext());
-
- uniqueConstraints = secondaryTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- secondaryTable.removeUniqueConstraint(0);
- uniqueConstraintAnnotations = secondaryTableAnnotation.uniqueConstraints();
- assertFalse(uniqueConstraintAnnotations.hasNext());
- uniqueConstraints = secondaryTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- secondaryTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- secondaryTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- secondaryTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType resourcePersistentType = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation secondaryTableAnnotation = (SecondaryTableAnnotation) resourcePersistentType.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals(3, secondaryTableAnnotation.uniqueConstraintsSize());
-
-
- secondaryTable.moveUniqueConstraint(2, 0);
- ListIterator<UniqueConstraint> uniqueConstraints = secondaryTable.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- ListIterator<UniqueConstraintAnnotation> uniqueConstraintAnnotations = secondaryTableAnnotation.uniqueConstraints();
- assertEquals("BAR", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
-
-
- secondaryTable.moveUniqueConstraint(0, 1);
- uniqueConstraints = secondaryTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- uniqueConstraintAnnotations = secondaryTableAnnotation.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAR", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- }
-
- public void testUpdateUniqueConstraints() throws Exception {
- createTestEntityWithSecondaryTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- SecondaryTable secondaryTable = javaEntity().specifiedSecondaryTables().next();
- JavaResourcePersistentType resourcePersistentType = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- SecondaryTableAnnotation secondaryTableAnnotation = (SecondaryTableAnnotation) resourcePersistentType.getAnnotation(JPA.SECONDARY_TABLE);
-
- secondaryTableAnnotation.addUniqueConstraint(0).addColumnName("FOO");
- secondaryTableAnnotation.addUniqueConstraint(1).addColumnName("BAR");
- secondaryTableAnnotation.addUniqueConstraint(2).addColumnName("BAZ");
-
-
- ListIterator<UniqueConstraint> uniqueConstraints = secondaryTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- secondaryTableAnnotation.moveUniqueConstraint(2, 0);
- uniqueConstraints = secondaryTable.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- secondaryTableAnnotation.moveUniqueConstraint(0, 1);
- uniqueConstraints = secondaryTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- secondaryTableAnnotation.removeUniqueConstraint(1);
- uniqueConstraints = secondaryTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- secondaryTableAnnotation.removeUniqueConstraint(1);
- uniqueConstraints = secondaryTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- secondaryTableAnnotation.removeUniqueConstraint(0);
- uniqueConstraints = secondaryTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSequenceGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSequenceGeneratorTests.java
deleted file mode 100644
index eb37d6b7d8..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSequenceGeneratorTests.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.Generator;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.SequenceGenerator;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaSequenceGeneratorTests extends ContextModelTestCase
-{
- private static final String SEQUENCE_GENERATOR_NAME = "MY_SEQUENCE_GENERATOR";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createSequenceGeneratorAnnotation() throws Exception{
- this.createAnnotationAndMembers("SequenceGenerator",
- "String name();" +
- "String sequenceName() default \"\"; " +
- "int initialValue() default 0; " +
- "int allocationSize() default 50;");
- }
-
- private IType createTestEntityWithSequenceGenerator() throws Exception {
- createEntityAnnotation();
- createSequenceGeneratorAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.SEQUENCE_GENERATOR, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id").append(CR);
- sb.append("@SequenceGenerator(name=\"" + SEQUENCE_GENERATOR_NAME + "\")");
- }
- });
- }
-
- public JavaSequenceGeneratorTests(String name) {
- super(name);
- }
-
- public void testGetName() throws Exception {
- createTestEntityWithSequenceGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- assertEquals(SEQUENCE_GENERATOR_NAME, idMapping.getSequenceGenerator().getName());
-
- //change resource model sequenceGenerator name, verify the context model is updated
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
-
- sequenceGenerator.setName("foo");
-
- assertEquals("foo", idMapping.getSequenceGenerator().getName());
- }
-
- public void testSetName() throws Exception {
- createTestEntityWithSequenceGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- assertEquals(SEQUENCE_GENERATOR_NAME, idMapping.getSequenceGenerator().getName());
-
- idMapping.getSequenceGenerator().setName("foo");
-
- assertEquals("foo", idMapping.getSequenceGenerator().getName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
-
- assertEquals("foo", sequenceGenerator.getName());
- }
-
- public void testSetSpecifiedNameNull() throws Exception {
- createTestEntityWithSequenceGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- assertEquals(SEQUENCE_GENERATOR_NAME, idMapping.getSequenceGenerator().getName());
-
- idMapping.getSequenceGenerator().setName(null);
-
- assertNull(idMapping.getSequenceGenerator());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
-
- assertNull(sequenceGenerator);
- }
-
- public void testGetInitialValue() throws Exception {
- createTestEntityWithSequenceGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(SequenceGenerator.DEFAULT_INITIAL_VALUE, idMapping.getSequenceGenerator().getInitialValue());
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
-
- sequenceGenerator.setInitialValue(Integer.valueOf(82));
-
- assertEquals(Integer.valueOf(82), idMapping.getSequenceGenerator().getInitialValue());
- assertEquals(Integer.valueOf(82), idMapping.getSequenceGenerator().getSpecifiedInitialValue());
- }
-
- public void testGetDefaultInitialValue() throws Exception {
- createTestEntityWithSequenceGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(SequenceGenerator.DEFAULT_INITIAL_VALUE, idMapping.getSequenceGenerator().getDefaultInitialValue());
-
- idMapping.getSequenceGenerator().setSpecifiedInitialValue(Integer.valueOf(82));
-
- assertEquals(SequenceGenerator.DEFAULT_INITIAL_VALUE, idMapping.getSequenceGenerator().getDefaultInitialValue());
- assertEquals(Integer.valueOf(82), idMapping.getSequenceGenerator().getSpecifiedInitialValue());
- }
-
- public void testSetSpecifiedInitialValue() throws Exception {
- createTestEntityWithSequenceGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getSequenceGenerator().setSpecifiedInitialValue(Integer.valueOf(20));
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
-
- assertEquals(Integer.valueOf(20), sequenceGenerator.getInitialValue());
-
- idMapping.getSequenceGenerator().setName(null);
- idMapping.getSequenceGenerator().setSpecifiedInitialValue(null);
- assertNull(attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR));
- }
-
- public void testGetAllocationSize() throws Exception {
- createTestEntityWithSequenceGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(Generator.DEFAULT_ALLOCATION_SIZE, idMapping.getSequenceGenerator().getAllocationSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
-
- sequenceGenerator.setAllocationSize(Integer.valueOf(20));
-
- assertEquals(Integer.valueOf(20), idMapping.getSequenceGenerator().getAllocationSize());
- assertEquals(Integer.valueOf(20), idMapping.getSequenceGenerator().getSpecifiedAllocationSize());
- }
-
- public void testGetDefaultAllocationSize() throws Exception {
- createTestEntityWithSequenceGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(Generator.DEFAULT_ALLOCATION_SIZE, idMapping.getSequenceGenerator().getDefaultAllocationSize());
-
- idMapping.getSequenceGenerator().setSpecifiedAllocationSize(Integer.valueOf(20));
-
- assertEquals(Generator.DEFAULT_ALLOCATION_SIZE, idMapping.getSequenceGenerator().getDefaultAllocationSize());
- assertEquals(Integer.valueOf(20), idMapping.getSequenceGenerator().getSpecifiedAllocationSize());
- }
-
- public void testSetSpecifiedAllocationSize() throws Exception {
- createTestEntityWithSequenceGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getSequenceGenerator().setSpecifiedAllocationSize(Integer.valueOf(25));
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
-
- assertEquals(Integer.valueOf(25), sequenceGenerator.getAllocationSize());
-
- idMapping.getSequenceGenerator().setName(null);
- idMapping.getSequenceGenerator().setSpecifiedAllocationSize(null);
- assertNull(attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR));
- }
-
-
-
- public void testGetSequenceName() throws Exception {
- createTestEntityWithSequenceGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(idMapping.getSequenceGenerator().getSequenceName());
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
-
- sequenceGenerator.setSequenceName("mySequenceName");
-
- assertEquals("mySequenceName", idMapping.getSequenceGenerator().getSequenceName());
- assertEquals("mySequenceName", idMapping.getSequenceGenerator().getSpecifiedSequenceName());
- }
-
- public void testGetDefaultSequenceName() throws Exception {
- createTestEntityWithSequenceGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(idMapping.getSequenceGenerator().getDefaultSequenceName());
-
- idMapping.getSequenceGenerator().setSpecifiedSequenceName("mySequenceName");
-
- assertNull(idMapping.getSequenceGenerator().getDefaultSequenceName());
- assertEquals("mySequenceName", idMapping.getSequenceGenerator().getSpecifiedSequenceName());
- }
-
- public void testSetSpecifiedSequenceName() throws Exception {
- createTestEntityWithSequenceGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getSequenceGenerator().setSpecifiedSequenceName("mySequenceName");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
-
- assertEquals("mySequenceName", sequenceGenerator.getSequenceName());
-
- idMapping.getSequenceGenerator().setName(null);
- idMapping.getSequenceGenerator().setSpecifiedSequenceName(null);
- assertNull(attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR));
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableGeneratorTests.java
deleted file mode 100644
index 6b94bcbf26..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableGeneratorTests.java
+++ /dev/null
@@ -1,699 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.Generator;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.TableGenerator;
-import org.eclipse.jpt.core.context.UniqueConstraint;
-import org.eclipse.jpt.core.context.java.JavaUniqueConstraint;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation;
-import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaTableGeneratorTests extends ContextModelTestCase
-{
- private static final String TABLE_GENERATOR_NAME = "MY_TABLE_GENERATOR";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createTableGeneratorAnnotation() throws Exception{
- this.createAnnotationAndMembers("TableGenerator",
- "String name(); " +
- "String table() default \"\"; " +
- "String catalog() default \"\"; " +
- "String schema() default \"\";" +
- "String pkColumnName() default \"\"; " +
- "String valueColumnName() default \"\"; " +
- "String pkColumnValue() default \"\"; " +
- "int initialValue() default 0; " +
- "int allocationSize() default 50; " +
- "UniqueConstraint[] uniqueConstraints() default {};");
- }
-
- private void createUniqueConstraintAnnotation() throws Exception{
- this.createAnnotationAndMembers("UniqueConstraint",
- "String[] columnNames(); ");
- }
-
- private IType createTestEntityWithTableGenerator() throws Exception {
- createEntityAnnotation();
- createTableGeneratorAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.TABLE_GENERATOR, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id").append(CR);
- sb.append("@TableGenerator(name=\"" + TABLE_GENERATOR_NAME + "\")");
- }
- });
- }
-
- public JavaTableGeneratorTests(String name) {
- super(name);
- }
-
- public void testGetName() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- assertEquals(TABLE_GENERATOR_NAME, idMapping.getTableGenerator().getName());
-
- //change resource model tableGenerator name, verify the context model is updated
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.setName("foo");
-
- assertEquals("foo", idMapping.getTableGenerator().getName());
- }
-
- public void testSetName() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- assertEquals(TABLE_GENERATOR_NAME, idMapping.getTableGenerator().getName());
-
- idMapping.getTableGenerator().setName("foo");
-
- assertEquals("foo", idMapping.getTableGenerator().getName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertEquals("foo", tableGenerator.getName());
- }
-
- public void testSetSpecifiedNameNull() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- assertEquals(TABLE_GENERATOR_NAME, idMapping.getTableGenerator().getName());
-
- idMapping.getTableGenerator().setName(null);
-
- assertNull(idMapping.getTableGenerator());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertNull(tableGenerator);
- }
-
- public void testGetCatalog() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(idMapping.getTableGenerator().getCatalog());
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.setCatalog("myCatalog");
-
- assertEquals("myCatalog", idMapping.getTableGenerator().getCatalog());
- assertEquals("myCatalog", idMapping.getTableGenerator().getSpecifiedCatalog());
- }
-
- public void testGetDefaultCatalog() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(idMapping.getTableGenerator().getDefaultCatalog());
-
- idMapping.getTableGenerator().setSpecifiedCatalog("myCatalog");
-
- assertNull(idMapping.getTableGenerator().getDefaultCatalog());
- assertEquals("myCatalog", idMapping.getTableGenerator().getSpecifiedCatalog());
- }
-
- public void testSetSpecifiedCatalog() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getTableGenerator().setSpecifiedCatalog("myCatalog");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertEquals("myCatalog", tableGenerator.getCatalog());
-
- idMapping.getTableGenerator().setName(null);
- idMapping.getTableGenerator().setSpecifiedCatalog(null);
- assertNull(attributeResource.getAnnotation(JPA.TABLE_GENERATOR));
- }
-
- public void testGetSchema() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(idMapping.getTableGenerator().getSchema());
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.setSchema("mySchema");
-
- assertEquals("mySchema", idMapping.getTableGenerator().getSchema());
- assertEquals("mySchema", idMapping.getTableGenerator().getSpecifiedSchema());
- }
-
- public void testGetDefaultSchema() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(idMapping.getTableGenerator().getDefaultSchema());
-
- idMapping.getTableGenerator().setSpecifiedSchema("mySchema");
-
- assertNull(idMapping.getTableGenerator().getDefaultSchema());
- assertEquals("mySchema", idMapping.getTableGenerator().getSpecifiedSchema());
- }
-
- public void testSetSpecifiedSchema() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getTableGenerator().setSpecifiedSchema("mySchema");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertEquals("mySchema", tableGenerator.getSchema());
-
- idMapping.getTableGenerator().setName(null);
- idMapping.getTableGenerator().setSpecifiedSchema(null);
- assertNull(attributeResource.getAnnotation(JPA.TABLE_GENERATOR));
- }
-
- public void testGetPkColumnName() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(idMapping.getTableGenerator().getPkColumnName());
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.setPkColumnName("myPkColumnName");
-
- assertEquals("myPkColumnName", idMapping.getTableGenerator().getPkColumnName());
- assertEquals("myPkColumnName", idMapping.getTableGenerator().getSpecifiedPkColumnName());
- }
-
- public void testGetDefaultPkColumnName() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(idMapping.getTableGenerator().getDefaultPkColumnName());
-
- idMapping.getTableGenerator().setSpecifiedPkColumnName("myPkColumnName");
-
- assertNull(idMapping.getTableGenerator().getDefaultPkColumnName());
- assertEquals("myPkColumnName", idMapping.getTableGenerator().getSpecifiedPkColumnName());
- }
-
- public void testSetSpecifiedPkColumnName() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getTableGenerator().setSpecifiedPkColumnName("myPkColumnName");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertEquals("myPkColumnName", tableGenerator.getPkColumnName());
-
- idMapping.getTableGenerator().setName(null);
- idMapping.getTableGenerator().setSpecifiedPkColumnName(null);
- assertNull(attributeResource.getAnnotation(JPA.TABLE_GENERATOR));
- }
-
- public void testGetValueColumnName() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(idMapping.getTableGenerator().getValueColumnName());
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.setValueColumnName("myValueColumnName");
-
- assertEquals("myValueColumnName", idMapping.getTableGenerator().getValueColumnName());
- assertEquals("myValueColumnName", idMapping.getTableGenerator().getSpecifiedValueColumnName());
- }
-
- public void testGetDefaultValueColumnName() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(idMapping.getTableGenerator().getDefaultValueColumnName());
-
- idMapping.getTableGenerator().setSpecifiedValueColumnName("myValueColumnName");
-
- assertNull(idMapping.getTableGenerator().getDefaultValueColumnName());
- assertEquals("myValueColumnName", idMapping.getTableGenerator().getSpecifiedValueColumnName());
- }
-
- public void testSetSpecifiedValueColumnName() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getTableGenerator().setSpecifiedValueColumnName("myValueColumnName");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertEquals("myValueColumnName", tableGenerator.getValueColumnName());
-
- idMapping.getTableGenerator().setName(null);
- idMapping.getTableGenerator().setSpecifiedValueColumnName(null);
- assertNull(attributeResource.getAnnotation(JPA.TABLE_GENERATOR));
- }
-
- public void testGetPkColumnValue() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(idMapping.getTableGenerator().getPkColumnValue());
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.setPkColumnValue("myPkColumnValue");
-
- assertEquals("myPkColumnValue", idMapping.getTableGenerator().getPkColumnValue());
- assertEquals("myPkColumnValue", idMapping.getTableGenerator().getSpecifiedPkColumnValue());
- }
-
- public void testGetDefaultPkColumnValue() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(idMapping.getTableGenerator().getDefaultPkColumnValue());
-
- idMapping.getTableGenerator().setSpecifiedPkColumnValue("myPkColumnValue");
-
- assertNull(idMapping.getTableGenerator().getDefaultPkColumnValue());
- assertEquals("myPkColumnValue", idMapping.getTableGenerator().getSpecifiedPkColumnValue());
- }
-
- public void testSetSpecifiedPkColumnValue() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getTableGenerator().setSpecifiedPkColumnValue("myPkColumnValue");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertEquals("myPkColumnValue", tableGenerator.getPkColumnValue());
-
- idMapping.getTableGenerator().setName(null);
- idMapping.getTableGenerator().setSpecifiedPkColumnValue(null);
- assertNull(attributeResource.getAnnotation(JPA.TABLE_GENERATOR));
- }
-
- public void testGetInitialValue() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(TableGenerator.DEFAULT_INITIAL_VALUE, idMapping.getTableGenerator().getInitialValue());
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.setInitialValue(Integer.valueOf(82));
-
- assertEquals(Integer.valueOf(82), idMapping.getTableGenerator().getInitialValue());
- assertEquals(Integer.valueOf(82), idMapping.getTableGenerator().getSpecifiedInitialValue());
- }
-
- public void testGetDefaultInitialValue() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(TableGenerator.DEFAULT_INITIAL_VALUE, idMapping.getTableGenerator().getDefaultInitialValue());
-
- idMapping.getTableGenerator().setSpecifiedInitialValue(Integer.valueOf(82));
-
- assertEquals(TableGenerator.DEFAULT_INITIAL_VALUE, idMapping.getTableGenerator().getDefaultInitialValue());
- assertEquals(Integer.valueOf(82), idMapping.getTableGenerator().getSpecifiedInitialValue());
- }
-
- public void testSetSpecifiedInitialValue() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getTableGenerator().setSpecifiedInitialValue(Integer.valueOf(20));
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertEquals(Integer.valueOf(20), tableGenerator.getInitialValue());
-
- idMapping.getTableGenerator().setName(null);
- idMapping.getTableGenerator().setSpecifiedInitialValue(null);
- assertNull(attributeResource.getAnnotation(JPA.TABLE_GENERATOR));
- }
-
- public void testGetAllocationSize() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(Generator.DEFAULT_ALLOCATION_SIZE, idMapping.getTableGenerator().getAllocationSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.setAllocationSize(Integer.valueOf(20));
-
- assertEquals(Integer.valueOf(20), idMapping.getTableGenerator().getAllocationSize());
- assertEquals(Integer.valueOf(20), idMapping.getTableGenerator().getSpecifiedAllocationSize());
- }
-
- public void testGetDefaultAllocationSize() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(Generator.DEFAULT_ALLOCATION_SIZE, idMapping.getTableGenerator().getDefaultAllocationSize());
-
- idMapping.getTableGenerator().setSpecifiedAllocationSize(Integer.valueOf(20));
-
- assertEquals(Generator.DEFAULT_ALLOCATION_SIZE, idMapping.getTableGenerator().getDefaultAllocationSize());
- assertEquals(Integer.valueOf(20), idMapping.getTableGenerator().getSpecifiedAllocationSize());
- }
-
- public void testSetSpecifiedAllocationSize() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IdMapping idMapping = (IdMapping) javaPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getTableGenerator().setSpecifiedAllocationSize(Integer.valueOf(25));
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertEquals(Integer.valueOf(25), tableGenerator.getAllocationSize());
-
- idMapping.getTableGenerator().setName(null);
- idMapping.getTableGenerator().setSpecifiedAllocationSize(null);
- assertNull(attributeResource.getAnnotation(JPA.TABLE_GENERATOR));
- }
-
-
- public void testUniqueConstraints() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- TableGenerator tableGenerator = ((IdMapping) javaPersistentType().getAttributeNamed("id").getMapping()).getTableGenerator();
-
- ListIterator<JavaUniqueConstraint> uniqueConstraints = tableGenerator.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGeneratorAnnotation = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- tableGeneratorAnnotation.addUniqueConstraint(0).addColumnName(0, "foo");
- tableGeneratorAnnotation.addUniqueConstraint(0).addColumnName(0, "bar");
-
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("bar", uniqueConstraints.next().columnNames().next());
- assertEquals("foo", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testUniqueConstraintsSize() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- TableGenerator tableGenerator = ((IdMapping) javaPersistentType().getAttributeNamed("id").getMapping()).getTableGenerator();
-
- assertEquals(0, tableGenerator.uniqueConstraintsSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGeneratorAnnotation = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- tableGeneratorAnnotation.addUniqueConstraint(0).addColumnName(0, "foo");
- tableGeneratorAnnotation.addUniqueConstraint(1).addColumnName(0, "bar");
-
- assertEquals(2, tableGenerator.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- TableGenerator tableGenerator = ((IdMapping) javaPersistentType().getAttributeNamed("id").getMapping()).getTableGenerator();
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "FOO");
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "BAR");
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGeneratorAnnotation = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- ListIterator<UniqueConstraintAnnotation> uniqueConstraints = tableGeneratorAnnotation.uniqueConstraints();
-
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testAddUniqueConstraint2() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- TableGenerator tableGenerator = ((IdMapping) javaPersistentType().getAttributeNamed("id").getMapping()).getTableGenerator();
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "FOO");
- tableGenerator.addUniqueConstraint(1).addColumnName(0, "BAR");
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGeneratorAnnotation = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- ListIterator<UniqueConstraintAnnotation> uniqueConstraints = tableGeneratorAnnotation.uniqueConstraints();
-
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- TableGenerator tableGenerator = ((IdMapping) javaPersistentType().getAttributeNamed("id").getMapping()).getTableGenerator();
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "FOO");
- tableGenerator.addUniqueConstraint(1).addColumnName(0, "BAR");
- tableGenerator.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGeneratorAnnotation = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertEquals(3, tableGeneratorAnnotation.uniqueConstraintsSize());
-
- tableGenerator.removeUniqueConstraint(1);
-
- ListIterator<UniqueConstraintAnnotation> uniqueConstraintAnnotations = tableGeneratorAnnotation.uniqueConstraints();
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertFalse(uniqueConstraintAnnotations.hasNext());
-
- Iterator<UniqueConstraint> uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- tableGenerator.removeUniqueConstraint(1);
- uniqueConstraintAnnotations = tableGeneratorAnnotation.uniqueConstraints();
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- assertFalse(uniqueConstraintAnnotations.hasNext());
-
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- tableGenerator.removeUniqueConstraint(0);
- uniqueConstraintAnnotations = tableGeneratorAnnotation.uniqueConstraints();
- assertFalse(uniqueConstraintAnnotations.hasNext());
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- TableGenerator tableGenerator = ((IdMapping) javaPersistentType().getAttributeNamed("id").getMapping()).getTableGenerator();
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "FOO");
- tableGenerator.addUniqueConstraint(1).addColumnName(0, "BAR");
- tableGenerator.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGeneratorAnnotation = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertEquals(3, tableGeneratorAnnotation.uniqueConstraintsSize());
-
-
- tableGenerator.moveUniqueConstraint(2, 0);
- ListIterator<UniqueConstraint> uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- ListIterator<UniqueConstraintAnnotation> uniqueConstraintAnnotations = tableGeneratorAnnotation.uniqueConstraints();
- assertEquals("BAR", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
-
-
- tableGenerator.moveUniqueConstraint(0, 1);
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- uniqueConstraintAnnotations = tableGeneratorAnnotation.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAR", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- }
-
- public void testUpdateUniqueConstraints() throws Exception {
- createTestEntityWithTableGenerator();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- TableGenerator tableGenerator = ((IdMapping) javaPersistentType().getAttributeNamed("id").getMapping()).getTableGenerator();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TableGeneratorAnnotation tableGeneratorAnnotation = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGeneratorAnnotation.addUniqueConstraint(0).addColumnName("FOO");
- tableGeneratorAnnotation.addUniqueConstraint(1).addColumnName("BAR");
- tableGeneratorAnnotation.addUniqueConstraint(2).addColumnName("BAZ");
-
-
- ListIterator<UniqueConstraint> uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableGeneratorAnnotation.moveUniqueConstraint(2, 0);
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableGeneratorAnnotation.moveUniqueConstraint(0, 1);
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableGeneratorAnnotation.removeUniqueConstraint(1);
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableGeneratorAnnotation.removeUniqueConstraint(1);
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableGeneratorAnnotation.removeUniqueConstraint(0);
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableTests.java
deleted file mode 100644
index 493913cfeb..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableTests.java
+++ /dev/null
@@ -1,573 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.UniqueConstraint;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.context.java.JavaUniqueConstraint;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.TableAnnotation;
-import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaTableTests extends ContextModelTestCase
-{
- private static final String TABLE_NAME = "MY_TABLE";
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
- private void createTableAnnotation() throws Exception{
- this.createAnnotationAndMembers("Table",
- "String name() default \"\"; " +
- "String catalog() default \"\"; " +
- "String schema() default \"\";");
- }
-
- private void createUniqueConstraintAnnotation() throws Exception{
- this.createAnnotationAndMembers("UniqueConstraint",
- "String[] columnNames(); ");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private IType createTestEntityWithTable() throws Exception {
- createEntityAnnotation();
- createTableAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@Table(name=\"" + TABLE_NAME + "\")");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- return this.createTestType(PACKAGE_NAME, "AnnotationTestTypeChild.java", "AnnotationTestTypeChild", new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendExtendsImplementsTo(StringBuilder sb) {
- sb.append("extends " + TYPE_NAME + " ");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- });
- }
-
-
-
- public JavaTableTests(String name) {
- super(name);
- }
-
- public void testGetSpecifiedNameNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getTable().getSpecifiedName());
- }
-
- public void testGetSpecifiedName() throws Exception {
- createTestEntityWithTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(TABLE_NAME, javaEntity().getTable().getSpecifiedName());
- }
-
- public void testGetDefaultNameSpecifiedNameNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(TYPE_NAME, javaEntity().getTable().getDefaultName());
- }
-
- public void testGetDefaultName() throws Exception {
- createTestEntityWithTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(TYPE_NAME, javaEntity().getTable().getDefaultName());
-
- //test that setting the java entity name will change the table default name
- javaEntity().setSpecifiedName("foo");
- assertEquals("foo", javaEntity().getTable().getDefaultName());
- }
-
- public void testGetDefaultNameSingleTableInheritance() throws Exception {
- createTestEntity();
- createTestSubType();
-
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNotSame(javaEntity(), javaEntity().getRootEntity());
- assertEquals(TYPE_NAME, javaEntity().getTable().getDefaultName());
- assertEquals(TYPE_NAME, javaEntity().getRootEntity().getTable().getDefaultName());
-
- //test that setting the root java entity name will change the table default name of the child
- javaEntity().getRootEntity().setSpecifiedName("foo");
- assertEquals("foo", javaEntity().getTable().getDefaultName());
- }
-
- public void testUpdateDefaultSchemaFromPersistenceUnitDefaults() throws Exception {
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
-
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- JavaEntity javaEntity = ormEntity.getJavaEntity();
-
- assertNull(javaEntity.getTable().getDefaultSchema());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedSchema("FOO");
- assertEquals("FOO", javaEntity.getTable().getDefaultSchema());
-
- ormEntity.getEntityMappings().setSpecifiedSchema("BAR");
- assertEquals("BAR", javaEntity.getTable().getDefaultSchema());
-
- ormEntity.getTable().setSpecifiedSchema("XML_SCHEMA");
- assertEquals("BAR", javaEntity.getTable().getDefaultSchema());
-
- entityMappings().removeOrmPersistentType(0);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- //default schema taken from persistence-unit-defaults not entity-mappings since the entity is not in an orm.xml file
- assertEquals("FOO", javaEntity().getTable().getDefaultSchema());
-
- IFile file = ormResource().getFile();
- //remove the mapping file reference from the persistence.xml. default schema
- //should still come from persistence-unit-defaults because of implied mapped-file-ref
- xmlPersistenceUnit().getMappingFiles().remove(mappingFileRef);
- assertEquals("FOO", javaEntity().getTable().getDefaultSchema());
-
- file.delete(true, null);
- assertNull(javaEntity().getTable().getDefaultSchema());
- }
-
- public void testGetNameSpecifiedNameNull() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(TYPE_NAME, javaEntity().getTable().getName());
- }
-
- public void testGetName() throws Exception {
- createTestEntityWithTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(TABLE_NAME, javaEntity().getTable().getName());
- }
-
- public void testSetSpecifiedName() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().getTable().setSpecifiedName("foo");
-
- assertEquals("foo", javaEntity().getTable().getSpecifiedName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- assertEquals("foo", table.getName());
- }
-
- public void testSetSpecifiedNameNull() throws Exception {
- createTestEntityWithTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- javaEntity().getTable().setSpecifiedName(null);
-
- assertNull(javaEntity().getTable().getSpecifiedName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- assertNull(table);
- }
-
- public void testUpdateFromSpecifiedNameChangeInResourceModel() throws Exception {
- createTestEntityWithTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- table.setName("foo");
-
- assertEquals("foo", javaEntity().getTable().getSpecifiedName());
-
- typeResource.removeAnnotation(JPA.TABLE);
- assertNull(javaEntity().getTable().getSpecifiedName());
- }
-
- public void testGetCatalog() throws Exception {
- createTestEntityWithTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- table.setCatalog("myCatalog");
-
- assertEquals("myCatalog", javaEntity().getTable().getSpecifiedCatalog());
- assertEquals("myCatalog", javaEntity().getTable().getCatalog());
- }
-
- public void testGetDefaultCatalog() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getTable().getDefaultCatalog());
-
- javaEntity().getTable().setSpecifiedCatalog("myCatalog");
-
- assertNull(javaEntity().getTable().getDefaultCatalog());
- }
-
- public void testUpdateDefaultCatalogFromPersistenceUnitDefaults() throws Exception {
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
-
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- JavaEntity javaEntity = ormEntity.getJavaEntity();
-
- assertNull(javaEntity.getTable().getDefaultCatalog());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedCatalog("FOO");
- assertEquals("FOO", javaEntity.getTable().getDefaultCatalog());
-
- ormEntity.getEntityMappings().setSpecifiedCatalog("BAR");
- assertEquals("BAR", javaEntity.getTable().getDefaultCatalog());
-
- ormEntity.getTable().setSpecifiedCatalog("XML_CATALOG");
- assertEquals("BAR", javaEntity.getTable().getDefaultCatalog());
-
- entityMappings().removeOrmPersistentType(0);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- //default catalog taken from persistence-unite-defaults not entity-mappings since the entity is not in an orm.xml file
- assertEquals("FOO", javaEntity().getTable().getDefaultCatalog());
-
- IFile file = ormResource().getFile();
- //remove the mapping file reference from the persistence.xml. default schema
- //should still come from persistence-unit-defaults because of implied mapped-file-ref
- xmlPersistenceUnit().getMappingFiles().remove(mappingFileRef);
- assertEquals("FOO", javaEntity().getTable().getDefaultCatalog());
-
- file.delete(true, null);
- assertNull(javaEntity().getTable().getDefaultCatalog());
- }
-
- public void testSetSpecifiedCatalog() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Table table = javaEntity().getTable();
- table.setSpecifiedCatalog("myCatalog");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation tableResource = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- assertEquals("myCatalog", tableResource.getCatalog());
-
- table.setSpecifiedCatalog(null);
- assertNull(typeResource.getAnnotation(JPA.TABLE));
- }
-
- public void testGetSchema() throws Exception {
- createTestEntityWithTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- table.setSchema("mySchema");
-
- assertEquals("mySchema", javaEntity().getTable().getSpecifiedSchema());
- assertEquals("mySchema", javaEntity().getTable().getSchema());
- }
-
- public void testGetDefaultSchema() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertNull(javaEntity().getTable().getDefaultSchema());
-
- javaEntity().getTable().setSpecifiedSchema("mySchema");
-
- assertNull(javaEntity().getTable().getDefaultSchema());
- }
-
- public void testSetSpecifiedSchema() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- Table table = javaEntity().getTable();
- table.setSpecifiedSchema("mySchema");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation tableResource = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- assertEquals("mySchema", tableResource.getSchema());
-
- table.setSpecifiedSchema(null);
- assertNull(typeResource.getAnnotation(JPA.TABLE));
- }
-
- public void testUniqueConstraints() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- ListIterator<JavaUniqueConstraint> uniqueConstraints = javaEntity().getTable().uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation tableAnnotation = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- tableAnnotation.addUniqueConstraint(0).addColumnName(0, "foo");
- tableAnnotation.addUniqueConstraint(0).addColumnName(0, "bar");
-
- uniqueConstraints = javaEntity().getTable().uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("bar", uniqueConstraints.next().columnNames().next());
- assertEquals("foo", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testUniqueConstraintsSize() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(0, javaEntity().getTable().uniqueConstraintsSize());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation tableAnnotation = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- tableAnnotation.addUniqueConstraint(0).addColumnName(0, "foo");
- tableAnnotation.addUniqueConstraint(1).addColumnName(0, "bar");
-
- assertEquals(2, javaEntity().getTable().uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Table table = javaEntity().getTable();
- table.addUniqueConstraint(0).addColumnName(0, "FOO");
- table.addUniqueConstraint(0).addColumnName(0, "BAR");
- table.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation tableAnnotation = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- ListIterator<UniqueConstraintAnnotation> uniqueConstraints = tableAnnotation.uniqueConstraints();
-
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testAddUniqueConstraint2() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntityWithTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Table table = javaEntity().getTable();
- table.addUniqueConstraint(0).addColumnName(0, "FOO");
- table.addUniqueConstraint(1).addColumnName(0, "BAR");
- table.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation tableAnnotation = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- ListIterator<UniqueConstraintAnnotation> uniqueConstraints = tableAnnotation.uniqueConstraints();
-
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Table table = javaEntity().getTable();
- table.addUniqueConstraint(0).addColumnName(0, "FOO");
- table.addUniqueConstraint(1).addColumnName(0, "BAR");
- table.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation tableAnnotation = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- assertEquals(3, tableAnnotation.uniqueConstraintsSize());
-
- table.removeUniqueConstraint(1);
-
- ListIterator<UniqueConstraintAnnotation> uniqueConstraintAnnotations = tableAnnotation.uniqueConstraints();
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertFalse(uniqueConstraintAnnotations.hasNext());
-
- Iterator<UniqueConstraint> uniqueConstraints = table.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- table.removeUniqueConstraint(1);
- uniqueConstraintAnnotations = tableAnnotation.uniqueConstraints();
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- assertFalse(uniqueConstraintAnnotations.hasNext());
-
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- table.removeUniqueConstraint(0);
- uniqueConstraintAnnotations = tableAnnotation.uniqueConstraints();
- assertFalse(uniqueConstraintAnnotations.hasNext());
- uniqueConstraints = table.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- createUniqueConstraintAnnotation();
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Table table = javaEntity().getTable();
- table.addUniqueConstraint(0).addColumnName(0, "FOO");
- table.addUniqueConstraint(1).addColumnName(0, "BAR");
- table.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation tableAnnotation = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- assertEquals(3, tableAnnotation.uniqueConstraintsSize());
-
-
- table.moveUniqueConstraint(2, 0);
- ListIterator<UniqueConstraint> uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- ListIterator<UniqueConstraintAnnotation> uniqueConstraintAnnotations = tableAnnotation.uniqueConstraints();
- assertEquals("BAR", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
-
-
- table.moveUniqueConstraint(0, 1);
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- uniqueConstraintAnnotations = tableAnnotation.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAR", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- }
-
- public void testUpdateUniqueConstraints() throws Exception {
- createTestEntityWithTable();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Table table = javaEntity().getTable();
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- TableAnnotation tableAnnotation = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- tableAnnotation.addUniqueConstraint(0).addColumnName("FOO");
- tableAnnotation.addUniqueConstraint(1).addColumnName("BAR");
- tableAnnotation.addUniqueConstraint(2).addColumnName("BAZ");
-
-
- ListIterator<UniqueConstraint> uniqueConstraints = table.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableAnnotation.moveUniqueConstraint(2, 0);
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableAnnotation.moveUniqueConstraint(0, 1);
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableAnnotation.removeUniqueConstraint(1);
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableAnnotation.removeUniqueConstraint(1);
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableAnnotation.removeUniqueConstraint(0);
- uniqueConstraints = table.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTransientMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTransientMappingTests.java
deleted file mode 100644
index c00fdc2187..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTransientMappingTests.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaTransientMappingTests extends ContextModelTestCase
-{
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createTransientAnnotation() throws Exception{
- this.createAnnotationAndMembers("Transient", "");
- }
-
- private IType createTestEntityWithTransientMapping() throws Exception {
- createEntityAnnotation();
- createTransientAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.TRANSIENT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Transient").append(CR);
- }
- });
- }
-
- public JavaTransientMappingTests(String name) {
- super(name);
- }
-
- public void testMorphToBasicMapping() throws Exception {
- createTestEntityWithTransientMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToDefault() throws Exception {
- createTestEntityWithTransientMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
- assertTrue(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToVersionMapping() throws Exception {
- createTestEntityWithTransientMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedMapping() throws Exception {
- createTestEntityWithTransientMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToIdMapping() throws Exception {
- createTestEntityWithTransientMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityWithTransientMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToOneMapping() throws Exception {
- createTestEntityWithTransientMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToManyMapping() throws Exception {
- createTestEntityWithTransientMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToOneMapping() throws Exception {
- createTestEntityWithTransientMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToManyMapping() throws Exception {
- createTestEntityWithTransientMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- }
-
- public void testTransientMapping() throws Exception {
- createTestEntityWithTransientMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- TransientMapping transientMapping = (TransientMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNotNull(transientMapping);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaVersionMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaVersionMappingTests.java
deleted file mode 100644
index e6577fcc5b..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaVersionMappingTests.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.TemporalType;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.core.resource.java.TemporalAnnotation;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaVersionMappingTests extends ContextModelTestCase
-{
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createVersionAnnotation() throws Exception{
- this.createAnnotationAndMembers("Version", "");
- }
-
- private void createTemporalAnnotation() throws Exception{
- this.createAnnotationAndMembers("Temporal", "TemporalType value();");
- }
-
- private IType createTestEntityWithVersionMapping() throws Exception {
- createEntityAnnotation();
- createVersionAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.VERSION);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Version").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithTemporal() throws Exception {
- createEntityAnnotation();
- createTemporalAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.VERSION, JPA.TEMPORAL, JPA.TEMPORAL_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Version").append(CR);
- sb.append("@Temporal(TemporalType.TIMESTAMP)").append(CR);
- }
- });
- }
-
- public JavaVersionMappingTests(String name) {
- super(name);
- }
-
- public void testMorphToBasicMapping() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertEquals("FOO", ((BasicMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
- assertEquals(TemporalType.TIME, ((BasicMapping) persistentAttribute.getMapping()).getTemporal());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToDefault() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertEquals("FOO", ((BasicMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
- assertEquals(TemporalType.TIME, ((BasicMapping) persistentAttribute.getMapping()).getTemporal());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToIdMapping() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals("FOO", ((IdMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
- assertEquals(TemporalType.TIME, ((IdMapping) persistentAttribute.getMapping()).getTemporal());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedMapping() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToTransientMapping() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToOneMapping() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToManyMapping() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToOneMapping() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToManyMapping() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testGetTemporal() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(versionMapping.getTemporal());
- }
-
- public void testGetTemporal2() throws Exception {
- createTestEntityWithTemporal();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getSpecifiedMapping();
-
- assertEquals(TemporalType.TIMESTAMP, versionMapping.getTemporal());
- }
-
- public void testSetTemporal() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getSpecifiedMapping();
- assertNull(versionMapping.getTemporal());
-
- versionMapping.setTemporal(TemporalType.TIME);
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.core.resource.java.TemporalType.TIME, temporal.getValue());
-
- versionMapping.setTemporal(null);
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testGetTemporalUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(versionMapping.getTemporal());
-
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.addAnnotation(TemporalAnnotation.ANNOTATION_NAME);
- temporal.setValue(org.eclipse.jpt.core.resource.java.TemporalType.DATE);
-
- assertEquals(TemporalType.DATE, versionMapping.getTemporal());
-
- attributeResource.removeAnnotation(TemporalAnnotation.ANNOTATION_NAME);
-
- assertNull(versionMapping.getTemporal());
- assertFalse(versionMapping.isDefault());
- assertSame(versionMapping, persistentAttribute.getSpecifiedMapping());
- }
-
- public void testGetColumn() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getSpecifiedMapping();
-
- assertNull(versionMapping.getColumn().getSpecifiedName());
- assertEquals("id", versionMapping.getColumn().getName());
-
- JavaResourcePersistentType typeResource = jpaProject().getJavaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
- column.setName("foo");
-
- assertEquals("foo", versionMapping.getColumn().getSpecifiedName());
- assertEquals("foo", versionMapping.getColumn().getName());
- assertEquals("id", versionMapping.getColumn().getDefaultName());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JptCoreContextJavaModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JptCoreContextJavaModelTests.java
deleted file mode 100644
index 26e0df5cc6..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JptCoreContextJavaModelTests.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.java;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JptCoreContextJavaModelTests extends TestCase
-{
- public static Test suite() {
- return suite(true);
- }
-
- public static Test suite(boolean all) {
- TestSuite suite = new TestSuite(JptCoreContextJavaModelTests.class.getName());
- suite.addTestSuite(JavaAssociationOverrideTests.class);
- suite.addTestSuite(JavaAttributeOverrideTests.class);
- suite.addTestSuite(JavaBasicMappingTests.class);
- suite.addTestSuite(JavaColumnTests.class);
- suite.addTestSuite(JavaDiscriminatorColumnTests.class);
- suite.addTestSuite(JavaEmbeddableTests.class);
- suite.addTestSuite(JavaEmbeddedIdMappingTests.class);
- suite.addTestSuite(JavaEmbeddedMappingTests.class);
- suite.addTestSuite(JavaEntityTests.class);
- suite.addTestSuite(JavaGeneratedValueTests.class);
- suite.addTestSuite(JavaIdMappingTests.class);
- suite.addTestSuite(JavaJoinColumnTests.class);
- suite.addTestSuite(JavaJoinTableTests.class);
- suite.addTestSuite(JavaMappedSuperclassTests.class);
- suite.addTestSuite(JavaManyToManyMappingTests.class);
- suite.addTestSuite(JavaManyToOneMappingTests.class);
- suite.addTestSuite(JavaNamedQueryTests.class);
- suite.addTestSuite(JavaNamedNativeQueryTests.class);
- suite.addTestSuite(JavaQueryHintTests.class);
- suite.addTestSuite(JavaOneToManyMappingTests.class);
- suite.addTestSuite(JavaOneToOneMappingTests.class);
- suite.addTestSuite(JavaPersistentTypeTests.class);
- suite.addTestSuite(JavaPersistentAttributeTests.class);
- suite.addTestSuite(JavaPrimaryKeyJoinColumnTests.class);
- suite.addTestSuite(JavaSecondaryTableTests.class);
- suite.addTestSuite(JavaSequenceGeneratorTests.class);
- suite.addTestSuite(JavaTableGeneratorTests.class);
- suite.addTestSuite(JavaTableTests.class);
- suite.addTestSuite(JavaTransientMappingTests.class);
- suite.addTestSuite(JavaVersionMappingTests.class);
- return suite;
- }
-
- private JptCoreContextJavaModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/EntityMappingsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/EntityMappingsTests.java
deleted file mode 100644
index cc8b88427b..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/EntityMappingsTests.java
+++ /dev/null
@@ -1,1067 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.SequenceGenerator;
-import org.eclipse.jpt.core.context.TableGenerator;
-import org.eclipse.jpt.core.context.orm.OrmNamedNativeQuery;
-import org.eclipse.jpt.core.context.orm.OrmNamedQuery;
-import org.eclipse.jpt.core.context.orm.OrmSequenceGenerator;
-import org.eclipse.jpt.core.context.orm.OrmTableGenerator;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddable;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.orm.XmlMappedSuperclass;
-import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator;
-import org.eclipse.jpt.core.resource.orm.XmlTableGenerator;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-public class EntityMappingsTests extends ContextModelTestCase
-{
- public EntityMappingsTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testGetVersion() throws Exception {
- assertEquals("1.0", entityMappings().getVersion());
- }
-
- public void testUpdateDescription() throws Exception {
- assertNull(entityMappings().getDescription());
- assertNull(ormResource().getEntityMappings().getDescription());
-
- //set description in the resource model, verify context model updated
- ormResource().getEntityMappings().setDescription("newDescription");
- assertEquals("newDescription", entityMappings().getDescription());
- assertEquals("newDescription", ormResource().getEntityMappings().getDescription());
-
- //set description to null in the resource model
- ormResource().getEntityMappings().setDescription(null);
- assertNull(entityMappings().getDescription());
- assertNull(ormResource().getEntityMappings().getDescription());
- }
-
- public void testModifyDescription() throws Exception {
- assertNull(entityMappings().getDescription());
- assertNull(ormResource().getEntityMappings().getDescription());
-
- //set description in the context model, verify resource model modified
- entityMappings().setDescription("newDescription");
- assertEquals("newDescription", entityMappings().getDescription());
- assertEquals("newDescription", ormResource().getEntityMappings().getDescription());
-
- //set description to null in the context model
- entityMappings().setDescription(null);
- assertNull(entityMappings().getDescription());
- assertNull(ormResource().getEntityMappings().getDescription());
- }
-
- public void testUpdatePackage() throws Exception {
- assertNull(entityMappings().getPackage());
- assertNull(ormResource().getEntityMappings().getPackage());
-
- //set package in the resource model, verify context model updated
- ormResource().getEntityMappings().setPackage("foo.model");
- assertEquals("foo.model", entityMappings().getPackage());
- assertEquals("foo.model", ormResource().getEntityMappings().getPackage());
-
- //set package to null in the resource model
- ormResource().getEntityMappings().setPackage(null);
- assertNull(entityMappings().getPackage());
- assertNull(ormResource().getEntityMappings().getPackage());
- }
-
- public void testModifyPackage() throws Exception {
- assertNull(entityMappings().getPackage());
- assertNull(ormResource().getEntityMappings().getPackage());
-
- //set package in the context model, verify resource model modified
- entityMappings().setPackage("foo.model");
- assertEquals("foo.model", entityMappings().getPackage());
- assertEquals("foo.model", ormResource().getEntityMappings().getPackage());
-
- //set package to null in the context model
- entityMappings().setPackage(null);
- assertNull(entityMappings().getPackage());
- assertNull(ormResource().getEntityMappings().getPackage());
- }
-
- public void testUpdateSpecifiedSchema() throws Exception {
- assertNull(entityMappings().getSpecifiedSchema());
- assertNull(ormResource().getEntityMappings().getSchema());
-
- //set schema in the resource model, verify context model updated
- ormResource().getEntityMappings().setSchema("MY_SCHEMA");
- assertEquals("MY_SCHEMA", entityMappings().getSpecifiedSchema());
- assertEquals("MY_SCHEMA", ormResource().getEntityMappings().getSchema());
-
- //set schema to null in the resource model
- ormResource().getEntityMappings().setSchema(null);
- assertNull(entityMappings().getSpecifiedSchema());
- assertNull(ormResource().getEntityMappings().getSchema());
- }
-
- public void testModifySpecifiedSchema() throws Exception {
- assertNull(entityMappings().getSpecifiedSchema());
- assertNull(ormResource().getEntityMappings().getSchema());
-
- //set schema in the context model, verify resource model modified
- entityMappings().setSpecifiedSchema("MY_SCHEMA");
- assertEquals("MY_SCHEMA", entityMappings().getSpecifiedSchema());
- assertEquals("MY_SCHEMA", ormResource().getEntityMappings().getSchema());
-
- //set schema to null in the context model
- entityMappings().setSpecifiedSchema(null);
- assertNull(entityMappings().getSpecifiedSchema());
- assertNull(ormResource().getEntityMappings().getSchema());
- }
-
- public void testUpdateSpecifiedCatalog() throws Exception {
- assertNull(entityMappings().getSpecifiedCatalog());
- assertNull(ormResource().getEntityMappings().getCatalog());
-
- //set catalog in the resource model, verify context model updated
- ormResource().getEntityMappings().setCatalog("MY_CATALOG");
- assertEquals("MY_CATALOG", entityMappings().getSpecifiedCatalog());
- assertEquals("MY_CATALOG", ormResource().getEntityMappings().getCatalog());
-
- //set catalog to null in the resource model
- ormResource().getEntityMappings().setCatalog(null);
- assertNull(entityMappings().getSpecifiedCatalog());
- assertNull(ormResource().getEntityMappings().getCatalog());
- }
-
- public void testUpdateDefaultSchema() throws Exception {
- assertNull(entityMappings().getDefaultSchema());
- assertNull(entityMappings().getSpecifiedSchema());
- assertNull(ormResource().getEntityMappings().getSchema());
-
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- org.eclipse.jpt.core.resource.orm.XmlPersistenceUnitDefaults persistenceUnitDefaults = OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults();
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(persistenceUnitDefaults);
- persistenceUnitDefaults.setSchema("MY_SCHEMA");
- assertEquals("MY_SCHEMA", entityMappings().getDefaultSchema());
- assertNull(entityMappings().getSpecifiedSchema());
- assertNull(ormResource().getEntityMappings().getSchema());
- assertEquals("MY_SCHEMA", ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
-
- persistenceUnitDefaults.setSchema(null);
- assertNull(entityMappings().getDefaultSchema());
- assertNull(entityMappings().getSpecifiedSchema());
- assertNull(ormResource().getEntityMappings().getSchema());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
- }
-
- public void testUpdateSchema() throws Exception {
- assertNull(entityMappings().getDefaultSchema());
- assertNull(entityMappings().getSchema());
- assertNull(entityMappings().getSpecifiedSchema());
- assertNull(ormResource().getEntityMappings().getSchema());
-
- ormResource().getEntityMappings().setSchema("MY_SCHEMA");
- assertNull(entityMappings().getDefaultSchema());
- assertEquals("MY_SCHEMA", entityMappings().getSchema());
- assertEquals("MY_SCHEMA", entityMappings().getSpecifiedSchema());
- assertEquals("MY_SCHEMA", ormResource().getEntityMappings().getSchema());
-
- ormResource().getEntityMappings().setSchema(null);
- assertNull(entityMappings().getDefaultSchema());
- assertNull(entityMappings().getSchema());
- assertNull(entityMappings().getSpecifiedSchema());
- assertNull(ormResource().getEntityMappings().getSchema());
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedSchema("DEFAULT_SCHEMA");
- assertEquals("DEFAULT_SCHEMA", entityMappings().getDefaultSchema());
- assertEquals("DEFAULT_SCHEMA", entityMappings().getSchema());
- assertNull(entityMappings().getSpecifiedSchema());
- assertNull(ormResource().getEntityMappings().getSchema());
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedSchema(null);
- assertNull(entityMappings().getDefaultSchema());
- assertNull(entityMappings().getSchema());
- assertNull(entityMappings().getSpecifiedSchema());
- assertNull(ormResource().getEntityMappings().getSchema());
- }
-
- public void testModifySpecifiedCatalog() throws Exception {
- assertNull(entityMappings().getSpecifiedCatalog());
- assertNull(ormResource().getEntityMappings().getCatalog());
-
- //set catalog in the context model, verify resource model modified
- entityMappings().setSpecifiedCatalog("MY_CATALOG");
- assertEquals("MY_CATALOG", entityMappings().getSpecifiedCatalog());
- assertEquals("MY_CATALOG", ormResource().getEntityMappings().getCatalog());
-
- //set catalog to null in the context model
- entityMappings().setSpecifiedCatalog(null);
- assertNull(entityMappings().getSpecifiedCatalog());
- assertNull(ormResource().getEntityMappings().getCatalog());
- }
-
- public void testUpdateDefaultCatalog() throws Exception {
- assertNull(entityMappings().getDefaultCatalog());
- assertNull(entityMappings().getSpecifiedCatalog());
- assertNull(ormResource().getEntityMappings().getCatalog());
-
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- org.eclipse.jpt.core.resource.orm.XmlPersistenceUnitDefaults persistenceUnitDefaults = OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults();
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(persistenceUnitDefaults);
- persistenceUnitDefaults.setCatalog("MY_CATALOG");
- assertEquals("MY_CATALOG", entityMappings().getDefaultCatalog());
- assertNull(entityMappings().getSpecifiedCatalog());
- assertNull(ormResource().getEntityMappings().getCatalog());
- assertEquals("MY_CATALOG", ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
-
- persistenceUnitDefaults.setCatalog(null);
- assertNull(entityMappings().getDefaultCatalog());
- assertNull(entityMappings().getSpecifiedCatalog());
- assertNull(ormResource().getEntityMappings().getCatalog());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
- }
-
- public void testUpdateCatalog() throws Exception {
- assertNull(entityMappings().getDefaultCatalog());
- assertNull(entityMappings().getCatalog());
- assertNull(entityMappings().getSpecifiedCatalog());
- assertNull(ormResource().getEntityMappings().getCatalog());
-
- ormResource().getEntityMappings().setCatalog("MY_CATALOG");
- assertNull(entityMappings().getDefaultCatalog());
- assertEquals("MY_CATALOG", entityMappings().getCatalog());
- assertEquals("MY_CATALOG", entityMappings().getSpecifiedCatalog());
- assertEquals("MY_CATALOG", ormResource().getEntityMappings().getCatalog());
-
- ormResource().getEntityMappings().setCatalog(null);
- assertNull(entityMappings().getDefaultCatalog());
- assertNull(entityMappings().getCatalog());
- assertNull(entityMappings().getSpecifiedCatalog());
- assertNull(ormResource().getEntityMappings().getCatalog());
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedCatalog("DEFAULT_CATALOG");
- assertEquals("DEFAULT_CATALOG", entityMappings().getDefaultCatalog());
- assertEquals("DEFAULT_CATALOG", entityMappings().getCatalog());
- assertNull(entityMappings().getSpecifiedCatalog());
- assertNull(ormResource().getEntityMappings().getCatalog());
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedCatalog(null);
- assertNull(entityMappings().getDefaultCatalog());
- assertNull(entityMappings().getCatalog());
- assertNull(entityMappings().getSpecifiedCatalog());
- assertNull(ormResource().getEntityMappings().getCatalog());
- }
-
- public void testUpdateSpecifiedAccess() throws Exception {
- assertNull(entityMappings().getSpecifiedAccess());
- assertNull(ormResource().getEntityMappings().getAccess());
-
- //set access in the resource model, verify context model updated
- ormResource().getEntityMappings().setAccess(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, entityMappings().getSpecifiedAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, ormResource().getEntityMappings().getAccess());
-
- //set access to null in the resource model
- ormResource().getEntityMappings().setAccess(null);
- assertNull(entityMappings().getSpecifiedAccess());
- assertNull(ormResource().getEntityMappings().getAccess());
- }
-
- public void testModifySpecifiedAccess() throws Exception {
- assertNull(entityMappings().getSpecifiedAccess());
- assertNull(ormResource().getEntityMappings().getAccess());
-
- //set access in the context model, verify resource model modified
- entityMappings().setSpecifiedAccess(AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, entityMappings().getSpecifiedAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, ormResource().getEntityMappings().getAccess());
-
- //set access to null in the context model
- entityMappings().setSpecifiedAccess(null);
- assertNull(entityMappings().getSpecifiedAccess());
- assertNull(ormResource().getEntityMappings().getAccess());
- }
-
- public void testUpdateDefaultAccess() throws Exception {
- assertNull(entityMappings().getDefaultAccess());
- assertNull(entityMappings().getSpecifiedAccess());
- assertNull(ormResource().getEntityMappings().getAccess());
-
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- org.eclipse.jpt.core.resource.orm.XmlPersistenceUnitDefaults persistenceUnitDefaults = OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults();
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(persistenceUnitDefaults);
- persistenceUnitDefaults.setAccess(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, entityMappings().getDefaultAccess());
- assertNull(entityMappings().getSpecifiedAccess());
- assertNull(ormResource().getEntityMappings().getAccess());
-
- persistenceUnitDefaults.setAccess(org.eclipse.jpt.core.resource.orm.AccessType.FIELD);
- assertEquals(AccessType.FIELD, entityMappings().getDefaultAccess());
- assertNull(entityMappings().getSpecifiedAccess());
- assertNull(ormResource().getEntityMappings().getAccess());
-
- persistenceUnitDefaults.setAccess(null);
- assertNull(entityMappings().getDefaultAccess());
- assertNull(entityMappings().getSpecifiedAccess());
- assertNull(ormResource().getEntityMappings().getAccess());
- }
-
- public void testUpdateAccess() throws Exception {
- assertNull(entityMappings().getAccess());
- assertNull(entityMappings().getDefaultAccess());
- assertNull(entityMappings().getSpecifiedAccess());
- assertNull(ormResource().getEntityMappings().getAccess());
-
- ormResource().getEntityMappings().setAccess(org.eclipse.jpt.core.resource.orm.AccessType.FIELD);
- assertNull(entityMappings().getDefaultAccess());
- assertEquals(AccessType.FIELD, entityMappings().getAccess());
- assertEquals(AccessType.FIELD, entityMappings().getSpecifiedAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.FIELD, ormResource().getEntityMappings().getAccess());
-
- ormResource().getEntityMappings().setAccess(null);
- assertNull(entityMappings().getAccess());
- assertNull(entityMappings().getDefaultAccess());
- assertNull(entityMappings().getSpecifiedAccess());
- assertNull(ormResource().getEntityMappings().getAccess());
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.FIELD);
- assertEquals(AccessType.FIELD, entityMappings().getDefaultAccess());
- assertEquals(AccessType.FIELD, entityMappings().getAccess());
- assertNull(entityMappings().getSpecifiedAccess());
- assertNull(ormResource().getEntityMappings().getAccess());
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(null);
- assertNull(entityMappings().getDefaultAccess());
- assertNull(entityMappings().getAccess());
- assertNull(entityMappings().getSpecifiedAccess());
- assertNull(ormResource().getEntityMappings().getAccess());
- }
-
-
- public void testUpdateOrmPersistentTypes() throws Exception {
- assertFalse(entityMappings().ormPersistentTypes().hasNext());
- assertTrue(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEntities().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEmbeddables().isEmpty());
-
- //add embeddable in the resource model, verify context model updated
- XmlEmbeddable embeddable = OrmFactory.eINSTANCE.createXmlEmbeddable();
- ormResource().getEntityMappings().getEmbeddables().add(embeddable);
- embeddable.setClassName("model.Foo");
- assertTrue(entityMappings().ormPersistentTypes().hasNext());
- assertEquals("model.Foo", entityMappings().ormPersistentTypes().next().getMapping().getClass_());
- assertTrue(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEntities().isEmpty());
- assertFalse(ormResource().getEntityMappings().getEmbeddables().isEmpty());
- assertEquals("model.Foo", ormResource().getEntityMappings().getEmbeddables().get(0).getClassName());
-
- //add entity in the resource model, verify context model updated
- XmlEntity entity = OrmFactory.eINSTANCE.createXmlEntity();
- ormResource().getEntityMappings().getEntities().add(entity);
- entity.setClassName("model.Foo2");
- assertTrue(entityMappings().ormPersistentTypes().hasNext());
- assertEquals("model.Foo2", entityMappings().ormPersistentTypes().next().getMapping().getClass_());
- assertTrue(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertFalse(ormResource().getEntityMappings().getEntities().isEmpty());
- assertFalse(ormResource().getEntityMappings().getEmbeddables().isEmpty());
- assertEquals("model.Foo2", ormResource().getEntityMappings().getEntities().get(0).getClassName());
-
- //add mapped-superclass in the resource model, verify context model updated
- XmlMappedSuperclass mappedSuperclass = OrmFactory.eINSTANCE.createXmlMappedSuperclass();
- ormResource().getEntityMappings().getMappedSuperclasses().add(mappedSuperclass);
- mappedSuperclass.setClassName("model.Foo3");
- assertTrue(entityMappings().ormPersistentTypes().hasNext());
- assertEquals("model.Foo3", entityMappings().ormPersistentTypes().next().getMapping().getClass_());
- assertFalse(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertFalse(ormResource().getEntityMappings().getEntities().isEmpty());
- assertFalse(ormResource().getEntityMappings().getEmbeddables().isEmpty());
- assertEquals("model.Foo3", ormResource().getEntityMappings().getMappedSuperclasses().get(0).getClassName());
- }
-
-
- public void testAddOrmPersistentType() throws Exception {
- assertFalse(entityMappings().ormPersistentTypes().hasNext());
- assertTrue(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEntities().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEmbeddables().isEmpty());
-
- //add embeddable in the context model, verify resource model modified
- entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- assertTrue(entityMappings().ormPersistentTypes().hasNext());
- assertEquals("model.Foo", entityMappings().ormPersistentTypes().next().getMapping().getClass_());
- assertEquals(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, entityMappings().ormPersistentTypes().next().getMapping().getKey());
- assertTrue(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEntities().isEmpty());
- assertFalse(ormResource().getEntityMappings().getEmbeddables().isEmpty());
- assertEquals("model.Foo", ormResource().getEntityMappings().getEmbeddables().get(0).getClassName());
-
- //add entity in the context model, verify resource model modified
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
- assertTrue(entityMappings().ormPersistentTypes().hasNext());
- assertEquals("model.Foo2", entityMappings().ormPersistentTypes().next().getMapping().getClass_());
- assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, entityMappings().ormPersistentTypes().next().getMapping().getKey());
- assertTrue(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertFalse(ormResource().getEntityMappings().getEntities().isEmpty());
- assertFalse(ormResource().getEntityMappings().getEmbeddables().isEmpty());
- assertEquals("model.Foo2", ormResource().getEntityMappings().getEntities().get(0).getClassName());
-
- //add mapped-superclass in the context model, verify resource model modified
- entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo3");
- assertTrue(entityMappings().ormPersistentTypes().hasNext());
- assertEquals("model.Foo3", entityMappings().ormPersistentTypes().next().getMapping().getClass_());
- assertEquals(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, entityMappings().ormPersistentTypes().next().getMapping().getKey());
- assertFalse(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertFalse(ormResource().getEntityMappings().getEntities().isEmpty());
- assertFalse(ormResource().getEntityMappings().getEmbeddables().isEmpty());
- assertEquals("model.Foo3", ormResource().getEntityMappings().getMappedSuperclasses().get(0).getClassName());
- }
-
- public void testRemoveOrmPersistentType() throws Exception {
- assertFalse(entityMappings().ormPersistentTypes().hasNext());
- assertTrue(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEntities().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEmbeddables().isEmpty());
-
- entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
- entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo3");
-
- //remove ormPersistentType from the context model, verify resource model modified
- entityMappings().removeOrmPersistentType(1);
- assertFalse(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEntities().isEmpty());
- assertFalse(ormResource().getEntityMappings().getEmbeddables().isEmpty());
-
- entityMappings().removeOrmPersistentType(1);
- assertFalse(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEntities().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEmbeddables().isEmpty());
-
- entityMappings().removeOrmPersistentType(0);
- assertTrue(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEntities().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEmbeddables().isEmpty());
- }
-
- public void testUpdateTableGenerators() throws Exception {
- assertEquals(0, entityMappings().tableGeneratorsSize());
- assertEquals(0, ormResource().getEntityMappings().getTableGenerators().size());
- assertEquals(0, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- XmlTableGenerator tableGeneratorResource = OrmFactory.eINSTANCE.createXmlTableGeneratorImpl();
- ormResource().getEntityMappings().getTableGenerators().add(tableGeneratorResource);
- tableGeneratorResource.setName("FOO");
-
- TableGenerator tableGenerator = entityMappings().tableGenerators().next();
- assertEquals("FOO", tableGenerator.getName());
- assertEquals(1, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- XmlTableGenerator tableGeneratorResource2 = OrmFactory.eINSTANCE.createXmlTableGeneratorImpl();
- ormResource().getEntityMappings().getTableGenerators().add(0, tableGeneratorResource2);
- tableGeneratorResource2.setName("BAR");
-
- ListIterator<OrmTableGenerator> tableGenerators = entityMappings().tableGenerators();
- assertEquals("BAR", tableGenerators.next().getName());
- assertEquals("FOO", tableGenerators.next().getName());
- assertFalse(tableGenerators.hasNext());
- assertEquals(2, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- XmlTableGenerator tableGeneratorResource3 = OrmFactory.eINSTANCE.createXmlTableGeneratorImpl();
- ormResource().getEntityMappings().getTableGenerators().add(1, tableGeneratorResource3);
- tableGeneratorResource3.setName("BAZ");
-
- tableGenerators = entityMappings().tableGenerators();
- assertEquals("BAR", tableGenerators.next().getName());
- assertEquals("BAZ", tableGenerators.next().getName());
- assertEquals("FOO", tableGenerators.next().getName());
- assertFalse(tableGenerators.hasNext());
- assertEquals(3, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- ormResource().getEntityMappings().getTableGenerators().move(2, 0);
- tableGenerators = entityMappings().tableGenerators();
- assertEquals("BAZ", tableGenerators.next().getName());
- assertEquals("FOO", tableGenerators.next().getName());
- assertEquals("BAR", tableGenerators.next().getName());
- assertFalse(tableGenerators.hasNext());
- assertEquals(3, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- ormResource().getEntityMappings().getTableGenerators().remove(0);
- tableGenerators = entityMappings().tableGenerators();
- assertEquals("FOO", tableGenerators.next().getName());
- assertEquals("BAR", tableGenerators.next().getName());
- assertFalse(tableGenerators.hasNext());
- assertEquals(2, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- ormResource().getEntityMappings().getTableGenerators().remove(1);
- tableGenerators = entityMappings().tableGenerators();
- assertEquals("FOO", tableGenerators.next().getName());
- assertFalse(tableGenerators.hasNext());
- assertEquals(1, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- ormResource().getEntityMappings().getTableGenerators().clear();
- tableGenerators = entityMappings().tableGenerators();
- assertFalse(tableGenerators.hasNext());
- assertEquals(0, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
- }
-
- public void testAddTableGenerator() throws Exception {
- assertEquals(0, entityMappings().tableGeneratorsSize());
- assertEquals(0, ormResource().getEntityMappings().getTableGenerators().size());
- entityMappings().addTableGenerator(0).setName("FOO");
-
- assertEquals("FOO", ormResource().getEntityMappings().getTableGenerators().get(0).getName());
-
- entityMappings().addTableGenerator(0).setName("BAR");
- assertEquals("BAR", ormResource().getEntityMappings().getTableGenerators().get(0).getName());
- assertEquals("FOO", ormResource().getEntityMappings().getTableGenerators().get(1).getName());
- assertEquals(2, ormResource().getEntityMappings().getTableGenerators().size());
-
- ListIterator<OrmTableGenerator> tableGenerators = entityMappings().tableGenerators();
- assertEquals("BAR", tableGenerators.next().getName());
- assertEquals("FOO", tableGenerators.next().getName());
- assertFalse(tableGenerators.hasNext());
- }
-
- public void testRemoveTableGenerator() throws Exception {
- assertEquals(0, entityMappings().tableGeneratorsSize());
- assertEquals(0, ormResource().getEntityMappings().getTableGenerators().size());
-
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- tableGenerator.setName("FOO");
- TableGenerator tableGenerator2 = entityMappings().addTableGenerator(1);
- tableGenerator2.setName("BAR");
- TableGenerator tableGenerator3 = entityMappings().addTableGenerator(2);
- tableGenerator3.setName("BAZ");
- assertEquals("FOO", ormResource().getEntityMappings().getTableGenerators().get(0).getName());
- assertEquals("BAR", ormResource().getEntityMappings().getTableGenerators().get(1).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getTableGenerators().get(2).getName());
- assertEquals(3, ormResource().getEntityMappings().getTableGenerators().size());
-
- entityMappings().removeTableGenerator(0);
- assertEquals("BAR", ormResource().getEntityMappings().getTableGenerators().get(0).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getTableGenerators().get(1).getName());
-
- ListIterator<OrmTableGenerator> tableGenerators = entityMappings().tableGenerators();
- OrmTableGenerator xmlTableGenerator = tableGenerators.next();
- assertEquals("BAR", xmlTableGenerator.getName());
- assertEquals(tableGenerator2, xmlTableGenerator);
- xmlTableGenerator = tableGenerators.next();
- assertEquals("BAZ", xmlTableGenerator.getName());
- assertEquals(tableGenerator3, xmlTableGenerator);
- assertFalse(tableGenerators.hasNext());
-
-
- entityMappings().removeTableGenerator(1);
- assertEquals("BAR", ormResource().getEntityMappings().getTableGenerators().get(0).getName());
- tableGenerators = entityMappings().tableGenerators();
- xmlTableGenerator = tableGenerators.next();
- assertEquals("BAR", xmlTableGenerator.getName());
- assertEquals(tableGenerator2, xmlTableGenerator);
- assertFalse(tableGenerators.hasNext());
-
-
- entityMappings().removeTableGenerator(0);
- assertEquals(0, ormResource().getEntityMappings().getTableGenerators().size());
- tableGenerators = entityMappings().tableGenerators();
- assertFalse(tableGenerators.hasNext());
- }
-
- public void testMoveTableGenerator() throws Exception {
- assertEquals(0, entityMappings().tableGeneratorsSize());
- assertEquals(0, ormResource().getEntityMappings().getTableGenerators().size());
-
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- tableGenerator.setName("FOO");
- TableGenerator tableGenerator2 = entityMappings().addTableGenerator(1);
- tableGenerator2.setName("BAR");
- TableGenerator tableGenerator3 = entityMappings().addTableGenerator(2);
- tableGenerator3.setName("BAZ");
- assertEquals("FOO", ormResource().getEntityMappings().getTableGenerators().get(0).getName());
- assertEquals("BAR", ormResource().getEntityMappings().getTableGenerators().get(1).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getTableGenerators().get(2).getName());
- assertEquals(3, ormResource().getEntityMappings().getTableGenerators().size());
-
- entityMappings().moveTableGenerator(2, 0);
- assertEquals("BAR", ormResource().getEntityMappings().getTableGenerators().get(0).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getTableGenerators().get(1).getName());
- assertEquals("FOO", ormResource().getEntityMappings().getTableGenerators().get(2).getName());
- assertEquals(3, ormResource().getEntityMappings().getTableGenerators().size());
-
- entityMappings().moveTableGenerator(0, 2);
- assertEquals("FOO", ormResource().getEntityMappings().getTableGenerators().get(0).getName());
- assertEquals("BAR", ormResource().getEntityMappings().getTableGenerators().get(1).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getTableGenerators().get(2).getName());
- assertEquals(3, ormResource().getEntityMappings().getTableGenerators().size());
- }
-
- public void testTableGeneratorsSize() throws Exception {
- assertEquals(0, entityMappings().tableGeneratorsSize());
- assertEquals(0, ormResource().getEntityMappings().getTableGenerators().size());
-
-
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- tableGenerator.setName("FOO");
- TableGenerator tableGenerator2 = entityMappings().addTableGenerator(1);
- tableGenerator2.setName("BAR");
- TableGenerator tableGenerator3 = entityMappings().addTableGenerator(2);
- tableGenerator3.setName("BAZ");
-
- assertEquals(3, entityMappings().tableGeneratorsSize());
-
- ormResource().getEntityMappings().getTableGenerators().remove(0);
- assertEquals(2, entityMappings().tableGeneratorsSize());
- }
-
- public void testUpdateSequenceGenerators() throws Exception {
- assertEquals(0, entityMappings().sequenceGeneratorsSize());
- assertEquals(0, ormResource().getEntityMappings().getSequenceGenerators().size());
- assertEquals(0, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- XmlSequenceGenerator sequenceGeneratorResource = OrmFactory.eINSTANCE.createXmlSequenceGeneratorImpl();
- ormResource().getEntityMappings().getSequenceGenerators().add(sequenceGeneratorResource);
- sequenceGeneratorResource.setName("FOO");
-
- SequenceGenerator sequenceGenerator = entityMappings().sequenceGenerators().next();
- assertEquals("FOO", sequenceGenerator.getName());
- assertEquals(1, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- XmlSequenceGenerator sequenceGeneratorResource2 = OrmFactory.eINSTANCE.createXmlSequenceGeneratorImpl();
- ormResource().getEntityMappings().getSequenceGenerators().add(0, sequenceGeneratorResource2);
- sequenceGeneratorResource2.setName("BAR");
-
- ListIterator<OrmSequenceGenerator> sequenceGenerators = entityMappings().sequenceGenerators();
- assertEquals("BAR", sequenceGenerators.next().getName());
- assertEquals("FOO", sequenceGenerators.next().getName());
- assertFalse(sequenceGenerators.hasNext());
- assertEquals(2, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- XmlSequenceGenerator sequenceGeneratorResource3 = OrmFactory.eINSTANCE.createXmlSequenceGeneratorImpl();
- ormResource().getEntityMappings().getSequenceGenerators().add(1, sequenceGeneratorResource3);
- sequenceGeneratorResource3.setName("BAZ");
-
- sequenceGenerators = entityMappings().sequenceGenerators();
- assertEquals("BAR", sequenceGenerators.next().getName());
- assertEquals("BAZ", sequenceGenerators.next().getName());
- assertEquals("FOO", sequenceGenerators.next().getName());
- assertFalse(sequenceGenerators.hasNext());
- assertEquals(3, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- ormResource().getEntityMappings().getSequenceGenerators().move(2, 0);
- sequenceGenerators = entityMappings().sequenceGenerators();
- assertEquals("BAZ", sequenceGenerators.next().getName());
- assertEquals("FOO", sequenceGenerators.next().getName());
- assertEquals("BAR", sequenceGenerators.next().getName());
- assertFalse(sequenceGenerators.hasNext());
-
- ormResource().getEntityMappings().getSequenceGenerators().remove(0);
- sequenceGenerators = entityMappings().sequenceGenerators();
- assertEquals("FOO", sequenceGenerators.next().getName());
- assertEquals("BAR", sequenceGenerators.next().getName());
- assertFalse(sequenceGenerators.hasNext());
- assertEquals(2, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- ormResource().getEntityMappings().getSequenceGenerators().remove(1);
- sequenceGenerators = entityMappings().sequenceGenerators();
- assertEquals("FOO", sequenceGenerators.next().getName());
- assertFalse(sequenceGenerators.hasNext());
- assertEquals(1, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
-
- ormResource().getEntityMappings().getSequenceGenerators().clear();
- sequenceGenerators = entityMappings().sequenceGenerators();
- assertFalse(sequenceGenerators.hasNext());
- assertEquals(0, CollectionTools.size(entityMappings().getPersistenceUnit().allGenerators()));
- }
-
- public void testAddSequenceGenerator() throws Exception {
- assertEquals(0, entityMappings().sequenceGeneratorsSize());
- assertEquals(0, ormResource().getEntityMappings().getSequenceGenerators().size());
-
- entityMappings().addSequenceGenerator(0).setName("FOO");
-
- assertEquals("FOO", ormResource().getEntityMappings().getSequenceGenerators().get(0).getName());
-
- entityMappings().addSequenceGenerator(0).setName("BAR");
- assertEquals("BAR", ormResource().getEntityMappings().getSequenceGenerators().get(0).getName());
- assertEquals("FOO", ormResource().getEntityMappings().getSequenceGenerators().get(1).getName());
- assertEquals(2, ormResource().getEntityMappings().getSequenceGenerators().size());
-
- ListIterator<OrmSequenceGenerator> sequenceGenerators = entityMappings().sequenceGenerators();
- assertEquals("BAR", sequenceGenerators.next().getName());
- assertEquals("FOO", sequenceGenerators.next().getName());
- assertFalse(sequenceGenerators.hasNext());
- }
-
- public void testRemoveSequenceGenerator() throws Exception {
- assertEquals(0, entityMappings().sequenceGeneratorsSize());
- assertEquals(0, ormResource().getEntityMappings().getSequenceGenerators().size());
-
- SequenceGenerator sequenceGenerator = entityMappings().addSequenceGenerator(0);
- sequenceGenerator.setName("FOO");
- SequenceGenerator sequenceGenerator2 = entityMappings().addSequenceGenerator(1);
- sequenceGenerator2.setName("BAR");
- SequenceGenerator sequenceGenerator3 = entityMappings().addSequenceGenerator(2);
- sequenceGenerator3.setName("BAZ");
- assertEquals("FOO", ormResource().getEntityMappings().getSequenceGenerators().get(0).getName());
- assertEquals("BAR", ormResource().getEntityMappings().getSequenceGenerators().get(1).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getSequenceGenerators().get(2).getName());
- assertEquals(3, ormResource().getEntityMappings().getSequenceGenerators().size());
-
- entityMappings().removeSequenceGenerator(0);
- assertEquals("BAR", ormResource().getEntityMappings().getSequenceGenerators().get(0).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getSequenceGenerators().get(1).getName());
-
- ListIterator<OrmSequenceGenerator> sequenceGenerators = entityMappings().sequenceGenerators();
- SequenceGenerator xmlSequenceGenerator = sequenceGenerators.next();
- assertEquals("BAR", xmlSequenceGenerator.getName());
- assertEquals(sequenceGenerator2, xmlSequenceGenerator);
- xmlSequenceGenerator = sequenceGenerators.next();
- assertEquals("BAZ", xmlSequenceGenerator.getName());
- assertEquals(sequenceGenerator3, xmlSequenceGenerator);
- assertFalse(sequenceGenerators.hasNext());
-
-
- entityMappings().removeSequenceGenerator(1);
- assertEquals("BAR", ormResource().getEntityMappings().getSequenceGenerators().get(0).getName());
- sequenceGenerators = entityMappings().sequenceGenerators();
- xmlSequenceGenerator = sequenceGenerators.next();
- assertEquals("BAR", xmlSequenceGenerator.getName());
- assertEquals(sequenceGenerator2, xmlSequenceGenerator);
- assertFalse(sequenceGenerators.hasNext());
-
-
- entityMappings().removeSequenceGenerator(0);
- assertEquals(0, ormResource().getEntityMappings().getSequenceGenerators().size());
- sequenceGenerators = entityMappings().sequenceGenerators();
- assertFalse(sequenceGenerators.hasNext());
- }
-
- public void testMoveSequenceGenerator() throws Exception {
- assertEquals(0, entityMappings().sequenceGeneratorsSize());
- assertEquals(0, ormResource().getEntityMappings().getSequenceGenerators().size());
-
- SequenceGenerator sequenceGenerator = entityMappings().addSequenceGenerator(0);
- sequenceGenerator.setName("FOO");
- SequenceGenerator sequenceGenerator2 = entityMappings().addSequenceGenerator(1);
- sequenceGenerator2.setName("BAR");
- SequenceGenerator sequenceGenerator3 = entityMappings().addSequenceGenerator(2);
- sequenceGenerator3.setName("BAZ");
- assertEquals("FOO", ormResource().getEntityMappings().getSequenceGenerators().get(0).getName());
- assertEquals("BAR", ormResource().getEntityMappings().getSequenceGenerators().get(1).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getSequenceGenerators().get(2).getName());
- assertEquals(3, ormResource().getEntityMappings().getSequenceGenerators().size());
-
- entityMappings().moveSequenceGenerator(2, 0);
- assertEquals("BAR", ormResource().getEntityMappings().getSequenceGenerators().get(0).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getSequenceGenerators().get(1).getName());
- assertEquals("FOO", ormResource().getEntityMappings().getSequenceGenerators().get(2).getName());
- assertEquals(3, ormResource().getEntityMappings().getSequenceGenerators().size());
-
- entityMappings().moveSequenceGenerator(0, 2);
- assertEquals("FOO", ormResource().getEntityMappings().getSequenceGenerators().get(0).getName());
- assertEquals("BAR", ormResource().getEntityMappings().getSequenceGenerators().get(1).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getSequenceGenerators().get(2).getName());
- assertEquals(3, ormResource().getEntityMappings().getSequenceGenerators().size());
-
- }
-
- public void testSequenceGeneratorsSize() throws Exception {
- assertEquals(0, entityMappings().sequenceGeneratorsSize());
- assertEquals(0, ormResource().getEntityMappings().getSequenceGenerators().size());
-
-
- SequenceGenerator sequenceGenerator = entityMappings().addSequenceGenerator(0);
- sequenceGenerator.setName("FOO");
- SequenceGenerator sequenceGenerator2 = entityMappings().addSequenceGenerator(1);
- sequenceGenerator2.setName("BAR");
- SequenceGenerator sequenceGenerator3 = entityMappings().addSequenceGenerator(2);
- sequenceGenerator3.setName("BAZ");
-
- assertEquals(3, entityMappings().sequenceGeneratorsSize());
-
- ormResource().getEntityMappings().getSequenceGenerators().remove(0);
- assertEquals(2, entityMappings().sequenceGeneratorsSize());
- }
-
-
- public void testAddNamedQuery() throws Exception {
- OrmNamedQuery namedQuery = entityMappings().addNamedQuery(0);
- namedQuery.setName("FOO");
-
- assertEquals("FOO", ormResource().getEntityMappings().getNamedQueries().get(0).getName());
-
- OrmNamedQuery namedQuery2 = entityMappings().addNamedQuery(0);
- namedQuery2.setName("BAR");
-
- assertEquals("BAR", ormResource().getEntityMappings().getNamedQueries().get(0).getName());
- assertEquals("FOO", ormResource().getEntityMappings().getNamedQueries().get(1).getName());
-
- OrmNamedQuery namedQuery3 = entityMappings().addNamedQuery(1);
- namedQuery3.setName("BAZ");
-
- assertEquals("BAR", ormResource().getEntityMappings().getNamedQueries().get(0).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getNamedQueries().get(1).getName());
- assertEquals("FOO", ormResource().getEntityMappings().getNamedQueries().get(2).getName());
-
- ListIterator<OrmNamedQuery> namedQueries = entityMappings().namedQueries();
- assertEquals(namedQuery2, namedQueries.next());
- assertEquals(namedQuery3, namedQueries.next());
- assertEquals(namedQuery, namedQueries.next());
-
- namedQueries = entityMappings().namedQueries();
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- }
-
- public void testRemoveNamedQuery() throws Exception {
- entityMappings().addNamedQuery(0).setName("FOO");
- entityMappings().addNamedQuery(1).setName("BAR");
- entityMappings().addNamedQuery(2).setName("BAZ");
-
- assertEquals(3, ormResource().getEntityMappings().getNamedQueries().size());
-
- entityMappings().removeNamedQuery(0);
- assertEquals(2, ormResource().getEntityMappings().getNamedQueries().size());
- assertEquals("BAR", ormResource().getEntityMappings().getNamedQueries().get(0).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getNamedQueries().get(1).getName());
-
- entityMappings().removeNamedQuery(0);
- assertEquals(1, ormResource().getEntityMappings().getNamedQueries().size());
- assertEquals("BAZ", ormResource().getEntityMappings().getNamedQueries().get(0).getName());
-
- entityMappings().removeNamedQuery(0);
- assertEquals(0, ormResource().getEntityMappings().getNamedQueries().size());
- }
-
- public void testMoveNamedQuery() throws Exception {
- entityMappings().addNamedQuery(0).setName("FOO");
- entityMappings().addNamedQuery(1).setName("BAR");
- entityMappings().addNamedQuery(2).setName("BAZ");
-
- assertEquals(3, ormResource().getEntityMappings().getNamedQueries().size());
-
-
- entityMappings().moveNamedQuery(2, 0);
- ListIterator<OrmNamedQuery> namedQueries = entityMappings().namedQueries();
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
-
- assertEquals("BAR", ormResource().getEntityMappings().getNamedQueries().get(0).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getNamedQueries().get(1).getName());
- assertEquals("FOO", ormResource().getEntityMappings().getNamedQueries().get(2).getName());
-
-
- entityMappings().moveNamedQuery(0, 1);
- namedQueries = entityMappings().namedQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
-
- assertEquals("BAZ", ormResource().getEntityMappings().getNamedQueries().get(0).getName());
- assertEquals("BAR", ormResource().getEntityMappings().getNamedQueries().get(1).getName());
- assertEquals("FOO", ormResource().getEntityMappings().getNamedQueries().get(2).getName());
- }
-
- public void testUpdateNamedQueries() throws Exception {
- assertEquals(0, CollectionTools.size(entityMappings().getPersistenceUnit().allQueries()));
-
- ormResource().getEntityMappings().getNamedQueries().add(OrmFactory.eINSTANCE.createXmlNamedQuery());
- ormResource().getEntityMappings().getNamedQueries().add(OrmFactory.eINSTANCE.createXmlNamedQuery());
- ormResource().getEntityMappings().getNamedQueries().add(OrmFactory.eINSTANCE.createXmlNamedQuery());
-
- ormResource().getEntityMappings().getNamedQueries().get(0).setName("FOO");
- ormResource().getEntityMappings().getNamedQueries().get(1).setName("BAR");
- ormResource().getEntityMappings().getNamedQueries().get(2).setName("BAZ");
-
- ListIterator<OrmNamedQuery> namedQueries = entityMappings().namedQueries();
- assertEquals("FOO", namedQueries.next().getName());
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
- assertEquals(3, CollectionTools.size(entityMappings().getPersistenceUnit().allQueries()));
-
- ormResource().getEntityMappings().getNamedQueries().move(2, 0);
- namedQueries = entityMappings().namedQueries();
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
-
- ormResource().getEntityMappings().getNamedQueries().move(0, 1);
- namedQueries = entityMappings().namedQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
-
- ormResource().getEntityMappings().getNamedQueries().remove(1);
- namedQueries = entityMappings().namedQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
- assertEquals(2, CollectionTools.size(entityMappings().getPersistenceUnit().allQueries()));
-
- ormResource().getEntityMappings().getNamedQueries().remove(1);
- namedQueries = entityMappings().namedQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
- assertEquals(1, CollectionTools.size(entityMappings().getPersistenceUnit().allQueries()));
-
- ormResource().getEntityMappings().getNamedQueries().remove(0);
- assertFalse(entityMappings().namedQueries().hasNext());
- assertEquals(0, CollectionTools.size(entityMappings().getPersistenceUnit().allQueries()));
- }
-
- public void testAddNamedNativeQuery() throws Exception {
- OrmNamedNativeQuery namedNativeQuery = entityMappings().addNamedNativeQuery(0);
- namedNativeQuery.setName("FOO");
-
- assertEquals("FOO", ormResource().getEntityMappings().getNamedNativeQueries().get(0).getName());
-
- OrmNamedNativeQuery namedNativeQuery2 = entityMappings().addNamedNativeQuery(0);
- namedNativeQuery2.setName("BAR");
-
- assertEquals("BAR", ormResource().getEntityMappings().getNamedNativeQueries().get(0).getName());
- assertEquals("FOO", ormResource().getEntityMappings().getNamedNativeQueries().get(1).getName());
-
- OrmNamedNativeQuery namedNativeQuery3 = entityMappings().addNamedNativeQuery(1);
- namedNativeQuery3.setName("BAZ");
-
- assertEquals("BAR", ormResource().getEntityMappings().getNamedNativeQueries().get(0).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getNamedNativeQueries().get(1).getName());
- assertEquals("FOO", ormResource().getEntityMappings().getNamedNativeQueries().get(2).getName());
-
- ListIterator<OrmNamedNativeQuery> namedNativeQueries = entityMappings().namedNativeQueries();
- assertEquals(namedNativeQuery2, namedNativeQueries.next());
- assertEquals(namedNativeQuery3, namedNativeQueries.next());
- assertEquals(namedNativeQuery, namedNativeQueries.next());
-
- namedNativeQueries = entityMappings().namedNativeQueries();
- assertEquals("BAR", namedNativeQueries.next().getName());
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertEquals("FOO", namedNativeQueries.next().getName());
- }
-
- public void testRemoveNamedNativeQuery() throws Exception {
- entityMappings().addNamedNativeQuery(0).setName("FOO");
- entityMappings().addNamedNativeQuery(1).setName("BAR");
- entityMappings().addNamedNativeQuery(2).setName("BAZ");
-
- assertEquals(3, ormResource().getEntityMappings().getNamedNativeQueries().size());
-
- entityMappings().removeNamedNativeQuery(0);
- assertEquals(2, ormResource().getEntityMappings().getNamedNativeQueries().size());
- assertEquals("BAR", ormResource().getEntityMappings().getNamedNativeQueries().get(0).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getNamedNativeQueries().get(1).getName());
-
- entityMappings().removeNamedNativeQuery(0);
- assertEquals(1, ormResource().getEntityMappings().getNamedNativeQueries().size());
- assertEquals("BAZ", ormResource().getEntityMappings().getNamedNativeQueries().get(0).getName());
-
- entityMappings().removeNamedNativeQuery(0);
- assertEquals(0, ormResource().getEntityMappings().getNamedNativeQueries().size());
- }
-
- public void testMoveNamedNativeQuery() throws Exception {
- entityMappings().addNamedNativeQuery(0).setName("FOO");
- entityMappings().addNamedNativeQuery(1).setName("BAR");
- entityMappings().addNamedNativeQuery(2).setName("BAZ");
-
- assertEquals(3, ormResource().getEntityMappings().getNamedNativeQueries().size());
-
-
- entityMappings().moveNamedNativeQuery(2, 0);
- ListIterator<OrmNamedNativeQuery> namedNativeQueries = entityMappings().namedNativeQueries();
- assertEquals("BAR", namedNativeQueries.next().getName());
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertEquals("FOO", namedNativeQueries.next().getName());
-
- assertEquals("BAR", ormResource().getEntityMappings().getNamedNativeQueries().get(0).getName());
- assertEquals("BAZ", ormResource().getEntityMappings().getNamedNativeQueries().get(1).getName());
- assertEquals("FOO", ormResource().getEntityMappings().getNamedNativeQueries().get(2).getName());
-
-
- entityMappings().moveNamedNativeQuery(0, 1);
- namedNativeQueries = entityMappings().namedNativeQueries();
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertEquals("BAR", namedNativeQueries.next().getName());
- assertEquals("FOO", namedNativeQueries.next().getName());
-
- assertEquals("BAZ", ormResource().getEntityMappings().getNamedNativeQueries().get(0).getName());
- assertEquals("BAR", ormResource().getEntityMappings().getNamedNativeQueries().get(1).getName());
- assertEquals("FOO", ormResource().getEntityMappings().getNamedNativeQueries().get(2).getName());
- }
-
- public void testUpdateNamedNativeQueries() throws Exception {
- assertEquals(0, CollectionTools.size(entityMappings().getPersistenceUnit().allQueries()));
-
- ormResource().getEntityMappings().getNamedNativeQueries().add(OrmFactory.eINSTANCE.createXmlNamedNativeQuery());
- ormResource().getEntityMappings().getNamedNativeQueries().add(OrmFactory.eINSTANCE.createXmlNamedNativeQuery());
- ormResource().getEntityMappings().getNamedNativeQueries().add(OrmFactory.eINSTANCE.createXmlNamedNativeQuery());
-
- ormResource().getEntityMappings().getNamedNativeQueries().get(0).setName("FOO");
- ormResource().getEntityMappings().getNamedNativeQueries().get(1).setName("BAR");
- ormResource().getEntityMappings().getNamedNativeQueries().get(2).setName("BAZ");
-
- ListIterator<OrmNamedNativeQuery> namedNativeQueries = entityMappings().namedNativeQueries();
- assertEquals("FOO", namedNativeQueries.next().getName());
- assertEquals("BAR", namedNativeQueries.next().getName());
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertFalse(namedNativeQueries.hasNext());
- assertEquals(3, CollectionTools.size(entityMappings().getPersistenceUnit().allQueries()));
-
- ormResource().getEntityMappings().getNamedNativeQueries().move(2, 0);
- namedNativeQueries = entityMappings().namedNativeQueries();
- assertEquals("BAR", namedNativeQueries.next().getName());
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertEquals("FOO", namedNativeQueries.next().getName());
- assertFalse(namedNativeQueries.hasNext());
-
- ormResource().getEntityMappings().getNamedNativeQueries().move(0, 1);
- namedNativeQueries = entityMappings().namedNativeQueries();
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertEquals("BAR", namedNativeQueries.next().getName());
- assertEquals("FOO", namedNativeQueries.next().getName());
- assertFalse(namedNativeQueries.hasNext());
-
- ormResource().getEntityMappings().getNamedNativeQueries().remove(1);
- namedNativeQueries = entityMappings().namedNativeQueries();
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertEquals("FOO", namedNativeQueries.next().getName());
- assertFalse(namedNativeQueries.hasNext());
- assertEquals(2, CollectionTools.size(entityMappings().getPersistenceUnit().allQueries()));
-
- ormResource().getEntityMappings().getNamedNativeQueries().remove(1);
- namedNativeQueries = entityMappings().namedNativeQueries();
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertFalse(namedNativeQueries.hasNext());
- assertEquals(1, CollectionTools.size(entityMappings().getPersistenceUnit().allQueries()));
-
- ormResource().getEntityMappings().getNamedNativeQueries().remove(0);
- assertFalse(entityMappings().namedNativeQueries().hasNext());
- assertEquals(0, CollectionTools.size(entityMappings().getPersistenceUnit().allQueries()));
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/JptCoreOrmContextModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/JptCoreOrmContextModelTests.java
deleted file mode 100644
index 2c98ed8e0b..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/JptCoreOrmContextModelTests.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JptCoreOrmContextModelTests extends TestCase
-{
- public static Test suite() {
- return suite(true);
- }
-
- public static Test suite(boolean all) {
- TestSuite suite = new TestSuite(JptCoreOrmContextModelTests.class.getName());
- suite.addTestSuite(OrmXmlTests.class);
- suite.addTestSuite(EntityMappingsTests.class);
- suite.addTestSuite(PersistenceUnitMetadataTests.class);
- suite.addTestSuite(PersistenceUnitDefaultsTests.class);
- suite.addTestSuite(OrmPersistentAttributeTests.class);
- suite.addTestSuite(OrmPersistentTypeTests.class);
- suite.addTestSuite(OrmAssociationOverrideTests.class);
- suite.addTestSuite(OrmAttributeOverrideTests.class);
- suite.addTestSuite(OrmBasicMappingTests.class);
- suite.addTestSuite(OrmCascadeTests.class);
- suite.addTestSuite(OrmColumnTests.class);
- suite.addTestSuite(OrmDiscriminatorColumnTests.class);
- suite.addTestSuite(OrmIdMappingTests.class);
- suite.addTestSuite(OrmEmbeddableTests.class);
- suite.addTestSuite(OrmEmbeddedMappingTests.class);
- suite.addTestSuite(OrmEmbeddedIdMappingTests.class);
- suite.addTestSuite(OrmEntityTests.class);
- suite.addTestSuite(OrmGeneratedValueTests.class);
- suite.addTestSuite(OrmJoinColumnTests.class);
- suite.addTestSuite(OrmJoinTableTests.class);
- suite.addTestSuite(OrmMappedSuperclassTests.class);
- suite.addTestSuite(OrmManyToManyMappingTests.class);
- suite.addTestSuite(OrmManyToOneMappingTests.class);
- suite.addTestSuite(OrmNamedQueryTests.class);
- suite.addTestSuite(OrmNamedNativeQueryTests.class);
- suite.addTestSuite(OrmOneToManyMappingTests.class);
- suite.addTestSuite(OrmOneToOneMappingTests.class);
- suite.addTestSuite(OrmPrimaryKeyJoinColumnTests.class);
- suite.addTestSuite(OrmQueryHintTests.class);
- suite.addTestSuite(OrmSecondaryTableTests.class);
- suite.addTestSuite(OrmSequenceGeneratorTests.class);
- suite.addTestSuite(OrmTableGeneratorTests.class);
- suite.addTestSuite(OrmTableTests.class);
- suite.addTestSuite(OrmTransientMappingTests.class);
- suite.addTestSuite(OrmVersionMappingTests.class);
- return suite;
- }
-
- private JptCoreOrmContextModelTests() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmAssociationOverrideTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmAssociationOverrideTests.java
deleted file mode 100644
index 5ab76feb9a..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmAssociationOverrideTests.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmAssociationOverride;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmAssociationOverrideTests extends ContextModelTestCase
-{
- public OrmAssociationOverrideTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverrideImpl());
- XmlAssociationOverride xmlAssociationOverride = entityResource.getAssociationOverrides().get(0);
- OrmAssociationOverride ormAssociationOverride = ormEntity.specifiedAssociationOverrides().next();
-
- assertNull(ormAssociationOverride.getName());
- assertNull(xmlAssociationOverride.getName());
- assertTrue(ormEntity.associationOverrides().hasNext());
- assertFalse(entityResource.getAssociationOverrides().isEmpty());
-
- //set name in the resource model, verify context model updated
- xmlAssociationOverride.setName("FOO");
- assertEquals("FOO", ormAssociationOverride.getName());
- assertEquals("FOO", xmlAssociationOverride.getName());
-
- //set name to null in the resource model
- xmlAssociationOverride.setName(null);
- assertNull(ormAssociationOverride.getName());
- assertNull(xmlAssociationOverride.getName());
-
- xmlAssociationOverride.setName("FOO");
- assertEquals("FOO", ormAssociationOverride.getName());
- assertEquals("FOO", xmlAssociationOverride.getName());
-
- entityResource.getAssociationOverrides().remove(0);
- assertFalse(ormEntity.associationOverrides().hasNext());
- assertTrue(entityResource.getAssociationOverrides().isEmpty());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverrideImpl());
- XmlAssociationOverride xmlAssociationOverride = entityResource.getAssociationOverrides().get(0);
- OrmAssociationOverride ormAssociationOverride = ormEntity.specifiedAssociationOverrides().next();
-
- assertNull(ormAssociationOverride.getName());
- assertNull(xmlAssociationOverride.getName());
-
- //set name in the context model, verify resource model modified
- ormAssociationOverride.setName("foo");
- assertEquals("foo", ormAssociationOverride.getName());
- assertEquals("foo", xmlAssociationOverride.getName());
-
- //set name to null in the context model
- ormAssociationOverride.setName(null);
- assertNull(ormAssociationOverride.getName());
- assertNull(entityResource.getAssociationOverrides().get(0).getName());
- }
-
-
- public void testAddSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverrideImpl());
- OrmAssociationOverride ormAssociationOverride = ormEntity.specifiedAssociationOverrides().next();
-
- XmlAssociationOverride xmlAssociationOverride = entityResource.getAssociationOverrides().get(0);
-
- OrmJoinColumn joinColumn = ormAssociationOverride.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("FOO");
-
- assertEquals("FOO", xmlAssociationOverride.getJoinColumns().get(0).getName());
-
- OrmJoinColumn joinColumn2 = ormAssociationOverride.addSpecifiedJoinColumn(0);
- joinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", xmlAssociationOverride.getJoinColumns().get(0).getName());
- assertEquals("FOO", xmlAssociationOverride.getJoinColumns().get(1).getName());
-
- OrmJoinColumn joinColumn3 = ormAssociationOverride.addSpecifiedJoinColumn(1);
- joinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", xmlAssociationOverride.getJoinColumns().get(0).getName());
- assertEquals("BAZ", xmlAssociationOverride.getJoinColumns().get(1).getName());
- assertEquals("FOO", xmlAssociationOverride.getJoinColumns().get(2).getName());
-
- ListIterator<OrmJoinColumn> joinColumns = ormAssociationOverride.specifiedJoinColumns();
- assertEquals(joinColumn2, joinColumns.next());
- assertEquals(joinColumn3, joinColumns.next());
- assertEquals(joinColumn, joinColumns.next());
-
- joinColumns = ormAssociationOverride.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- }
-
- public void testRemoveSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverrideImpl());
- OrmAssociationOverride ormAssociationOverride = ormEntity.specifiedAssociationOverrides().next();
-
- XmlAssociationOverride xmlAssociationOverride = entityResource.getAssociationOverrides().get(0);
-
- ormAssociationOverride.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- ormAssociationOverride.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- ormAssociationOverride.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- assertEquals(3, xmlAssociationOverride.getJoinColumns().size());
-
- ormAssociationOverride.removeSpecifiedJoinColumn(0);
- assertEquals(2, xmlAssociationOverride.getJoinColumns().size());
- assertEquals("BAR", xmlAssociationOverride.getJoinColumns().get(0).getName());
- assertEquals("BAZ", xmlAssociationOverride.getJoinColumns().get(1).getName());
-
- ormAssociationOverride.removeSpecifiedJoinColumn(0);
- assertEquals(1, xmlAssociationOverride.getJoinColumns().size());
- assertEquals("BAZ", xmlAssociationOverride.getJoinColumns().get(0).getName());
-
- ormAssociationOverride.removeSpecifiedJoinColumn(0);
- assertEquals(0, xmlAssociationOverride.getJoinColumns().size());
- }
-
- public void testMoveSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverrideImpl());
- OrmAssociationOverride ormAssociationOverride = ormEntity.specifiedAssociationOverrides().next();
-
- XmlAssociationOverride xmlAssociationOverride = entityResource.getAssociationOverrides().get(0);
-
- ormAssociationOverride.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- ormAssociationOverride.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- ormAssociationOverride.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- assertEquals(3, xmlAssociationOverride.getJoinColumns().size());
-
-
- ormAssociationOverride.moveSpecifiedJoinColumn(2, 0);
- ListIterator<OrmJoinColumn> joinColumns = ormAssociationOverride.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAR", xmlAssociationOverride.getJoinColumns().get(0).getName());
- assertEquals("BAZ", xmlAssociationOverride.getJoinColumns().get(1).getName());
- assertEquals("FOO", xmlAssociationOverride.getJoinColumns().get(2).getName());
-
-
- ormAssociationOverride.moveSpecifiedJoinColumn(0, 1);
- joinColumns = ormAssociationOverride.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAZ", xmlAssociationOverride.getJoinColumns().get(0).getName());
- assertEquals("BAR", xmlAssociationOverride.getJoinColumns().get(1).getName());
- assertEquals("FOO", xmlAssociationOverride.getJoinColumns().get(2).getName());
- }
-
- public void testUpdateJoinColumns() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverrideImpl());
- OrmAssociationOverride ormAssociationOverride = ormEntity.specifiedAssociationOverrides().next();
-
- XmlAssociationOverride xmlAssociationOverride = entityResource.getAssociationOverrides().get(0);
-
- xmlAssociationOverride.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumnImpl());
- xmlAssociationOverride.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumnImpl());
- xmlAssociationOverride.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumnImpl());
-
- xmlAssociationOverride.getJoinColumns().get(0).setName("FOO");
- xmlAssociationOverride.getJoinColumns().get(1).setName("BAR");
- xmlAssociationOverride.getJoinColumns().get(2).setName("BAZ");
-
- ListIterator<OrmJoinColumn> joinColumns = ormAssociationOverride.specifiedJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- xmlAssociationOverride.getJoinColumns().move(2, 0);
- joinColumns = ormAssociationOverride.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- xmlAssociationOverride.getJoinColumns().move(0, 1);
- joinColumns = ormAssociationOverride.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- xmlAssociationOverride.getJoinColumns().remove(1);
- joinColumns = ormAssociationOverride.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- xmlAssociationOverride.getJoinColumns().remove(1);
- joinColumns = ormAssociationOverride.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- xmlAssociationOverride.getJoinColumns().remove(0);
- assertFalse(ormAssociationOverride.specifiedJoinColumns().hasNext());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmAttributeOverrideTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmAttributeOverrideTests.java
deleted file mode 100644
index f511d12f58..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmAttributeOverrideTests.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmAttributeOverride;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmAttributeOverrideTests extends ContextModelTestCase
-{
- public OrmAttributeOverrideTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- XmlAttributeOverride attributeOverrideResource = entityResource.getAttributeOverrides().get(0);
- OrmAttributeOverride ormAttributeOverride = ormEntity.specifiedAttributeOverrides().next();
-
- assertNull(ormAttributeOverride.getName());
- assertNull(attributeOverrideResource.getName());
- assertTrue(ormEntity.attributeOverrides().hasNext());
- assertFalse(entityResource.getAttributeOverrides().isEmpty());
-
- //set name in the resource model, verify context model updated
- attributeOverrideResource.setName("FOO");
- assertEquals("FOO", ormAttributeOverride.getName());
- assertEquals("FOO", attributeOverrideResource.getName());
-
- //set name to null in the resource model
- attributeOverrideResource.setName(null);
- assertNull(ormAttributeOverride.getName());
- assertNull(attributeOverrideResource.getName());
-
- attributeOverrideResource.setName("FOO");
- assertEquals("FOO", ormAttributeOverride.getName());
- assertEquals("FOO", attributeOverrideResource.getName());
-
- entityResource.getAttributeOverrides().remove(0);
- assertFalse(ormEntity.attributeOverrides().hasNext());
- assertTrue(entityResource.getAttributeOverrides().isEmpty());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- XmlAttributeOverride attributeOverrideResource = entityResource.getAttributeOverrides().get(0);
- OrmAttributeOverride ormAttributeOverride = ormEntity.specifiedAttributeOverrides().next();
-
- assertNull(ormAttributeOverride.getName());
- assertNull(attributeOverrideResource.getName());
-
- //set name in the context model, verify resource model modified
- ormAttributeOverride.setName("foo");
- assertEquals("foo", ormAttributeOverride.getName());
- assertEquals("foo", attributeOverrideResource.getName());
-
- //set name to null in the context model
- ormAttributeOverride.setName(null);
- assertNull(ormAttributeOverride.getName());
- assertNull(entityResource.getAttributeOverrides().get(0).getName());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmBasicMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmBasicMappingTests.java
deleted file mode 100644
index 1db379656e..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmBasicMappingTests.java
+++ /dev/null
@@ -1,764 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.EnumType;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.TemporalType;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.core.context.orm.OrmColumn;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmBasicMappingTests extends ContextModelTestCase
-{
- public OrmBasicMappingTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createBasicAnnotation() throws Exception{
- this.createAnnotationAndMembers("Basic", "FetchType fetch() default EAGER; boolean optional() default true;");
- }
-
- private void createColumnAnnotation() throws Exception{
- this.createAnnotationAndMembers("Column",
- "String name() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";" +
- "int length() default 255;" +
- "int precision() default 0;" +
- "int scale() default 0;");
- }
-
- private void createLobAnnotation() throws Exception{
- this.createAnnotationAndMembers("Lob", "");
- }
-
- private void createEnumeratedAnnotation() throws Exception{
- this.createAnnotationAndMembers("Enumerated", "EnumType value() default ORDINAL;");
- }
-
- private void createTemporalAnnotation() throws Exception{
- this.createAnnotationAndMembers("Temporal", "TemporalType value();");
- }
-
- private IType createTestEntityBasicMapping() throws Exception {
- createEntityAnnotation();
- createBasicAnnotation();
- createColumnAnnotation();
- createLobAnnotation();
- createTemporalAnnotation();
- createEnumeratedAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, JPA.FETCH_TYPE, JPA.COLUMN, JPA.LOB, JPA.TEMPORAL, JPA.TEMPORAL_TYPE, JPA.ENUMERATED, JPA.ENUM_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic(fetch=FetchType.LAZY, optional=false)");
- sb.append(CR);
- sb.append(" @Column(name=\"MY_COLUMN\", unique=true, nullable=false, insertable=false, updatable=false, columnDefinition=\"COLUMN_DEFINITION\", table=\"MY_TABLE\", length=5, precision=6, scale=7)");
- sb.append(CR);
- sb.append(" @Lob");
- sb.append(CR);
- sb.append(" @Temporal(TemporalType.TIMESTAMP)");
- sb.append(CR);
- sb.append(" @Enumerated(EnumType.STRING)");
- }
- });
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertEquals("basicMapping", ormBasicMapping.getName());
- assertEquals("basicMapping", basicResource.getName());
-
- //set name in the resource model, verify context model updated
- basicResource.setName("newName");
- assertEquals("newName", ormBasicMapping.getName());
- assertEquals("newName", basicResource.getName());
-
- //set name to null in the resource model
- basicResource.setName(null);
- assertNull(ormBasicMapping.getName());
- assertNull(basicResource.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertEquals("basicMapping", ormBasicMapping.getName());
- assertEquals("basicMapping", basicResource.getName());
-
- //set name in the context model, verify resource model updated
- ormBasicMapping.setName("newName");
- assertEquals("newName", ormBasicMapping.getName());
- assertEquals("newName", basicResource.getName());
-
- //set name to null in the context model
- ormBasicMapping.setName(null);
- assertNull(ormBasicMapping.getName());
- assertNull(basicResource.getName());
- }
-
- public void testUpdateSpecifiedFetch() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertNull(ormBasicMapping.getSpecifiedFetch());
- assertNull(basicResource.getFetch());
-
- //set fetch in the resource model, verify context model updated
- basicResource.setFetch(org.eclipse.jpt.core.resource.orm.FetchType.EAGER);
- assertEquals(FetchType.EAGER, ormBasicMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.EAGER, basicResource.getFetch());
-
- basicResource.setFetch(org.eclipse.jpt.core.resource.orm.FetchType.LAZY);
- assertEquals(FetchType.LAZY, ormBasicMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.LAZY, basicResource.getFetch());
-
- //set fetch to null in the resource model
- basicResource.setFetch(null);
- assertNull(ormBasicMapping.getSpecifiedFetch());
- assertNull(basicResource.getFetch());
- }
-
- public void testModifySpecifiedFetch() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertNull(ormBasicMapping.getSpecifiedFetch());
- assertNull(basicResource.getFetch());
-
- //set fetch in the context model, verify resource model updated
- ormBasicMapping.setSpecifiedFetch(FetchType.EAGER);
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.EAGER, basicResource.getFetch());
- assertEquals(FetchType.EAGER, ormBasicMapping.getSpecifiedFetch());
-
- ormBasicMapping.setSpecifiedFetch(FetchType.LAZY);
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.LAZY, basicResource.getFetch());
- assertEquals(FetchType.LAZY, ormBasicMapping.getSpecifiedFetch());
-
- //set fetch to null in the context model
- ormBasicMapping.setSpecifiedFetch(null);
- assertNull(basicResource.getFetch());
- assertNull(ormBasicMapping.getSpecifiedFetch());
- }
-
- public void testUpdateSpecifiedEnumerated() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertNull(ormBasicMapping.getSpecifiedEnumerated());
- assertNull(basicResource.getEnumerated());
-
- //set enumerated in the resource model, verify context model updated
- basicResource.setEnumerated(org.eclipse.jpt.core.resource.orm.EnumType.ORDINAL);
- assertEquals(EnumType.ORDINAL, ormBasicMapping.getSpecifiedEnumerated());
- assertEquals(org.eclipse.jpt.core.resource.orm.EnumType.ORDINAL, basicResource.getEnumerated());
-
- basicResource.setEnumerated(org.eclipse.jpt.core.resource.orm.EnumType.STRING);
- assertEquals(EnumType.STRING, ormBasicMapping.getSpecifiedEnumerated());
- assertEquals(org.eclipse.jpt.core.resource.orm.EnumType.STRING, basicResource.getEnumerated());
-
- //set enumerated to null in the resource model
- basicResource.setEnumerated(null);
- assertNull(ormBasicMapping.getSpecifiedEnumerated());
- assertNull(basicResource.getEnumerated());
- }
-
- public void testModifySpecifiedEnumerated() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertNull(ormBasicMapping.getSpecifiedEnumerated());
- assertNull(basicResource.getEnumerated());
-
- //set enumerated in the context model, verify resource model updated
- ormBasicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- assertEquals(org.eclipse.jpt.core.resource.orm.EnumType.ORDINAL, basicResource.getEnumerated());
- assertEquals(EnumType.ORDINAL, ormBasicMapping.getSpecifiedEnumerated());
-
- ormBasicMapping.setSpecifiedEnumerated(EnumType.STRING);
- assertEquals(org.eclipse.jpt.core.resource.orm.EnumType.STRING, basicResource.getEnumerated());
- assertEquals(EnumType.STRING, ormBasicMapping.getSpecifiedEnumerated());
-
- //set enumerated to null in the context model
- ormBasicMapping.setSpecifiedEnumerated(null);
- assertNull(basicResource.getEnumerated());
- assertNull(ormBasicMapping.getSpecifiedEnumerated());
- }
-
- public void testUpdateSpecifiedOptional() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertNull(ormBasicMapping.getSpecifiedOptional());
- assertNull(basicResource.getOptional());
-
- //set enumerated in the resource model, verify context model updated
- basicResource.setOptional(Boolean.TRUE);
- assertEquals(Boolean.TRUE, ormBasicMapping.getSpecifiedOptional());
- assertEquals(Boolean.TRUE, basicResource.getOptional());
-
- basicResource.setOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormBasicMapping.getSpecifiedOptional());
- assertEquals(Boolean.FALSE, basicResource.getOptional());
-
- //set enumerated to null in the resource model
- basicResource.setOptional(null);
- assertNull(ormBasicMapping.getSpecifiedOptional());
- assertNull(basicResource.getOptional());
- }
-
- public void testModifySpecifiedOptional() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertNull(ormBasicMapping.getSpecifiedOptional());
- assertNull(basicResource.getOptional());
-
- //set enumerated in the context model, verify resource model updated
- ormBasicMapping.setSpecifiedOptional(Boolean.TRUE);
- assertEquals(Boolean.TRUE, basicResource.getOptional());
- assertEquals(Boolean.TRUE, ormBasicMapping.getSpecifiedOptional());
-
- ormBasicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, basicResource.getOptional());
- assertEquals(Boolean.FALSE, ormBasicMapping.getSpecifiedOptional());
-
- //set enumerated to null in the context model
- ormBasicMapping.setSpecifiedOptional(null);
- assertNull(basicResource.getOptional());
- assertNull(ormBasicMapping.getSpecifiedOptional());
- }
-
- public void testUpdateSpecifiedLob() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertFalse(ormBasicMapping.isLob());
- assertFalse(basicResource.isLob());
-
- //set lob in the resource model, verify context model updated
- basicResource.setLob(true);
- assertTrue(ormBasicMapping.isLob());
- assertTrue(basicResource.isLob());
-
- //set lob to null in the resource model
- basicResource.setLob(false);
- assertFalse(ormBasicMapping.isLob());
- assertFalse(basicResource.isLob());
- }
-
- public void testModifySpecifiedLob() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertFalse(ormBasicMapping.isLob());
- assertFalse(basicResource.isLob());
-
- //set lob in the context model, verify resource model updated
- ormBasicMapping.setLob(true);
- assertTrue(basicResource.isLob());
- assertTrue(ormBasicMapping.isLob());
-
- //set lob to false in the context model
- ormBasicMapping.setLob(false);
- assertFalse(basicResource.isLob());
- assertFalse(ormBasicMapping.isLob());
- }
-
- public void testUpdateTemporal() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertNull(ormBasicMapping.getTemporal());
- assertNull(basicResource.getTemporal());
-
- //set temporal in the resource model, verify context model updated
- basicResource.setTemporal(org.eclipse.jpt.core.resource.orm.TemporalType.DATE);
- assertEquals(TemporalType.DATE, ormBasicMapping.getTemporal());
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.DATE, basicResource.getTemporal());
-
- basicResource.setTemporal(org.eclipse.jpt.core.resource.orm.TemporalType.TIME);
- assertEquals(TemporalType.TIME, ormBasicMapping.getTemporal());
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.TIME, basicResource.getTemporal());
-
- basicResource.setTemporal(org.eclipse.jpt.core.resource.orm.TemporalType.TIMESTAMP);
- assertEquals(TemporalType.TIMESTAMP, ormBasicMapping.getTemporal());
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.TIMESTAMP, basicResource.getTemporal());
-
- //set temporal to null in the resource model
- basicResource.setTemporal(null);
- assertNull(ormBasicMapping.getTemporal());
- assertNull(basicResource.getTemporal());
- }
-
- public void testModifyTemporal() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertNull(ormBasicMapping.getTemporal());
- assertNull(basicResource.getTemporal());
-
- //set temporal in the context model, verify resource model updated
- ormBasicMapping.setTemporal(TemporalType.DATE);
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.DATE, basicResource.getTemporal());
- assertEquals(TemporalType.DATE, ormBasicMapping.getTemporal());
-
- ormBasicMapping.setTemporal(TemporalType.TIME);
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.TIME, basicResource.getTemporal());
- assertEquals(TemporalType.TIME, ormBasicMapping.getTemporal());
-
- ormBasicMapping.setTemporal(TemporalType.TIMESTAMP);
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.TIMESTAMP, basicResource.getTemporal());
- assertEquals(TemporalType.TIMESTAMP, ormBasicMapping.getTemporal());
-
- //set temporal to null in the context model
- ormBasicMapping.setTemporal(null);
- assertNull(basicResource.getTemporal());
- assertNull(ormBasicMapping.getTemporal());
- }
-
- //TODO test defaults
- //TODO test overriding java mapping with a different mapping type in xml
-
-
- public void testBasicMappingNoUnderylingJavaAttribute() throws Exception {
- createTestEntityBasicMapping();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "foo");
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("foo", ormBasicMapping.getName());
- assertNull(ormBasicMapping.getSpecifiedEnumerated());
- assertNull(ormBasicMapping.getSpecifiedFetch());
- assertNull(ormBasicMapping.getSpecifiedOptional());
- assertFalse(ormBasicMapping.isLob());
- assertEquals(EnumType.ORDINAL, ormBasicMapping.getEnumerated());
- assertEquals(FetchType.EAGER, ormBasicMapping.getFetch());
- assertEquals(Boolean.TRUE, ormBasicMapping.getOptional());
- assertNull(ormBasicMapping.getTemporal());
-
-
- OrmColumn ormColumn = ormBasicMapping.getColumn();
- assertNull(ormColumn.getSpecifiedName());
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(ormColumn.getColumnDefinition());
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(ormColumn.getSpecifiedPrecision());
- assertNull(ormColumn.getSpecifiedScale());
-
- assertEquals("foo", ormColumn.getDefaultName());
- assertEquals(Boolean.FALSE, ormColumn.getDefaultUnique());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultNullable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultUpdatable());
- assertEquals(null, ormColumn.getColumnDefinition());
- assertEquals(TYPE_NAME, ormColumn.getDefaultTable());
- assertEquals(Integer.valueOf(255), ormColumn.getDefaultLength());
- assertEquals(Integer.valueOf(0), ormColumn.getDefaultPrecision());
- assertEquals(Integer.valueOf(0), ormColumn.getDefaultScale());
- }
-
- //@Basic(fetch=FetchType.LAZY, optional=false)
- //@Column(name="MY_COLUMN", unique=true, nullable=false, insertable=false, updatable=false,
- // columnDefinition="COLUMN_DEFINITION", table="MY_TABLE", length=5, precision=6, scale=7)");
- //@Column(
- //@Lob
- //@Temporal(TemporalType.TIMESTAMP)
- //@Enumerated(EnumType.STRING)
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityBasicMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- assertEquals("id", ormBasicMapping.getName());
- assertTrue(ormBasicMapping.isLob());
- assertEquals(EnumType.STRING, ormBasicMapping.getSpecifiedEnumerated());
- assertEquals(FetchType.LAZY, ormBasicMapping.getSpecifiedFetch());
- assertEquals(Boolean.FALSE, ormBasicMapping.getSpecifiedOptional());
- assertEquals(TemporalType.TIMESTAMP, ormBasicMapping.getTemporal());
-
- OrmColumn ormColumn = ormBasicMapping.getColumn();
- assertEquals("MY_COLUMN", ormColumn.getSpecifiedName());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUnique());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUpdatable());
- assertEquals("COLUMN_DEFINITION", ormColumn.getColumnDefinition());
- assertEquals("MY_TABLE", ormColumn.getSpecifiedTable());
- assertEquals(Integer.valueOf(5), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(6), ormColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(7), ormColumn.getSpecifiedScale());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityBasicMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- assertEquals("id", ormBasicMapping.getName());
- assertFalse(ormBasicMapping.isLob());
- assertEquals(EnumType.ORDINAL, ormBasicMapping.getSpecifiedEnumerated());
- assertEquals(FetchType.EAGER, ormBasicMapping.getSpecifiedFetch());
- assertEquals(Boolean.TRUE, ormBasicMapping.getSpecifiedOptional());
- assertNull(ormBasicMapping.getTemporal());
-
- OrmColumn ormColumn = ormBasicMapping.getColumn();
- assertEquals("id", ormColumn.getSpecifiedName());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUnique());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUpdatable());
- assertNull(ormColumn.getColumnDefinition());
- assertEquals(TYPE_NAME, ormColumn.getSpecifiedTable());
- assertEquals(Integer.valueOf(255), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(0), ormColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(0), ormColumn.getSpecifiedScale());
- }
-
- public void testSpecifiedMapping() throws Exception {
- createTestEntityBasicMapping();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- assertEquals(1, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("id", ormBasicMapping.getName());
- assertNull(ormBasicMapping.getSpecifiedEnumerated());
- assertNull(ormBasicMapping.getSpecifiedFetch());
- assertNull(ormBasicMapping.getSpecifiedOptional());
- assertFalse(ormBasicMapping.isLob());
- assertEquals(EnumType.ORDINAL, ormBasicMapping.getDefaultEnumerated());
- assertEquals(FetchType.EAGER, ormBasicMapping.getDefaultFetch());
- assertEquals(Boolean.TRUE, ormBasicMapping.getDefaultOptional());
- assertNull(ormBasicMapping.getTemporal());
-
- OrmColumn ormColumn = ormBasicMapping.getColumn();
- assertNull(ormColumn.getSpecifiedName());
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(ormColumn.getColumnDefinition());
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(ormColumn.getSpecifiedPrecision());
- assertNull(ormColumn.getSpecifiedScale());
-
- assertEquals("id", ormColumn.getDefaultName());
- assertEquals(Boolean.FALSE, ormColumn.getDefaultUnique());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultNullable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultUpdatable());
- assertEquals(null, ormColumn.getColumnDefinition());
- assertEquals(TYPE_NAME, ormColumn.getDefaultTable());
- assertEquals(Integer.valueOf(255), ormColumn.getDefaultLength());
- assertEquals(Integer.valueOf(0), ormColumn.getDefaultPrecision());
- assertEquals(Integer.valueOf(0), ormColumn.getDefaultScale());
-
- }
- //3 things tested above
- //1. virtual mapping metadata complete=false - defaults are taken from the java annotations
- //2. virtual mapping metadata complete=true - defaults are taken from java defaults,annotations ignored
- //3. specified mapping (metadata complete=true/false - defaults are taken from java annotations
-
-
- public void testBasicMorphToIdMapping() throws Exception {
- createTestEntityBasicMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic");
-
- BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setLob(true);
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping);
- assertEquals("basic", ormPersistentAttribute.getMapping().getName());
- assertEquals(TemporalType.TIME, ((IdMapping) ormPersistentAttribute.getMapping()).getTemporal());
- assertEquals("FOO", ((IdMapping) ormPersistentAttribute.getMapping()).getColumn().getSpecifiedName());
- }
-
- public void testBasicMorphToVersionMapping() throws Exception {
- createTestEntityBasicMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic");
-
- BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setLob(true);
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping);
- assertEquals("basic", ormPersistentAttribute.getMapping().getName());
- assertEquals(TemporalType.TIME, ((VersionMapping) ormPersistentAttribute.getMapping()).getTemporal());
- assertEquals("FOO", ((VersionMapping) ormPersistentAttribute.getMapping()).getColumn().getSpecifiedName());
- }
-
- public void testBasicMorphToTransientMapping() throws Exception {
- createTestEntityBasicMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic");
-
- BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setLob(true);
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping);
- assertEquals("basic", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testBasicMorphToEmbeddedMapping() throws Exception {
- createTestEntityBasicMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic");
-
- BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setLob(true);
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertEquals("basic", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testBasicMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityBasicMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic");
-
- BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setLob(true);
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertEquals("basic", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testBasicMorphToOneToOneMapping() throws Exception {
- createTestEntityBasicMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic");
-
- BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setLob(true);
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping);
- assertEquals("basic", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testBasicMorphToOneToManyMapping() throws Exception {
- createTestEntityBasicMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic");
-
- BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setLob(true);
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping);
- assertEquals("basic", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testBasicMorphToManyToOneMapping() throws Exception {
- createTestEntityBasicMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic");
-
- BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setLob(true);
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertEquals("basic", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testBasicMorphToManyToManyMapping() throws Exception {
- createTestEntityBasicMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic");
-
- BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping();
- assertFalse(basicMapping.isDefault());
- basicMapping.getColumn().setSpecifiedName("FOO");
- basicMapping.setLob(true);
- basicMapping.setTemporal(TemporalType.TIME);
- basicMapping.setSpecifiedEnumerated(EnumType.ORDINAL);
- basicMapping.setSpecifiedFetch(FetchType.EAGER);
- basicMapping.setSpecifiedOptional(Boolean.FALSE);
- assertFalse(basicMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertEquals("basic", ormPersistentAttribute.getMapping().getName());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmCascadeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmCascadeTests.java
deleted file mode 100644
index 88a74c4dd0..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmCascadeTests.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.Cascade;
-import org.eclipse.jpt.core.context.orm.OrmOneToOneMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlOneToOne;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmCascadeTests extends ContextModelTestCase
-{
- public OrmCascadeTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testUpdateCascadeAll() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
- Cascade cascade = ormOneToOneMapping.getCascade();
-
- assertEquals(false, cascade.isAll());
- assertNull(oneToOne.getCascade());
-
- //set cascade in the resource model, verify context model does not change
- oneToOne.setCascade(OrmFactory.eINSTANCE.createCascadeTypeImpl());
- assertEquals(false, cascade.isAll());
- assertNotNull(oneToOne.getCascade());
-
- //set all in the resource model, verify context model updated
- oneToOne.getCascade().setCascadeAll(true);
- assertEquals(true, cascade.isAll());
- assertEquals(true, oneToOne.getCascade().isCascadeAll());
-
- //set all to false in the resource model
- oneToOne.getCascade().setCascadeAll(false);
- assertEquals(false, cascade.isAll());
- assertEquals(false, oneToOne.getCascade().isCascadeAll());
- }
-
- public void testModifyCascadeAll() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- Cascade cascade = ormOneToOneMapping.getCascade();
-
- assertEquals(false, cascade.isAll());
- assertNull(oneToOne.getCascade());
-
- //set all in the context model, verify resource model updated
- cascade.setAll(true);
- assertEquals(true, cascade.isAll());
- assertEquals(true, oneToOne.getCascade().isCascadeAll());
-
- //set all to false in the context model
- cascade.setAll(false);
- assertEquals(false, cascade.isAll());
- assertNull(oneToOne.getCascade());
- }
-
- public void testUpdateCascadePersist() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
- Cascade cascade = ormOneToOneMapping.getCascade();
-
- assertEquals(false, cascade.isPersist());
- assertNull(oneToOne.getCascade());
-
- //set cascade in the resource model, verify context model does not change
- oneToOne.setCascade(OrmFactory.eINSTANCE.createCascadeTypeImpl());
- assertEquals(false, cascade.isPersist());
- assertNotNull(oneToOne.getCascade());
-
- //set Persist in the resource model, verify context model updated
- oneToOne.getCascade().setCascadePersist(true);
- assertEquals(true, cascade.isPersist());
- assertEquals(true, oneToOne.getCascade().isCascadePersist());
-
- //set Persist to false in the resource model
- oneToOne.getCascade().setCascadePersist(false);
- assertEquals(false, cascade.isPersist());
- assertEquals(false, oneToOne.getCascade().isCascadePersist());
- }
-
- public void testModifyCascadePersist() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- Cascade cascade = ormOneToOneMapping.getCascade();
-
- assertEquals(false, cascade.isPersist());
- assertNull(oneToOne.getCascade());
-
- //set Persist in the context model, verify resource model updated
- cascade.setPersist(true);
- assertEquals(true, cascade.isPersist());
- assertEquals(true, oneToOne.getCascade().isCascadePersist());
-
- //set Persist to false in the context model
- cascade.setPersist(false);
- assertEquals(false, cascade.isPersist());
- assertNull(oneToOne.getCascade());
- }
-
- public void testUpdateCascadeMerge() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
- Cascade cascade = ormOneToOneMapping.getCascade();
-
- assertEquals(false, cascade.isMerge());
- assertNull(oneToOne.getCascade());
-
- //set cascade in the resource model, verify context model does not change
- oneToOne.setCascade(OrmFactory.eINSTANCE.createCascadeTypeImpl());
- assertEquals(false, cascade.isMerge());
- assertNotNull(oneToOne.getCascade());
-
- //set Merge in the resource model, verify context model updated
- oneToOne.getCascade().setCascadeMerge(true);
- assertEquals(true, cascade.isMerge());
- assertEquals(true, oneToOne.getCascade().isCascadeMerge());
-
- //set Merge to false in the resource model
- oneToOne.getCascade().setCascadeMerge(false);
- assertEquals(false, cascade.isMerge());
- assertEquals(false, oneToOne.getCascade().isCascadeMerge());
- }
-
- public void testModifyCascadeMerge() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- Cascade cascade = ormOneToOneMapping.getCascade();
-
- assertEquals(false, cascade.isMerge());
- assertNull(oneToOne.getCascade());
-
- //set Merge in the context model, verify resource model updated
- cascade.setMerge(true);
- assertEquals(true, cascade.isMerge());
- assertEquals(true, oneToOne.getCascade().isCascadeMerge());
-
- //set Merge to false in the context model
- cascade.setMerge(false);
- assertEquals(false, cascade.isMerge());
- assertNull(oneToOne.getCascade());
- }
-
- public void testUpdateCascadeRemove() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
- Cascade cascade = ormOneToOneMapping.getCascade();
-
- assertEquals(false, cascade.isRemove());
- assertNull(oneToOne.getCascade());
-
- //set cascade in the resource model, verify context model does not change
- oneToOne.setCascade(OrmFactory.eINSTANCE.createCascadeTypeImpl());
- assertEquals(false, cascade.isRemove());
- assertNotNull(oneToOne.getCascade());
-
- //set Remove in the resource model, verify context model updated
- oneToOne.getCascade().setCascadeRemove(true);
- assertEquals(true, cascade.isRemove());
- assertEquals(true, oneToOne.getCascade().isCascadeRemove());
-
- //set Remove to false in the resource model
- oneToOne.getCascade().setCascadeRemove(false);
- assertEquals(false, cascade.isRemove());
- assertEquals(false, oneToOne.getCascade().isCascadeRemove());
- }
-
- public void testModifyCascadeRemove() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- Cascade cascade = ormOneToOneMapping.getCascade();
-
- assertEquals(false, cascade.isRemove());
- assertNull(oneToOne.getCascade());
-
- //set Remove in the context model, verify resource model updated
- cascade.setRemove(true);
- assertEquals(true, cascade.isRemove());
- assertEquals(true, oneToOne.getCascade().isCascadeRemove());
-
- //set Remove to false in the context model
- cascade.setRemove(false);
- assertEquals(false, cascade.isRemove());
- assertNull(oneToOne.getCascade());
- }
-
- public void testUpdateCascadeRefresh() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
- Cascade cascade = ormOneToOneMapping.getCascade();
-
- assertEquals(false, cascade.isRefresh());
- assertNull(oneToOne.getCascade());
-
- //set cascade in the resource model, verify context model does not change
- oneToOne.setCascade(OrmFactory.eINSTANCE.createCascadeTypeImpl());
- assertEquals(false, cascade.isRefresh());
- assertNotNull(oneToOne.getCascade());
-
- //set Refresh in the resource model, verify context model updated
- oneToOne.getCascade().setCascadeRefresh(true);
- assertEquals(true, cascade.isRefresh());
- assertEquals(true, oneToOne.getCascade().isCascadeRefresh());
-
- //set Refresh to false in the resource model
- oneToOne.getCascade().setCascadeRefresh(false);
- assertEquals(false, cascade.isRefresh());
- assertEquals(false, oneToOne.getCascade().isCascadeRefresh());
- }
-
- public void testModifyCascadeRefresh() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- Cascade cascade = ormOneToOneMapping.getCascade();
-
- assertEquals(false, cascade.isRefresh());
- assertNull(oneToOne.getCascade());
-
- //set Refresh in the context model, verify resource model updated
- cascade.setRefresh(true);
- assertEquals(true, cascade.isRefresh());
- assertEquals(true, oneToOne.getCascade().isCascadeRefresh());
-
- //set Refresh to false in the context model
- cascade.setRefresh(false);
- assertEquals(false, cascade.isRefresh());
- assertNull(oneToOne.getCascade());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmColumnTests.java
deleted file mode 100644
index 7b027f4d2b..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmColumnTests.java
+++ /dev/null
@@ -1,850 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.core.context.orm.OrmColumn;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmColumnTests extends ContextModelTestCase
-{
- public OrmColumnTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- public void testUpdateSpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedName());
- assertNull(basic.getColumn());
-
- //set name in the resource model, verify context model updated
- basic.setColumn(OrmFactory.eINSTANCE.createXmlColumnImpl());
- basic.getColumn().setName("FOO");
- ormResource().save(null);
- assertEquals("FOO", ormColumn.getSpecifiedName());
- assertEquals("FOO", basic.getColumn().getName());
-
- //set name to null in the resource model
- basic.getColumn().setName(null);
- assertNull(ormColumn.getSpecifiedName());
- assertNull(basic.getColumn().getName());
-
- basic.getColumn().setName("FOO");
- assertEquals("FOO", ormColumn.getSpecifiedName());
- assertEquals("FOO", basic.getColumn().getName());
-
- basic.setColumn(null);
- assertNull(ormColumn.getSpecifiedName());
- assertNull(basic.getColumn());
- }
-
- public void testModifySpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedName());
- assertNull(basic.getColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setSpecifiedName("foo");
- assertEquals("foo", ormColumn.getSpecifiedName());
- assertEquals("foo", basic.getColumn().getName());
-
- //set name to null in the context model
- ormColumn.setSpecifiedName(null);
- assertNull(ormColumn.getSpecifiedName());
- assertNull(basic.getColumn());
- }
-
- public void testUpdateColumnDefinition() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getColumnDefinition());
- assertNull(basic.getColumn());
-
- //set name in the resource model, verify context model updated
- basic.setColumn(OrmFactory.eINSTANCE.createXmlColumnImpl());
- basic.getColumn().setColumnDefinition("FOO");
- assertEquals("FOO", ormColumn.getColumnDefinition());
- assertEquals("FOO", basic.getColumn().getColumnDefinition());
-
- //set name to null in the resource model
- basic.getColumn().setColumnDefinition(null);
- assertNull(ormColumn.getColumnDefinition());
- assertNull(basic.getColumn().getColumnDefinition());
-
- basic.getColumn().setColumnDefinition("FOO");
- assertEquals("FOO", ormColumn.getColumnDefinition());
- assertEquals("FOO", basic.getColumn().getColumnDefinition());
-
- basic.setColumn(null);
- assertNull(ormColumn.getColumnDefinition());
- assertNull(basic.getColumn());
- }
-
- public void testModifyColumnDefinition() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getColumnDefinition());
- assertNull(basic.getColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setColumnDefinition("foo");
- assertEquals("foo", ormColumn.getColumnDefinition());
- assertEquals("foo", basic.getColumn().getColumnDefinition());
-
- //set name to null in the context model
- ormColumn.setColumnDefinition(null);
- assertNull(ormColumn.getColumnDefinition());
- assertNull(basic.getColumn());
- }
-
- public void testUpdateSpecifiedTable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(basic.getColumn());
-
- //set name in the resource model, verify context model updated
- basic.setColumn(OrmFactory.eINSTANCE.createXmlColumnImpl());
- basic.getColumn().setTable("FOO");
- assertEquals("FOO", ormColumn.getSpecifiedTable());
- assertEquals("FOO", basic.getColumn().getTable());
-
- //set name to null in the resource model
- basic.getColumn().setTable(null);
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(basic.getColumn().getTable());
-
- basic.getColumn().setTable("FOO");
- assertEquals("FOO", ormColumn.getSpecifiedTable());
- assertEquals("FOO", basic.getColumn().getTable());
-
- basic.setColumn(null);
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(basic.getColumn());
- }
-
- public void testModifySpecifiedTable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(basic.getColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setSpecifiedTable("foo");
- assertEquals("foo", ormColumn.getSpecifiedTable());
- assertEquals("foo", basic.getColumn().getTable());
-
- //set name to null in the context model
- ormColumn.setSpecifiedTable(null);
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(basic.getColumn());
- }
-
- public void testUpdateSpecifiedNullable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(basic.getColumn());
-
- //set name in the resource model, verify context model updated
- basic.setColumn(OrmFactory.eINSTANCE.createXmlColumnImpl());
- basic.getColumn().setNullable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.TRUE, basic.getColumn().getNullable());
-
- //set name to null in the resource model
- basic.getColumn().setNullable(null);
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(basic.getColumn().getNullable());
-
- basic.getColumn().setNullable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, basic.getColumn().getNullable());
-
- basic.setColumn(null);
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(basic.getColumn());
- }
-
- public void testModifySpecifiedNullable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(basic.getColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setSpecifiedNullable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, basic.getColumn().getNullable());
-
- //set name to null in the context model
- ormColumn.setSpecifiedNullable(null);
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(basic.getColumn());
- }
-
- public void testUpdateSpecifiedUpdatable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(basic.getColumn());
-
- //set name in the resource model, verify context model updated
- basic.setColumn(OrmFactory.eINSTANCE.createXmlColumnImpl());
- basic.getColumn().setUpdatable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.TRUE, basic.getColumn().getUpdatable());
-
- //set name to null in the resource model
- basic.getColumn().setUpdatable(null);
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(basic.getColumn().getUpdatable());
-
- basic.getColumn().setUpdatable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.FALSE, basic.getColumn().getUpdatable());
-
- basic.setColumn(null);
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(basic.getColumn());
- }
-
- public void testModifySpecifiedUpdatable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(basic.getColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setSpecifiedUpdatable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.FALSE, basic.getColumn().getUpdatable());
-
- //set name to null in the context model
- ormColumn.setSpecifiedUpdatable(null);
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(basic.getColumn());
- }
-
- public void testUpdateSpecifiedInsertable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(basic.getColumn());
-
- //set name in the resource model, verify context model updated
- basic.setColumn(OrmFactory.eINSTANCE.createXmlColumnImpl());
- basic.getColumn().setInsertable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.TRUE, basic.getColumn().getInsertable());
-
- //set name to null in the resource model
- basic.getColumn().setInsertable(null);
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(basic.getColumn().getInsertable());
-
- basic.getColumn().setInsertable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, basic.getColumn().getInsertable());
-
- basic.setColumn(null);
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(basic.getColumn());
- }
-
- public void testModifySpecifiedInsertable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(basic.getColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setSpecifiedInsertable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, basic.getColumn().getInsertable());
-
- //set name to null in the context model
- ormColumn.setSpecifiedInsertable(null);
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(basic.getColumn());
- }
-
- public void testUpdateSpecifiedUnique() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(basic.getColumn());
-
- //set name in the resource model, verify context model updated
- basic.setColumn(OrmFactory.eINSTANCE.createXmlColumnImpl());
- basic.getColumn().setUnique(Boolean.TRUE);
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUnique());
- assertEquals(Boolean.TRUE, basic.getColumn().getUnique());
-
- //set name to null in the resource model
- basic.getColumn().setUnique(null);
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(basic.getColumn().getUnique());
-
- basic.getColumn().setUnique(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUnique());
- assertEquals(Boolean.FALSE, basic.getColumn().getUnique());
-
- basic.setColumn(null);
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(basic.getColumn());
- }
-
- public void testModifySpecifiedUnique() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(basic.getColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setSpecifiedUnique(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUnique());
- assertEquals(Boolean.FALSE, basic.getColumn().getUnique());
-
- //set name to null in the context model
- ormColumn.setSpecifiedUnique(null);
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(basic.getColumn());
- }
-
- public void testUpdateSpecifiedLength() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn());
-
- //set name in the resource model, verify context model updated
- basic.setColumn(OrmFactory.eINSTANCE.createXmlColumnImpl());
- basic.getColumn().setLength(Integer.valueOf(8));
- assertEquals(Integer.valueOf(8), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(8), basic.getColumn().getLength());
-
- //set name to null in the resource model
- basic.getColumn().setLength(null);
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn().getLength());
-
- basic.getColumn().setLength(Integer.valueOf(11));
- assertEquals(Integer.valueOf(11), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(11), basic.getColumn().getLength());
-
- basic.setColumn(null);
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn());
- }
-
- public void testModifySpecifiedLength() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setSpecifiedLength(Integer.valueOf(7));
- assertEquals(Integer.valueOf(7), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(7), basic.getColumn().getLength());
-
- //set name to null in the context model
- ormColumn.setSpecifiedLength(null);
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn());
- }
-
- public void testUpdateSpecifiedPrecision() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn());
-
- //set name in the resource model, verify context model updated
- basic.setColumn(OrmFactory.eINSTANCE.createXmlColumnImpl());
- basic.getColumn().setPrecision(Integer.valueOf(8));
- assertEquals(Integer.valueOf(8), ormColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(8), basic.getColumn().getPrecision());
-
- //set name to null in the resource model
- basic.getColumn().setPrecision(null);
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn().getPrecision());
-
- basic.getColumn().setPrecision(Integer.valueOf(11));
- assertEquals(Integer.valueOf(11), ormColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(11), basic.getColumn().getPrecision());
-
- basic.setColumn(null);
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn());
- }
-
- public void testModifySpecifiedPrecision() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setSpecifiedPrecision(Integer.valueOf(7));
- assertEquals(Integer.valueOf(7), ormColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(7), basic.getColumn().getPrecision());
-
- //set name to null in the context model
- ormColumn.setSpecifiedPrecision(null);
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn());
- }
-
- public void testUpdateSpecifiedScale() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn());
-
- //set name in the resource model, verify context model updated
- basic.setColumn(OrmFactory.eINSTANCE.createXmlColumnImpl());
- basic.getColumn().setScale(Integer.valueOf(8));
- assertEquals(Integer.valueOf(8), ormColumn.getSpecifiedScale());
- assertEquals(Integer.valueOf(8), basic.getColumn().getScale());
-
- //set name to null in the resource model
- basic.getColumn().setScale(null);
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn().getScale());
-
- basic.getColumn().setScale(Integer.valueOf(11));
- assertEquals(Integer.valueOf(11), ormColumn.getSpecifiedScale());
- assertEquals(Integer.valueOf(11), basic.getColumn().getScale());
-
- basic.setColumn(null);
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn());
- }
-
- public void testModifySpecifiedScale() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- OrmColumn ormColumn = ormBasicMapping.getColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entityResource.getAttributes().getBasics().get(0);
-
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setSpecifiedScale(Integer.valueOf(7));
- assertEquals(Integer.valueOf(7), ormColumn.getSpecifiedScale());
- assertEquals(Integer.valueOf(7), basic.getColumn().getScale());
-
- //set name to null in the context model
- ormColumn.setSpecifiedScale(null);
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(basic.getColumn());
- }
-
- public void testVirtualColumnDefaults() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ListIterator<OrmPersistentAttribute> attributes = ormPersistentType.virtualAttributes();
- attributes.next();
-
- //virtual attrubte in orm.xml, java attribute has no Column annotation
- OrmPersistentAttribute namePersistentAttribute = attributes.next();
- OrmBasicMapping nameVirtualMapping = (OrmBasicMapping) namePersistentAttribute.getMapping();
- OrmColumn ormColumn = nameVirtualMapping.getColumn();
- assertEquals("name", ormColumn.getSpecifiedName());
- assertEquals(TYPE_NAME, ormColumn.getSpecifiedTable());
- assertEquals(null, ormColumn.getColumnDefinition());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUnique());
- assertEquals(Column.DEFAULT_LENGTH, ormColumn.getSpecifiedLength());
- assertEquals(Column.DEFAULT_PRECISION, ormColumn.getSpecifiedPrecision());
- assertEquals(Column.DEFAULT_SCALE, ormColumn.getSpecifiedScale());
-
- //set Column annotation in Java
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("name").getMapping();
- javaBasicMapping.getColumn().setSpecifiedName("FOO");
- javaBasicMapping.getColumn().setSpecifiedTable("FOO_TABLE");
- javaBasicMapping.getColumn().setColumnDefinition("COLUMN_DEFINITION");
- javaBasicMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
- javaBasicMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
- javaBasicMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
- javaBasicMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- javaBasicMapping.getColumn().setSpecifiedLength(new Integer(45));
- javaBasicMapping.getColumn().setSpecifiedPrecision(new Integer(46));
- javaBasicMapping.getColumn().setSpecifiedScale(new Integer(47));
-
- assertEquals("FOO", ormColumn.getSpecifiedName());
- assertEquals("FOO_TABLE", ormColumn.getSpecifiedTable());
- assertEquals("COLUMN_DEFINITION", ormColumn.getColumnDefinition());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUnique());
- assertEquals(Integer.valueOf(45), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(46), ormColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(47), ormColumn.getSpecifiedScale());
-
-
- //set metadata-complete, orm.xml virtual column ignores java column annotation
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals("name", ormColumn.getSpecifiedName());
- assertEquals(TYPE_NAME, ormColumn.getSpecifiedTable());
- assertEquals(null, ormColumn.getColumnDefinition());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUnique());
- assertEquals(Column.DEFAULT_LENGTH, ormColumn.getSpecifiedLength());
- assertEquals(Column.DEFAULT_PRECISION, ormColumn.getSpecifiedPrecision());
- assertEquals(Column.DEFAULT_SCALE, ormColumn.getSpecifiedScale());
-
- ormPersistentType.getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.FALSE);
- assertEquals("name", ormColumn.getSpecifiedName());
- assertEquals(TYPE_NAME, ormColumn.getSpecifiedTable());
- assertEquals(null, ormColumn.getColumnDefinition());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUnique());
- assertEquals(Column.DEFAULT_LENGTH, ormColumn.getSpecifiedLength());
- assertEquals(Column.DEFAULT_PRECISION, ormColumn.getSpecifiedPrecision());
- assertEquals(Column.DEFAULT_SCALE, ormColumn.getSpecifiedScale());
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(null);
- assertEquals("name", ormColumn.getSpecifiedName());
- assertEquals(TYPE_NAME, ormColumn.getSpecifiedTable());
- assertEquals(null, ormColumn.getColumnDefinition());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUnique());
- assertEquals(Column.DEFAULT_LENGTH, ormColumn.getSpecifiedLength());
- assertEquals(Column.DEFAULT_PRECISION, ormColumn.getSpecifiedPrecision());
- assertEquals(Column.DEFAULT_SCALE, ormColumn.getSpecifiedScale());
-
- //set metadata-complete false, orm.xml virtual column gets setting from java annotation
- ormPersistentType.getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertEquals("FOO", ormColumn.getSpecifiedName());
- assertEquals("FOO_TABLE", ormColumn.getSpecifiedTable());
- assertEquals("COLUMN_DEFINITION", ormColumn.getColumnDefinition());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUnique());
- assertEquals(Integer.valueOf(45), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(46), ormColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(47), ormColumn.getSpecifiedScale());
- }
-
- public void testNullColumnDefaults() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute namePersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "name");
-
- OrmBasicMapping nameVirtualMapping = (OrmBasicMapping) namePersistentAttribute.getMapping();
- OrmColumn ormColumn = nameVirtualMapping.getColumn();
-
- //set Column annotation in Java
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("name").getMapping();
- javaBasicMapping.getColumn().setSpecifiedName("FOO");
- javaBasicMapping.getColumn().setSpecifiedTable("FOO_TABLE");
- javaBasicMapping.getColumn().setColumnDefinition("COLUMN_DEFINITION");
- javaBasicMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
- javaBasicMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
- javaBasicMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
- javaBasicMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- javaBasicMapping.getColumn().setSpecifiedLength(new Integer(45));
- javaBasicMapping.getColumn().setSpecifiedPrecision(new Integer(46));
- javaBasicMapping.getColumn().setSpecifiedScale(new Integer(47));
-
-
- assertEquals("name", ormColumn.getDefaultName());
- assertEquals(TYPE_NAME, ormColumn.getDefaultTable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultUpdatable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultNullable());
- assertEquals(Boolean.FALSE, ormColumn.getDefaultUnique());
- assertEquals(Column.DEFAULT_LENGTH, ormColumn.getDefaultLength());
- assertEquals(Column.DEFAULT_PRECISION, ormColumn.getDefaultPrecision());
- assertEquals(Column.DEFAULT_SCALE, ormColumn.getDefaultScale());
- assertNull(ormColumn.getSpecifiedName());
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(ormColumn.getColumnDefinition());
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(ormColumn.getSpecifiedPrecision());
- assertNull(ormColumn.getSpecifiedScale());
- }
-
- public void testVirtualColumnTable() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ListIterator<OrmPersistentAttribute> attributes = ormPersistentType.virtualAttributes();
- attributes.next();
-
- //virtual attribute in orm.xml, java attribute has no Column annotation
- OrmPersistentAttribute namePersistentAttribute = attributes.next();
- OrmBasicMapping nameVirtualMapping = (OrmBasicMapping) namePersistentAttribute.getMapping();
- OrmColumn ormColumn = nameVirtualMapping.getColumn();
-
- assertEquals(TYPE_NAME, ormColumn.getSpecifiedTable());
-
- ((OrmEntity) ormPersistentType.getMapping()).getTable().setSpecifiedName("ORM_TABLE");
- assertEquals("ORM_TABLE", ormColumn.getSpecifiedTable());
-
- //set Column table element in Java
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("name").getMapping();
- javaBasicMapping.getColumn().setSpecifiedTable("JAVA_TABLE");
- assertEquals("JAVA_TABLE", ormColumn.getSpecifiedTable());
-
- //make name persistent attribute not virtual
- namePersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "name");
- nameVirtualMapping = (OrmBasicMapping) namePersistentAttribute.getMapping();
- ormColumn = nameVirtualMapping.getColumn();
- assertNull(ormColumn.getSpecifiedTable());
- assertEquals("ORM_TABLE", ormColumn.getDefaultTable());
-
- }
-
-//public void testUpdateDefaultNameNoJava() throws Exception {
-// createTestEntity();
-//
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlEntity xmlEntity = (XmlEntity) ormPersistentType.getMapping();
-// assertEquals("Foo", xmlEntity.getTable().getDefaultName());
-//}
-//
-//public void testUpdateDefaultNameFromParent() throws Exception {
-// createTestEntity();
-// createTestSubType();
-//
-// OrmPersistentType parentOrmPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// OrmPersistentType childOrmPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
-// XmlEntity parentXmlEntity = (XmlEntity) parentOrmPersistentType.getMapping();
-// XmlEntity childXmlEntity = (XmlEntity) childOrmPersistentType.getMapping();
-//
-// assertEquals(TYPE_NAME, parentXmlEntity.getTable().getDefaultName());
-// assertEquals(TYPE_NAME, childXmlEntity.getTable().getDefaultName());
-//
-// parentXmlEntity.getTable().setSpecifiedName("FOO");
-// assertEquals(TYPE_NAME, parentXmlEntity.getTable().getDefaultName());
-// assertEquals("FOO", childXmlEntity.getTable().getDefaultName());
-//
-// parentXmlEntity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
-// assertEquals(TYPE_NAME, parentXmlEntity.getTable().getDefaultName());
-// assertEquals("AnnotationTestTypeChild", childXmlEntity.getTable().getDefaultName());
-//}
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmDiscriminatorColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmDiscriminatorColumnTests.java
deleted file mode 100644
index 72b36218b1..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmDiscriminatorColumnTests.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.DiscriminatorType;
-import org.eclipse.jpt.core.context.orm.OrmDiscriminatorColumn;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmDiscriminatorColumnTests extends ContextModelTestCase
-{
- public OrmDiscriminatorColumnTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- public void testUpdateSpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmDiscriminatorColumn ormColumn = ormEntity.getDiscriminatorColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormColumn.getSpecifiedName());
- assertNull(entityResource.getDiscriminatorColumn());
-
- //set name in the resource model, verify context model updated
- entityResource.setDiscriminatorColumn(OrmFactory.eINSTANCE.createXmlDiscriminatorColumn());
- entityResource.getDiscriminatorColumn().setName("FOO");
- assertEquals("FOO", ormColumn.getSpecifiedName());
- assertEquals("FOO", entityResource.getDiscriminatorColumn().getName());
-
- //set name to null in the resource model
- entityResource.getDiscriminatorColumn().setName(null);
- assertNull(ormColumn.getSpecifiedName());
- assertNull(entityResource.getDiscriminatorColumn().getName());
-
- entityResource.getDiscriminatorColumn().setName("FOO");
- assertEquals("FOO", ormColumn.getSpecifiedName());
- assertEquals("FOO", entityResource.getDiscriminatorColumn().getName());
-
- entityResource.setDiscriminatorColumn(null);
- assertNull(ormColumn.getSpecifiedName());
- assertNull(entityResource.getDiscriminatorColumn());
- }
-
- public void testModifySpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmDiscriminatorColumn ormColumn = ormEntity.getDiscriminatorColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormColumn.getSpecifiedName());
- assertNull(entityResource.getDiscriminatorColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setSpecifiedName("foo");
- assertEquals("foo", ormColumn.getSpecifiedName());
- assertEquals("foo", entityResource.getDiscriminatorColumn().getName());
-
- //set name to null in the context model
- ormColumn.setSpecifiedName(null);
- assertNull(ormColumn.getSpecifiedName());
- assertNull(entityResource.getDiscriminatorColumn());
- }
-
-// public void testUpdateDefaultNameFromJavaTable() throws Exception {
-// createTestEntity();
-//
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// XmlEntity ormEntity = (XmlEntity) ormPersistentType.getMapping();
-// assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-//
-// ormEntity.javaEntity().getTable().setSpecifiedName("Foo");
-// assertEquals("Foo", ormEntity.getTable().getDefaultName());
-//
-// ormEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-// assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-//
-// ormEntity.entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
-// ormEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
-// assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-//
-// ormEntity.setSpecifiedMetadataComplete(null);
-// assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-//
-// ormEntity.entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
-// assertEquals("Foo", ormEntity.getTable().getDefaultName());
-//
-// ormEntity.getTable().setSpecifiedName("Bar");
-// assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-// }
-//
-// public void testUpdateDefaultNameNoJava() throws Exception {
-// createTestEntity();
-//
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlEntity ormEntity = (XmlEntity) ormPersistentType.getMapping();
-// assertEquals("Foo", ormEntity.getTable().getDefaultName());
-// }
-//
-// public void testUpdateDefaultNameFromParent() throws Exception {
-// createTestEntity();
-// createTestSubType();
-//
-// OrmPersistentType parentOrmPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// OrmPersistentType childOrmPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
-// XmlEntity parentXmlEntity = (XmlEntity) parentOrmPersistentType.getMapping();
-// XmlEntity childXmlEntity = (XmlEntity) childOrmPersistentType.getMapping();
-//
-// assertEquals(TYPE_NAME, parentXmlEntity.getTable().getDefaultName());
-// assertEquals(TYPE_NAME, childXmlEntity.getTable().getDefaultName());
-//
-// parentXmlEntity.getTable().setSpecifiedName("FOO");
-// assertEquals(TYPE_NAME, parentXmlEntity.getTable().getDefaultName());
-// assertEquals("FOO", childXmlEntity.getTable().getDefaultName());
-//
-// parentXmlEntity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
-// assertEquals(TYPE_NAME, parentXmlEntity.getTable().getDefaultName());
-// assertEquals("AnnotationTestTypeChild", childXmlEntity.getTable().getDefaultName());
-// }
-
- public void testUpdateSpecifiedLength() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmDiscriminatorColumn ormColumn = ormEntity.getDiscriminatorColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(entityResource.getDiscriminatorColumn());
-
- //set name in the resource model, verify context model updated
- entityResource.setDiscriminatorColumn(OrmFactory.eINSTANCE.createXmlDiscriminatorColumn());
- entityResource.getDiscriminatorColumn().setLength(Integer.valueOf(8));
- assertEquals(Integer.valueOf(8), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(8), entityResource.getDiscriminatorColumn().getLength());
-
- //set name to null in the resource model
- entityResource.getDiscriminatorColumn().setLength(null);
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(entityResource.getDiscriminatorColumn().getLength());
-
- entityResource.getDiscriminatorColumn().setLength(Integer.valueOf(11));
- assertEquals(Integer.valueOf(11), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(11), entityResource.getDiscriminatorColumn().getLength());
-
- entityResource.setDiscriminatorColumn(null);
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(entityResource.getDiscriminatorColumn());
- }
-
- public void testModifySpecifiedLength() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmDiscriminatorColumn ormColumn = ormEntity.getDiscriminatorColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(entityResource.getDiscriminatorColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setSpecifiedLength(Integer.valueOf(7));
- assertEquals(Integer.valueOf(7), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(7), entityResource.getDiscriminatorColumn().getLength());
-
- //set name to null in the context model
- ormColumn.setSpecifiedLength(null);
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(entityResource.getDiscriminatorColumn());
- }
-
- public void testUpdateSpecifiedColumnDefinition() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmDiscriminatorColumn ormColumn = ormEntity.getDiscriminatorColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormColumn.getColumnDefinition());
- assertNull(entityResource.getDiscriminatorColumn());
-
- //set name in the resource model, verify context model updated
- entityResource.setDiscriminatorColumn(OrmFactory.eINSTANCE.createXmlDiscriminatorColumn());
- entityResource.getDiscriminatorColumn().setColumnDefinition("FOO");
- assertEquals("FOO", ormColumn.getColumnDefinition());
- assertEquals("FOO", entityResource.getDiscriminatorColumn().getColumnDefinition());
-
- //set name to null in the resource model
- entityResource.getDiscriminatorColumn().setColumnDefinition(null);
- assertNull(ormColumn.getColumnDefinition());
- assertNull(entityResource.getDiscriminatorColumn().getColumnDefinition());
-
- entityResource.getDiscriminatorColumn().setColumnDefinition("FOO");
- assertEquals("FOO", ormColumn.getColumnDefinition());
- assertEquals("FOO", entityResource.getDiscriminatorColumn().getColumnDefinition());
-
- entityResource.setDiscriminatorColumn(null);
- assertNull(ormColumn.getColumnDefinition());
- assertNull(entityResource.getDiscriminatorColumn());
- }
-
- public void testModifySpecifiedColumnDefinition() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmDiscriminatorColumn ormColumn = ormEntity.getDiscriminatorColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormColumn.getColumnDefinition());
- assertNull(entityResource.getDiscriminatorColumn());
-
- //set name in the context model, verify resource model modified
- ormColumn.setColumnDefinition("foo");
- assertEquals("foo", ormColumn.getColumnDefinition());
- assertEquals("foo", entityResource.getDiscriminatorColumn().getColumnDefinition());
-
- //set name to null in the context model
- ormColumn.setColumnDefinition(null);
- assertNull(ormColumn.getColumnDefinition());
- assertNull(entityResource.getDiscriminatorColumn());
- }
-
- public void testUpdateSpecifiedDiscriminatorType() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmDiscriminatorColumn ormColumn = ormEntity.getDiscriminatorColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormColumn.getSpecifiedDiscriminatorType());
- assertNull(entityResource.getDiscriminatorColumn());
-
- //set discriminator type in the resource model, verify context model updated
- entityResource.setDiscriminatorColumn(OrmFactory.eINSTANCE.createXmlDiscriminatorColumn());
- entityResource.getDiscriminatorColumn().setDiscriminatorType(org.eclipse.jpt.core.resource.orm.DiscriminatorType.STRING);
- assertEquals(DiscriminatorType.STRING, ormColumn.getSpecifiedDiscriminatorType());
- assertEquals(org.eclipse.jpt.core.resource.orm.DiscriminatorType.STRING, entityResource.getDiscriminatorColumn().getDiscriminatorType());
-
- //set discriminator type to null in the resource model
- entityResource.getDiscriminatorColumn().setDiscriminatorType(null);
- assertNull(ormColumn.getSpecifiedDiscriminatorType());
- assertNull(entityResource.getDiscriminatorColumn().getDiscriminatorType());
-
- entityResource.getDiscriminatorColumn().setDiscriminatorType(org.eclipse.jpt.core.resource.orm.DiscriminatorType.CHAR);
- assertEquals(DiscriminatorType.CHAR, ormColumn.getSpecifiedDiscriminatorType());
- assertEquals(org.eclipse.jpt.core.resource.orm.DiscriminatorType.CHAR, entityResource.getDiscriminatorColumn().getDiscriminatorType());
-
- entityResource.setDiscriminatorColumn(null);
- assertNull(ormColumn.getSpecifiedDiscriminatorType());
- assertNull(entityResource.getDiscriminatorColumn());
- }
-
- public void testModifySpecifiedDiscriminatorType() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmDiscriminatorColumn ormColumn = ormEntity.getDiscriminatorColumn();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormColumn.getSpecifiedDiscriminatorType());
- assertNull(entityResource.getDiscriminatorColumn());
-
- //set discriminator type in the context model, verify resource model modified
- ormColumn.setSpecifiedDiscriminatorType(DiscriminatorType.STRING);
- assertEquals(DiscriminatorType.STRING, ormColumn.getSpecifiedDiscriminatorType());
- assertEquals(org.eclipse.jpt.core.resource.orm.DiscriminatorType.STRING, entityResource.getDiscriminatorColumn().getDiscriminatorType());
-
- //set discriminator type to null in the context model
- ormColumn.setSpecifiedDiscriminatorType(null);
- assertNull(ormColumn.getSpecifiedDiscriminatorType());
- assertNull(entityResource.getDiscriminatorColumn());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddableTests.java
deleted file mode 100644
index c1f8207037..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddableTests.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.orm.OrmEmbeddable;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddable;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.orm.XmlMappedSuperclass;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmEmbeddableTests extends ContextModelTestCase
-{
- public OrmEmbeddableTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testUpdateClass() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) ormPersistentType.getMapping();
- XmlEmbeddable embeddableResource = ormResource().getEntityMappings().getEmbeddables().get(0);
- assertEquals("model.Foo", ormEmbeddable.getClass_());
- assertEquals("model.Foo", embeddableResource.getClassName());
-
- //set class in the resource model, verify context model updated
- embeddableResource.setClassName("com.Bar");
- assertEquals("com.Bar", ormEmbeddable.getClass_());
- assertEquals("com.Bar", embeddableResource.getClassName());
-
- //set class to null in the resource model
- embeddableResource.setClassName(null);
- assertNull(ormEmbeddable.getClass_());
- assertNull(embeddableResource.getClassName());
- }
-
- public void testModifyClass() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) ormPersistentType.getMapping();
- XmlEmbeddable embeddableResource = ormResource().getEntityMappings().getEmbeddables().get(0);
- assertEquals("model.Foo", ormEmbeddable.getClass_());
- assertEquals("model.Foo", embeddableResource.getClassName());
-
- //set class in the context model, verify resource model modified
- ormEmbeddable.setClass("com.Bar");
- assertEquals("com.Bar", ormEmbeddable.getClass_());
- assertEquals("com.Bar", embeddableResource.getClassName());
-
- //set class to null in the context model
- ormEmbeddable.setClass(null);
- assertNull(ormEmbeddable.getClass_());
- assertNull(embeddableResource.getClassName());
- }
- //TODO add tests for setting the className when the package is set on entity-mappings
-
- public void testUpdateSpecifiedAccess() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) ormPersistentType.getMapping();
- XmlEmbeddable embeddableResource = ormResource().getEntityMappings().getEmbeddables().get(0);
- assertNull(ormEmbeddable.getSpecifiedAccess());
- assertNull(embeddableResource.getAccess());
-
- //set access in the resource model, verify context model updated
- embeddableResource.setAccess(org.eclipse.jpt.core.resource.orm.AccessType.FIELD);
- assertEquals(AccessType.FIELD, ormEmbeddable.getSpecifiedAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.FIELD, embeddableResource.getAccess());
-
- //set access to null in the resource model
- embeddableResource.setAccess(null);
- assertNull(ormEmbeddable.getSpecifiedAccess());
- assertNull(embeddableResource.getAccess());
- }
-
- public void testModifySpecifiedAccess() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) ormPersistentType.getMapping();
- XmlEmbeddable embeddableResource = ormResource().getEntityMappings().getEmbeddables().get(0);
- assertNull(ormEmbeddable.getSpecifiedAccess());
- assertNull(embeddableResource.getAccess());
-
- //set access in the context model, verify resource model modified
- ormEmbeddable.setSpecifiedAccess(AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, ormEmbeddable.getSpecifiedAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, embeddableResource.getAccess());
-
- //set access to null in the context model
- ormEmbeddable.setSpecifiedAccess(null);
- assertNull(ormEmbeddable.getSpecifiedAccess());
- assertNull(embeddableResource.getAccess());
- }
- //TODO test default access from
- //underlying java
- //persistence-unit-defaults
- //entity-mappings
- //with xml-mapping-metadata-complete set
-
- public void testUpdateSpecifiedMetadataComplete() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) ormPersistentType.getMapping();
- XmlEmbeddable embeddableResource = ormResource().getEntityMappings().getEmbeddables().get(0);
- assertNull(embeddableResource.getMetadataComplete());
-
- //set metadata-complete in the resource model, verify context model updated
- embeddableResource.setMetadataComplete(true);
- assertTrue(ormEmbeddable.getSpecifiedMetadataComplete());
- assertTrue(embeddableResource.getMetadataComplete());
-
- //set access to false in the resource model
- embeddableResource.setMetadataComplete(false);
- assertFalse(ormEmbeddable.getSpecifiedMetadataComplete());
- assertFalse(embeddableResource.getMetadataComplete());
-
- embeddableResource.setMetadataComplete(null);
- assertNull(ormEmbeddable.getSpecifiedMetadataComplete());
- assertNull(embeddableResource.getMetadataComplete());
- }
-
- public void testModifySpecifiedMetadataComplete() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) ormPersistentType.getMapping();
- XmlEmbeddable embeddableResource = ormResource().getEntityMappings().getEmbeddables().get(0);
- assertNull(embeddableResource.getMetadataComplete());
-
- //set access in the context model, verify resource model modified
- ormEmbeddable.setSpecifiedMetadataComplete(Boolean.TRUE);
- assertTrue(ormEmbeddable.getSpecifiedMetadataComplete());
- assertTrue(embeddableResource.getMetadataComplete());
-
- //set access to null in the context model
- ormEmbeddable.setSpecifiedMetadataComplete(Boolean.FALSE);
- assertFalse(ormEmbeddable.getSpecifiedMetadataComplete());
- assertFalse(embeddableResource.getMetadataComplete());
-
- ormEmbeddable.setSpecifiedMetadataComplete(null);
- assertNull(ormEmbeddable.getSpecifiedMetadataComplete());
- assertNull(embeddableResource.getMetadataComplete());
- }
-
- public void testUpdateDefaultMetadataComplete() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) ormPersistentType.getMapping();
- XmlEmbeddable embeddableResource = ormResource().getEntityMappings().getEmbeddables().get(0);
- assertNull(ormEmbeddable.getSpecifiedMetadataComplete());
- assertFalse(ormEmbeddable.isDefaultMetadataComplete());
- assertNull(embeddableResource.getMetadataComplete());
-
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertTrue(ormEmbeddable.isDefaultMetadataComplete());
- assertNull(ormEmbeddable.getSpecifiedMetadataComplete());
- assertNull(embeddableResource.getMetadataComplete());
-
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertNull(ormEmbeddable.getSpecifiedMetadataComplete());
- assertFalse(ormEmbeddable.isDefaultMetadataComplete());
- assertNull(embeddableResource.getMetadataComplete());
- }
-
- public void testUpdateMetadataComplete() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) ormPersistentType.getMapping();
- XmlEmbeddable embeddableResource = ormResource().getEntityMappings().getEmbeddables().get(0);
- assertNull(ormEmbeddable.getSpecifiedMetadataComplete());
- assertFalse(ormEmbeddable.isMetadataComplete());
- assertNull(embeddableResource.getMetadataComplete());
-
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertTrue(ormEmbeddable.isMetadataComplete());
- assertNull(ormEmbeddable.getSpecifiedMetadataComplete());
- assertNull(embeddableResource.getMetadataComplete());
-
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertFalse(ormEmbeddable.isMetadataComplete());
- assertNull(ormEmbeddable.getSpecifiedMetadataComplete());
- assertNull(embeddableResource.getMetadataComplete());
- }
-
- public void testMakeEmbeddableEntity() throws Exception {
- OrmPersistentType embeddablePersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable embeddable = (OrmEmbeddable) embeddablePersistentType.getMapping();
- embeddable.setSpecifiedAccess(AccessType.PROPERTY);
- embeddable.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- embeddablePersistentType.setMappingKey(MappingKeys.ENTITY_TYPE_MAPPING_KEY);
-
- XmlEntity entity = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals("model.Foo", entity.getClassName());
- assertEquals(Boolean.TRUE, entity.getMetadataComplete());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, entity.getAccess());
- assertNull(entity.getDiscriminatorValue());
- assertNull(entity.getName());
-
- OrmEntity ormEntity = (OrmEntity) embeddablePersistentType.getMapping();
- assertEquals("model.Foo", ormEntity.getClass_());
- assertEquals(Boolean.TRUE, ormEntity.getSpecifiedMetadataComplete());
- assertEquals(AccessType.PROPERTY, ormEntity.getSpecifiedAccess());
- }
-
- //test with 2 Embeddables, make the second one an Entity so it has to move to the front of the list
- public void testMakeEmbeddableEntity2() throws Exception {
- entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo2");
- OrmPersistentType embeddablePersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable embeddable = (OrmEmbeddable) embeddablePersistentType.getMapping();
- embeddable.setSpecifiedAccess(AccessType.PROPERTY);
- embeddable.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- embeddablePersistentType.setMappingKey(MappingKeys.ENTITY_TYPE_MAPPING_KEY);
-
- XmlEntity entity = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals("model.Foo", entity.getClassName());
- assertEquals(Boolean.TRUE, entity.getMetadataComplete());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, entity.getAccess());
- assertNull(entity.getDiscriminatorValue());
- assertNull(entity.getName());
-
- OrmEntity ormEntity = (OrmEntity) embeddablePersistentType.getMapping();
- assertEquals("model.Foo", ormEntity.getClass_());
- assertEquals(Boolean.TRUE, ormEntity.getSpecifiedMetadataComplete());
- assertEquals(AccessType.PROPERTY, ormEntity.getSpecifiedAccess());
-
- ListIterator<OrmPersistentType> persistentTypes = entityMappings().ormPersistentTypes();
- assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
- assertEquals(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
- }
-
- public void testMakeEmbeddableMappedSuperclass() throws Exception {
- OrmPersistentType embeddablePersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable embeddable = (OrmEmbeddable) embeddablePersistentType.getMapping();
- embeddable.setSpecifiedAccess(AccessType.PROPERTY);
- embeddable.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- embeddablePersistentType.setMappingKey(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY);
-
- XmlMappedSuperclass mappedSuperclass = ormResource().getEntityMappings().getMappedSuperclasses().get(0);
- assertEquals("model.Foo", mappedSuperclass.getClassName());
- assertEquals(Boolean.TRUE, mappedSuperclass.getMetadataComplete());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, mappedSuperclass.getAccess());
-
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) embeddablePersistentType.getMapping();
- assertEquals("model.Foo", ormMappedSuperclass.getClass_());
- assertEquals(Boolean.TRUE, ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertEquals(AccessType.PROPERTY, ormMappedSuperclass.getSpecifiedAccess());
- }
-
- //test with 2 Embeddables, make the second one a MappedSuperclass so it has to move to the front of the list
- public void testMakeEmbeddableMappedSuperclass2() throws Exception {
- entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo2");
- OrmPersistentType embeddablePersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable embeddable = (OrmEmbeddable) embeddablePersistentType.getMapping();
- embeddable.setSpecifiedAccess(AccessType.PROPERTY);
- embeddable.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- embeddablePersistentType.setMappingKey(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY);
-
- XmlMappedSuperclass mappedSuperclass = ormResource().getEntityMappings().getMappedSuperclasses().get(0);
- assertEquals("model.Foo", mappedSuperclass.getClassName());
- assertEquals(Boolean.TRUE, mappedSuperclass.getMetadataComplete());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, mappedSuperclass.getAccess());
-
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) embeddablePersistentType.getMapping();
- assertEquals("model.Foo", ormMappedSuperclass.getClass_());
- assertEquals(Boolean.TRUE, ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertEquals(AccessType.PROPERTY, ormMappedSuperclass.getSpecifiedAccess());
-
- ListIterator<OrmPersistentType> persistentTypes = entityMappings().ormPersistentTypes();
- assertEquals(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
- assertEquals(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedIdMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedIdMappingTests.java
deleted file mode 100644
index 9632e885fc..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedIdMappingTests.java
+++ /dev/null
@@ -1,493 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddedId;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmEmbeddedIdMappingTests extends ContextModelTestCase
-{
- private static final String ATTRIBUTE_OVERRIDE_NAME = "city";
- private static final String ATTRIBUTE_OVERRIDE_COLUMN_NAME = "E_CITY";
-
- public OrmEmbeddedIdMappingTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createEmbeddedIdAnnotation() throws Exception{
- this.createAnnotationAndMembers("EmbeddedId", "");
- }
-
- private void createColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("Column",
- "String name() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";" +
- "int length() default 255;" +
- "int precision() default 0;" +
- "int scale() default 0;");
- }
-
- private void createAttributeOverrideAnnotation() throws Exception {
- createColumnAnnotation();
- this.createAnnotationAndMembers("AttributeOverride",
- "String name();" +
- "Column column();");
- }
- private IType createTestEntityEmbeddedIdMapping() throws Exception {
- createEntityAnnotation();
- createEmbeddedIdAnnotation();
- createAttributeOverrideAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.EMBEDDED_ID, JPA.ATTRIBUTE_OVERRIDE, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @EmbeddedId");
- sb.append(CR);
- sb.append(" @AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\", column=@Column(name=\"" + ATTRIBUTE_OVERRIDE_COLUMN_NAME + "\"))");
- sb.append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- sb.append(" @Id");
- }
- });
- }
-
-
-// public void testUpdateName() throws Exception {
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(IMappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedIdMapping");
-// XmlEmbeddedIdMapping xmlEmbeddedIdMapping = (XmlEmbeddedIdMapping) ormPersistentAttribute.getMapping();
-// EmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
-//
-// assertEquals("embeddedIdMapping", xmlEmbeddedIdMapping.getName());
-// assertEquals("embeddedIdMapping", embeddedIdResource.getName());
-//
-// //set name in the resource model, verify context model updated
-// embeddedIdResource.setName("newName");
-// assertEquals("newName", xmlEmbeddedIdMapping.getName());
-// assertEquals("newName", embeddedIdResource.getName());
-//
-// //set name to null in the resource model
-// embeddedIdResource.setName(null);
-// assertNull(xmlEmbeddedIdMapping.getName());
-// assertNull(embeddedIdResource.getName());
-// }
-//
-// public void testModifyName() throws Exception {
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(IMappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedIdMapping");
-// XmlEmbeddedIdMapping xmlEmbeddedIdMapping = (XmlEmbeddedIdMapping) ormPersistentAttribute.getMapping();
-// EmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
-//
-// assertEquals("embeddedIdMapping", xmlEmbeddedIdMapping.getName());
-// assertEquals("embeddedIdMapping", embeddedIdResource.getName());
-//
-// //set name in the context model, verify resource model updated
-// xmlEmbeddedIdMapping.setName("newName");
-// assertEquals("newName", xmlEmbeddedIdMapping.getName());
-// assertEquals("newName", embeddedIdResource.getName());
-//
-// //set name to null in the context model
-// xmlEmbeddedIdMapping.setName(null);
-// assertNull(xmlEmbeddedIdMapping.getName());
-// assertNull(embeddedIdResource.getName());
-// }
-//
-// public void testAddSpecifiedAttributeOverride() throws Exception {
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(IMappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedIdMapping");
-// XmlEmbeddedIdMapping xmlEmbeddedIdMapping = (XmlEmbeddedIdMapping) ormPersistentAttribute.getMapping();
-// EmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
-//
-// XmlAttributeOverride attributeOverride = xmlEmbeddedIdMapping.addSpecifiedAttributeOverride(0);
-// ormResource().save(null);
-// attributeOverride.setName("FOO");
-// ormResource().save(null);
-//
-// assertEquals("FOO", embeddedIdResource.getAttributeOverrides().get(0).getName());
-//
-// XmlAttributeOverride attributeOverride2 = xmlEmbeddedIdMapping.addSpecifiedAttributeOverride(0);
-// ormResource().save(null);
-// attributeOverride2.setName("BAR");
-// ormResource().save(null);
-//
-// assertEquals("BAR", embeddedIdResource.getAttributeOverrides().get(0).getName());
-// assertEquals("FOO", embeddedIdResource.getAttributeOverrides().get(1).getName());
-//
-// XmlAttributeOverride attributeOverride3 = xmlEmbeddedIdMapping.addSpecifiedAttributeOverride(1);
-// ormResource().save(null);
-// attributeOverride3.setName("BAZ");
-// ormResource().save(null);
-//
-// assertEquals("BAR", embeddedIdResource.getAttributeOverrides().get(0).getName());
-// assertEquals("BAZ", embeddedIdResource.getAttributeOverrides().get(1).getName());
-// assertEquals("FOO", embeddedIdResource.getAttributeOverrides().get(2).getName());
-//
-// ListIterator<XmlAttributeOverride> attributeOverrides = xmlEmbeddedIdMapping.specifiedAttributeOverrides();
-// assertEquals(attributeOverride2, attributeOverrides.next());
-// assertEquals(attributeOverride3, attributeOverrides.next());
-// assertEquals(attributeOverride, attributeOverrides.next());
-//
-// attributeOverrides = xmlEmbeddedIdMapping.specifiedAttributeOverrides();
-// assertEquals("BAR", attributeOverrides.next().getName());
-// assertEquals("BAZ", attributeOverrides.next().getName());
-// assertEquals("FOO", attributeOverrides.next().getName());
-// }
-//
-// public void testRemoveSpecifiedAttributeOverride() throws Exception {
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(IMappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedIdMapping");
-// XmlEmbeddedIdMapping xmlEmbeddedIdMapping = (XmlEmbeddedIdMapping) ormPersistentAttribute.getMapping();
-// EmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
-//
-// xmlEmbeddedIdMapping.addSpecifiedAttributeOverride(0).setName("FOO");
-// xmlEmbeddedIdMapping.addSpecifiedAttributeOverride(1).setName("BAR");
-// xmlEmbeddedIdMapping.addSpecifiedAttributeOverride(2).setName("BAZ");
-//
-// assertEquals(3, embeddedIdResource.getAttributeOverrides().size());
-//
-// xmlEmbeddedIdMapping.removeSpecifiedAttributeOverride(0);
-// assertEquals(2, embeddedIdResource.getAttributeOverrides().size());
-// assertEquals("BAR", embeddedIdResource.getAttributeOverrides().get(0).getName());
-// assertEquals("BAZ", embeddedIdResource.getAttributeOverrides().get(1).getName());
-//
-// xmlEmbeddedIdMapping.removeSpecifiedAttributeOverride(0);
-// assertEquals(1, embeddedIdResource.getAttributeOverrides().size());
-// assertEquals("BAZ", embeddedIdResource.getAttributeOverrides().get(0).getName());
-//
-// xmlEmbeddedIdMapping.removeSpecifiedAttributeOverride(0);
-// assertEquals(0, embeddedIdResource.getAttributeOverrides().size());
-// }
-//
-// public void testMoveSpecifiedAttributeOverride() throws Exception {
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(IMappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedIdMapping");
-// XmlEmbeddedIdMapping xmlEmbeddedIdMapping = (XmlEmbeddedIdMapping) ormPersistentAttribute.getMapping();
-// EmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
-//
-// xmlEmbeddedIdMapping.addSpecifiedAttributeOverride(0).setName("FOO");
-// xmlEmbeddedIdMapping.addSpecifiedAttributeOverride(1).setName("BAR");
-// xmlEmbeddedIdMapping.addSpecifiedAttributeOverride(2).setName("BAZ");
-//
-// assertEquals(3, embeddedIdResource.getAttributeOverrides().size());
-//
-//
-// xmlEmbeddedIdMapping.moveSpecifiedAttributeOverride(2, 0);
-// ListIterator<XmlAttributeOverride> attributeOverrides = xmlEmbeddedIdMapping.specifiedAttributeOverrides();
-// assertEquals("BAR", attributeOverrides.next().getName());
-// assertEquals("BAZ", attributeOverrides.next().getName());
-// assertEquals("FOO", attributeOverrides.next().getName());
-//
-// assertEquals("BAR", embeddedIdResource.getAttributeOverrides().get(0).getName());
-// assertEquals("BAZ", embeddedIdResource.getAttributeOverrides().get(1).getName());
-// assertEquals("FOO", embeddedIdResource.getAttributeOverrides().get(2).getName());
-//
-//
-// xmlEmbeddedIdMapping.moveSpecifiedAttributeOverride(0, 1);
-// attributeOverrides = xmlEmbeddedIdMapping.specifiedAttributeOverrides();
-// assertEquals("BAZ", attributeOverrides.next().getName());
-// assertEquals("BAR", attributeOverrides.next().getName());
-// assertEquals("FOO", attributeOverrides.next().getName());
-//
-// assertEquals("BAZ", embeddedIdResource.getAttributeOverrides().get(0).getName());
-// assertEquals("BAR", embeddedIdResource.getAttributeOverrides().get(1).getName());
-// assertEquals("FOO", embeddedIdResource.getAttributeOverrides().get(2).getName());
-// }
-//
-// public void testUpdateAttributeOverrides() throws Exception {
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(IMappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedIdMapping");
-// XmlEmbeddedIdMapping xmlEmbeddedIdMapping = (XmlEmbeddedIdMapping) ormPersistentAttribute.getMapping();
-// EmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
-//
-// embeddedIdResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createAttributeOverrideImpl());
-// embeddedIdResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createAttributeOverrideImpl());
-// embeddedIdResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createAttributeOverrideImpl());
-//
-// embeddedIdResource.getAttributeOverrides().get(0).setName("FOO");
-// embeddedIdResource.getAttributeOverrides().get(1).setName("BAR");
-// embeddedIdResource.getAttributeOverrides().get(2).setName("BAZ");
-//
-// ListIterator<XmlAttributeOverride> attributeOverrides = xmlEmbeddedIdMapping.specifiedAttributeOverrides();
-// assertEquals("FOO", attributeOverrides.next().getName());
-// assertEquals("BAR", attributeOverrides.next().getName());
-// assertEquals("BAZ", attributeOverrides.next().getName());
-// assertFalse(attributeOverrides.hasNext());
-//
-// embeddedIdResource.getAttributeOverrides().move(2, 0);
-// attributeOverrides = xmlEmbeddedIdMapping.specifiedAttributeOverrides();
-// assertEquals("BAR", attributeOverrides.next().getName());
-// assertEquals("BAZ", attributeOverrides.next().getName());
-// assertEquals("FOO", attributeOverrides.next().getName());
-// assertFalse(attributeOverrides.hasNext());
-//
-// embeddedIdResource.getAttributeOverrides().move(0, 1);
-// attributeOverrides = xmlEmbeddedIdMapping.specifiedAttributeOverrides();
-// assertEquals("BAZ", attributeOverrides.next().getName());
-// assertEquals("BAR", attributeOverrides.next().getName());
-// assertEquals("FOO", attributeOverrides.next().getName());
-// assertFalse(attributeOverrides.hasNext());
-//
-// embeddedIdResource.getAttributeOverrides().remove(1);
-// attributeOverrides = xmlEmbeddedIdMapping.specifiedAttributeOverrides();
-// assertEquals("BAZ", attributeOverrides.next().getName());
-// assertEquals("FOO", attributeOverrides.next().getName());
-// assertFalse(attributeOverrides.hasNext());
-//
-// embeddedIdResource.getAttributeOverrides().remove(1);
-// attributeOverrides = xmlEmbeddedIdMapping.specifiedAttributeOverrides();
-// assertEquals("BAZ", attributeOverrides.next().getName());
-// assertFalse(attributeOverrides.hasNext());
-//
-// embeddedIdResource.getAttributeOverrides().remove(0);
-// assertFalse(xmlEmbeddedIdMapping.specifiedAttributeOverrides().hasNext());
-// }
-
- public void testEmbeddedIdMorphToIdMapping() throws Exception {
- createTestEntityEmbeddedIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId");
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedIdMapping.isDefault());
- XmlEmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
- embeddedIdResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedIdMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedIdMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping);
- assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedIdMorphToVersionMapping() throws Exception {
- createTestEntityEmbeddedIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId");
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedIdMapping.isDefault());
- XmlEmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
- embeddedIdResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedIdMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedIdMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping);
- assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedIdMorphToTransientMapping() throws Exception {
- createTestEntityEmbeddedIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId");
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedIdMapping.isDefault());
- XmlEmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
- embeddedIdResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedIdMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedIdMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping);
- assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedIdMorphToBasicMapping() throws Exception {
- createTestEntityEmbeddedIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId");
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedIdMapping.isDefault());
- XmlEmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
- embeddedIdResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedIdMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedIdMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping);
- assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedIdMorphToEmbeddedMapping() throws Exception {
- createTestEntityEmbeddedIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId");
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedIdMapping.isDefault());
- XmlEmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
- embeddedIdResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedIdMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedIdMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName());
- attributeOverride = ((EmbeddedMapping) ormPersistentAttribute.getMapping()).specifiedAttributeOverrides().next();
- assertEquals("override", attributeOverride.getName());
- assertEquals("OVERRIDE_COLUMN", attributeOverride.getColumn().getSpecifiedName());
- }
-
- public void testEmbeddedIdMorphToOneToOneMapping() throws Exception {
- createTestEntityEmbeddedIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId");
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedIdMapping.isDefault());
- XmlEmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
- embeddedIdResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedIdMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedIdMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping);
- assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedIdMorphToOneToManyMapping() throws Exception {
- createTestEntityEmbeddedIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId");
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedIdMapping.isDefault());
- XmlEmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
- embeddedIdResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedIdMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedIdMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping);
- assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedIdMorphToManyToOneMapping() throws Exception {
- createTestEntityEmbeddedIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId");
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedIdMapping.isDefault());
- XmlEmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
- embeddedIdResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedIdMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedIdMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedIdMorphToManyToManyMapping() throws Exception {
- createTestEntityEmbeddedIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId");
-
- EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedIdMapping.isDefault());
- XmlEmbeddedId embeddedIdResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0);
- embeddedIdResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedIdMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedIdMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedMappingTests.java
deleted file mode 100644
index fdd8858331..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedMappingTests.java
+++ /dev/null
@@ -1,700 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeOverride;
-import org.eclipse.jpt.core.context.orm.OrmColumn;
-import org.eclipse.jpt.core.context.orm.OrmEmbeddedMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlEmbedded;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmEmbeddedMappingTests extends ContextModelTestCase
-{
- private static final String ATTRIBUTE_OVERRIDE_NAME = "city";
- private static final String ATTRIBUTE_OVERRIDE_COLUMN_NAME = "E_CITY";
-
- public OrmEmbeddedMappingTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createEmbeddedAnnotation() throws Exception{
- this.createAnnotationAndMembers("Embedded", "");
- }
-
- private void createColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("Column",
- "String name() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";" +
- "int length() default 255;" +
- "int precision() default 0;" +
- "int scale() default 0;");
- }
-
- private void createAttributeOverrideAnnotation() throws Exception {
- createColumnAnnotation();
- this.createAnnotationAndMembers("AttributeOverride",
- "String name();" +
- "Column column();");
- }
-
- private IType createTestEntityEmbeddedMapping() throws Exception {
- createEntityAnnotation();
- createEmbeddedAnnotation();
- createAttributeOverrideAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.EMBEDDED, JPA.ATTRIBUTE_OVERRIDE, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @Embedded");
- sb.append(CR);
- sb.append(" @AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\", column=@Column(name=\"" + ATTRIBUTE_OVERRIDE_COLUMN_NAME + "\"))");
- sb.append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- sb.append(" @Id");
- }
- });
- }
-
- private IType createTestEmbeddableAddress() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.EMBEDDABLE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.COLUMN);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int id;").append(CR);
- sb.append(CR);
- sb.append(" private String city;").append(CR);
- sb.append(CR);
- sb.append(" @Column(name=\"A_STATE\")").append(CR);
- sb.append(" private String state;").append(CR);
- sb.append(CR);
- sb.append(" private int zip;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter);
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping");
- OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping();
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
-
- assertEquals("embeddedMapping", ormEmbeddedMapping.getName());
- assertEquals("embeddedMapping", embeddedResource.getName());
-
- //set name in the resource model, verify context model updated
- embeddedResource.setName("newName");
- assertEquals("newName", ormEmbeddedMapping.getName());
- assertEquals("newName", embeddedResource.getName());
-
- //set name to null in the resource model
- embeddedResource.setName(null);
- assertNull(ormEmbeddedMapping.getName());
- assertNull(embeddedResource.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping");
- OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping();
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
-
- assertEquals("embeddedMapping", ormEmbeddedMapping.getName());
- assertEquals("embeddedMapping", embeddedResource.getName());
-
- //set name in the context model, verify resource model updated
- ormEmbeddedMapping.setName("newName");
- assertEquals("newName", ormEmbeddedMapping.getName());
- assertEquals("newName", embeddedResource.getName());
-
- //set name to null in the context model
- ormEmbeddedMapping.setName(null);
- assertNull(ormEmbeddedMapping.getName());
- assertNull(embeddedResource.getName());
- }
-
-// public void testAddSpecifiedAttributeOverride() throws Exception {
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping");
-// OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping();
-// XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
-//
-// OrmAttributeOverride attributeOverride = ormEmbeddedMapping.addSpecifiedAttributeOverride(0);
-// attributeOverride.setName("FOO");
-//
-// assertEquals("FOO", embeddedResource.getAttributeOverrides().get(0).getName());
-//
-// OrmAttributeOverride attributeOverride2 = ormEmbeddedMapping.addSpecifiedAttributeOverride(0);
-// attributeOverride2.setName("BAR");
-//
-// assertEquals("BAR", embeddedResource.getAttributeOverrides().get(0).getName());
-// assertEquals("FOO", embeddedResource.getAttributeOverrides().get(1).getName());
-//
-// OrmAttributeOverride attributeOverride3 = ormEmbeddedMapping.addSpecifiedAttributeOverride(1);
-// attributeOverride3.setName("BAZ");
-//
-// assertEquals("BAR", embeddedResource.getAttributeOverrides().get(0).getName());
-// assertEquals("BAZ", embeddedResource.getAttributeOverrides().get(1).getName());
-// assertEquals("FOO", embeddedResource.getAttributeOverrides().get(2).getName());
-//
-// ListIterator<OrmAttributeOverride> attributeOverrides = ormEmbeddedMapping.specifiedAttributeOverrides();
-// assertEquals(attributeOverride2, attributeOverrides.next());
-// assertEquals(attributeOverride3, attributeOverrides.next());
-// assertEquals(attributeOverride, attributeOverrides.next());
-//
-// attributeOverrides = ormEmbeddedMapping.specifiedAttributeOverrides();
-// assertEquals("BAR", attributeOverrides.next().getName());
-// assertEquals("BAZ", attributeOverrides.next().getName());
-// assertEquals("FOO", attributeOverrides.next().getName());
-// }
-//
-// public void testRemoveSpecifiedAttributeOverride() throws Exception {
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping");
-// OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping();
-// XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
-//
-// ormEmbeddedMapping.addSpecifiedAttributeOverride(0).setName("FOO");
-// ormEmbeddedMapping.addSpecifiedAttributeOverride(1).setName("BAR");
-// ormEmbeddedMapping.addSpecifiedAttributeOverride(2).setName("BAZ");
-//
-// assertEquals(3, embeddedResource.getAttributeOverrides().size());
-//
-// ormEmbeddedMapping.removeSpecifiedAttributeOverride(0);
-// assertEquals(2, embeddedResource.getAttributeOverrides().size());
-// assertEquals("BAR", embeddedResource.getAttributeOverrides().get(0).getName());
-// assertEquals("BAZ", embeddedResource.getAttributeOverrides().get(1).getName());
-//
-// ormEmbeddedMapping.removeSpecifiedAttributeOverride(0);
-// assertEquals(1, embeddedResource.getAttributeOverrides().size());
-// assertEquals("BAZ", embeddedResource.getAttributeOverrides().get(0).getName());
-//
-// ormEmbeddedMapping.removeSpecifiedAttributeOverride(0);
-// assertEquals(0, embeddedResource.getAttributeOverrides().size());
-// }
-
- public void testMoveSpecifiedAttributeOverride() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping");
- OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping();
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
-
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
-
- embeddedResource.getAttributeOverrides().get(0).setName("FOO");
- embeddedResource.getAttributeOverrides().get(1).setName("BAR");
- embeddedResource.getAttributeOverrides().get(2).setName("BAZ");
-
- assertEquals(3, embeddedResource.getAttributeOverrides().size());
-
- ormEmbeddedMapping.moveSpecifiedAttributeOverride(2, 0);
- ListIterator<OrmAttributeOverride> attributeOverrides = ormEmbeddedMapping.specifiedAttributeOverrides();
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
-
- assertEquals("BAR", embeddedResource.getAttributeOverrides().get(0).getName());
- assertEquals("BAZ", embeddedResource.getAttributeOverrides().get(1).getName());
- assertEquals("FOO", embeddedResource.getAttributeOverrides().get(2).getName());
-
-
- ormEmbeddedMapping.moveSpecifiedAttributeOverride(0, 1);
- attributeOverrides = ormEmbeddedMapping.specifiedAttributeOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
-
- assertEquals("BAZ", embeddedResource.getAttributeOverrides().get(0).getName());
- assertEquals("BAR", embeddedResource.getAttributeOverrides().get(1).getName());
- assertEquals("FOO", embeddedResource.getAttributeOverrides().get(2).getName());
- }
-
- public void testUpdateAttributeOverrides() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping");
- OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping();
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
-
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
-
- embeddedResource.getAttributeOverrides().get(0).setName("FOO");
- embeddedResource.getAttributeOverrides().get(1).setName("BAR");
- embeddedResource.getAttributeOverrides().get(2).setName("BAZ");
-
- ListIterator<OrmAttributeOverride> attributeOverrides = ormEmbeddedMapping.specifiedAttributeOverrides();
- assertEquals("FOO", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- embeddedResource.getAttributeOverrides().move(2, 0);
- attributeOverrides = ormEmbeddedMapping.specifiedAttributeOverrides();
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- embeddedResource.getAttributeOverrides().move(0, 1);
- attributeOverrides = ormEmbeddedMapping.specifiedAttributeOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- embeddedResource.getAttributeOverrides().remove(1);
- attributeOverrides = ormEmbeddedMapping.specifiedAttributeOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- embeddedResource.getAttributeOverrides().remove(1);
- attributeOverrides = ormEmbeddedMapping.specifiedAttributeOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- embeddedResource.getAttributeOverrides().remove(0);
- assertFalse(ormEmbeddedMapping.specifiedAttributeOverrides().hasNext());
- }
-
-
- public void testEmbeddedMappingNoUnderylingJavaAttribute() throws Exception {
- createTestEntityEmbeddedMapping();
- createTestEmbeddableAddress();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "foo");
- assertEquals(3, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("foo", ormEmbeddedMapping.getName());
-
-
- assertFalse(ormEmbeddedMapping.specifiedAttributeOverrides().hasNext());
- assertFalse(ormEmbeddedMapping.virtualAttributeOverrides().hasNext());
- }
-
-
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityEmbeddedMapping();
- createTestEmbeddableAddress();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- assertEquals(3, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping();
- assertEquals("address", ormEmbeddedMapping.getName());
-
- assertEquals(4, ormEmbeddedMapping.specifiedAttributeOverridesSize());
- assertEquals(0, ormEmbeddedMapping.virtualAttributeOverridesSize());
- ListIterator<OrmAttributeOverride> ormAttributeOverrides = ormEmbeddedMapping.specifiedAttributeOverrides();
-
- OrmAttributeOverride ormAttributeOverride = ormAttributeOverrides.next();
- assertEquals(ATTRIBUTE_OVERRIDE_NAME, ormAttributeOverride.getName());
- OrmColumn ormColumn = ormAttributeOverride.getColumn();
- assertEquals(ATTRIBUTE_OVERRIDE_COLUMN_NAME, ormColumn.getSpecifiedName());
-// assertEquals(Boolean.TRUE, xmlColumn.getSpecifiedUnique());
-// assertEquals(Boolean.FALSE, xmlColumn.getSpecifiedNullable());
-// assertEquals(Boolean.FALSE, xmlColumn.getSpecifiedInsertable());
-// assertEquals(Boolean.FALSE, xmlColumn.getSpecifiedUpdatable());
-// assertEquals("COLUMN_DEFINITION", xmlColumn.getColumnDefinition());
-// assertEquals("MY_TABLE", xmlColumn.getSpecifiedTable());
-// assertEquals(Integer.valueOf(5), xmlColumn.getSpecifiedLength());
-// assertEquals(Integer.valueOf(6), xmlColumn.getSpecifiedPrecision());
-// assertEquals(Integer.valueOf(7), xmlColumn.getSpecifiedScale());
-
- ormAttributeOverride = ormAttributeOverrides.next();
- assertEquals("id", ormAttributeOverride.getName());
- ormColumn = ormAttributeOverride.getColumn();
- assertEquals("id", ormColumn.getSpecifiedName());
-
- ormAttributeOverride = ormAttributeOverrides.next();
- assertEquals("state", ormAttributeOverride.getName());
- ormColumn = ormAttributeOverride.getColumn();
- assertEquals("A_STATE", ormColumn.getSpecifiedName());
-
- ormAttributeOverride = ormAttributeOverrides.next();
- assertEquals("zip", ormAttributeOverride.getName());
- ormColumn = ormAttributeOverride.getColumn();
- assertEquals("zip", ormColumn.getSpecifiedName());
-
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityEmbeddedMapping();
- createTestEmbeddableAddress();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(3, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping();
- assertEquals("address", ormEmbeddedMapping.getName());
-
- //TODO
-// assertEquals(4, ormEmbeddedMapping.specifiedAttributeOverridesSize());
-// assertEquals(0, CollectionTools.size(ormEmbeddedMapping.defaultAttributeOverrides()));
-// ListIterator<XmlAttributeOverride> ormAttributeOverrides = ormEmbeddedMapping.specifiedAttributeOverrides();
-//
-// XmlAttributeOverride ormAttributeOverride = ormAttributeOverrides.next();
-// assertEquals(ATTRIBUTE_OVERRIDE_NAME, ormAttributeOverride.getName());
-// XmlColumn xmlColumn = ormAttributeOverride.getColumn();
-// assertEquals("city", xmlColumn.getSpecifiedName());
-//// assertEquals(Boolean.TRUE, xmlColumn.getSpecifiedUnique());
-//// assertEquals(Boolean.FALSE, xmlColumn.getSpecifiedNullable());
-//// assertEquals(Boolean.FALSE, xmlColumn.getSpecifiedInsertable());
-//// assertEquals(Boolean.FALSE, xmlColumn.getSpecifiedUpdatable());
-//// assertEquals("COLUMN_DEFINITION", xmlColumn.getColumnDefinition());
-//// assertEquals("MY_TABLE", xmlColumn.getSpecifiedTable());
-//// assertEquals(Integer.valueOf(5), xmlColumn.getSpecifiedLength());
-//// assertEquals(Integer.valueOf(6), xmlColumn.getSpecifiedPrecision());
-//// assertEquals(Integer.valueOf(7), xmlColumn.getSpecifiedScale());
-//
-// ormAttributeOverride = ormAttributeOverrides.next();
-// assertEquals("id", ormAttributeOverride.getName());
-// xmlColumn = ormAttributeOverride.getColumn();
-// assertEquals("id", xmlColumn.getSpecifiedName());
-//
-// ormAttributeOverride = ormAttributeOverrides.next();
-// assertEquals("state", ormAttributeOverride.getName());
-// xmlColumn = ormAttributeOverride.getColumn();
-// assertEquals("state", xmlColumn.getSpecifiedName());
-//
-// ormAttributeOverride = ormAttributeOverrides.next();
-// assertEquals("zip", ormAttributeOverride.getName());
-// xmlColumn = ormAttributeOverride.getColumn();
-// assertEquals("zip", xmlColumn.getSpecifiedName());
- }
-
- public void testSpecifiedMapping() throws Exception {
- createTestEntityEmbeddedMapping();
- createTestEmbeddableAddress();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "address");
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("address", ormEmbeddedMapping.getName());
-
- assertEquals(0, ormEmbeddedMapping.specifiedAttributeOverridesSize());
- //TODO
-// assertEquals(4, CollectionTools.size(ormEmbeddedMapping.defaultAttributeOverrides()));
-// ListIterator<XmlAttributeOverride> ormAttributeOverrides = ormEmbeddedMapping.defaultAttributeOverrides();
-//
-// XmlAttributeOverride ormAttributeOverride = ormAttributeOverrides.next();
-// assertEquals(ATTRIBUTE_OVERRIDE_NAME, ormAttributeOverride.getName());
-// XmlColumn xmlColumn = ormAttributeOverride.getColumn();
-// assertEquals("city", xmlColumn.getDefaultName());
-//// assertEquals(Boolean.TRUE, xmlColumn.getSpecifiedUnique());
-//// assertEquals(Boolean.FALSE, xmlColumn.getSpecifiedNullable());
-//// assertEquals(Boolean.FALSE, xmlColumn.getSpecifiedInsertable());
-//// assertEquals(Boolean.FALSE, xmlColumn.getSpecifiedUpdatable());
-//// assertEquals("COLUMN_DEFINITION", xmlColumn.getColumnDefinition());
-//// assertEquals("MY_TABLE", xmlColumn.getSpecifiedTable());
-//// assertEquals(Integer.valueOf(5), xmlColumn.getSpecifiedLength());
-//// assertEquals(Integer.valueOf(6), xmlColumn.getSpecifiedPrecision());
-//// assertEquals(Integer.valueOf(7), xmlColumn.getSpecifiedScale());
-//
-// ormAttributeOverride = ormAttributeOverrides.next();
-// assertEquals("id", ormAttributeOverride.getName());
-// xmlColumn = ormAttributeOverride.getColumn();
-// assertEquals("id", xmlColumn.getDefaultName());
-//
-// ormAttributeOverride = ormAttributeOverrides.next();
-// assertEquals("state", ormAttributeOverride.getName());
-// xmlColumn = ormAttributeOverride.getColumn();
-// assertEquals("state", xmlColumn.getDefaultName());
-//
-// ormAttributeOverride = ormAttributeOverrides.next();
-// assertEquals("zip", ormAttributeOverride.getName());
-// xmlColumn = ormAttributeOverride.getColumn();
-// assertEquals("zip", xmlColumn.getDefaultName());
- }
-
-
- public void testEmbeddedMorphToIdMapping() throws Exception {
- createTestEntityEmbeddedMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded");
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedMapping.isDefault());
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping);
- assertEquals("embedded", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedMorphToVersionMapping() throws Exception {
- createTestEntityEmbeddedMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded");
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedMapping.isDefault());
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping);
- assertEquals("embedded", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedMorphToTransientMapping() throws Exception {
- createTestEntityEmbeddedMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded");
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedMapping.isDefault());
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping);
- assertEquals("embedded", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedMorphToBasicMapping() throws Exception {
- createTestEntityEmbeddedMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded");
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedMapping.isDefault());
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping);
- assertEquals("embedded", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityEmbeddedMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded");
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedMapping.isDefault());
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertEquals("embedded", ormPersistentAttribute.getMapping().getName());
- attributeOverride = ((EmbeddedIdMapping) ormPersistentAttribute.getMapping()).specifiedAttributeOverrides().next();
- assertEquals("override", attributeOverride.getName());
- assertEquals("OVERRIDE_COLUMN", attributeOverride.getColumn().getSpecifiedName());
- }
-
- public void testEmbeddedMorphToOneToOneMapping() throws Exception {
- createTestEntityEmbeddedMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded");
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedMapping.isDefault());
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping);
- assertEquals("embedded", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedMorphToOneToManyMapping() throws Exception {
- createTestEntityEmbeddedMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded");
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedMapping.isDefault());
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping);
- assertEquals("embedded", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedMorphToManyToOneMapping() throws Exception {
- createTestEntityEmbeddedMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded");
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedMapping.isDefault());
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertEquals("embedded", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testEmbeddedMorphToManyToManyMapping() throws Exception {
- createTestEntityEmbeddedMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded");
-
- EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping();
- assertFalse(embeddedMapping.isDefault());
- XmlEmbedded embeddedResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0);
- embeddedResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- AttributeOverride attributeOverride = embeddedMapping.specifiedAttributeOverrides().next();
- attributeOverride.setName("override");
- attributeOverride.getColumn().setSpecifiedName("OVERRIDE_COLUMN");
- assertFalse(embeddedMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertEquals("embedded", ormPersistentAttribute.getMapping().getName());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java
deleted file mode 100644
index 1b3e0e13f0..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java
+++ /dev/null
@@ -1,1909 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.InheritanceType;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.context.java.JavaSecondaryTable;
-import org.eclipse.jpt.core.context.orm.OrmAssociationOverride;
-import org.eclipse.jpt.core.context.orm.OrmAttributeOverride;
-import org.eclipse.jpt.core.context.orm.OrmEmbeddable;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass;
-import org.eclipse.jpt.core.context.orm.OrmNamedNativeQuery;
-import org.eclipse.jpt.core.context.orm.OrmNamedQuery;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmSecondaryTable;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddable;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.orm.XmlMappedSuperclass;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmEntityTests extends ContextModelTestCase
-{
- public OrmEntityTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- }
-
- private IType createTestEntityDefaultFieldAccess() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private IType createTestEntityFieldAccess() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestEntityPropertyAccess() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
-
- public void testUpdateSpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormEntity.getSpecifiedName());
- assertNull(entityResource.getName());
-
- //set name in the resource model, verify context model updated
- entityResource.setName("foo");
- assertEquals("foo", ormEntity.getSpecifiedName());
- assertEquals("foo", entityResource.getName());
-
- //set name to null in the resource model
- entityResource.setName(null);
- assertNull(ormEntity.getSpecifiedName());
- assertNull(entityResource.getName());
- }
-
- public void testModifySpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormEntity.getSpecifiedName());
- assertNull(entityResource.getName());
-
- //set name in the context model, verify resource model modified
- ormEntity.setSpecifiedName("foo");
- assertEquals("foo", ormEntity.getSpecifiedName());
- assertEquals("foo", entityResource.getName());
-
- //set name to null in the context model
- ormEntity.setSpecifiedName(null);
- assertNull(ormEntity.getSpecifiedName());
- assertNull(entityResource.getName());
- }
-
- public void testUpdateDefaultName() throws Exception {
- createTestEntityFieldAccess();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals(TYPE_NAME, ormEntity.getDefaultName());
-
- ormEntity.getJavaEntity().setSpecifiedName("Foo");
- //xml default name is not affect by what is specified in java
- assertEquals(TYPE_NAME, ormEntity.getDefaultName());
-
- //set class in the resource model, verify context model updated
- entityResource.setClassName("com.Bar");
- assertEquals("Bar", ormEntity.getDefaultName());
-
- //set class to null in the resource model
- entityResource.setClassName(null);
- assertNull(ormEntity.getDefaultName());
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals("Foo", ormEntity.getName());
-
- //set class in the resource model, verify context model updated
- entityResource.setClassName("com.Bar");
- assertEquals("Bar", ormEntity.getName());
-
- entityResource.setName("Baz");
- assertEquals("Baz", ormEntity.getName());
-
- //set class to null in the resource model
- entityResource.setClassName(null);
- assertEquals("Baz", ormEntity.getName());
-
- entityResource.setName(null);
- assertNull(ormEntity.getName());
- }
-
- public void testUpdateClass() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals("model.Foo", ormEntity.getClass_());
- assertEquals("model.Foo", entityResource.getClassName());
-
- //set class in the resource model, verify context model updated
- entityResource.setClassName("com.Bar");
- assertEquals("com.Bar", ormEntity.getClass_());
- assertEquals("com.Bar", entityResource.getClassName());
-
- //set class to null in the resource model
- entityResource.setClassName(null);
- assertNull(ormEntity.getClass_());
- assertNull(entityResource.getClassName());
- }
-
- public void testModifyClass() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals("model.Foo", ormEntity.getClass_());
- assertEquals("model.Foo", entityResource.getClassName());
-
- //set class in the context model, verify resource model modified
- ormEntity.setClass("com.Bar");
- assertEquals("com.Bar", ormEntity.getClass_());
- assertEquals("com.Bar", entityResource.getClassName());
-
- //set class to null in the context model
- ormEntity.setClass(null);
- assertNull(ormEntity.getClass_());
- assertNull(entityResource.getClassName());
- }
- //TODO add tests for setting the className when the package is set on entity-mappings
-
- public void testUpdateSpecifiedAccess() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormEntity.getSpecifiedAccess());
- assertNull(entityResource.getAccess());
-
- //set access in the resource model, verify context model updated
- entityResource.setAccess(org.eclipse.jpt.core.resource.orm.AccessType.FIELD);
- assertEquals(AccessType.FIELD, ormEntity.getSpecifiedAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.FIELD, entityResource.getAccess());
-
- //set access to null in the resource model
- entityResource.setAccess(null);
- assertNull(ormEntity.getSpecifiedAccess());
- assertNull(entityResource.getAccess());
- }
-
- public void testModifySpecifiedAccess() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormEntity.getSpecifiedAccess());
- assertNull(entityResource.getAccess());
-
- //set access in the context model, verify resource model modified
- ormEntity.setSpecifiedAccess(AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, ormEntity.getSpecifiedAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, entityResource.getAccess());
-
- //set access to null in the context model
- ormEntity.setSpecifiedAccess(null);
- assertNull(ormEntity.getSpecifiedAccess());
- assertNull(entityResource.getAccess());
- }
-
- public void testUpdateDefaultAccessFromPersistenceUnitDefaults() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormEntity.getSpecifiedAccess());
- assertNull(ormEntity.getDefaultAccess());
- assertNull(entityResource.getAccess());
-
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(org.eclipse.jpt.core.resource.orm.AccessType.FIELD);
- assertEquals(AccessType.FIELD, ormEntity.getDefaultAccess());
- assertNull(ormEntity.getSpecifiedAccess());
- assertNull(entityResource.getAccess());
-
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, ormEntity.getDefaultAccess());
- assertNull(ormEntity.getSpecifiedAccess());
- assertNull(entityResource.getAccess());
-
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(null);
- assertNull(ormEntity.getSpecifiedAccess());
- assertNull(ormEntity.getDefaultAccess());
- assertNull(entityResource.getAccess());
- }
-
- public void testUpdateDefaultAccessFromJava() throws Exception {
- createTestEntityDefaultFieldAccess();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- //java has no annotations, so defaultAccess in xml is null
- assertNull(ormEntity.getDefaultAccess());
-
- entityMappings().setSpecifiedAccess(AccessType.FIELD);
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.PROPERTY);
- //entityMappings access wins over persistence-unit-defaults access
- assertEquals(AccessType.FIELD, ormEntity.getDefaultAccess());
-
- entityMappings().setSpecifiedAccess(null);
- //persistence-unit-defaults access used now
- assertEquals(AccessType.PROPERTY, ormEntity.getDefaultAccess());
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(null);
- assertNull(ormEntity.getDefaultAccess());
-
- ormPersistentType.getJavaPersistentType().getAttributeNamed("id").setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- //java has annotations on fields now, that should win in all cases
- assertEquals(AccessType.FIELD, ormEntity.getDefaultAccess());
-
- entityMappings().setSpecifiedAccess(AccessType.PROPERTY);
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.PROPERTY);
- assertEquals(AccessType.FIELD, ormEntity.getDefaultAccess());
-
- ormPersistentType.getJavaPersistentType().getAttributeNamed("id").setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertEquals(AccessType.PROPERTY, ormEntity.getDefaultAccess());
- }
-
- public void testUpdateDefaultAccessFromJavaFieldAccess() throws Exception {
- createTestEntityFieldAccess();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertEquals(AccessType.FIELD, ormEntity.getDefaultAccess());
-
- ormEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
- assertNull(ormEntity.getDefaultAccess());
-
- ormEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
- assertEquals(AccessType.FIELD, ormEntity.getDefaultAccess());
-
- entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertNull(ormEntity.getDefaultAccess());
-
- ormEntity.setSpecifiedMetadataComplete(null);
- assertNull(ormEntity.getDefaultAccess());
-
- entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertEquals(AccessType.FIELD, ormEntity.getDefaultAccess());
- }
-
- public void testUpdateDefaultAccessFromJavaPropertyAccess() throws Exception {
- createTestEntityPropertyAccess();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertEquals(AccessType.PROPERTY, ormEntity.getDefaultAccess());
-
- ormEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
- assertNull(ormEntity.getDefaultAccess());
-
- ormEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
- assertEquals(AccessType.PROPERTY, ormEntity.getDefaultAccess());
-
- entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertNull(ormEntity.getDefaultAccess());
-
- ormEntity.setSpecifiedMetadataComplete(null);
- assertNull(ormEntity.getDefaultAccess());
-
- entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertEquals(AccessType.PROPERTY, ormEntity.getDefaultAccess());
- }
-
- public void testUpdateDefaultAccessNoUnderlyingJava() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertNull(ormEntity.getDefaultAccess());
- }
-
- public void testUpdateSpecifiedMetadataComplete() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormEntity.getSpecifiedMetadataComplete());
- assertNull(entityResource.getMetadataComplete());
-
- //set metadata-complete in the resource model, verify context model updated
- entityResource.setMetadataComplete(Boolean.TRUE);
- assertEquals(Boolean.TRUE, ormEntity.getSpecifiedMetadataComplete());
- assertEquals(Boolean.TRUE, entityResource.getMetadataComplete());
-
- //set access to false in the resource model
- entityResource.setMetadataComplete(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormEntity.getSpecifiedMetadataComplete());
- assertEquals(Boolean.FALSE, entityResource.getMetadataComplete());
-
- entityResource.setMetadataComplete(null);
- assertNull(ormEntity.getSpecifiedMetadataComplete());
- assertNull(entityResource.getMetadataComplete());
- }
-
- public void testModifySpecifiedMetadataComplete() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormEntity.getSpecifiedMetadataComplete());
- assertNull(entityResource.getMetadataComplete());
-
- //set access in the context model, verify resource model modified
- ormEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
- assertTrue(ormEntity.getSpecifiedMetadataComplete().booleanValue());
- assertTrue(entityResource.getMetadataComplete().booleanValue());
-
- //set access to null in the context model
- ormEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
- assertFalse(ormEntity.getSpecifiedMetadataComplete().booleanValue());
- assertFalse(entityResource.getMetadataComplete().booleanValue());
-
- ormEntity.setSpecifiedMetadataComplete(null);
- assertNull(ormEntity.getSpecifiedMetadataComplete());
- assertNull(entityResource.getMetadataComplete());
- }
-
- public void testUpdateDefaultMetadataComplete() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormEntity.getSpecifiedMetadataComplete());
- assertFalse(ormEntity.isDefaultMetadataComplete());
- assertNull(entityResource.getMetadataComplete());
-
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertTrue(ormEntity.isDefaultMetadataComplete());
- assertNull(ormEntity.getSpecifiedMetadataComplete());
- assertNull(entityResource.getMetadataComplete());
-
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertNull(ormEntity.getSpecifiedMetadataComplete());
- assertFalse(ormEntity.isDefaultMetadataComplete());
- assertNull(entityResource.getMetadataComplete());
-
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- ormEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormEntity.getSpecifiedMetadataComplete());
- assertTrue(ormEntity.isDefaultMetadataComplete());
- assertTrue(ormEntity.isMetadataComplete());
- }
-
- public void testUpdateMetadataComplete() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormEntity.getSpecifiedMetadataComplete());
- assertFalse(ormEntity.isMetadataComplete());
- assertNull(entityResource.getMetadataComplete());
-
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertTrue(ormEntity.isMetadataComplete());
- assertNull(ormEntity.getSpecifiedMetadataComplete());
- assertNull(entityResource.getMetadataComplete());
-
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertFalse(ormEntity.isMetadataComplete());
- assertNull(ormEntity.getSpecifiedMetadataComplete());
- assertNull(entityResource.getMetadataComplete());
- }
-
-
- public void testUpdateInheritanceStrategy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals(InheritanceType.SINGLE_TABLE, ormEntity.getInheritanceStrategy());
- assertNull(entityResource.getInheritance());
-
- //set inheritance strategy in the resource model, verify context model updated
- entityResource.setInheritance(OrmFactory.eINSTANCE.createInheritance());
- entityResource.getInheritance().setStrategy(org.eclipse.jpt.core.resource.orm.InheritanceType.TABLE_PER_CLASS);
-
- assertEquals(InheritanceType.TABLE_PER_CLASS, ormEntity.getInheritanceStrategy());
- assertEquals(org.eclipse.jpt.core.resource.orm.InheritanceType.TABLE_PER_CLASS, entityResource.getInheritance().getStrategy());
- }
-
- public void testUpdateDefaultInheritanceStrategyFromJava() throws Exception {
- createTestEntityDefaultFieldAccess();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- //no inheritance strategy specified in java so single-table is default
- assertEquals(InheritanceType.SINGLE_TABLE, ormEntity.getDefaultInheritanceStrategy());
-
- ormEntity.getJavaEntity().setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- assertEquals(InheritanceType.JOINED, ormEntity.getDefaultInheritanceStrategy());
-
- ormEntity.setSpecifiedInheritanceStrategy(InheritanceType.TABLE_PER_CLASS);
- //inheritance tag exists in xml, so it overrides anything in java
- assertEquals(InheritanceType.SINGLE_TABLE, ormEntity.getDefaultInheritanceStrategy());
-
- ormEntity.setSpecifiedInheritanceStrategy(null);
- assertEquals(InheritanceType.JOINED, ormEntity.getDefaultInheritanceStrategy());
-
- ormEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(InheritanceType.SINGLE_TABLE, ormEntity.getDefaultInheritanceStrategy());
-
- ormEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
- assertEquals(InheritanceType.JOINED, ormEntity.getDefaultInheritanceStrategy());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- //this setting overrides the false meta-data complete found on ormEntity
- assertEquals(InheritanceType.SINGLE_TABLE, ormEntity.getDefaultInheritanceStrategy());
- }
-
- public void testUpdateDefaultInheritanceStrategyFromParent() throws Exception {
- createTestEntityDefaultFieldAccess();
- createTestSubType();
-
- OrmPersistentType parentPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentType childPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
- OrmEntity parentXmlEntity = (OrmEntity) parentPersistentType.getMapping();
- OrmEntity childXmlEntity = (OrmEntity) childPersistentType.getMapping();
-
- assertEquals(parentXmlEntity, childXmlEntity.getParentEntity());
- assertEquals(InheritanceType.SINGLE_TABLE, childXmlEntity.getDefaultInheritanceStrategy());
-
- //change root inheritance strategy, verify default is changed for child entity
- parentXmlEntity.setSpecifiedInheritanceStrategy(InheritanceType.TABLE_PER_CLASS);
- assertEquals(InheritanceType.SINGLE_TABLE, parentXmlEntity.getDefaultInheritanceStrategy());
- assertEquals(InheritanceType.TABLE_PER_CLASS, childXmlEntity.getDefaultInheritanceStrategy());
- assertNull(childXmlEntity.getSpecifiedInheritanceStrategy());
-
- //set specified inheritance strategy in java and verify defaults in xml are correct
- parentXmlEntity.setSpecifiedInheritanceStrategy(null);
- parentXmlEntity.getJavaEntity().setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- assertEquals(InheritanceType.JOINED, parentXmlEntity.getDefaultInheritanceStrategy());
- assertEquals(InheritanceType.JOINED, childXmlEntity.getDefaultInheritanceStrategy());
- assertNull(parentXmlEntity.getSpecifiedInheritanceStrategy());
- assertNull(childXmlEntity.getSpecifiedInheritanceStrategy());
-
- parentPersistentType.getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertEquals(InheritanceType.SINGLE_TABLE, parentXmlEntity.getDefaultInheritanceStrategy());
- assertEquals(InheritanceType.SINGLE_TABLE, childXmlEntity.getDefaultInheritanceStrategy());
- }
-
- public void testUpdateSpecifiedInheritanceStrategy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormEntity.getSpecifiedInheritanceStrategy());
- assertNull(entityResource.getInheritance());
-
- //set strategy in the resource model, verify context model updated
- entityResource.setInheritance(OrmFactory.eINSTANCE.createInheritance());
- entityResource.getInheritance().setStrategy(org.eclipse.jpt.core.resource.orm.InheritanceType.JOINED);
- assertEquals(InheritanceType.JOINED, ormEntity.getSpecifiedInheritanceStrategy());
- assertEquals(org.eclipse.jpt.core.resource.orm.InheritanceType.JOINED, entityResource.getInheritance().getStrategy());
-
- //set strategy to null in the resource model
- entityResource.getInheritance().setStrategy(null);
- assertNull(ormEntity.getSpecifiedInheritanceStrategy());
- assertNull(entityResource.getInheritance().getStrategy());
-
- entityResource.getInheritance().setStrategy(org.eclipse.jpt.core.resource.orm.InheritanceType.SINGLE_TABLE);
- assertEquals(InheritanceType.SINGLE_TABLE, ormEntity.getSpecifiedInheritanceStrategy());
- assertEquals(org.eclipse.jpt.core.resource.orm.InheritanceType.SINGLE_TABLE, entityResource.getInheritance().getStrategy());
-
- entityResource.setInheritance(null);
- assertNull(ormEntity.getSpecifiedInheritanceStrategy());
- assertNull(entityResource.getInheritance());
- }
-
- public void testModifySpecifiedInheritanceStrategy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormEntity.getSpecifiedInheritanceStrategy());
- assertNull(entityResource.getInheritance());
-
- //set strategy in the context model, verify resource model modified
- ormEntity.setSpecifiedInheritanceStrategy(InheritanceType.TABLE_PER_CLASS);
- assertEquals(InheritanceType.TABLE_PER_CLASS, ormEntity.getSpecifiedInheritanceStrategy());
- assertEquals(org.eclipse.jpt.core.resource.orm.InheritanceType.TABLE_PER_CLASS, entityResource.getInheritance().getStrategy());
-
- //set strategy to null in the context model
- ormEntity.setSpecifiedInheritanceStrategy(null);
- assertNull(ormEntity.getSpecifiedInheritanceStrategy());
- assertNull(entityResource.getInheritance());
- }
-
- public void testAddSpecifiedSecondaryTable() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- OrmSecondaryTable secondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- secondaryTable.setSpecifiedName("FOO");
-
- assertEquals("FOO", entityResource.getSecondaryTables().get(0).getName());
-
- OrmSecondaryTable secondaryTable2 = ormEntity.addSpecifiedSecondaryTable(0);
- secondaryTable2.setSpecifiedName("BAR");
-
- assertEquals("BAR", entityResource.getSecondaryTables().get(0).getName());
- assertEquals("FOO", entityResource.getSecondaryTables().get(1).getName());
-
- OrmSecondaryTable secondaryTable3 = ormEntity.addSpecifiedSecondaryTable(1);
- secondaryTable3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", entityResource.getSecondaryTables().get(0).getName());
- assertEquals("BAZ", entityResource.getSecondaryTables().get(1).getName());
- assertEquals("FOO", entityResource.getSecondaryTables().get(2).getName());
-
- ListIterator<OrmSecondaryTable> secondaryTables = ormEntity.specifiedSecondaryTables();
- assertEquals(secondaryTable2, secondaryTables.next());
- assertEquals(secondaryTable3, secondaryTables.next());
- assertEquals(secondaryTable, secondaryTables.next());
-
- secondaryTables = ormEntity.specifiedSecondaryTables();
- assertEquals("BAR", secondaryTables.next().getName());
- assertEquals("BAZ", secondaryTables.next().getName());
- assertEquals("FOO", secondaryTables.next().getName());
- }
-
- public void testRemoveSpecifiedSecondaryTable() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- ormEntity.addSpecifiedSecondaryTable(0).setSpecifiedName("FOO");
- ormEntity.addSpecifiedSecondaryTable(1).setSpecifiedName("BAR");
- ormEntity.addSpecifiedSecondaryTable(2).setSpecifiedName("BAZ");
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals(3, entityResource.getSecondaryTables().size());
-
- ormEntity.removeSpecifiedSecondaryTable(0);
- assertEquals(2, entityResource.getSecondaryTables().size());
- assertEquals("BAR", entityResource.getSecondaryTables().get(0).getName());
- assertEquals("BAZ", entityResource.getSecondaryTables().get(1).getName());
-
- ormEntity.removeSpecifiedSecondaryTable(0);
- assertEquals(1, entityResource.getSecondaryTables().size());
- assertEquals("BAZ", entityResource.getSecondaryTables().get(0).getName());
-
- ormEntity.removeSpecifiedSecondaryTable(0);
- assertEquals(0, entityResource.getSecondaryTables().size());
- }
-
- public void testMoveSpecifiedSecondaryTable() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- ormEntity.addSpecifiedSecondaryTable(0).setSpecifiedName("FOO");
- ormEntity.addSpecifiedSecondaryTable(1).setSpecifiedName("BAR");
- ormEntity.addSpecifiedSecondaryTable(2).setSpecifiedName("BAZ");
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals(3, entityResource.getSecondaryTables().size());
-
-
- ormEntity.moveSpecifiedSecondaryTable(2, 0);
- ListIterator<OrmSecondaryTable> secondaryTables = ormEntity.specifiedSecondaryTables();
- assertEquals("BAR", secondaryTables.next().getName());
- assertEquals("BAZ", secondaryTables.next().getName());
- assertEquals("FOO", secondaryTables.next().getName());
-
- assertEquals("BAR", entityResource.getSecondaryTables().get(0).getName());
- assertEquals("BAZ", entityResource.getSecondaryTables().get(1).getName());
- assertEquals("FOO", entityResource.getSecondaryTables().get(2).getName());
-
-
- ormEntity.moveSpecifiedSecondaryTable(0, 1);
- secondaryTables = ormEntity.specifiedSecondaryTables();
- assertEquals("BAZ", secondaryTables.next().getName());
- assertEquals("BAR", secondaryTables.next().getName());
- assertEquals("FOO", secondaryTables.next().getName());
-
- assertEquals("BAZ", entityResource.getSecondaryTables().get(0).getName());
- assertEquals("BAR", entityResource.getSecondaryTables().get(1).getName());
- assertEquals("FOO", entityResource.getSecondaryTables().get(2).getName());
- }
-
- public void testUpdateSecondaryTables() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getSecondaryTables().add(OrmFactory.eINSTANCE.createXmlSecondaryTableImpl());
- entityResource.getSecondaryTables().add(OrmFactory.eINSTANCE.createXmlSecondaryTableImpl());
- entityResource.getSecondaryTables().add(OrmFactory.eINSTANCE.createXmlSecondaryTableImpl());
-
- entityResource.getSecondaryTables().get(0).setName("FOO");
- entityResource.getSecondaryTables().get(1).setName("BAR");
- entityResource.getSecondaryTables().get(2).setName("BAZ");
-
- ListIterator<OrmSecondaryTable> secondaryTables = ormEntity.specifiedSecondaryTables();
- assertEquals("FOO", secondaryTables.next().getName());
- assertEquals("BAR", secondaryTables.next().getName());
- assertEquals("BAZ", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
-
- entityResource.getSecondaryTables().move(2, 0);
- secondaryTables = ormEntity.specifiedSecondaryTables();
- assertEquals("BAR", secondaryTables.next().getName());
- assertEquals("BAZ", secondaryTables.next().getName());
- assertEquals("FOO", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
-
- entityResource.getSecondaryTables().move(0, 1);
- secondaryTables = ormEntity.specifiedSecondaryTables();
- assertEquals("BAZ", secondaryTables.next().getName());
- assertEquals("BAR", secondaryTables.next().getName());
- assertEquals("FOO", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
-
- entityResource.getSecondaryTables().remove(1);
- secondaryTables = ormEntity.specifiedSecondaryTables();
- assertEquals("BAZ", secondaryTables.next().getName());
- assertEquals("FOO", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
-
- entityResource.getSecondaryTables().remove(1);
- secondaryTables = ormEntity.specifiedSecondaryTables();
- assertEquals("BAZ", secondaryTables.next().getName());
- assertFalse(secondaryTables.hasNext());
-
- entityResource.getSecondaryTables().remove(0);
- assertFalse(ormEntity.specifiedSecondaryTables().hasNext());
- }
-
- public void testVirtualSecondaryTables() throws Exception {
- createTestEntityFieldAccess();
- createTestSubType();
-
- OrmPersistentType parentPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentType childPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
- OrmEntity parentOrmEntity = (OrmEntity) parentPersistentType.getMapping();
- OrmEntity childOrmEntity = (OrmEntity) childPersistentType.getMapping();
- JavaEntity javaEntity = childOrmEntity.getJavaEntity();
-
- JavaSecondaryTable javaSecondaryTableFoo = javaEntity.addSpecifiedSecondaryTable(0);
- javaSecondaryTableFoo.setSpecifiedName("FOO");
- OrmSecondaryTable virtualSecondaryTableFoo = childOrmEntity.virtualSecondaryTables().next();
- assertEquals("FOO", childOrmEntity.secondaryTables().next().getName());
- assertEquals("FOO", virtualSecondaryTableFoo.getName());
- assertEquals(0, virtualSecondaryTableFoo.specifiedPrimaryKeyJoinColumnsSize());
- assertEquals("id", virtualSecondaryTableFoo.getDefaultPrimaryKeyJoinColumn().getDefaultName());
- assertEquals("id", virtualSecondaryTableFoo.getDefaultPrimaryKeyJoinColumn().getDefaultReferencedColumnName());
-
- assertEquals(0, childOrmEntity.specifiedSecondaryTablesSize());
- assertEquals(1, childOrmEntity.virtualSecondaryTablesSize());
- assertEquals(1, childOrmEntity.secondaryTablesSize());
-
- javaEntity.addSpecifiedSecondaryTable(0).setSpecifiedName("BAR");
- ListIterator<OrmSecondaryTable> virtualSecondaryTables = childOrmEntity.virtualSecondaryTables();
- ListIterator<OrmSecondaryTable> secondaryTables = childOrmEntity.secondaryTables();
- assertEquals("BAR", virtualSecondaryTables.next().getName());
- assertEquals("FOO", virtualSecondaryTables.next().getName());
- assertEquals("BAR", secondaryTables.next().getName());
- assertEquals("FOO", secondaryTables.next().getName());
- assertEquals(0, childOrmEntity.specifiedSecondaryTablesSize());
- assertEquals(2, childOrmEntity.virtualSecondaryTablesSize());
- assertEquals(2, childOrmEntity.secondaryTablesSize());
-
- childOrmEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(0, childOrmEntity.virtualSecondaryTablesSize());
-
- childOrmEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
- assertEquals(2, childOrmEntity.virtualSecondaryTablesSize());
-
-
- childOrmEntity.setSecondaryTablesDefinedInXml(true);
- assertEquals(0, childOrmEntity.virtualSecondaryTablesSize());
- assertEquals(2, childOrmEntity.specifiedSecondaryTablesSize());
- assertEquals(2, childOrmEntity.secondaryTablesSize());
- ListIterator<OrmSecondaryTable> specifiedSecondaryTables = childOrmEntity.specifiedSecondaryTables();
- assertEquals("BAR", specifiedSecondaryTables.next().getName());
- OrmSecondaryTable specifiedSecondaryTableFoo = specifiedSecondaryTables.next();
- assertEquals("FOO", specifiedSecondaryTableFoo.getName());
- assertEquals(0, specifiedSecondaryTableFoo.specifiedPrimaryKeyJoinColumnsSize());
- assertEquals("id", specifiedSecondaryTableFoo.getDefaultPrimaryKeyJoinColumn().getDefaultName());
- assertEquals("id", specifiedSecondaryTableFoo.getDefaultPrimaryKeyJoinColumn().getDefaultReferencedColumnName());
-
-
- childOrmEntity.removeSpecifiedSecondaryTable(0);
- assertEquals(0, childOrmEntity.virtualSecondaryTablesSize());
- assertEquals(1, childOrmEntity.specifiedSecondaryTablesSize());
- assertEquals(1, childOrmEntity.secondaryTablesSize());
- assertEquals("FOO", childOrmEntity.specifiedSecondaryTables().next().getName());
-
-
- childOrmEntity.removeSpecifiedSecondaryTable(0);
- assertEquals(0, childOrmEntity.specifiedSecondaryTablesSize());
- assertEquals(2, childOrmEntity.virtualSecondaryTablesSize());
- assertEquals(2, childOrmEntity.secondaryTablesSize());
- virtualSecondaryTables = childOrmEntity.virtualSecondaryTables();
- assertEquals("BAR", virtualSecondaryTables.next().getName());
- assertEquals("FOO", virtualSecondaryTables.next().getName());
-
-
- //add a specified secondary table to the parent, this will not affect virtual secondaryTables in child
- parentOrmEntity.addSpecifiedSecondaryTable(0).setSpecifiedName("PARENT_TABLE");
- assertEquals(2, childOrmEntity.virtualSecondaryTablesSize());
- }
-
- //test that inherited tables don't show up in this list
- public void testAssociatedTables() throws Exception {
-
- }
-
- public void testAssociatedTableNamesIncludingInherited() throws Exception {
-
- }
-
- public void testTableNameIsInvalid() throws Exception {
-
- }
-
- public void testMakeEntityEmbeddable() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity entity = (OrmEntity) entityPersistentType.getMapping();
- entity.setSpecifiedAccess(AccessType.PROPERTY);
- entity.setSpecifiedDiscriminatorValue("DISC_VALUE");
- entity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- entity.setSpecifiedMetadataComplete(Boolean.TRUE);
- entity.setSpecifiedName("ENTITY_NAME");
-
- entityPersistentType.setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
-
- XmlEmbeddable embeddable = ormResource().getEntityMappings().getEmbeddables().get(0);
- assertEquals("model.Foo", embeddable.getClassName());
- assertEquals(Boolean.TRUE, embeddable.getMetadataComplete());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, embeddable.getAccess());
-
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) entityPersistentType.getMapping();
- assertEquals("model.Foo", ormEmbeddable.getClass_());
- assertEquals(Boolean.TRUE, ormEmbeddable.getSpecifiedMetadataComplete());
- assertEquals(AccessType.PROPERTY, ormEmbeddable.getSpecifiedAccess());
- }
-
- //TODO test that attribute mappings are not removed when changing type mapping.
- public void testMakeEntityEmbeddable2() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
- OrmEntity entity = (OrmEntity) entityPersistentType.getMapping();
- entity.setSpecifiedAccess(AccessType.PROPERTY);
- entity.setSpecifiedDiscriminatorValue("DISC_VALUE");
- entity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- entity.setSpecifiedMetadataComplete(Boolean.TRUE);
- entity.setSpecifiedName("ENTITY_NAME");
-// entityPersistentType.addSpecifiedPersistentAttribute(IMappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
-
- entityPersistentType.setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
-
- XmlEmbeddable embeddable = ormResource().getEntityMappings().getEmbeddables().get(0);
- assertEquals("model.Foo", embeddable.getClassName());
- assertEquals(Boolean.TRUE, embeddable.getMetadataComplete());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, embeddable.getAccess());
-// assertEquals("basicMapping", embeddable.getAttributes().getBasics().get(0).getName());
-
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) entityPersistentType.getMapping();
- assertEquals("model.Foo", ormEmbeddable.getClass_());
- assertEquals(Boolean.TRUE, ormEmbeddable.getSpecifiedMetadataComplete());
- assertEquals(AccessType.PROPERTY, ormEmbeddable.getSpecifiedAccess());
-// assertEquals("basicMapping", ormEmbeddable.persistentType().attributes().next().getName());
- }
-
- public void testMakeEntityMappedSuperclass() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity entity = (OrmEntity) entityPersistentType.getMapping();
- entity.setSpecifiedAccess(AccessType.PROPERTY);
- entity.setSpecifiedDiscriminatorValue("DISC_VALUE");
- entity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- entity.setSpecifiedMetadataComplete(Boolean.TRUE);
- entity.setSpecifiedName("ENTITY_NAME");
-
- entityPersistentType.setMappingKey(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY);
-
- XmlMappedSuperclass mappedSuperclass = ormResource().getEntityMappings().getMappedSuperclasses().get(0);
- assertEquals("model.Foo", mappedSuperclass.getClassName());
- assertEquals(Boolean.TRUE, mappedSuperclass.getMetadataComplete());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, mappedSuperclass.getAccess());
-
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) entityPersistentType.getMapping();
- assertEquals("model.Foo", ormMappedSuperclass.getClass_());
- assertEquals(Boolean.TRUE, ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertEquals(AccessType.PROPERTY, ormMappedSuperclass.getSpecifiedAccess());
- }
-
- public void testMakeEntityMappedSuperclass2() throws Exception {
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity entity = (OrmEntity) entityPersistentType.getMapping();
- entity.setSpecifiedAccess(AccessType.PROPERTY);
- entity.setSpecifiedDiscriminatorValue("DISC_VALUE");
- entity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- entity.setSpecifiedMetadataComplete(Boolean.TRUE);
- entity.setSpecifiedName("ENTITY_NAME");
-
- entityPersistentType.setMappingKey(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY);
-
- XmlMappedSuperclass mappedSuperclass = ormResource().getEntityMappings().getMappedSuperclasses().get(0);
- assertEquals("model.Foo", mappedSuperclass.getClassName());
- assertEquals(Boolean.TRUE, mappedSuperclass.getMetadataComplete());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, mappedSuperclass.getAccess());
-
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) entityPersistentType.getMapping();
- assertEquals("model.Foo", ormMappedSuperclass.getClass_());
- assertEquals(Boolean.TRUE, ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertEquals(AccessType.PROPERTY, ormMappedSuperclass.getSpecifiedAccess());
- }
-
-
- public void testAddSequenceGenerator() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormEntity.getSequenceGenerator());
- assertNull(entityResource.getSequenceGenerator());
-
- ormEntity.addSequenceGenerator();
-
- assertNotNull(entityResource.getSequenceGenerator());
- assertNotNull(ormEntity.getSequenceGenerator());
-
- //try adding another sequence generator, should get an IllegalStateException
- try {
- ormEntity.addSequenceGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testRemoveSequenceGenerator() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormEntity.getSequenceGenerator());
- assertNull(entityResource.getSequenceGenerator());
-
- ormEntity.addSequenceGenerator();
- assertNotNull(entityResource.getSequenceGenerator());
- assertNotNull(ormEntity.getSequenceGenerator());
-
- ormEntity.removeSequenceGenerator();
-
- assertNull(ormEntity.getSequenceGenerator());
- assertNull(entityResource.getSequenceGenerator());
-
- //try removing the sequence generator again, should get an IllegalStateException
- try {
- ormEntity.removeSequenceGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testUpdateSequenceGenerator() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormEntity.getSequenceGenerator());
- assertNull(entityResource.getSequenceGenerator());
- assertEquals(0, CollectionTools.size(ormEntity.getPersistenceUnit().allGenerators()));
-
- entityResource.setSequenceGenerator(OrmFactory.eINSTANCE.createXmlSequenceGeneratorImpl());
-
- assertNotNull(ormEntity.getSequenceGenerator());
- assertNotNull(entityResource.getSequenceGenerator());
- assertEquals(1, CollectionTools.size(ormEntity.getPersistenceUnit().allGenerators()));
-
- ormEntity.getSequenceGenerator().setName("foo");
- assertEquals(1, CollectionTools.size(ormEntity.getPersistenceUnit().allGenerators()));
-
- entityResource.setSequenceGenerator(null);
- assertNull(ormEntity.getSequenceGenerator());
- assertNull(entityResource.getSequenceGenerator());
- assertEquals(0, CollectionTools.size(ormEntity.getPersistenceUnit().allGenerators()));
- }
-
- public void testAddTableGenerator() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormEntity.getTableGenerator());
- assertNull(entityResource.getTableGenerator());
-
- ormEntity.addTableGenerator();
-
- assertNotNull(entityResource.getTableGenerator());
- assertNotNull(ormEntity.getTableGenerator());
-
- //try adding another table generator, should get an IllegalStateException
- try {
- ormEntity.addTableGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testRemoveTableGenerator() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormEntity.getTableGenerator());
- assertNull(entityResource.getTableGenerator());
-
- ormEntity.addTableGenerator();
- assertNotNull(entityResource.getTableGenerator());
- assertNotNull(ormEntity.getTableGenerator());
-
- ormEntity.removeTableGenerator();
-
- assertNull(ormEntity.getTableGenerator());
- assertNull(entityResource.getTableGenerator());
-
- //try removing the table generator again, should get an IllegalStateException
- try {
- ormEntity.removeTableGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testUpdateTableGenerator() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormEntity.getTableGenerator());
- assertNull(entityResource.getTableGenerator());
- assertEquals(0, CollectionTools.size(ormEntity.getPersistenceUnit().allGenerators()));
-
- entityResource.setTableGenerator(OrmFactory.eINSTANCE.createXmlTableGeneratorImpl());
-
- assertNotNull(ormEntity.getTableGenerator());
- assertNotNull(entityResource.getTableGenerator());
- assertEquals(1, CollectionTools.size(ormEntity.getPersistenceUnit().allGenerators()));
-
- ormEntity.getTableGenerator().setName("foo");
- assertEquals(1, CollectionTools.size(ormEntity.getPersistenceUnit().allGenerators()));
-
- entityResource.setTableGenerator(null);
- assertNull(ormEntity.getTableGenerator());
- assertNull(entityResource.getTableGenerator());
- assertEquals(0, CollectionTools.size(ormEntity.getPersistenceUnit().allGenerators()));
- }
-
- public void testUpdateDiscriminatorColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNotNull(ormEntity.getDiscriminatorColumn());
-
- entityResource.setDiscriminatorColumn(OrmFactory.eINSTANCE.createXmlDiscriminatorColumn());
- entityResource.getDiscriminatorColumn().setName("FOO");
-
- assertEquals("FOO", ormEntity.getDiscriminatorColumn().getSpecifiedName());
- assertEquals("FOO", entityResource.getDiscriminatorColumn().getName());
-
- entityResource.getDiscriminatorColumn().setName(null);
-
- assertNull(ormEntity.getDiscriminatorColumn().getSpecifiedName());
- assertNull(entityResource.getDiscriminatorColumn().getName());
-
- entityResource.setDiscriminatorColumn(null);
-
- assertNotNull(ormEntity.getDiscriminatorColumn());
- }
-
- public void testUpdateDiscriminatorValue() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormEntity.getSpecifiedDiscriminatorValue());
- assertNull(entityResource.getDiscriminatorValue());
-
- entityResource.setDiscriminatorValue("FOO");
-
- assertEquals("FOO", ormEntity.getSpecifiedDiscriminatorValue());
- assertEquals("FOO", entityResource.getDiscriminatorValue());
-
- entityResource.setDiscriminatorValue(null);
-
- assertNull(ormEntity.getSpecifiedDiscriminatorValue());
- assertNull(entityResource.getDiscriminatorValue());
- }
-
- public void testModifyDiscriminatorValue() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormEntity.getSpecifiedDiscriminatorValue());
- assertNull(entityResource.getDiscriminatorValue());
-
- ormEntity.setSpecifiedDiscriminatorValue("FOO");
-
- assertEquals("FOO", ormEntity.getSpecifiedDiscriminatorValue());
- assertEquals("FOO", entityResource.getDiscriminatorValue());
-
- ormEntity.setSpecifiedDiscriminatorValue(null);
-
- assertNull(ormEntity.getSpecifiedDiscriminatorValue());
- assertNull(entityResource.getDiscriminatorValue());
- }
-
- public void testAddSpecifiedPrimaryKeyJoinColumn() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- OrmPrimaryKeyJoinColumn primaryKeyJoinColumn = ormEntity.addSpecifiedPrimaryKeyJoinColumn(0);
- primaryKeyJoinColumn.setSpecifiedName("FOO");
-
- assertEquals("FOO", entityResource.getPrimaryKeyJoinColumns().get(0).getName());
-
- OrmPrimaryKeyJoinColumn primaryKeyJoinColumn2 = ormEntity.addSpecifiedPrimaryKeyJoinColumn(0);
- primaryKeyJoinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", entityResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("FOO", entityResource.getPrimaryKeyJoinColumns().get(1).getName());
-
- OrmPrimaryKeyJoinColumn primaryKeyJoinColumn3 = ormEntity.addSpecifiedPrimaryKeyJoinColumn(1);
- primaryKeyJoinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", entityResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("BAZ", entityResource.getPrimaryKeyJoinColumns().get(1).getName());
- assertEquals("FOO", entityResource.getPrimaryKeyJoinColumns().get(2).getName());
-
- ListIterator<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns = ormEntity.specifiedPrimaryKeyJoinColumns();
- assertEquals(primaryKeyJoinColumn2, primaryKeyJoinColumns.next());
- assertEquals(primaryKeyJoinColumn3, primaryKeyJoinColumns.next());
- assertEquals(primaryKeyJoinColumn, primaryKeyJoinColumns.next());
-
- primaryKeyJoinColumns = ormEntity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- }
-
- public void testRemoveSpecifiedPrimaryKeyJoinColumn() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- ormEntity.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- ormEntity.addSpecifiedPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- ormEntity.addSpecifiedPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals(3, entityResource.getPrimaryKeyJoinColumns().size());
-
- ormEntity.removeSpecifiedPrimaryKeyJoinColumn(0);
- assertEquals(2, entityResource.getPrimaryKeyJoinColumns().size());
- assertEquals("BAR", entityResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("BAZ", entityResource.getPrimaryKeyJoinColumns().get(1).getName());
-
- ormEntity.removeSpecifiedPrimaryKeyJoinColumn(0);
- assertEquals(1, entityResource.getPrimaryKeyJoinColumns().size());
- assertEquals("BAZ", entityResource.getPrimaryKeyJoinColumns().get(0).getName());
-
- ormEntity.removeSpecifiedPrimaryKeyJoinColumn(0);
- assertEquals(0, entityResource.getPrimaryKeyJoinColumns().size());
- }
-
- public void testMoveSpecifiedPrimaryKeyJoinColumn() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- ormEntity.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- ormEntity.addSpecifiedPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- ormEntity.addSpecifiedPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals(3, entityResource.getPrimaryKeyJoinColumns().size());
-
-
- ormEntity.moveSpecifiedPrimaryKeyJoinColumn(2, 0);
- ListIterator<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns = ormEntity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
-
- assertEquals("BAR", entityResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("BAZ", entityResource.getPrimaryKeyJoinColumns().get(1).getName());
- assertEquals("FOO", entityResource.getPrimaryKeyJoinColumns().get(2).getName());
-
-
- ormEntity.moveSpecifiedPrimaryKeyJoinColumn(0, 1);
- primaryKeyJoinColumns = ormEntity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
-
- assertEquals("BAZ", entityResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("BAR", entityResource.getPrimaryKeyJoinColumns().get(1).getName());
- assertEquals("FOO", entityResource.getPrimaryKeyJoinColumns().get(2).getName());
- }
-
- public void testUpdatePrimaryKeyJoinColumns() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getPrimaryKeyJoinColumns().add(OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl());
- entityResource.getPrimaryKeyJoinColumns().add(OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl());
- entityResource.getPrimaryKeyJoinColumns().add(OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl());
-
- entityResource.getPrimaryKeyJoinColumns().get(0).setName("FOO");
- entityResource.getPrimaryKeyJoinColumns().get(1).setName("BAR");
- entityResource.getPrimaryKeyJoinColumns().get(2).setName("BAZ");
-
- ListIterator<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns = ormEntity.specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- entityResource.getPrimaryKeyJoinColumns().move(2, 0);
- primaryKeyJoinColumns = ormEntity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- entityResource.getPrimaryKeyJoinColumns().move(0, 1);
- primaryKeyJoinColumns = ormEntity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- entityResource.getPrimaryKeyJoinColumns().remove(1);
- primaryKeyJoinColumns = ormEntity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- entityResource.getPrimaryKeyJoinColumns().remove(1);
- primaryKeyJoinColumns = ormEntity.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- entityResource.getPrimaryKeyJoinColumns().remove(0);
- assertFalse(ormEntity.specifiedPrimaryKeyJoinColumns().hasNext());
- }
-
-// public void testAddSpecifiedAttributeOverride() throws Exception {
-// OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-// XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-//
-// OrmAttributeOverride attributeOverride = ormEntity.addSpecifiedAttributeOverride(0);
-// attributeOverride.setName("FOO");
-//
-// assertEquals("FOO", entityResource.getAttributeOverrides().get(0).getName());
-//
-// OrmAttributeOverride attributeOverride2 = ormEntity.addSpecifiedAttributeOverride(0);
-// attributeOverride2.setName("BAR");
-//
-// assertEquals("BAR", entityResource.getAttributeOverrides().get(0).getName());
-// assertEquals("FOO", entityResource.getAttributeOverrides().get(1).getName());
-//
-// OrmAttributeOverride attributeOverride3 = ormEntity.addSpecifiedAttributeOverride(1);
-// attributeOverride3.setName("BAZ");
-//
-// assertEquals("BAR", entityResource.getAttributeOverrides().get(0).getName());
-// assertEquals("BAZ", entityResource.getAttributeOverrides().get(1).getName());
-// assertEquals("FOO", entityResource.getAttributeOverrides().get(2).getName());
-//
-// ListIterator<OrmAttributeOverride> attributeOverrides = ormEntity.specifiedAttributeOverrides();
-// assertEquals(attributeOverride2, attributeOverrides.next());
-// assertEquals(attributeOverride3, attributeOverrides.next());
-// assertEquals(attributeOverride, attributeOverrides.next());
-//
-// attributeOverrides = ormEntity.specifiedAttributeOverrides();
-// assertEquals("BAR", attributeOverrides.next().getName());
-// assertEquals("BAZ", attributeOverrides.next().getName());
-// assertEquals("FOO", attributeOverrides.next().getName());
-// }
-//
-// public void testRemoveSpecifiedAttributeOverride() throws Exception {
-// OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-//
-// ormEntity.addSpecifiedAttributeOverride(0).setName("FOO");
-// ormEntity.addSpecifiedAttributeOverride(1).setName("BAR");
-// ormEntity.addSpecifiedAttributeOverride(2).setName("BAZ");
-//
-// XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-// assertEquals(3, entityResource.getAttributeOverrides().size());
-//
-// ormEntity.removeSpecifiedAttributeOverride(0);
-// assertEquals(2, entityResource.getAttributeOverrides().size());
-// assertEquals("BAR", entityResource.getAttributeOverrides().get(0).getName());
-// assertEquals("BAZ", entityResource.getAttributeOverrides().get(1).getName());
-//
-// ormEntity.removeSpecifiedAttributeOverride(0);
-// assertEquals(1, entityResource.getAttributeOverrides().size());
-// assertEquals("BAZ", entityResource.getAttributeOverrides().get(0).getName());
-//
-// ormEntity.removeSpecifiedAttributeOverride(0);
-// assertEquals(0, entityResource.getAttributeOverrides().size());
-// }
-
- public void testMoveSpecifiedAttributeOverride() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- entityResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- entityResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
-
- entityResource.getAttributeOverrides().get(0).setName("FOO");
- entityResource.getAttributeOverrides().get(1).setName("BAR");
- entityResource.getAttributeOverrides().get(2).setName("BAZ");
-
- assertEquals(3, entityResource.getAttributeOverrides().size());
-
-
- ormEntity.moveSpecifiedAttributeOverride(2, 0);
- ListIterator<OrmAttributeOverride> attributeOverrides = ormEntity.specifiedAttributeOverrides();
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
-
- assertEquals("BAR", entityResource.getAttributeOverrides().get(0).getName());
- assertEquals("BAZ", entityResource.getAttributeOverrides().get(1).getName());
- assertEquals("FOO", entityResource.getAttributeOverrides().get(2).getName());
-
-
- ormEntity.moveSpecifiedAttributeOverride(0, 1);
- attributeOverrides = ormEntity.specifiedAttributeOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
-
- assertEquals("BAZ", entityResource.getAttributeOverrides().get(0).getName());
- assertEquals("BAR", entityResource.getAttributeOverrides().get(1).getName());
- assertEquals("FOO", entityResource.getAttributeOverrides().get(2).getName());
- }
-
- public void testUpdateAttributeOverrides() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- entityResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
- entityResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl());
-
- entityResource.getAttributeOverrides().get(0).setName("FOO");
- entityResource.getAttributeOverrides().get(1).setName("BAR");
- entityResource.getAttributeOverrides().get(2).setName("BAZ");
-
- ListIterator<OrmAttributeOverride> attributeOverrides = ormEntity.specifiedAttributeOverrides();
- assertEquals("FOO", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().move(2, 0);
- attributeOverrides = ormEntity.specifiedAttributeOverrides();
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().move(0, 1);
- attributeOverrides = ormEntity.specifiedAttributeOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().remove(1);
- attributeOverrides = ormEntity.specifiedAttributeOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().remove(1);
- attributeOverrides = ormEntity.specifiedAttributeOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().remove(0);
- assertFalse(ormEntity.specifiedAttributeOverrides().hasNext());
- }
-
-// public void testAddSpecifiedAssociationOverride() throws Exception {
-// OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-// XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-//
-// OrmAssociationOverride associationOverride = ormEntity.addSpecifiedAssociationOverride(0);
-// associationOverride.setName("FOO");
-//
-// assertEquals("FOO", entityResource.getAssociationOverrides().get(0).getName());
-//
-// OrmAssociationOverride associationOverride2 = ormEntity.addSpecifiedAssociationOverride(0);
-// associationOverride2.setName("BAR");
-//
-// assertEquals("BAR", entityResource.getAssociationOverrides().get(0).getName());
-// assertEquals("FOO", entityResource.getAssociationOverrides().get(1).getName());
-//
-// OrmAssociationOverride associationOverride3 = ormEntity.addSpecifiedAssociationOverride(1);
-// associationOverride3.setName("BAZ");
-//
-// assertEquals("BAR", entityResource.getAssociationOverrides().get(0).getName());
-// assertEquals("BAZ", entityResource.getAssociationOverrides().get(1).getName());
-// assertEquals("FOO", entityResource.getAssociationOverrides().get(2).getName());
-//
-// ListIterator<OrmAssociationOverride> associationOverrides = ormEntity.specifiedAssociationOverrides();
-// assertEquals(associationOverride2, associationOverrides.next());
-// assertEquals(associationOverride3, associationOverrides.next());
-// assertEquals(associationOverride, associationOverrides.next());
-//
-// associationOverrides = ormEntity.specifiedAssociationOverrides();
-// assertEquals("BAR", associationOverrides.next().getName());
-// assertEquals("BAZ", associationOverrides.next().getName());
-// assertEquals("FOO", associationOverrides.next().getName());
-// }
-//
-// public void testRemoveSpecifiedAssociationOverride() throws Exception {
-// OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-//
-// ormEntity.addSpecifiedAssociationOverride(0).setName("FOO");
-// ormEntity.addSpecifiedAssociationOverride(1).setName("BAR");
-// ormEntity.addSpecifiedAssociationOverride(2).setName("BAZ");
-//
-// XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-// assertEquals(3, entityResource.getAssociationOverrides().size());
-//
-// ormEntity.removeSpecifiedAssociationOverride(0);
-// assertEquals(2, entityResource.getAssociationOverrides().size());
-// assertEquals("BAR", entityResource.getAssociationOverrides().get(0).getName());
-// assertEquals("BAZ", entityResource.getAssociationOverrides().get(1).getName());
-//
-// ormEntity.removeSpecifiedAssociationOverride(0);
-// assertEquals(1, entityResource.getAssociationOverrides().size());
-// assertEquals("BAZ", entityResource.getAssociationOverrides().get(0).getName());
-//
-// ormEntity.removeSpecifiedAssociationOverride(0);
-// assertEquals(0, entityResource.getAssociationOverrides().size());
-// }
-
- public void testMoveSpecifiedAssociationOverride() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverrideImpl());
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverrideImpl());
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverrideImpl());
-
- entityResource.getAssociationOverrides().get(0).setName("FOO");
- entityResource.getAssociationOverrides().get(1).setName("BAR");
- entityResource.getAssociationOverrides().get(2).setName("BAZ");
-
- assertEquals(3, entityResource.getAssociationOverrides().size());
-
-
- ormEntity.moveSpecifiedAssociationOverride(2, 0);
- ListIterator<OrmAssociationOverride> associationOverrides = ormEntity.specifiedAssociationOverrides();
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
-
- assertEquals("BAR", entityResource.getAssociationOverrides().get(0).getName());
- assertEquals("BAZ", entityResource.getAssociationOverrides().get(1).getName());
- assertEquals("FOO", entityResource.getAssociationOverrides().get(2).getName());
-
-
- ormEntity.moveSpecifiedAssociationOverride(0, 1);
- associationOverrides = ormEntity.specifiedAssociationOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
-
- assertEquals("BAZ", entityResource.getAssociationOverrides().get(0).getName());
- assertEquals("BAR", entityResource.getAssociationOverrides().get(1).getName());
- assertEquals("FOO", entityResource.getAssociationOverrides().get(2).getName());
- }
-
- public void testUpdateAssociationOverrides() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverrideImpl());
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverrideImpl());
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverrideImpl());
-
- entityResource.getAssociationOverrides().get(0).setName("FOO");
- entityResource.getAssociationOverrides().get(1).setName("BAR");
- entityResource.getAssociationOverrides().get(2).setName("BAZ");
-
- ListIterator<OrmAssociationOverride> associationOverrides = ormEntity.specifiedAssociationOverrides();
- assertEquals("FOO", associationOverrides.next().getName());
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("BAZ", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- entityResource.getAssociationOverrides().move(2, 0);
- associationOverrides = ormEntity.specifiedAssociationOverrides();
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- entityResource.getAssociationOverrides().move(0, 1);
- associationOverrides = ormEntity.specifiedAssociationOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- entityResource.getAssociationOverrides().remove(1);
- associationOverrides = ormEntity.specifiedAssociationOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- entityResource.getAssociationOverrides().remove(1);
- associationOverrides = ormEntity.specifiedAssociationOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- entityResource.getAssociationOverrides().remove(0);
- assertFalse(ormEntity.specifiedAssociationOverrides().hasNext());
- }
-
-
- public void testAddNamedQuery() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- OrmNamedQuery namedQuery = ormEntity.addNamedQuery(0);
- namedQuery.setName("FOO");
-
- assertEquals("FOO", entityResource.getNamedQueries().get(0).getName());
-
- OrmNamedQuery namedQuery2 = ormEntity.addNamedQuery(0);
- namedQuery2.setName("BAR");
-
- assertEquals("BAR", entityResource.getNamedQueries().get(0).getName());
- assertEquals("FOO", entityResource.getNamedQueries().get(1).getName());
-
- OrmNamedQuery namedQuery3 = ormEntity.addNamedQuery(1);
- namedQuery3.setName("BAZ");
-
- assertEquals("BAR", entityResource.getNamedQueries().get(0).getName());
- assertEquals("BAZ", entityResource.getNamedQueries().get(1).getName());
- assertEquals("FOO", entityResource.getNamedQueries().get(2).getName());
-
- ListIterator<OrmNamedQuery> namedQueries = ormEntity.namedQueries();
- assertEquals(namedQuery2, namedQueries.next());
- assertEquals(namedQuery3, namedQueries.next());
- assertEquals(namedQuery, namedQueries.next());
-
- namedQueries = ormEntity.namedQueries();
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- }
-
- public void testRemoveNamedQuery() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- ormEntity.addNamedQuery(0).setName("FOO");
- ormEntity.addNamedQuery(1).setName("BAR");
- ormEntity.addNamedQuery(2).setName("BAZ");
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals(3, entityResource.getNamedQueries().size());
-
- ormEntity.removeNamedQuery(0);
- assertEquals(2, entityResource.getNamedQueries().size());
- assertEquals("BAR", entityResource.getNamedQueries().get(0).getName());
- assertEquals("BAZ", entityResource.getNamedQueries().get(1).getName());
-
- ormEntity.removeNamedQuery(0);
- assertEquals(1, entityResource.getNamedQueries().size());
- assertEquals("BAZ", entityResource.getNamedQueries().get(0).getName());
-
- ormEntity.removeNamedQuery(0);
- assertEquals(0, entityResource.getNamedQueries().size());
- }
-
- public void testMoveNamedQuery() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- ormEntity.addNamedQuery(0).setName("FOO");
- ormEntity.addNamedQuery(1).setName("BAR");
- ormEntity.addNamedQuery(2).setName("BAZ");
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals(3, entityResource.getNamedQueries().size());
-
-
- ormEntity.moveNamedQuery(2, 0);
- ListIterator<OrmNamedQuery> namedQueries = ormEntity.namedQueries();
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
-
- assertEquals("BAR", entityResource.getNamedQueries().get(0).getName());
- assertEquals("BAZ", entityResource.getNamedQueries().get(1).getName());
- assertEquals("FOO", entityResource.getNamedQueries().get(2).getName());
-
-
- ormEntity.moveNamedQuery(0, 1);
- namedQueries = ormEntity.namedQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
-
- assertEquals("BAZ", entityResource.getNamedQueries().get(0).getName());
- assertEquals("BAR", entityResource.getNamedQueries().get(1).getName());
- assertEquals("FOO", entityResource.getNamedQueries().get(2).getName());
- }
-
- public void testUpdateNamedQueries() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- assertEquals(0, CollectionTools.size(ormEntity.getPersistenceUnit().allQueries()));
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getNamedQueries().add(OrmFactory.eINSTANCE.createXmlNamedQuery());
- entityResource.getNamedQueries().add(OrmFactory.eINSTANCE.createXmlNamedQuery());
- entityResource.getNamedQueries().add(OrmFactory.eINSTANCE.createXmlNamedQuery());
- entityResource.getNamedQueries().get(0).setName("FOO");
- entityResource.getNamedQueries().get(1).setName("BAR");
- entityResource.getNamedQueries().get(2).setName("BAZ");
-
- ListIterator<OrmNamedQuery> namedQueries = ormEntity.namedQueries();
- assertEquals("FOO", namedQueries.next().getName());
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
- assertEquals(3, CollectionTools.size(ormEntity.getPersistenceUnit().allQueries()));
-
- entityResource.getNamedQueries().move(2, 0);
- namedQueries = ormEntity.namedQueries();
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
-
- entityResource.getNamedQueries().move(0, 1);
- namedQueries = ormEntity.namedQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("BAR", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
-
- entityResource.getNamedQueries().remove(1);
- namedQueries = ormEntity.namedQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertEquals("FOO", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
- assertEquals(2, CollectionTools.size(ormEntity.getPersistenceUnit().allQueries()));
-
- entityResource.getNamedQueries().remove(1);
- namedQueries = ormEntity.namedQueries();
- assertEquals("BAZ", namedQueries.next().getName());
- assertFalse(namedQueries.hasNext());
- assertEquals(1, CollectionTools.size(ormEntity.getPersistenceUnit().allQueries()));
-
- entityResource.getNamedQueries().remove(0);
- assertFalse(ormEntity.namedQueries().hasNext());
- assertEquals(0, CollectionTools.size(ormEntity.getPersistenceUnit().allQueries()));
- }
-
- public void testAddNamedNativeQuery() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- OrmNamedNativeQuery namedNativeQuery = ormEntity.addNamedNativeQuery(0);
- namedNativeQuery.setName("FOO");
-
- assertEquals("FOO", entityResource.getNamedNativeQueries().get(0).getName());
-
- OrmNamedNativeQuery namedNativeQuery2 = ormEntity.addNamedNativeQuery(0);
- namedNativeQuery2.setName("BAR");
-
- assertEquals("BAR", entityResource.getNamedNativeQueries().get(0).getName());
- assertEquals("FOO", entityResource.getNamedNativeQueries().get(1).getName());
-
- OrmNamedNativeQuery namedNativeQuery3 = ormEntity.addNamedNativeQuery(1);
- namedNativeQuery3.setName("BAZ");
-
- assertEquals("BAR", entityResource.getNamedNativeQueries().get(0).getName());
- assertEquals("BAZ", entityResource.getNamedNativeQueries().get(1).getName());
- assertEquals("FOO", entityResource.getNamedNativeQueries().get(2).getName());
-
- ListIterator<OrmNamedNativeQuery> namedNativeQueries = ormEntity.namedNativeQueries();
- assertEquals(namedNativeQuery2, namedNativeQueries.next());
- assertEquals(namedNativeQuery3, namedNativeQueries.next());
- assertEquals(namedNativeQuery, namedNativeQueries.next());
-
- namedNativeQueries = ormEntity.namedNativeQueries();
- assertEquals("BAR", namedNativeQueries.next().getName());
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertEquals("FOO", namedNativeQueries.next().getName());
- }
-
- public void testRemoveNamedNativeQuery() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- ormEntity.addNamedNativeQuery(0).setName("FOO");
- ormEntity.addNamedNativeQuery(1).setName("BAR");
- ormEntity.addNamedNativeQuery(2).setName("BAZ");
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals(3, entityResource.getNamedNativeQueries().size());
-
- ormEntity.removeNamedNativeQuery(0);
- assertEquals(2, entityResource.getNamedNativeQueries().size());
- assertEquals("BAR", entityResource.getNamedNativeQueries().get(0).getName());
- assertEquals("BAZ", entityResource.getNamedNativeQueries().get(1).getName());
-
- ormEntity.removeNamedNativeQuery(0);
- assertEquals(1, entityResource.getNamedNativeQueries().size());
- assertEquals("BAZ", entityResource.getNamedNativeQueries().get(0).getName());
-
- ormEntity.removeNamedNativeQuery(0);
- assertEquals(0, entityResource.getNamedNativeQueries().size());
- }
-
- public void testMoveNamedNativeQuery() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- ormEntity.addNamedNativeQuery(0).setName("FOO");
- ormEntity.addNamedNativeQuery(1).setName("BAR");
- ormEntity.addNamedNativeQuery(2).setName("BAZ");
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals(3, entityResource.getNamedNativeQueries().size());
-
-
- ormEntity.moveNamedNativeQuery(2, 0);
- ListIterator<OrmNamedNativeQuery> namedNativeQueries = ormEntity.namedNativeQueries();
- assertEquals("BAR", namedNativeQueries.next().getName());
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertEquals("FOO", namedNativeQueries.next().getName());
-
- assertEquals("BAR", entityResource.getNamedNativeQueries().get(0).getName());
- assertEquals("BAZ", entityResource.getNamedNativeQueries().get(1).getName());
- assertEquals("FOO", entityResource.getNamedNativeQueries().get(2).getName());
-
-
- ormEntity.moveNamedNativeQuery(0, 1);
- namedNativeQueries = ormEntity.namedNativeQueries();
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertEquals("BAR", namedNativeQueries.next().getName());
- assertEquals("FOO", namedNativeQueries.next().getName());
-
- assertEquals("BAZ", entityResource.getNamedNativeQueries().get(0).getName());
- assertEquals("BAR", entityResource.getNamedNativeQueries().get(1).getName());
- assertEquals("FOO", entityResource.getNamedNativeQueries().get(2).getName());
- }
-
- public void testUpdateNamedNativeQueries() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- assertEquals(0, CollectionTools.size(ormEntity.getPersistenceUnit().allQueries()));
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- entityResource.getNamedNativeQueries().add(OrmFactory.eINSTANCE.createXmlNamedNativeQuery());
- entityResource.getNamedNativeQueries().add(OrmFactory.eINSTANCE.createXmlNamedNativeQuery());
- entityResource.getNamedNativeQueries().add(OrmFactory.eINSTANCE.createXmlNamedNativeQuery());
- entityResource.getNamedNativeQueries().get(0).setName("FOO");
- entityResource.getNamedNativeQueries().get(1).setName("BAR");
- entityResource.getNamedNativeQueries().get(2).setName("BAZ");
- ListIterator<OrmNamedNativeQuery> namedNativeQueries = ormEntity.namedNativeQueries();
- assertEquals("FOO", namedNativeQueries.next().getName());
- assertEquals("BAR", namedNativeQueries.next().getName());
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertFalse(namedNativeQueries.hasNext());
- assertEquals(3, CollectionTools.size(ormEntity.getPersistenceUnit().allQueries()));
-
- entityResource.getNamedNativeQueries().move(2, 0);
- namedNativeQueries = ormEntity.namedNativeQueries();
- assertEquals("BAR", namedNativeQueries.next().getName());
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertEquals("FOO", namedNativeQueries.next().getName());
- assertFalse(namedNativeQueries.hasNext());
-
- entityResource.getNamedNativeQueries().move(0, 1);
- namedNativeQueries = ormEntity.namedNativeQueries();
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertEquals("BAR", namedNativeQueries.next().getName());
- assertEquals("FOO", namedNativeQueries.next().getName());
- assertFalse(namedNativeQueries.hasNext());
-
- entityResource.getNamedNativeQueries().remove(1);
- namedNativeQueries = ormEntity.namedNativeQueries();
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertEquals("FOO", namedNativeQueries.next().getName());
- assertFalse(namedNativeQueries.hasNext());
- assertEquals(2, CollectionTools.size(ormEntity.getPersistenceUnit().allQueries()));
-
- entityResource.getNamedNativeQueries().remove(1);
- namedNativeQueries = ormEntity.namedNativeQueries();
- assertEquals("BAZ", namedNativeQueries.next().getName());
- assertFalse(namedNativeQueries.hasNext());
- assertEquals(1, CollectionTools.size(ormEntity.getPersistenceUnit().allQueries()));
-
- entityResource.getNamedNativeQueries().remove(0);
- assertFalse(ormEntity.namedNativeQueries().hasNext());
- assertEquals(0, CollectionTools.size(ormEntity.getPersistenceUnit().allQueries()));
- }
-
- public void testUpdateIdClass() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormEntity.getIdClass());
- assertNull(entityResource.getIdClass());
-
- entityResource.setIdClass(OrmFactory.eINSTANCE.createXmlIdClass());
-
- assertNull(ormEntity.getIdClass());
- assertNotNull(entityResource.getIdClass());
-
- entityResource.getIdClass().setClassName("model.Foo");
- assertEquals("model.Foo", ormEntity.getIdClass());
- assertEquals("model.Foo", entityResource.getIdClass().getClassName());
-
- //test setting @IdClass value to null, id-class tag is not removed
- entityResource.getIdClass().setClassName(null);
- assertNull(ormEntity.getIdClass());
- assertNotNull(entityResource.getIdClass());
-
- //reset @IdClass value and then remove id-class tag
- entityResource.setIdClass(OrmFactory.eINSTANCE.createXmlIdClass());
- entityResource.getIdClass().setClassName("model.Foo");
- entityResource.setIdClass(null);
-
- assertNull(ormEntity.getIdClass());
- assertNull(entityResource.getIdClass());
- }
-
- public void testModifyIdClass() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- assertNull(ormEntity.getIdClass());
- assertNull(entityResource.getIdClass());
-
- ormEntity.setIdClass("model.Foo");
- assertEquals("model.Foo", entityResource.getIdClass().getClassName());
- assertEquals("model.Foo", ormEntity.getIdClass());
-
- ormEntity.setIdClass(null);
- assertNull(ormEntity.getIdClass());
- assertNull(entityResource.getIdClass());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmGeneratedValueTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmGeneratedValueTests.java
deleted file mode 100644
index 7a95b4027a..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmGeneratedValueTests.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmGeneratedValue;
-import org.eclipse.jpt.core.context.orm.OrmIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.XmlGeneratedValue;
-import org.eclipse.jpt.core.resource.orm.XmlId;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmGeneratedValueTests extends ContextModelTestCase
-{
- public OrmGeneratedValueTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- public void testUpdateSpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- OrmGeneratedValue ormGeneratedValue = ormIdMapping.addGeneratedValue();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
- XmlGeneratedValue generatedValueResource = idResource.getGeneratedValue();
-
- //set generator in the resource model, verify context model updated
- generatedValueResource.setGenerator("FOO");
- assertEquals("FOO", ormGeneratedValue.getSpecifiedGenerator());
- assertEquals("FOO", generatedValueResource.getGenerator());
-
- //set name to null in the resource model
- generatedValueResource.setGenerator(null);
- assertNull(ormGeneratedValue.getSpecifiedGenerator());
- assertNull(generatedValueResource.getGenerator());
- }
-
- public void testModifySpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- OrmGeneratedValue ormGeneratedValue = ormIdMapping.addGeneratedValue();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
- XmlGeneratedValue generatedValueResource = idResource.getGeneratedValue();
-
- //set name in the context model, verify resource model modified
- ormGeneratedValue.setSpecifiedGenerator("FOO");
- assertEquals("FOO", generatedValueResource.getGenerator());
- assertEquals("FOO", ormGeneratedValue.getSpecifiedGenerator());
-
- //set name to null in the context model
- ormGeneratedValue.setSpecifiedGenerator(null);
- assertNull(generatedValueResource.getGenerator());
- assertNull(ormGeneratedValue.getSpecifiedGenerator());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmIdMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmIdMappingTests.java
deleted file mode 100644
index 5fde4d5f1a..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmIdMappingTests.java
+++ /dev/null
@@ -1,796 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.GenerationType;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.TemporalType;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.orm.OrmColumn;
-import org.eclipse.jpt.core.context.orm.OrmGeneratedValue;
-import org.eclipse.jpt.core.context.orm.OrmIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmSequenceGenerator;
-import org.eclipse.jpt.core.context.orm.OrmTableGenerator;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlId;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmIdMappingTests extends ContextModelTestCase
-{
- public OrmIdMappingTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception{
- this.createAnnotationAndMembers("Id", "");
- }
-
- private void createColumnAnnotation() throws Exception{
- this.createAnnotationAndMembers("Column",
- "String name() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";" +
- "int length() default 255;" +
- "int precision() default 0;" +
- "int scale() default 0;");
- }
-
- private void createTemporalAnnotation() throws Exception{
- this.createAnnotationAndMembers("Temporal", "TemporalType value();");
- }
-
- private void createGeneratedValueAnnotation() throws Exception{
- this.createAnnotationAndMembers("GeneratedValue",
- "GenerationType strategy() default AUTO;" +
- "String generator() default \"\"; ");
- }
-
-
- private void createSequenceGeneratorAnnotation() throws Exception{
- this.createAnnotationAndMembers("SequenceGenerator",
- "String name();" +
- "String sequenceName() default \"\"; " +
- "int initialValue() default 0; " +
- "int allocationSize() default 50;");
- }
-
- private void createTableGeneratorAnnotation() throws Exception{
- this.createAnnotationAndMembers("TableGenerator",
- "String name(); " +
- "String table() default \"\"; " +
- "String catalog() default \"\"; " +
- "String schema() default \"\";" +
- "String pkColumnName() default \"\"; " +
- "String valueColumnName() default \"\"; " +
- "String pkColumnValue() default \"\"; " +
- "int initialValue() default 0; " +
- "int allocationSize() default 50; " +
- "UniqueConstraint[] uniqueConstraints() default {};");
- }
-
- private IType createTestEntityIdMapping() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
- createColumnAnnotation();
- createTemporalAnnotation();
- createGeneratedValueAnnotation();
- createSequenceGeneratorAnnotation();
- createTableGeneratorAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.COLUMN, JPA.TEMPORAL, JPA.TEMPORAL_TYPE, JPA.GENERATED_VALUE, JPA.GENERATION_TYPE, JPA.TABLE_GENERATOR, JPA.SEQUENCE_GENERATOR);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- sb.append(CR);
- sb.append(" @Column(name=\"MY_COLUMN\", unique=true, nullable=false, insertable=false, updatable=false, columnDefinition=\"COLUMN_DEFINITION\", table=\"MY_TABLE\", length=5, precision=6, scale=7)");
- sb.append(CR);
- sb.append(" @Temporal(TemporalType.TIMESTAMP)");
- sb.append(CR);
- sb.append(" @GeneratedValue(strategy=GenerationType.TABLE, generator=\"myTableGenerator\")");
- sb.append(CR);
- sb.append(" @TableGenerator(name=\"myTableGenerator\", table=\"myTable\", catalog=\"myCatalog\", schema=\"mySchema\", pkColumnName=\"myPkColumnName\", valueColumnName=\"myValueColumnName\", pkColumnValue=\"myPkColumnValue\", initialValue=1, allocationSize=1)");
- sb.append(CR);
- sb.append(" @SequenceGenerator(name=\"mySequenceGenerator\")");
- }
- });
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertEquals("idMapping", ormIdMapping.getName());
- assertEquals("idMapping", idResource.getName());
-
- //set name in the resource model, verify context model updated
- idResource.setName("newName");
- assertEquals("newName", ormIdMapping.getName());
- assertEquals("newName", idResource.getName());
-
- //set name to null in the resource model
- idResource.setName(null);
- assertNull(ormIdMapping.getName());
- assertNull(idResource.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertEquals("idMapping", ormIdMapping.getName());
- assertEquals("idMapping", idResource.getName());
-
- //set name in the context model, verify resource model updated
- ormIdMapping.setName("newName");
- assertEquals("newName", ormIdMapping.getName());
- assertEquals("newName", idResource.getName());
-
- //set name to null in the context model
- ormIdMapping.setName(null);
- assertNull(ormIdMapping.getName());
- assertNull(idResource.getName());
- }
-
- public void testUpdateTemporal() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertNull(ormIdMapping.getTemporal());
- assertNull(idResource.getTemporal());
-
- //set temporal in the resource model, verify context model updated
- idResource.setTemporal(org.eclipse.jpt.core.resource.orm.TemporalType.DATE);
- assertEquals(TemporalType.DATE, ormIdMapping.getTemporal());
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.DATE, idResource.getTemporal());
-
- idResource.setTemporal(org.eclipse.jpt.core.resource.orm.TemporalType.TIME);
- assertEquals(TemporalType.TIME, ormIdMapping.getTemporal());
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.TIME, idResource.getTemporal());
-
- idResource.setTemporal(org.eclipse.jpt.core.resource.orm.TemporalType.TIMESTAMP);
- assertEquals(TemporalType.TIMESTAMP, ormIdMapping.getTemporal());
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.TIMESTAMP, idResource.getTemporal());
-
- //set temporal to null in the resource model
- idResource.setTemporal(null);
- assertNull(ormIdMapping.getTemporal());
- assertNull(idResource.getTemporal());
- }
-
- public void testModifyTemporal() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertNull(ormIdMapping.getTemporal());
- assertNull(idResource.getTemporal());
-
- //set temporal in the context model, verify resource model updated
- ormIdMapping.setTemporal(TemporalType.DATE);
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.DATE, idResource.getTemporal());
- assertEquals(TemporalType.DATE, ormIdMapping.getTemporal());
-
- ormIdMapping.setTemporal(TemporalType.TIME);
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.TIME, idResource.getTemporal());
- assertEquals(TemporalType.TIME, ormIdMapping.getTemporal());
-
- ormIdMapping.setTemporal(TemporalType.TIMESTAMP);
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.TIMESTAMP, idResource.getTemporal());
- assertEquals(TemporalType.TIMESTAMP, ormIdMapping.getTemporal());
-
- //set temporal to null in the context model
- ormIdMapping.setTemporal(null);
- assertNull(idResource.getTemporal());
- assertNull(ormIdMapping.getTemporal());
- }
-
- //TODO test defaults
- //TODO test overriding java mapping with a different mapping type in xml
-
-
- public void testAddSequenceGenerator() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertNull(ormIdMapping.getSequenceGenerator());
- assertNull(idResource.getSequenceGenerator());
-
- ormIdMapping.addSequenceGenerator();
-
- assertNotNull(idResource.getSequenceGenerator());
- assertNotNull(ormIdMapping.getSequenceGenerator());
-
- //try adding another sequence generator, should get an IllegalStateException
- try {
- ormIdMapping.addSequenceGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testRemoveSequenceGenerator() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertNull(ormIdMapping.getSequenceGenerator());
- assertNull(idResource.getSequenceGenerator());
-
- ormIdMapping.addSequenceGenerator();
- assertNotNull(idResource.getSequenceGenerator());
- assertNotNull(ormIdMapping.getSequenceGenerator());
-
- ormIdMapping.removeSequenceGenerator();
-
- assertNull(ormIdMapping.getSequenceGenerator());
- assertNull(idResource.getSequenceGenerator());
-
- //try removing the sequence generator again, should get an IllegalStateException
- try {
- ormIdMapping.removeSequenceGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testUpdateSequenceGenerator() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertNull(ormIdMapping.getSequenceGenerator());
- assertNull(idResource.getSequenceGenerator());
- assertEquals(0, CollectionTools.size(ormIdMapping.getPersistenceUnit().allGenerators()));
-
- idResource.setSequenceGenerator(OrmFactory.eINSTANCE.createXmlSequenceGeneratorImpl());
- assertNotNull(ormIdMapping.getSequenceGenerator());
- assertNotNull(idResource.getSequenceGenerator());
- assertEquals(1, CollectionTools.size(ormIdMapping.getPersistenceUnit().allGenerators()));
-
- ormIdMapping.getSequenceGenerator().setName("foo");
- assertEquals(1, CollectionTools.size(ormIdMapping.getPersistenceUnit().allGenerators()));
-
- idResource.setSequenceGenerator(null);
- assertNull(ormIdMapping.getSequenceGenerator());
- assertNull(idResource.getSequenceGenerator());
- assertEquals(0, CollectionTools.size(ormIdMapping.getPersistenceUnit().allGenerators()));
- }
-
- public void testAddTableGenerator() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertNull(ormIdMapping.getTableGenerator());
- assertNull(idResource.getTableGenerator());
-
- ormIdMapping.addTableGenerator();
-
- assertNotNull(idResource.getTableGenerator());
- assertNotNull(ormIdMapping.getTableGenerator());
-
- //try adding another table generator, should get an IllegalStateException
- try {
- ormIdMapping.addTableGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testRemoveTableGenerator() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertNull(ormIdMapping.getTableGenerator());
- assertNull(idResource.getTableGenerator());
-
- ormIdMapping.addTableGenerator();
- assertNotNull(idResource.getTableGenerator());
- assertNotNull(ormIdMapping.getTableGenerator());
-
- ormIdMapping.removeTableGenerator();
-
- assertNull(ormIdMapping.getTableGenerator());
- assertNull(idResource.getTableGenerator());
-
- //try removing the table generator again, should get an IllegalStateException
- try {
- ormIdMapping.removeTableGenerator();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testUpdateTableGenerator() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertNull(ormIdMapping.getTableGenerator());
- assertNull(idResource.getTableGenerator());
- assertEquals(0, CollectionTools.size(ormIdMapping.getPersistenceUnit().allGenerators()));
-
- idResource.setTableGenerator(OrmFactory.eINSTANCE.createXmlTableGeneratorImpl());
- assertNotNull(ormIdMapping.getTableGenerator());
- assertNotNull(idResource.getTableGenerator());
- assertEquals(1, CollectionTools.size(ormIdMapping.getPersistenceUnit().allGenerators()));
-
- ormIdMapping.getTableGenerator().setName("foo");
- assertEquals(1, CollectionTools.size(ormIdMapping.getPersistenceUnit().allGenerators()));
-
- idResource.setTableGenerator(null);
- assertNull(ormIdMapping.getTableGenerator());
- assertNull(idResource.getTableGenerator());
- assertEquals(0, CollectionTools.size(ormIdMapping.getPersistenceUnit().allGenerators()));
- }
-
- public void testAddGeneratedValue() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertNull(ormIdMapping.getGeneratedValue());
- assertNull(idResource.getGeneratedValue());
-
- ormIdMapping.addGeneratedValue();
-
- assertNotNull(idResource.getGeneratedValue());
- assertNotNull(ormIdMapping.getGeneratedValue());
-
- //try adding another sequence generator, should get an IllegalStateException
- try {
- ormIdMapping.addGeneratedValue();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testRemoveGeneratedValue() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertNull(ormIdMapping.getGeneratedValue());
- assertNull(idResource.getGeneratedValue());
-
- ormIdMapping.addGeneratedValue();
- assertNotNull(idResource.getGeneratedValue());
- assertNotNull(ormIdMapping.getGeneratedValue());
-
- ormIdMapping.removeGeneratedValue();
-
- assertNull(ormIdMapping.getGeneratedValue());
- assertNull(idResource.getGeneratedValue());
-
- //try removing the sequence generator again, should get an IllegalStateException
- try {
- ormIdMapping.removeGeneratedValue();
- } catch (IllegalStateException e) {
- return;
- }
- fail("IllegalStateException not thrown");
- }
-
- public void testUpdateGeneratedValue() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId idResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertNull(ormIdMapping.getGeneratedValue());
- assertNull(idResource.getGeneratedValue());
-
- idResource.setGeneratedValue(OrmFactory.eINSTANCE.createXmlGeneratedValueImpl());
-
- assertNotNull(ormIdMapping.getGeneratedValue());
- assertNotNull(idResource.getGeneratedValue());
-
- idResource.setGeneratedValue(null);
- assertNull(ormIdMapping.getGeneratedValue());
- assertNull(idResource.getGeneratedValue());
- }
-
-
- public void testIdMappingNoUnderylingJavaAttribute() throws Exception {
- createTestEntityIdMapping();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "foo");
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("foo", ormIdMapping.getName());
- assertNull(ormIdMapping.getTemporal());
- assertNull(ormIdMapping.getGeneratedValue());
- assertNull(ormIdMapping.getSequenceGenerator());
- assertNull(ormIdMapping.getTableGenerator());
-
-
- OrmColumn ormColumn = ormIdMapping.getColumn();
- assertNull(ormColumn.getSpecifiedName());
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(ormColumn.getColumnDefinition());
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(ormColumn.getSpecifiedPrecision());
- assertNull(ormColumn.getSpecifiedScale());
-
- assertEquals("foo", ormColumn.getDefaultName());
- assertEquals(Boolean.FALSE, ormColumn.getDefaultUnique());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultNullable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultUpdatable());
- assertEquals(null, ormColumn.getColumnDefinition());
- assertEquals(TYPE_NAME, ormColumn.getDefaultTable());
- assertEquals(Integer.valueOf(255), ormColumn.getDefaultLength());
- assertEquals(Integer.valueOf(0), ormColumn.getDefaultPrecision());
- assertEquals(Integer.valueOf(0), ormColumn.getDefaultScale());
- }
-
- //@Basic(fetch=FetchType.LAZY, optional=false)
- //@Column(name="MY_COLUMN", unique=true, nullable=false, insertable=false, updatable=false,
- // columnDefinition="COLUMN_DEFINITION", table="MY_TABLE", length=5, precision=6, scale=7)");
- //@Column(
- //@Lob
- //@Temporal(TemporalType.TIMESTAMP)
- //@Enumerated(EnumType.STRING)
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- assertEquals("id", ormIdMapping.getName());
- assertEquals(TemporalType.TIMESTAMP, ormIdMapping.getTemporal());
-
- OrmColumn ormColumn = ormIdMapping.getColumn();
- assertEquals("MY_COLUMN", ormColumn.getSpecifiedName());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUnique());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUpdatable());
- assertEquals("COLUMN_DEFINITION", ormColumn.getColumnDefinition());
- assertEquals("MY_TABLE", ormColumn.getSpecifiedTable());
- assertEquals(Integer.valueOf(5), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(6), ormColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(7), ormColumn.getSpecifiedScale());
-
- OrmGeneratedValue ormGeneratedValue = ormIdMapping.getGeneratedValue();
- assertEquals("myTableGenerator", ormGeneratedValue.getSpecifiedGenerator());
- assertEquals(GenerationType.TABLE, ormGeneratedValue.getSpecifiedStrategy());
-
- OrmTableGenerator ormTableGenerator = ormIdMapping.getTableGenerator();
- assertEquals("myTableGenerator", ormTableGenerator.getName());
- assertEquals("myTable", ormTableGenerator.getSpecifiedTable());
- assertEquals("myCatalog", ormTableGenerator.getSpecifiedCatalog());
- assertEquals("mySchema", ormTableGenerator.getSpecifiedSchema());
- assertEquals("myPkColumnName", ormTableGenerator.getSpecifiedPkColumnName());
- assertEquals("myPkColumnValue", ormTableGenerator.getSpecifiedPkColumnValue());
- assertEquals("myValueColumnName", ormTableGenerator.getSpecifiedValueColumnName());
- assertEquals(Integer.valueOf(1), ormTableGenerator.getSpecifiedInitialValue());
- assertEquals(Integer.valueOf(1), ormTableGenerator.getSpecifiedAllocationSize());
-
- OrmSequenceGenerator ormSequenceGenerator = ormIdMapping.getSequenceGenerator();
- assertEquals("mySequenceGenerator", ormSequenceGenerator.getName());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
-
- ormPersistentAttribute.makeSpecified(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- ormPersistentAttribute= ormPersistentType.specifiedAttributes().next();
-
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- assertEquals("id", ormIdMapping.getName());
- assertNull(ormIdMapping.getTemporal());
- assertNull(ormIdMapping.getGeneratedValue());
- assertNull(ormIdMapping.getSequenceGenerator());
- assertNull(ormIdMapping.getTableGenerator());
-
- OrmColumn ormColumn = ormIdMapping.getColumn();
- assertEquals("id", ormColumn.getName());
- assertEquals(Boolean.FALSE, ormColumn.getUnique());
- assertEquals(Boolean.TRUE, ormColumn.getNullable());
- assertEquals(Boolean.TRUE, ormColumn.getInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getUpdatable());
- assertNull(ormColumn.getColumnDefinition());
- assertEquals(TYPE_NAME, ormColumn.getTable());
- assertEquals(Integer.valueOf(255), ormColumn.getLength());
- assertEquals(Integer.valueOf(0), ormColumn.getPrecision());
- assertEquals(Integer.valueOf(0), ormColumn.getScale());
- }
-
- public void testSpecifiedMapping() throws Exception {
- createTestEntityIdMapping();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
- assertEquals(1, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("id", ormIdMapping.getName());
- assertNull(ormIdMapping.getTemporal());
- assertNull(ormIdMapping.getGeneratedValue());
- assertNull(ormIdMapping.getSequenceGenerator());
- assertNull(ormIdMapping.getTableGenerator());
-
- OrmColumn ormColumn = ormIdMapping.getColumn();
- assertNull(ormColumn.getSpecifiedName());
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(ormColumn.getColumnDefinition());
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(ormColumn.getSpecifiedPrecision());
- assertNull(ormColumn.getSpecifiedScale());
-
- assertEquals("id", ormColumn.getDefaultName());
- assertEquals(Boolean.FALSE, ormColumn.getDefaultUnique());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultNullable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultUpdatable());
- assertEquals(null, ormColumn.getColumnDefinition());
- assertEquals(TYPE_NAME, ormColumn.getDefaultTable());
- assertEquals(Integer.valueOf(255), ormColumn.getDefaultLength());
- assertEquals(Integer.valueOf(0), ormColumn.getDefaultPrecision());
- assertEquals(Integer.valueOf(0), ormColumn.getDefaultScale());
- }
-
- //3 things tested above
- //1. virtual mapping metadata complete=false - defaults are taken from the java annotations
- //2. virtual mapping metadata complete=true - defaults are taken from java defaults,annotations ignored
- //3. specified mapping (metadata complete=true/false - defaults are taken from java annotations
-
- public void testIdMorphToBasicMapping() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
-
- IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- assertFalse(idMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping);
- assertEquals("id", ormPersistentAttribute.getMapping().getName());
- assertEquals(TemporalType.TIME, ((BasicMapping) ormPersistentAttribute.getMapping()).getTemporal());
- assertEquals("FOO", ((BasicMapping) ormPersistentAttribute.getMapping()).getColumn().getSpecifiedName());
- }
-
- public void testIdMorphToVersionMapping() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
-
- IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- assertFalse(idMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping);
- assertEquals("id", ormPersistentAttribute.getMapping().getName());
- assertEquals(TemporalType.TIME, ((VersionMapping) ormPersistentAttribute.getMapping()).getTemporal());
- assertEquals("FOO", ((VersionMapping) ormPersistentAttribute.getMapping()).getColumn().getSpecifiedName());
- }
-
- public void testIdMorphToTransientMapping() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
-
- IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- assertFalse(idMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping);
- assertEquals("id", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testIdMorphToEmbeddedMapping() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
-
- IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- assertFalse(idMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertEquals("id", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testIdMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
-
- IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- assertFalse(idMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertEquals("id", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testIdMorphToOneToOneMapping() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
-
- IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- assertFalse(idMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping);
- assertEquals("id", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testIdMorphToOneToManyMapping() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
-
- IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- assertFalse(idMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping);
- assertEquals("id", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testIdMorphToManyToOneMapping() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
-
- IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- assertFalse(idMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertEquals("id", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testIdMorphToManyToManyMapping() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
-
- IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping();
- assertFalse(idMapping.isDefault());
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.setTemporal(TemporalType.TIME);
- assertFalse(idMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertEquals("id", ormPersistentAttribute.getMapping().getName());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinColumnTests.java
deleted file mode 100644
index 24a19dba28..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinColumnTests.java
+++ /dev/null
@@ -1,506 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmJoinTable;
-import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmJoinColumnTests extends ContextModelTestCase
-{
- public OrmJoinColumnTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testUpdateSpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn joinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(joinColumn.getSpecifiedName());
- assertNull(joinColumnResource.getName());
-
- //set name in the resource model, verify context model updated
- joinColumnResource.setName("FOO");
- assertEquals("FOO", joinColumn.getSpecifiedName());
- assertEquals("FOO", joinColumnResource.getName());
-
- //set name to null in the resource model
- joinColumnResource.setName(null);
- assertNull(joinColumn.getSpecifiedName());
- assertNull(joinColumnResource.getName());
-
- joinColumnResource.setName("FOO");
- assertEquals("FOO", joinColumn.getSpecifiedName());
- assertEquals("FOO", joinColumnResource.getName());
-
- joinTableResource.getJoinColumns().remove(0);
- assertFalse(ormJoinTable.specifiedJoinColumns().hasNext());
- assertTrue(joinTableResource.getJoinColumns().isEmpty());
- }
-
- public void testModifySpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn joinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(joinColumn.getSpecifiedName());
- assertNull(joinColumnResource.getName());
-
- //set name in the context model, verify resource model modified
- joinColumn.setSpecifiedName("foo");
- assertEquals("foo", joinColumn.getSpecifiedName());
- assertEquals("foo", joinColumnResource.getName());
-
- //set name to null in the context model
- joinColumn.setSpecifiedName(null);
- assertNull(joinColumn.getSpecifiedName());
- assertNull(joinTableResource.getJoinColumns().get(0).getName());
- }
-
- public void testUpdateSpecifiedReferencedColumnName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn joinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(joinColumn.getSpecifiedReferencedColumnName());
- assertNull(joinColumnResource.getReferencedColumnName());
-
- //set name in the resource model, verify context model updated
- joinColumnResource.setReferencedColumnName("FOO");
- assertEquals("FOO", joinColumn.getSpecifiedReferencedColumnName());
- assertEquals("FOO", joinColumnResource.getReferencedColumnName());
-
- //set name to null in the resource model
- joinColumnResource.setReferencedColumnName(null);
- assertNull(joinColumn.getSpecifiedReferencedColumnName());
- assertNull(joinColumnResource.getReferencedColumnName());
-
- joinColumnResource.setReferencedColumnName("FOO");
- assertEquals("FOO", joinColumn.getSpecifiedReferencedColumnName());
- assertEquals("FOO", joinColumnResource.getReferencedColumnName());
-
- joinTableResource.getJoinColumns().remove(0);
- assertFalse(ormJoinTable.specifiedJoinColumns().hasNext());
- assertTrue(joinTableResource.getJoinColumns().isEmpty());
- }
-
- public void testModifySpecifiedReferencedColumnName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn joinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(joinColumn.getSpecifiedReferencedColumnName());
- assertNull(joinColumnResource.getReferencedColumnName());
-
- //set name in the context model, verify resource model modified
- joinColumn.setSpecifiedReferencedColumnName("foo");
- assertEquals("foo", joinColumn.getSpecifiedReferencedColumnName());
- assertEquals("foo", joinColumnResource.getReferencedColumnName());
-
- //set name to null in the context model
- joinColumn.setSpecifiedReferencedColumnName(null);
- assertNull(joinColumn.getSpecifiedReferencedColumnName());
- assertNull(joinTableResource.getJoinColumns().get(0).getReferencedColumnName());
- }
-
- public void testUpdateSpecifiedColumnDefinition() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn joinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(joinColumn.getColumnDefinition());
- assertNull(joinColumnResource.getColumnDefinition());
-
- //set name in the resource model, verify context model updated
- joinColumnResource.setColumnDefinition("FOO");
- assertEquals("FOO", joinColumn.getColumnDefinition());
- assertEquals("FOO", joinColumnResource.getColumnDefinition());
-
- //set name to null in the resource model
- joinColumnResource.setColumnDefinition(null);
- assertNull(joinColumn.getColumnDefinition());
- assertNull(joinColumnResource.getColumnDefinition());
-
- joinColumnResource.setColumnDefinition("FOO");
- assertEquals("FOO", joinColumn.getColumnDefinition());
- assertEquals("FOO", joinColumnResource.getColumnDefinition());
-
- joinTableResource.getJoinColumns().remove(0);
- assertFalse(ormJoinTable.specifiedJoinColumns().hasNext());
- assertTrue(joinTableResource.getJoinColumns().isEmpty());
- }
-
- public void testModifySpecifiedColumnDefinition() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn joinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(joinColumn.getColumnDefinition());
- assertNull(joinColumnResource.getColumnDefinition());
-
- //set name in the context model, verify resource model modified
- joinColumn.setColumnDefinition("foo");
- assertEquals("foo", joinColumn.getColumnDefinition());
- assertEquals("foo", joinColumnResource.getColumnDefinition());
-
- //set name to null in the context model
- joinColumn.setColumnDefinition(null);
- assertNull(joinColumn.getColumnDefinition());
- assertNull(joinTableResource.getJoinColumns().get(0).getColumnDefinition());
- }
-
- public void testUpdateSpecifiedTable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn ormJoinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(ormJoinColumn.getSpecifiedTable());
- assertNull(joinColumnResource.getTable());
-
- //set table in the resource model, verify context model updated
- joinColumnResource.setTable("FOO");
- assertEquals("FOO", ormJoinColumn.getSpecifiedTable());
- assertEquals("FOO", joinColumnResource.getTable());
-
- //set table to null in the resource model
- joinColumnResource.setTable(null);
- assertNull(ormJoinColumn.getSpecifiedTable());
- assertNull(joinColumnResource.getTable());
-
- joinColumnResource.setTable("FOO");
- assertEquals("FOO", ormJoinColumn.getSpecifiedTable());
- assertEquals("FOO", joinColumnResource.getTable());
-
- joinTableResource.getJoinColumns().remove(0);
- assertFalse(ormJoinTable.specifiedJoinColumns().hasNext());
- assertTrue(joinTableResource.getJoinColumns().isEmpty());
- }
-
- public void testModifySpecifiedTable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn ormJoinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(ormJoinColumn.getSpecifiedTable());
- assertNull(joinColumnResource.getTable());
-
- //set table in the context model, verify resource model modified
- ormJoinColumn.setSpecifiedTable("foo");
- assertEquals("foo", ormJoinColumn.getSpecifiedTable());
- assertEquals("foo", joinColumnResource.getTable());
-
- //set table to null in the context model
- ormJoinColumn.setSpecifiedTable(null);
- assertNull(ormJoinColumn.getSpecifiedTable());
- assertNull(joinTableResource.getJoinColumns().get(0).getTable());
- }
-
- public void testUpdateSpecifiedNullable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn ormJoinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(ormJoinColumn.getSpecifiedNullable());
- assertNull(joinColumnResource.getNullable());
-
- //set nullable in the resource model, verify context model updated
- joinColumnResource.setNullable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedNullable());
- assertEquals(Boolean.TRUE, joinColumnResource.getNullable());
-
- //set nullable to null in the resource model
- joinColumnResource.setNullable(null);
- assertNull(ormJoinColumn.getSpecifiedNullable());
- assertNull(joinColumnResource.getNullable());
-
- joinColumnResource.setNullable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, joinColumnResource.getNullable());
-
- joinTableResource.getJoinColumns().remove(0);
- assertFalse(ormJoinTable.specifiedJoinColumns().hasNext());
- assertTrue(joinTableResource.getJoinColumns().isEmpty());
- }
-
- public void testModifySpecifiedNullable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn ormJoinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(ormJoinColumn.getSpecifiedNullable());
- assertNull(joinColumnResource.getNullable());
-
- //set nullable in the context model, verify resource model modified
- ormJoinColumn.setSpecifiedNullable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, joinColumnResource.getNullable());
-
- //set nullable to null in the context model
- ormJoinColumn.setSpecifiedNullable(null);
- assertNull(ormJoinColumn.getSpecifiedNullable());
- assertNull(joinTableResource.getJoinColumns().get(0).getNullable());
- }
-
- public void testUpdateSpecifiedUpdatable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn ormJoinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(ormJoinColumn.getSpecifiedUpdatable());
- assertNull(joinColumnResource.getUpdatable());
-
- //set updatable in the resource model, verify context model updated
- joinColumnResource.setUpdatable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.TRUE, joinColumnResource.getUpdatable());
-
- //set updatable to null in the resource model
- joinColumnResource.setUpdatable(null);
- assertNull(ormJoinColumn.getSpecifiedUpdatable());
- assertNull(joinColumnResource.getUpdatable());
-
- joinColumnResource.setUpdatable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.FALSE, joinColumnResource.getUpdatable());
-
- joinTableResource.getJoinColumns().remove(0);
- assertFalse(ormJoinTable.specifiedJoinColumns().hasNext());
- assertTrue(joinTableResource.getJoinColumns().isEmpty());
- }
-
- public void testModifySpecifiedUpdatable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn ormJoinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(ormJoinColumn.getSpecifiedUpdatable());
- assertNull(joinColumnResource.getUpdatable());
-
- //set updatable in the context model, verify resource model modified
- ormJoinColumn.setSpecifiedUpdatable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.FALSE, joinColumnResource.getUpdatable());
-
- //set updatable to null in the context model
- ormJoinColumn.setSpecifiedUpdatable(null);
- assertNull(ormJoinColumn.getSpecifiedUpdatable());
- assertNull(joinTableResource.getJoinColumns().get(0).getUpdatable());
- }
-
- public void testUpdateSpecifiedInsertable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn ormJoinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(ormJoinColumn.getSpecifiedInsertable());
- assertNull(joinColumnResource.getInsertable());
-
- //set insertable in the resource model, verify context model updated
- joinColumnResource.setInsertable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedInsertable());
- assertEquals(Boolean.TRUE, joinColumnResource.getInsertable());
-
- //set insertable to null in the resource model
- joinColumnResource.setInsertable(null);
- assertNull(ormJoinColumn.getSpecifiedInsertable());
- assertNull(joinColumnResource.getInsertable());
-
- joinColumnResource.setInsertable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, joinColumnResource.getInsertable());
-
- joinTableResource.getJoinColumns().remove(0);
- assertFalse(ormJoinTable.specifiedJoinColumns().hasNext());
- assertTrue(joinTableResource.getJoinColumns().isEmpty());
- }
-
- public void testModifySpecifiedInsertable() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn ormJoinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(ormJoinColumn.getSpecifiedInsertable());
- assertNull(joinColumnResource.getInsertable());
-
- //set insertable in the context model, verify resource model modified
- ormJoinColumn.setSpecifiedInsertable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, joinColumnResource.getInsertable());
-
- //set insertable to null in the context model
- ormJoinColumn.setSpecifiedInsertable(null);
- assertNull(ormJoinColumn.getSpecifiedInsertable());
- assertNull(joinTableResource.getJoinColumns().get(0).getInsertable());
- }
-
- public void testUpdateSpecifiedUnique() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn ormJoinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(ormJoinColumn.getSpecifiedUnique());
- assertNull(joinColumnResource.getUnique());
-
- //set unique in the resource model, verify context model updated
- joinColumnResource.setUnique(Boolean.TRUE);
- assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedUnique());
- assertEquals(Boolean.TRUE, joinColumnResource.getUnique());
-
- //set unique to null in the resource model
- joinColumnResource.setUnique(null);
- assertNull(ormJoinColumn.getSpecifiedUnique());
- assertNull(joinColumnResource.getUnique());
-
- joinColumnResource.setUnique(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedUnique());
- assertEquals(Boolean.FALSE, joinColumnResource.getUnique());
-
- joinTableResource.getJoinColumns().remove(0);
- assertFalse(ormJoinTable.specifiedJoinColumns().hasNext());
- assertTrue(joinTableResource.getJoinColumns().isEmpty());
- }
-
- public void testModifySpecifiedUnique() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- OrmJoinColumn ormJoinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- XmlJoinColumn joinColumnResource = joinTableResource.getJoinColumns().get(0);
-
- assertNull(ormJoinColumn.getSpecifiedUnique());
- assertNull(joinColumnResource.getUnique());
-
- //set unique in the context model, verify resource model modified
- ormJoinColumn.setSpecifiedUnique(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedUnique());
- assertEquals(Boolean.FALSE, joinColumnResource.getUnique());
-
- //set unique to null in the context model
- ormJoinColumn.setSpecifiedUnique(null);
- assertNull(ormJoinColumn.getSpecifiedUnique());
- assertNull(joinTableResource.getJoinColumns().get(0).getUnique());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java
deleted file mode 100644
index 52fae36837..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java
+++ /dev/null
@@ -1,1181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaJoinTable;
-import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmJoinTable;
-import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmUniqueConstraint;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
-import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmJoinTableTests extends ContextModelTestCase
-{
- public OrmJoinTableTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- }
-
- private void createManyToManyAnnotation() throws Exception{
- this.createAnnotationAndMembers("ManyToMany", "");
- }
-
- private void createJoinTableAnnotation() throws Exception{
- //TODO
- this.createAnnotationAndMembers("JoinTable",
- "String name() default \"\"; " +
- "String catalog() default \"\"; " +
- "String schema() default \"\";");
- }
-
- private IType createTestEntityWithValidManyToMany() throws Exception {
- createEntityAnnotation();
- createManyToManyAnnotation();
- createJoinTableAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany").append(CR);
- sb.append(" private Collection<Project> projects;").append(CR);
- sb.append("@Id").append(CR);
- }
- });
- }
-
- private IType createTargetEntity() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class Project {").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int proj_id;").append(CR);
- sb.append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "Project.java", sourceWriter);
- }
-
- public void testUpdateSpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- assertNull(ormJoinTable.getSpecifiedName());
- assertNull(manyToMany.getJoinTable());
-
-
- //set name in the resource model, verify context model updated
- manyToMany.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTableImpl());
- manyToMany.getJoinTable().setName("FOO");
- assertEquals("FOO", ormJoinTable.getSpecifiedName());
- assertEquals("FOO", manyToMany.getJoinTable().getName());
-
- //set name to null in the resource model
- manyToMany.getJoinTable().setName(null);
- assertNull(ormJoinTable.getSpecifiedName());
- assertNull(manyToMany.getJoinTable().getName());
-
- manyToMany.getJoinTable().setName("FOO");
- assertEquals("FOO", ormJoinTable.getSpecifiedName());
- assertEquals("FOO", manyToMany.getJoinTable().getName());
-
- manyToMany.setJoinTable(null);
- assertNull(ormJoinTable.getSpecifiedName());
- assertNull(manyToMany.getJoinTable());
- }
-
- public void testModifySpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- assertNull(ormJoinTable.getSpecifiedName());
- assertNull(manyToMany.getJoinTable());
-
- //set name in the context model, verify resource model modified
- ormJoinTable.setSpecifiedName("foo");
- assertEquals("foo", ormJoinTable.getSpecifiedName());
- assertEquals("foo", manyToMany.getJoinTable().getName());
-
- //set name to null in the context model
- ormJoinTable.setSpecifiedName(null);
- assertNull(ormJoinTable.getSpecifiedName());
- assertNull(manyToMany.getJoinTable());
- }
-
- public void testVirtualJoinTable() throws Exception {
- createTestEntityWithValidManyToMany();
- createTargetEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("projects");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- assertTrue(ormPersistentAttribute.isVirtual());
- assertNull(ormJoinTable.getSpecifiedName());
-
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Project");
-
- assertEquals(TYPE_NAME + "_Project", ormJoinTable.getSpecifiedName());
- assertNull(ormJoinTable.getSpecifiedCatalog());
- assertNull(ormJoinTable.getSpecifiedSchema());
- assertEquals(0, ormJoinTable.specifiedJoinColumnsSize());
- assertEquals(0, ormJoinTable.specifiedInverseJoinColumnsSize());
- OrmJoinColumn ormJoinColumn = ormJoinTable.getDefaultJoinColumn();
-//TODO need to test joinColumn defaults here as well as in java and all the relatioship mapping types
-// assertEquals("id_project_id", ormJoinColumn.getDefaultName());
-// assertEquals("id_project_id", ormJoinColumn.getDefaultReferencedColumnName());
- OrmJoinColumn inverseOrmJoinColumn = ormJoinTable.getDefaultInverseJoinColumn();
-// assertEquals("id_project_id", inverseOrmJoinColumn.getDefaultName());
-// assertEquals("id_project_id", inverseOrmJoinColumn.getDefaultReferencedColumnName());
-
- JavaPersistentAttribute javaPersistentAttribute = ormManyToManyMapping.getJavaPersistentAttribute();
- JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) javaPersistentAttribute.getMapping();
- JavaJoinTable javaJoinTable = javaManyToManyMapping.getJoinTable();
- javaJoinTable.setSpecifiedName("FOO");
- javaJoinTable.setSpecifiedCatalog("CATALOG");
- javaJoinTable.setSpecifiedSchema("SCHEMA");
- JavaJoinColumn javaJoinColumn = javaJoinTable.addSpecifiedJoinColumn(0);
- javaJoinColumn.setSpecifiedName("NAME");
- javaJoinColumn.setSpecifiedReferencedColumnName("REFERENCED_NAME");
- JavaJoinColumn inverseJavaJoinColumn = javaJoinTable.addSpecifiedInverseJoinColumn(0);
- inverseJavaJoinColumn.setSpecifiedName("INVERSE_NAME");
- inverseJavaJoinColumn.setSpecifiedReferencedColumnName("INVERSE_REFERENCED_NAME");
-
- assertEquals("FOO", ormJoinTable.getSpecifiedName());
- assertEquals("CATALOG", ormJoinTable.getSpecifiedCatalog());
- assertEquals("SCHEMA", ormJoinTable.getSpecifiedSchema());
- assertEquals(1, ormJoinTable.specifiedJoinColumnsSize());
- assertEquals(1, ormJoinTable.specifiedInverseJoinColumnsSize());
- ormJoinColumn = ormJoinTable.specifiedJoinColumns().next();
- assertEquals("NAME", ormJoinColumn.getSpecifiedName());
- assertEquals("REFERENCED_NAME", ormJoinColumn.getSpecifiedReferencedColumnName());
- inverseOrmJoinColumn = ormJoinTable.specifiedInverseJoinColumns().next();
- assertEquals("INVERSE_NAME", inverseOrmJoinColumn.getSpecifiedName());
- assertEquals("INVERSE_REFERENCED_NAME", inverseOrmJoinColumn.getSpecifiedReferencedColumnName());
- }
-
- public void testUpdateDefaultNameFromJavaTable() throws Exception {
- createTestEntityWithValidManyToMany();
- createTargetEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "projects");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- assertNull(ormJoinTable.getDefaultName());
-
- OrmPersistentType targetPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Project");
- assertEquals(TYPE_NAME + "_Project", ormJoinTable.getDefaultName());
-
-
- ((JavaEntity) targetPersistentType.getJavaPersistentType().getMapping()).getTable().setSpecifiedName("FOO");
- assertEquals(TYPE_NAME + "_FOO", ormJoinTable.getDefaultName());
-
- ((JavaEntity) ormPersistentType.getJavaPersistentType().getMapping()).getTable().setSpecifiedName("BAR");
- assertEquals("BAR_FOO", ormJoinTable.getDefaultName());
-
- ormPersistentType.getJavaPersistentType().getAttributeNamed("projects").setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- JavaManyToManyMapping javaManyMapping = (JavaManyToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("projects").getMapping();
- javaManyMapping.getJoinTable().setSpecifiedName("JAVA_JOIN_TABLE");
-
- assertEquals("BAR_FOO", ormJoinTable.getDefaultName());
-
-
- //set metadata-complete to true, will ignore java annotation settings
- entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- //ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(TYPE_NAME + "_Project", ormJoinTable.getDefaultName());
-
-
- entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- //remove m-m mapping from the orm.xml file
- ormPersistentAttribute.makeVirtual();
- //ormPersistentType.getMapping().setSpecifiedMetadataComplete(null);
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("projects");
- ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- ormJoinTable = ormManyToManyMapping.getJoinTable();
- assertTrue(ormPersistentAttribute.isVirtual());
- assertEquals("JAVA_JOIN_TABLE", ormManyToManyMapping.getJoinTable().getSpecifiedName());//specifiedName since this is a virtual mapping now
-
- javaManyMapping.getJoinTable().setSpecifiedName(null);
- assertEquals("BAR_FOO", ormJoinTable.getSpecifiedName());
- assertEquals("BAR_FOO", ormJoinTable.getDefaultName());
-
- ((OrmEntity) ormPersistentType.getMapping()).getTable().setSpecifiedName("ORM_TABLE_NAME");
- assertEquals("ORM_TABLE_NAME_FOO", ormJoinTable.getDefaultName());
-
- ((OrmEntity) targetPersistentType.getMapping()).getTable().setSpecifiedName("ORM_TARGET");
- assertEquals("ORM_TABLE_NAME_ORM_TARGET", ormJoinTable.getDefaultName());
- }
-
- public void testUpdateSpecifiedSchema() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- assertNull(ormJoinTable.getSpecifiedSchema());
- assertNull(manyToMany.getJoinTable());
-
- //set schema in the resource model, verify context model updated
- manyToMany.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTableImpl());
- manyToMany.getJoinTable().setSchema("FOO");
- assertEquals("FOO", ormJoinTable.getSpecifiedSchema());
- assertEquals("FOO", manyToMany.getJoinTable().getSchema());
-
- //set Schema to null in the resource model
- manyToMany.getJoinTable().setSchema(null);
- assertNull(ormJoinTable.getSpecifiedSchema());
- assertNull(manyToMany.getJoinTable().getSchema());
-
- manyToMany.getJoinTable().setSchema("FOO");
- assertEquals("FOO", ormJoinTable.getSpecifiedSchema());
- assertEquals("FOO", manyToMany.getJoinTable().getSchema());
-
- manyToMany.setJoinTable(null);
- assertNull(ormJoinTable.getSpecifiedSchema());
- assertNull(manyToMany.getJoinTable());
- }
-
-// public void testUpdateDefaultSchemaFromJavaTable() throws Exception {
-// createTestEntity();
-//
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// XmlEntity xmlEntity = (XmlEntity) ormPersistentType.getMapping();
-// assertNull(xmlEntity.getTable().getDefaultSchema());
-//
-// xmlEntity.javaEntity().getTable().setSpecifiedSchema("Foo");
-// assertEquals("Foo", xmlEntity.getTable().getDefaultSchema());
-//
-// xmlEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-// assertNull(xmlEntity.getTable().getDefaultSchema());
-//
-// xmlEntity.entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
-// xmlEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
-// assertNull(xmlEntity.getTable().getDefaultSchema());
-//
-// xmlEntity.setSpecifiedMetadataComplete(null);
-// assertNull(xmlEntity.getTable().getDefaultSchema());
-//
-// xmlEntity.entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
-// assertEquals("Foo", xmlEntity.getTable().getDefaultSchema());
-//
-// xmlEntity.getTable().setSpecifiedName("Bar");
-// assertNull(xmlEntity.getTable().getDefaultSchema());
-// }
-//
-// public void testUpdateDefaultSchemaNoJava() throws Exception {
-// createTestEntity();
-//
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlEntity xmlEntity = (XmlEntity) ormPersistentType.getMapping();
-// assertNull(xmlEntity.getTable().getDefaultSchema());
-// }
-//
-// public void testUpdateDefaultSchemaFromParent() throws Exception {
-// createTestEntity();
-// createTestSubType();
-//
-// OrmPersistentType parentOrmPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// OrmPersistentType childOrmPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
-// XmlEntity parentXmlEntity = (XmlEntity) parentOrmPersistentType.getMapping();
-// XmlEntity childXmlEntity = (XmlEntity) childOrmPersistentType.getMapping();
-//
-// assertNull(parentXmlEntity.getTable().getDefaultSchema());
-// assertNull(childXmlEntity.getTable().getDefaultSchema());
-//
-// parentXmlEntity.getTable().setSpecifiedSchema("FOO");
-// assertNull(parentXmlEntity.getTable().getDefaultSchema());
-// assertEquals("FOO", childXmlEntity.getTable().getDefaultSchema());
-//
-// parentXmlEntity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
-// assertNull(parentXmlEntity.getTable().getDefaultSchema());
-// assertNull(childXmlEntity.getTable().getDefaultSchema());
-// }
-//
-// public void testUpdateDefaultSchemaFromPersistenceUnitDefaults() throws Exception {
-// createTestEntity();
-//
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// XmlEntity xmlEntity = (XmlEntity) ormPersistentType.getMapping();
-// assertNull(xmlEntity.getTable().getDefaultSchema());
-//
-// xmlEntity.entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSchema("FOO");
-// assertEquals("FOO", xmlEntity.getTable().getDefaultSchema());
-//
-// xmlEntity.entityMappings().setSpecifiedSchema("BAR");
-// assertEquals("BAR", xmlEntity.getTable().getDefaultSchema());
-//
-// xmlEntity.javaEntity().getTable().setSpecifiedSchema("JAVA_SCHEMA");
-// assertEquals("JAVA_SCHEMA", xmlEntity.getTable().getDefaultSchema());
-//
-// xmlEntity.getTable().setSpecifiedName("BLAH");
-// //xml entity now has a table element so default schema is not taken from java
-// assertEquals("BAR", xmlEntity.getTable().getDefaultSchema());
-//
-//
-// xmlEntity.entityMappings().setSpecifiedSchema(null);
-// assertEquals("FOO", xmlEntity.getTable().getDefaultSchema());
-//
-// xmlEntity.entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSchema(null);
-// assertNull(xmlEntity.getTable().getDefaultSchema());
-//
-// xmlEntity.getTable().setSpecifiedName(null);
-// assertEquals("JAVA_SCHEMA", xmlEntity.getTable().getDefaultSchema());
-// }
-
- public void testModifySpecifiedSchema() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- assertNull(ormJoinTable.getSpecifiedSchema());
- assertNull(manyToMany.getJoinTable());
-
- //set Schema in the context model, verify resource model modified
- ormJoinTable.setSpecifiedSchema("foo");
- assertEquals("foo", ormJoinTable.getSpecifiedSchema());
- assertEquals("foo", manyToMany.getJoinTable().getSchema());
-
- //set Schema to null in the context model
- ormJoinTable.setSpecifiedSchema(null);
- assertNull(ormJoinTable.getSpecifiedSchema());
- assertNull(manyToMany.getJoinTable());
- }
-
- public void testUpdateSpecifiedCatalog() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- assertNull(ormJoinTable.getSpecifiedCatalog());
- assertNull(manyToMany.getJoinTable());
-
- //set Catalog in the resource model, verify context model updated
- manyToMany.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTableImpl());
- manyToMany.getJoinTable().setCatalog("FOO");
- assertEquals("FOO", ormJoinTable.getSpecifiedCatalog());
- assertEquals("FOO", manyToMany.getJoinTable().getCatalog());
-
- //set Catalog to null in the resource model
- manyToMany.getJoinTable().setCatalog(null);
- assertNull(ormJoinTable.getSpecifiedCatalog());
- assertNull(manyToMany.getJoinTable().getCatalog());
-
- manyToMany.getJoinTable().setCatalog("FOO");
- assertEquals("FOO", ormJoinTable.getSpecifiedCatalog());
- assertEquals("FOO", manyToMany.getJoinTable().getCatalog());
-
- manyToMany.setJoinTable(null);
- assertNull(ormJoinTable.getSpecifiedCatalog());
- assertNull(manyToMany.getJoinTable());
- }
-
- public void testModifySpecifiedCatalog() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- assertNull(ormJoinTable.getSpecifiedCatalog());
- assertNull(manyToMany.getJoinTable());
-
- //set Catalog in the context model, verify resource model modified
- ormJoinTable.setSpecifiedCatalog("foo");
- assertEquals("foo", ormJoinTable.getSpecifiedCatalog());
- assertEquals("foo", manyToMany.getJoinTable().getCatalog());
-
- //set Catalog to null in the context model
- ormJoinTable.setSpecifiedCatalog(null);
- assertNull(ormJoinTable.getSpecifiedCatalog());
- assertNull(manyToMany.getJoinTable());
- }
-
-// public void testUpdateDefaultCatalogFromJavaTable() throws Exception {
-// createTestEntity();
-//
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// XmlEntity xmlEntity = (XmlEntity) ormPersistentType.getMapping();
-// assertNull(xmlEntity.getTable().getDefaultCatalog());
-//
-// xmlEntity.javaEntity().getTable().setSpecifiedCatalog("Foo");
-// assertEquals("Foo", xmlEntity.getTable().getDefaultCatalog());
-//
-// xmlEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-// assertNull(xmlEntity.getTable().getDefaultCatalog());
-//
-// xmlEntity.entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
-// xmlEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
-// assertNull(xmlEntity.getTable().getDefaultCatalog());
-//
-// xmlEntity.setSpecifiedMetadataComplete(null);
-// assertNull(xmlEntity.getTable().getDefaultCatalog());
-//
-// xmlEntity.entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
-// assertEquals("Foo", xmlEntity.getTable().getDefaultCatalog());
-//
-// xmlEntity.getTable().setSpecifiedName("Bar");
-// assertNull(xmlEntity.getTable().getDefaultCatalog());
-// }
-//
-// public void testUpdateDefaultCatalogNoJava() throws Exception {
-// createTestEntity();
-//
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlEntity xmlEntity = (XmlEntity) ormPersistentType.getMapping();
-// assertNull(xmlEntity.getTable().getDefaultCatalog());
-// }
-//
-// public void testUpdateDefaultCatalogFromParent() throws Exception {
-// createTestEntity();
-// createTestSubType();
-//
-// OrmPersistentType parentOrmPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// OrmPersistentType childOrmPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
-// XmlEntity parentXmlEntity = (XmlEntity) parentOrmPersistentType.getMapping();
-// XmlEntity childXmlEntity = (XmlEntity) childOrmPersistentType.getMapping();
-//
-// assertNull(parentXmlEntity.getTable().getDefaultCatalog());
-// assertNull(childXmlEntity.getTable().getDefaultCatalog());
-//
-// parentXmlEntity.getTable().setSpecifiedCatalog("FOO");
-// assertNull(parentXmlEntity.getTable().getDefaultCatalog());
-// assertEquals("FOO", childXmlEntity.getTable().getDefaultCatalog());
-//
-// parentXmlEntity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
-// assertNull(parentXmlEntity.getTable().getDefaultCatalog());
-// assertNull(childXmlEntity.getTable().getDefaultCatalog());
-// }
-//
-// public void testUpdateDefaultCatalogFromPersistenceUnitDefaults() throws Exception {
-// createTestEntity();
-//
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// XmlEntity xmlEntity = (XmlEntity) ormPersistentType.getMapping();
-// assertNull(xmlEntity.getTable().getDefaultCatalog());
-//
-// xmlEntity.entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCatalog("FOO");
-// assertEquals("FOO", xmlEntity.getTable().getDefaultCatalog());
-//
-// xmlEntity.entityMappings().setSpecifiedCatalog("BAR");
-// assertEquals("BAR", xmlEntity.getTable().getDefaultCatalog());
-//
-// xmlEntity.javaEntity().getTable().setSpecifiedCatalog("JAVA_CATALOG");
-// assertEquals("JAVA_CATALOG", xmlEntity.getTable().getDefaultCatalog());
-//
-// xmlEntity.getTable().setSpecifiedName("BLAH");
-// //xml entity now has a table element so default schema is not taken from java
-// assertEquals("BAR", xmlEntity.getTable().getDefaultCatalog());
-//
-//
-// xmlEntity.entityMappings().setSpecifiedCatalog(null);
-// assertEquals("FOO", xmlEntity.getTable().getDefaultCatalog());
-//
-// xmlEntity.entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCatalog(null);
-// assertNull(xmlEntity.getTable().getDefaultCatalog());
-//
-// xmlEntity.getTable().setSpecifiedName(null);
-// assertEquals("JAVA_CATALOG", xmlEntity.getTable().getDefaultCatalog());
-//}
-
-//
-// public void testUpdateName() throws Exception {
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlEntity xmlEntity = (XmlEntity) ormPersistentType.getMapping();
-// Entity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-// assertEquals("Foo", xmlEntity.getName());
-//
-// //set class in the resource model, verify context model updated
-// entityResource.setClassName("com.Bar");
-// assertEquals("Bar", xmlEntity.getName());
-//
-// entityResource.setName("Baz");
-// assertEquals("Baz", xmlEntity.getName());
-//
-// //set class to null in the resource model
-// entityResource.setClassName(null);
-// assertEquals("Baz", xmlEntity.getName());
-//
-// entityResource.setName(null);
-// assertNull(xmlEntity.getName());
-// }
-
-
- public void testAddSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- OrmJoinColumn joinColumn = ormJoinTable.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("FOO");
-
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- assertEquals("FOO", joinTableResource.getJoinColumns().get(0).getName());
-
- OrmJoinColumn joinColumn2 = ormJoinTable.addSpecifiedJoinColumn(0);
- joinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", joinTableResource.getJoinColumns().get(0).getName());
- assertEquals("FOO", joinTableResource.getJoinColumns().get(1).getName());
-
- OrmJoinColumn joinColumn3 = ormJoinTable.addSpecifiedJoinColumn(1);
- joinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", joinTableResource.getJoinColumns().get(0).getName());
- assertEquals("BAZ", joinTableResource.getJoinColumns().get(1).getName());
- assertEquals("FOO", joinTableResource.getJoinColumns().get(2).getName());
-
- ListIterator<OrmJoinColumn> joinColumns = ormJoinTable.specifiedJoinColumns();
- assertEquals(joinColumn2, joinColumns.next());
- assertEquals(joinColumn3, joinColumns.next());
- assertEquals(joinColumn, joinColumns.next());
-
- joinColumns = ormJoinTable.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- }
-
- public void testRemoveSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- ormJoinTable.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- ormJoinTable.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- ormJoinTable.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- assertEquals(3, joinTableResource.getJoinColumns().size());
-
- ormJoinTable.removeSpecifiedJoinColumn(0);
- assertEquals(2, joinTableResource.getJoinColumns().size());
- assertEquals("BAR", joinTableResource.getJoinColumns().get(0).getName());
- assertEquals("BAZ", joinTableResource.getJoinColumns().get(1).getName());
-
- ormJoinTable.removeSpecifiedJoinColumn(0);
- assertEquals(1, joinTableResource.getJoinColumns().size());
- assertEquals("BAZ", joinTableResource.getJoinColumns().get(0).getName());
-
- ormJoinTable.removeSpecifiedJoinColumn(0);
- assertEquals(0, joinTableResource.getJoinColumns().size());
- }
-
- public void testMoveSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- ormJoinTable.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- ormJoinTable.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- ormJoinTable.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- assertEquals(3, joinTableResource.getJoinColumns().size());
-
-
- ormJoinTable.moveSpecifiedJoinColumn(2, 0);
- ListIterator<OrmJoinColumn> joinColumns = ormJoinTable.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAR", joinTableResource.getJoinColumns().get(0).getName());
- assertEquals("BAZ", joinTableResource.getJoinColumns().get(1).getName());
- assertEquals("FOO", joinTableResource.getJoinColumns().get(2).getName());
-
-
- ormJoinTable.moveSpecifiedJoinColumn(0, 1);
- joinColumns = ormJoinTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAZ", joinTableResource.getJoinColumns().get(0).getName());
- assertEquals("BAR", joinTableResource.getJoinColumns().get(1).getName());
- assertEquals("FOO", joinTableResource.getJoinColumns().get(2).getName());
- }
-
- public void testUpdateInverseJoinColumns() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- manyToMany.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTableImpl());
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
-
- joinTableResource.getInverseJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumnImpl());
- joinTableResource.getInverseJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumnImpl());
- joinTableResource.getInverseJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumnImpl());
-
- joinTableResource.getInverseJoinColumns().get(0).setName("FOO");
- joinTableResource.getInverseJoinColumns().get(1).setName("BAR");
- joinTableResource.getInverseJoinColumns().get(2).setName("BAZ");
-
- ListIterator<OrmJoinColumn> joinColumns = ormJoinTable.specifiedInverseJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.getInverseJoinColumns().move(2, 0);
- joinColumns = ormJoinTable.specifiedInverseJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.getInverseJoinColumns().move(0, 1);
- joinColumns = ormJoinTable.specifiedInverseJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.getInverseJoinColumns().remove(1);
- joinColumns = ormJoinTable.specifiedInverseJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.getInverseJoinColumns().remove(1);
- joinColumns = ormJoinTable.specifiedInverseJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.getInverseJoinColumns().remove(0);
- assertFalse(ormJoinTable.specifiedInverseJoinColumns().hasNext());
- }
-
- public void testAddSpecifiedInverseJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- OrmJoinColumn joinColumn = ormJoinTable.addSpecifiedInverseJoinColumn(0);
- joinColumn.setSpecifiedName("FOO");
-
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- assertEquals("FOO", joinTableResource.getInverseJoinColumns().get(0).getName());
-
- OrmJoinColumn joinColumn2 = ormJoinTable.addSpecifiedInverseJoinColumn(0);
- joinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", joinTableResource.getInverseJoinColumns().get(0).getName());
- assertEquals("FOO", joinTableResource.getInverseJoinColumns().get(1).getName());
-
- OrmJoinColumn joinColumn3 = ormJoinTable.addSpecifiedInverseJoinColumn(1);
- joinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", joinTableResource.getInverseJoinColumns().get(0).getName());
- assertEquals("BAZ", joinTableResource.getInverseJoinColumns().get(1).getName());
- assertEquals("FOO", joinTableResource.getInverseJoinColumns().get(2).getName());
-
- ListIterator<OrmJoinColumn> joinColumns = ormJoinTable.specifiedInverseJoinColumns();
- assertEquals(joinColumn2, joinColumns.next());
- assertEquals(joinColumn3, joinColumns.next());
- assertEquals(joinColumn, joinColumns.next());
-
- joinColumns = ormJoinTable.specifiedInverseJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- }
-
- public void testRemoveSpecifiedInverseJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- ormJoinTable.addSpecifiedInverseJoinColumn(0).setSpecifiedName("FOO");
- ormJoinTable.addSpecifiedInverseJoinColumn(1).setSpecifiedName("BAR");
- ormJoinTable.addSpecifiedInverseJoinColumn(2).setSpecifiedName("BAZ");
-
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- assertEquals(3, joinTableResource.getInverseJoinColumns().size());
-
- ormJoinTable.removeSpecifiedInverseJoinColumn(0);
- assertEquals(2, joinTableResource.getInverseJoinColumns().size());
- assertEquals("BAR", joinTableResource.getInverseJoinColumns().get(0).getName());
- assertEquals("BAZ", joinTableResource.getInverseJoinColumns().get(1).getName());
-
- ormJoinTable.removeSpecifiedInverseJoinColumn(0);
- assertEquals(1, joinTableResource.getInverseJoinColumns().size());
- assertEquals("BAZ", joinTableResource.getInverseJoinColumns().get(0).getName());
-
- ormJoinTable.removeSpecifiedInverseJoinColumn(0);
- assertEquals(0, joinTableResource.getInverseJoinColumns().size());
- }
-
- public void testMoveSpecifiedInverseJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- ormJoinTable.addSpecifiedInverseJoinColumn(0).setSpecifiedName("FOO");
- ormJoinTable.addSpecifiedInverseJoinColumn(1).setSpecifiedName("BAR");
- ormJoinTable.addSpecifiedInverseJoinColumn(2).setSpecifiedName("BAZ");
-
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
- assertEquals(3, joinTableResource.getInverseJoinColumns().size());
-
-
- ormJoinTable.moveSpecifiedInverseJoinColumn(2, 0);
- ListIterator<OrmJoinColumn> joinColumns = ormJoinTable.specifiedInverseJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAR", joinTableResource.getInverseJoinColumns().get(0).getName());
- assertEquals("BAZ", joinTableResource.getInverseJoinColumns().get(1).getName());
- assertEquals("FOO", joinTableResource.getInverseJoinColumns().get(2).getName());
-
-
- ormJoinTable.moveSpecifiedInverseJoinColumn(0, 1);
- joinColumns = ormJoinTable.specifiedInverseJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAZ", joinTableResource.getInverseJoinColumns().get(0).getName());
- assertEquals("BAR", joinTableResource.getInverseJoinColumns().get(1).getName());
- assertEquals("FOO", joinTableResource.getInverseJoinColumns().get(2).getName());
- }
-
- public void testUpdateJoinColumns() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- manyToMany.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTableImpl());
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
-
- joinTableResource.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumnImpl());
- joinTableResource.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumnImpl());
- joinTableResource.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumnImpl());
-
- joinTableResource.getJoinColumns().get(0).setName("FOO");
- joinTableResource.getJoinColumns().get(1).setName("BAR");
- joinTableResource.getJoinColumns().get(2).setName("BAZ");
-
- ListIterator<OrmJoinColumn> joinColumns = ormJoinTable.specifiedJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.getJoinColumns().move(2, 0);
- joinColumns = ormJoinTable.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.getJoinColumns().move(0, 1);
- joinColumns = ormJoinTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.getJoinColumns().remove(1);
- joinColumns = ormJoinTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.getJoinColumns().remove(1);
- joinColumns = ormJoinTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.getJoinColumns().remove(0);
- assertFalse(ormJoinTable.specifiedJoinColumns().hasNext());
- }
-
-
- public void testUniqueConstraints() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- manyToMany.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTableImpl());
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
-
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- joinTableResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "foo");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- joinTableResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "bar");
-
- uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("bar", uniqueConstraints.next().columnNames().next());
- assertEquals("foo", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testUniqueConstraintsSize() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- manyToMany.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTableImpl());
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
-
- assertEquals(0, ormJoinTable.uniqueConstraintsSize());
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- joinTableResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "foo");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- joinTableResource.getUniqueConstraints().add(1, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "bar");
-
- assertEquals(2, ormJoinTable.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- manyToMany.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTableImpl());
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
-
- ormJoinTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- ormJoinTable.addUniqueConstraint(0).addColumnName(0, "BAR");
- ormJoinTable.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- ListIterator<XmlUniqueConstraint> uniqueConstraints = joinTableResource.getUniqueConstraints().listIterator();
-
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().get(0));
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testAddUniqueConstraint2() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- manyToMany.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTableImpl());
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
-
- ormJoinTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- ormJoinTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- ormJoinTable.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- ListIterator<XmlUniqueConstraint> uniqueConstraints = joinTableResource.getUniqueConstraints().listIterator();
-
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().get(0));
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- manyToMany.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTableImpl());
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
-
- ormJoinTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- ormJoinTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- ormJoinTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- assertEquals(3, joinTableResource.getUniqueConstraints().size());
-
- ormJoinTable.removeUniqueConstraint(1);
-
- ListIterator<XmlUniqueConstraint> uniqueConstraintResources = joinTableResource.getUniqueConstraints().listIterator();
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertFalse(uniqueConstraintResources.hasNext());
-
- Iterator<OrmUniqueConstraint> uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- ormJoinTable.removeUniqueConstraint(1);
- uniqueConstraintResources = joinTableResource.getUniqueConstraints().listIterator();
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- assertFalse(uniqueConstraintResources.hasNext());
-
- uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- ormJoinTable.removeUniqueConstraint(0);
- uniqueConstraintResources = joinTableResource.getUniqueConstraints().listIterator();
- assertFalse(uniqueConstraintResources.hasNext());
- uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- manyToMany.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTableImpl());
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
-
- ormJoinTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- ormJoinTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- ormJoinTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- assertEquals(3, joinTableResource.getUniqueConstraints().size());
-
-
- ormJoinTable.moveUniqueConstraint(2, 0);
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- ListIterator<XmlUniqueConstraint> uniqueConstraintResources = joinTableResource.getUniqueConstraints().listIterator();
- assertEquals("BAR", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
-
-
- ormJoinTable.moveUniqueConstraint(0, 1);
- uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- uniqueConstraintResources = joinTableResource.getUniqueConstraints().listIterator();
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- }
-
- public void testUpdateUniqueConstraints() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- manyToMany.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTableImpl());
- XmlJoinTable joinTableResource = manyToMany.getJoinTable();
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- joinTableResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "FOO");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- joinTableResource.getUniqueConstraints().add(1, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "BAR");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- joinTableResource.getUniqueConstraints().add(2, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "BAZ");
-
-
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableResource.getUniqueConstraints().move(2, 0);
- uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableResource.getUniqueConstraints().move(0, 1);
- uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableResource.getUniqueConstraints().remove(1);
- uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableResource.getUniqueConstraints().remove(1);
- uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableResource.getUniqueConstraints().remove(0);
- uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
-
- public void testUniqueConstraintsFromJava() throws Exception {
- createTestEntityWithValidManyToMany();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.attributes().next().getMapping();
- OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
-
- assertTrue(ormManyToManyMapping.getPersistentAttribute().isVirtual());
-
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
- JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) ormPersistentType.getJavaPersistentType().attributes().next().getMapping();
-
- javaManyToManyMapping.getJoinTable().addUniqueConstraint(0).addColumnName(0, "FOO");
- javaManyToManyMapping.getJoinTable().addUniqueConstraint(1).addColumnName(0, "BAR");
- javaManyToManyMapping.getJoinTable().addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- uniqueConstraints = ormJoinTable.uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- ormManyToManyMapping.getPersistentAttribute().makeSpecified();
-
- ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.attributes().next().getMapping();
- ormManyToManyMapping.getJoinTable();
- assertEquals(0, ormManyToManyMapping.getJoinTable().uniqueConstraintsSize());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToManyMappingTests.java
deleted file mode 100644
index 6507b43b0f..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToManyMappingTests.java
+++ /dev/null
@@ -1,654 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmManyToManyMappingTests extends ContextModelTestCase
-{
- public OrmManyToManyMappingTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertEquals("manyToManyMapping", ormManyToManyMapping.getName());
- assertEquals("manyToManyMapping", manyToMany.getName());
-
- //set name in the resource model, verify context model updated
- manyToMany.setName("newName");
- assertEquals("newName", ormManyToManyMapping.getName());
- assertEquals("newName", manyToMany.getName());
-
- //set name to null in the resource model
- manyToMany.setName(null);
- assertNull(ormManyToManyMapping.getName());
- assertNull(manyToMany.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertEquals("manyToManyMapping", ormManyToManyMapping.getName());
- assertEquals("manyToManyMapping", manyToMany.getName());
-
- //set name in the context model, verify resource model updated
- ormManyToManyMapping.setName("newName");
- assertEquals("newName", ormManyToManyMapping.getName());
- assertEquals("newName", manyToMany.getName());
-
- //set name to null in the context model
- ormManyToManyMapping.setName(null);
- assertNull(ormManyToManyMapping.getName());
- assertNull(manyToMany.getName());
- }
-
- public void testUpdateTargetEntity() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getSpecifiedTargetEntity());
- assertNull(manyToMany.getTargetEntity());
-
- //set target entity in the resource model, verify context model updated
- manyToMany.setTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", ormManyToManyMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", manyToMany.getTargetEntity());
-
- //set target entity to null in the resource model
- manyToMany.setTargetEntity(null);
- assertNull(ormManyToManyMapping.getSpecifiedTargetEntity());
- assertNull(manyToMany.getTargetEntity());
- }
-
- public void testModifyTargetEntity() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getSpecifiedTargetEntity());
- assertNull(manyToMany.getTargetEntity());
-
- //set target entity in the context model, verify resource model updated
- ormManyToManyMapping.setSpecifiedTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", ormManyToManyMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", manyToMany.getTargetEntity());
-
- //set target entity to null in the context model
- ormManyToManyMapping.setSpecifiedTargetEntity(null);
- assertNull(ormManyToManyMapping.getSpecifiedTargetEntity());
- assertNull(manyToMany.getTargetEntity());
- }
-
- public void testUpdateSpecifiedFetch() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToManyResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getSpecifiedFetch());
- assertNull(manyToManyResource.getFetch());
-
- //set fetch in the resource model, verify context model updated
- manyToManyResource.setFetch(org.eclipse.jpt.core.resource.orm.FetchType.EAGER);
- assertEquals(FetchType.EAGER, ormManyToManyMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.EAGER, manyToManyResource.getFetch());
-
- manyToManyResource.setFetch(org.eclipse.jpt.core.resource.orm.FetchType.LAZY);
- assertEquals(FetchType.LAZY, ormManyToManyMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.LAZY, manyToManyResource.getFetch());
-
- //set fetch to null in the resource model
- manyToManyResource.setFetch(null);
- assertNull(ormManyToManyMapping.getSpecifiedFetch());
- assertNull(manyToManyResource.getFetch());
- }
-
- public void testModifySpecifiedFetch() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToManyResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getSpecifiedFetch());
- assertNull(manyToManyResource.getFetch());
-
- //set fetch in the context model, verify resource model updated
- ormManyToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.EAGER, manyToManyResource.getFetch());
- assertEquals(FetchType.EAGER, ormManyToManyMapping.getSpecifiedFetch());
-
- ormManyToManyMapping.setSpecifiedFetch(FetchType.LAZY);
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.LAZY, manyToManyResource.getFetch());
- assertEquals(FetchType.LAZY, ormManyToManyMapping.getSpecifiedFetch());
-
- //set fetch to null in the context model
- ormManyToManyMapping.setSpecifiedFetch(null);
- assertNull(manyToManyResource.getFetch());
- assertNull(ormManyToManyMapping.getSpecifiedFetch());
- }
-
- public void testUpdateMappedBy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getMappedBy());
- assertNull(manyToMany.getMappedBy());
-
- //set mappedBy in the resource model, verify context model updated
- manyToMany.setMappedBy("newMappedBy");
- assertEquals("newMappedBy", ormManyToManyMapping.getMappedBy());
- assertEquals("newMappedBy", manyToMany.getMappedBy());
-
- //setmappedBy to null in the resource model
- manyToMany.setMappedBy(null);
- assertNull(ormManyToManyMapping.getMappedBy());
- assertNull(manyToMany.getMappedBy());
- }
-
- public void testModifyMappedBy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getMappedBy());
- assertNull(manyToMany.getMappedBy());
-
- //set mappedBy in the context model, verify resource model updated
- ormManyToManyMapping.setMappedBy("newMappedBy");
- assertEquals("newMappedBy", ormManyToManyMapping.getMappedBy());
- assertEquals("newMappedBy", manyToMany.getMappedBy());
-
- //set mappedBy to null in the context model
- ormManyToManyMapping.setMappedBy(null);
- assertNull(ormManyToManyMapping.getMappedBy());
- assertNull(manyToMany.getMappedBy());
- }
-
- public void testUpdateMapKey() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getMapKey());
- assertNull(manyToMany.getMapKey());
-
- //set mapKey in the resource model, verify context model does not change
- manyToMany.setMapKey(OrmFactory.eINSTANCE.createMapKeyImpl());
- assertNull(ormManyToManyMapping.getMapKey());
- assertNotNull(manyToMany.getMapKey());
-
- //set mapKey name in the resource model, verify context model updated
- manyToMany.getMapKey().setName("myMapKey");
- assertEquals("myMapKey", ormManyToManyMapping.getMapKey());
- assertEquals("myMapKey", manyToMany.getMapKey().getName());
-
- //set mapKey name to null in the resource model
- manyToMany.getMapKey().setName(null);
- assertNull(ormManyToManyMapping.getMapKey());
- assertNull(manyToMany.getMapKey().getName());
-
- manyToMany.getMapKey().setName("myMapKey");
- manyToMany.setMapKey(null);
- assertNull(ormManyToManyMapping.getMapKey());
- assertNull(manyToMany.getMapKey());
- }
-
- public void testModifyMapKey() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getMapKey());
- assertNull(manyToMany.getMapKey());
-
- //set mapKey in the context model, verify resource model updated
- ormManyToManyMapping.setMapKey("myMapKey");
- assertEquals("myMapKey", ormManyToManyMapping.getMapKey());
- assertEquals("myMapKey", manyToMany.getMapKey().getName());
-
- //set mapKey to null in the context model
- ormManyToManyMapping.setMapKey(null);
- assertNull(ormManyToManyMapping.getMapKey());
- assertNull(manyToMany.getMapKey());
- }
-
- public void testUpdateOrderBy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getOrderBy());
- assertNull(manyToMany.getOrderBy());
-
- //set orderBy in the resource model, verify context model updated
- manyToMany.setOrderBy("newOrderBy");
- assertEquals("newOrderBy", ormManyToManyMapping.getOrderBy());
- assertEquals("newOrderBy", manyToMany.getOrderBy());
-
- //set orderBy to null in the resource model
- manyToMany.setOrderBy(null);
- assertNull(ormManyToManyMapping.getOrderBy());
- assertNull(manyToMany.getOrderBy());
- }
-
- public void testModifyOrderBy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getOrderBy());
- assertNull(manyToMany.getOrderBy());
-
- //set mappedBy in the context model, verify resource model updated
- ormManyToManyMapping.setOrderBy("newOrderBy");
- assertEquals("newOrderBy", ormManyToManyMapping.getOrderBy());
- assertEquals("newOrderBy", manyToMany.getOrderBy());
-
- //set mappedBy to null in the context model
- ormManyToManyMapping.setOrderBy(null);
- assertNull(ormManyToManyMapping.getOrderBy());
- assertNull(manyToMany.getOrderBy());
- }
-
- public void testIsNoOrdering() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
-
- assertTrue(ormManyToManyMapping.isNoOrdering());
-
- ormManyToManyMapping.setOrderBy("foo");
- assertFalse(ormManyToManyMapping.isNoOrdering());
-
- ormManyToManyMapping.setOrderBy(null);
- assertTrue(ormManyToManyMapping.isNoOrdering());
- }
-
- public void testSetNoOrdering() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
-
- assertTrue(ormManyToManyMapping.isNoOrdering());
-
- ormManyToManyMapping.setOrderBy("foo");
- assertFalse(ormManyToManyMapping.isNoOrdering());
-
- ormManyToManyMapping.setNoOrdering(true);
- assertTrue(ormManyToManyMapping.isNoOrdering());
- assertNull(ormManyToManyMapping.getOrderBy());
- }
-//TODO
-// public boolean isOrderByPk() {
-// return "".equals(getOrderBy());
-// }
-//
-// public void setOrderByPk() {
-// setOrderBy("");
-// }
-
- public void testIsCustomOrdering() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
-
- assertFalse(ormManyToManyMapping.isCustomOrdering());
-
- ormManyToManyMapping.setOrderBy("foo");
- assertTrue(ormManyToManyMapping.isCustomOrdering());
-
- ormManyToManyMapping.setOrderBy(null);
- assertFalse(ormManyToManyMapping.isCustomOrdering());
- }
-
- public void testManyToManyMorphToIdMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany");
-
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(manyToManyMapping.isDefault());
- manyToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- manyToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- manyToManyMapping.setOrderBy("customOrder");
- manyToManyMapping.setMapKey("mapKey");
- manyToManyMapping.setMappedBy("mappedBy");
- manyToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = manyToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = manyToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(manyToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping);
- assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testManyToManyMorphToVersionMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany");
-
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(manyToManyMapping.isDefault());
- manyToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- manyToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- manyToManyMapping.setOrderBy("customOrder");
- manyToManyMapping.setMapKey("mapKey");
- manyToManyMapping.setMappedBy("mappedBy");
- manyToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = manyToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = manyToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(manyToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping);
- assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testManyToManyMorphToTransientMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany");
-
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(manyToManyMapping.isDefault());
- manyToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- manyToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- manyToManyMapping.setOrderBy("customOrder");
- manyToManyMapping.setMapKey("mapKey");
- manyToManyMapping.setMappedBy("mappedBy");
- manyToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = manyToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = manyToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(manyToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping);
- assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testManyToManyMorphToEmbeddedMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany");
-
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(manyToManyMapping.isDefault());
- manyToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- manyToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- manyToManyMapping.setOrderBy("customOrder");
- manyToManyMapping.setMapKey("mapKey");
- manyToManyMapping.setMappedBy("mappedBy");
- manyToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = manyToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = manyToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(manyToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testManyToManyMorphToEmbeddedIdMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany");
-
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(manyToManyMapping.isDefault());
- manyToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- manyToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- manyToManyMapping.setOrderBy("customOrder");
- manyToManyMapping.setMapKey("mapKey");
- manyToManyMapping.setMappedBy("mappedBy");
- manyToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = manyToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = manyToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(manyToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testManyToManyMorphToOneToOneMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany");
-
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(manyToManyMapping.isDefault());
- manyToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- manyToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- manyToManyMapping.setOrderBy("customOrder");
- manyToManyMapping.setMapKey("mapKey");
- manyToManyMapping.setMappedBy("mappedBy");
- manyToManyMapping.getCascade().setAll(true);
- manyToManyMapping.getCascade().setMerge(true);
- manyToManyMapping.getCascade().setPersist(true);
- manyToManyMapping.getCascade().setRefresh(true);
- manyToManyMapping.getCascade().setRemove(true);
- manyToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = manyToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = manyToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(manyToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping);
- assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName());
- assertEquals(FetchType.EAGER, ((OneToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- assertEquals("TargetEntity", ((OneToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity());
- assertEquals("mappedBy", ((OneToOneMapping) ormPersistentAttribute.getMapping()).getMappedBy());
- assertTrue(((OneToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isAll());
- assertTrue(((OneToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isMerge());
- assertTrue(((OneToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isPersist());
- assertTrue(((OneToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isRefresh());
- assertTrue(((OneToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isRemove());
- }
-
- public void testManyToManyMorphToOneToManyMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany");
-
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(manyToManyMapping.isDefault());
- manyToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- manyToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- manyToManyMapping.setOrderBy("customOrder");
- manyToManyMapping.setMapKey("mapKey");
- manyToManyMapping.setMappedBy("mappedBy");
- manyToManyMapping.getCascade().setAll(true);
- manyToManyMapping.getCascade().setMerge(true);
- manyToManyMapping.getCascade().setPersist(true);
- manyToManyMapping.getCascade().setRefresh(true);
- manyToManyMapping.getCascade().setRemove(true);
- manyToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = manyToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = manyToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(manyToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping);
- assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName());
- assertEquals(FetchType.EAGER, ((OneToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- assertEquals("TargetEntity", ((OneToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity());
- assertEquals("mappedBy", ((OneToManyMapping) ormPersistentAttribute.getMapping()).getMappedBy());
- assertTrue(((OneToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isAll());
- assertTrue(((OneToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isMerge());
- assertTrue(((OneToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isPersist());
- assertTrue(((OneToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isRefresh());
- assertTrue(((OneToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isRemove());
- JoinTable joinTable = ((OneToManyMapping) ormPersistentAttribute.getMapping()).getJoinTable();
- assertEquals("MY_JOIN_TABLE", joinTable.getName());
- assertEquals("name", joinTable.joinColumns().next().getSpecifiedName());
- assertEquals("referenceName", joinTable.joinColumns().next().getSpecifiedReferencedColumnName());
- assertEquals("inverseName", joinTable.inverseJoinColumns().next().getSpecifiedName());
- assertEquals("inverseReferenceName", joinTable.inverseJoinColumns().next().getSpecifiedReferencedColumnName());
- }
-
- public void testManyToManyMorphToManyToOneMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany");
-
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(manyToManyMapping.isDefault());
- manyToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- manyToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- manyToManyMapping.setOrderBy("customOrder");
- manyToManyMapping.setMapKey("mapKey");
- manyToManyMapping.setMappedBy("mappedBy");
- manyToManyMapping.getCascade().setAll(true);
- manyToManyMapping.getCascade().setMerge(true);
- manyToManyMapping.getCascade().setPersist(true);
- manyToManyMapping.getCascade().setRefresh(true);
- manyToManyMapping.getCascade().setRemove(true);
- manyToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = manyToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = manyToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(manyToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName());
- assertEquals(FetchType.EAGER, ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- assertEquals("TargetEntity", ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isAll());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isMerge());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isPersist());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isRefresh());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isRemove());
- }
-
- public void testManyToManyMorphToBasicMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany");
-
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(manyToManyMapping.isDefault());
- manyToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- manyToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- manyToManyMapping.setOrderBy("customOrder");
- manyToManyMapping.setMapKey("mapKey");
- manyToManyMapping.setMappedBy("mappedBy");
- manyToManyMapping.getCascade().setAll(true);
- manyToManyMapping.getCascade().setMerge(true);
- manyToManyMapping.getCascade().setPersist(true);
- manyToManyMapping.getCascade().setRefresh(true);
- manyToManyMapping.getCascade().setRemove(true);
- manyToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = manyToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = manyToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(manyToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping);
- assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName());
-//TODO assertEquals(FetchType.EAGER, ((IBasicMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToOneMappingTests.java
deleted file mode 100644
index 27b4851aa3..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToOneMappingTests.java
+++ /dev/null
@@ -1,570 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.Cascade;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmManyToOneMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.XmlManyToOne;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmManyToOneMappingTests extends ContextModelTestCase
-{
- public OrmManyToOneMappingTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createManyToOneAnnotation() throws Exception{
- this.createAnnotationAndMembers("ManyToOne",
- "Class targetEntity() default void.class;" +
- "CascadeType[] cascade() default {};" +
- "FetchType fetch() default EAGER;" +
- "boolean optional() default true;");
- }
-
- private void createJoinColumnAnnotation() throws Exception{
- this.createAnnotationAndMembers("JoinColumn",
- "String name() default \"\";" +
- "String referencedColumnName() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";");
- }
-
- private IType createTestEntityManyToOneMapping() throws Exception {
- createEntityAnnotation();
- createManyToOneAnnotation();
- createJoinColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_ONE, JPA.JOIN_COLUMN, JPA.FETCH_TYPE, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToOne(fetch=FetchType.LAZY, optional=false, targetEntity=Address.class, cascade={CascadeType.ALL, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH})");
- sb.append(CR);
- sb.append(" @JoinColumn(name=\"MY_COLUMN\", referencedColumnName=\"MY_REFERENCED_COLUMN\", unique=true, nullable=false, insertable=false, updatable=false, columnDefinition=\"COLUMN_DEFINITION\", table=\"MY_TABLE\")");
- sb.append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- sb.append(" @Id");
- }
- });
- }
-
- private IType createTestTargetEntityAddress() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int id;").append(CR);
- sb.append(CR);
- sb.append(" private String city;").append(CR);
- sb.append(CR);
- sb.append(" private String state;").append(CR);
- sb.append(CR);
- sb.append(" private int zip;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter);
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping");
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- XmlManyToOne manyToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0);
-
- assertEquals("manyToOneMapping", ormManyToOneMapping.getName());
- assertEquals("manyToOneMapping", manyToOne.getName());
-
- //set name in the resource model, verify context model updated
- manyToOne.setName("newName");
- assertEquals("newName", ormManyToOneMapping.getName());
- assertEquals("newName", manyToOne.getName());
-
- //set name to null in the resource model
- manyToOne.setName(null);
- assertNull(ormManyToOneMapping.getName());
- assertNull(manyToOne.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping");
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- XmlManyToOne manyToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0);
-
- assertEquals("manyToOneMapping", ormManyToOneMapping.getName());
- assertEquals("manyToOneMapping", manyToOne.getName());
-
- //set name in the context model, verify resource model updated
- ormManyToOneMapping.setName("newName");
- assertEquals("newName", ormManyToOneMapping.getName());
- assertEquals("newName", manyToOne.getName());
-
- //set name to null in the context model
- ormManyToOneMapping.setName(null);
- assertNull(ormManyToOneMapping.getName());
- assertNull(manyToOne.getName());
- }
-
- public void testUpdateTargetEntity() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping");
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- XmlManyToOne manyToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0);
-
- assertNull(ormManyToOneMapping.getSpecifiedTargetEntity());
- assertNull(manyToOne.getTargetEntity());
-
- //set target entity in the resource model, verify context model updated
- manyToOne.setTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", ormManyToOneMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", manyToOne.getTargetEntity());
-
- //set target entity to null in the resource model
- manyToOne.setTargetEntity(null);
- assertNull(ormManyToOneMapping.getSpecifiedTargetEntity());
- assertNull(manyToOne.getTargetEntity());
- }
-
- public void testModifyTargetEntity() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping");
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- XmlManyToOne manyToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0);
-
- assertNull(ormManyToOneMapping.getSpecifiedTargetEntity());
- assertNull(manyToOne.getTargetEntity());
-
- //set target entity in the context model, verify resource model updated
- ormManyToOneMapping.setSpecifiedTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", ormManyToOneMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", manyToOne.getTargetEntity());
-
- //set target entity to null in the context model
- ormManyToOneMapping.setSpecifiedTargetEntity(null);
- assertNull(ormManyToOneMapping.getSpecifiedTargetEntity());
- assertNull(manyToOne.getTargetEntity());
- }
-
- public void testUpdateSpecifiedFetch() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping");
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- XmlManyToOne manyToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0);
-
- assertNull(ormManyToOneMapping.getSpecifiedFetch());
- assertNull(manyToOneResource.getFetch());
-
- //set fetch in the resource model, verify context model updated
- manyToOneResource.setFetch(org.eclipse.jpt.core.resource.orm.FetchType.EAGER);
- assertEquals(FetchType.EAGER, ormManyToOneMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.EAGER, manyToOneResource.getFetch());
-
- manyToOneResource.setFetch(org.eclipse.jpt.core.resource.orm.FetchType.LAZY);
- assertEquals(FetchType.LAZY, ormManyToOneMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.LAZY, manyToOneResource.getFetch());
-
- //set fetch to null in the resource model
- manyToOneResource.setFetch(null);
- assertNull(ormManyToOneMapping.getSpecifiedFetch());
- assertNull(manyToOneResource.getFetch());
- }
-
- public void testModifySpecifiedFetch() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping");
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- XmlManyToOne manyToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0);
-
- assertNull(ormManyToOneMapping.getSpecifiedFetch());
- assertNull(manyToOneResource.getFetch());
-
- //set fetch in the context model, verify resource model updated
- ormManyToOneMapping.setSpecifiedFetch(FetchType.EAGER);
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.EAGER, manyToOneResource.getFetch());
- assertEquals(FetchType.EAGER, ormManyToOneMapping.getSpecifiedFetch());
-
- ormManyToOneMapping.setSpecifiedFetch(FetchType.LAZY);
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.LAZY, manyToOneResource.getFetch());
- assertEquals(FetchType.LAZY, ormManyToOneMapping.getSpecifiedFetch());
-
- //set fetch to null in the context model
- ormManyToOneMapping.setSpecifiedFetch(null);
- assertNull(manyToOneResource.getFetch());
- assertNull(ormManyToOneMapping.getSpecifiedFetch());
- }
-
- public void testUpdateSpecifiedOptional() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping");
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- XmlManyToOne manyToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0);
-
- assertNull(ormManyToOneMapping.getSpecifiedOptional());
- assertNull(manyToOneResource.getOptional());
-
- //set optional in the resource model, verify context model updated
- manyToOneResource.setOptional(Boolean.TRUE);
- assertEquals(Boolean.TRUE, ormManyToOneMapping.getSpecifiedOptional());
- assertEquals(Boolean.TRUE, manyToOneResource.getOptional());
-
- manyToOneResource.setOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormManyToOneMapping.getSpecifiedOptional());
- assertEquals(Boolean.FALSE, manyToOneResource.getOptional());
-
- //set optional to null in the resource model
- manyToOneResource.setOptional(null);
- assertNull(ormManyToOneMapping.getSpecifiedOptional());
- assertNull(manyToOneResource.getOptional());
- }
-
- public void testModifySpecifiedOptional() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping");
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- XmlManyToOne manyToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0);
-
- assertNull(ormManyToOneMapping.getSpecifiedOptional());
- assertNull(manyToOneResource.getOptional());
-
- //set optional in the context model, verify resource model updated
- ormManyToOneMapping.setSpecifiedOptional(Boolean.TRUE);
- assertEquals(Boolean.TRUE, manyToOneResource.getOptional());
- assertEquals(Boolean.TRUE, ormManyToOneMapping.getSpecifiedOptional());
-
- ormManyToOneMapping.setSpecifiedOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, manyToOneResource.getOptional());
- assertEquals(Boolean.FALSE, ormManyToOneMapping.getSpecifiedOptional());
-
- //set optional to null in the context model
- ormManyToOneMapping.setSpecifiedOptional(null);
- assertNull(manyToOneResource.getOptional());
- assertNull(ormManyToOneMapping.getSpecifiedOptional());
- }
-
- public void testAddSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping");
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- XmlManyToOne manyToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0);
-
- OrmJoinColumn joinColumn = ormManyToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("FOO");
-
- assertEquals("FOO", manyToOneResource.getJoinColumns().get(0).getName());
-
- OrmJoinColumn joinColumn2 = ormManyToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", manyToOneResource.getJoinColumns().get(0).getName());
- assertEquals("FOO", manyToOneResource.getJoinColumns().get(1).getName());
-
- OrmJoinColumn joinColumn3 = ormManyToOneMapping.addSpecifiedJoinColumn(1);
- joinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", manyToOneResource.getJoinColumns().get(0).getName());
- assertEquals("BAZ", manyToOneResource.getJoinColumns().get(1).getName());
- assertEquals("FOO", manyToOneResource.getJoinColumns().get(2).getName());
-
- ListIterator<OrmJoinColumn> joinColumns = ormManyToOneMapping.specifiedJoinColumns();
- assertEquals(joinColumn2, joinColumns.next());
- assertEquals(joinColumn3, joinColumns.next());
- assertEquals(joinColumn, joinColumns.next());
-
- joinColumns = ormManyToOneMapping.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- }
-
- public void testRemoveSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping");
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- XmlManyToOne manyToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0);
-
- ormManyToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- ormManyToOneMapping.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- ormManyToOneMapping.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- assertEquals(3, manyToOneResource.getJoinColumns().size());
-
- ormManyToOneMapping.removeSpecifiedJoinColumn(0);
- assertEquals(2, manyToOneResource.getJoinColumns().size());
- assertEquals("BAR", manyToOneResource.getJoinColumns().get(0).getName());
- assertEquals("BAZ", manyToOneResource.getJoinColumns().get(1).getName());
-
- ormManyToOneMapping.removeSpecifiedJoinColumn(0);
- assertEquals(1, manyToOneResource.getJoinColumns().size());
- assertEquals("BAZ", manyToOneResource.getJoinColumns().get(0).getName());
-
- ormManyToOneMapping.removeSpecifiedJoinColumn(0);
- assertEquals(0, manyToOneResource.getJoinColumns().size());
- }
-
- public void testMoveSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping");
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- XmlManyToOne manyToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0);
-
- ormManyToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- ormManyToOneMapping.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- ormManyToOneMapping.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- assertEquals(3, manyToOneResource.getJoinColumns().size());
-
-
- ormManyToOneMapping.moveSpecifiedJoinColumn(2, 0);
- ListIterator<OrmJoinColumn> joinColumns = ormManyToOneMapping.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAR", manyToOneResource.getJoinColumns().get(0).getName());
- assertEquals("BAZ", manyToOneResource.getJoinColumns().get(1).getName());
- assertEquals("FOO", manyToOneResource.getJoinColumns().get(2).getName());
-
-
- ormManyToOneMapping.moveSpecifiedJoinColumn(0, 1);
- joinColumns = ormManyToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAZ", manyToOneResource.getJoinColumns().get(0).getName());
- assertEquals("BAR", manyToOneResource.getJoinColumns().get(1).getName());
- assertEquals("FOO", manyToOneResource.getJoinColumns().get(2).getName());
- }
-
-
- public void testManyToOneMappingNoUnderylingJavaAttribute() throws Exception {
- createTestEntityManyToOneMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "foo");
- assertEquals(3, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("foo", ormManyToOneMapping.getName());
-
- assertNull(ormManyToOneMapping.getSpecifiedFetch());
- assertNull(ormManyToOneMapping.getSpecifiedOptional());
- assertNull(ormManyToOneMapping.getSpecifiedTargetEntity());
- assertEquals(FetchType.EAGER, ormManyToOneMapping.getFetch());
- assertEquals(Boolean.TRUE, ormManyToOneMapping.getOptional());
- assertNull(ormManyToOneMapping.getTargetEntity());
-
-
- assertFalse(ormManyToOneMapping.specifiedJoinColumns().hasNext());
- //TODO default joinColumns
- //assertTrue(ormManyToOneMapping.defaultJoinColumns().hasNext());
-
-
- Cascade cascade = ormManyToOneMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
- }
-
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityManyToOneMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- assertEquals(3, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- assertEquals("address", ormManyToOneMapping.getName());
- assertEquals(FetchType.LAZY, ormManyToOneMapping.getSpecifiedFetch());
- assertEquals(Boolean.FALSE, ormManyToOneMapping.getSpecifiedOptional());
- assertEquals("Address", ormManyToOneMapping.getSpecifiedTargetEntity());
-
- OrmJoinColumn ormJoinColumn = ormManyToOneMapping.specifiedJoinColumns().next();
- assertEquals("MY_COLUMN", ormJoinColumn.getSpecifiedName());
- assertEquals("MY_REFERENCED_COLUMN", ormJoinColumn.getSpecifiedReferencedColumnName());
- assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedUnique());
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedUpdatable());
- assertEquals("COLUMN_DEFINITION", ormJoinColumn.getColumnDefinition());
- assertEquals("MY_TABLE", ormJoinColumn.getSpecifiedTable());
-
- Cascade cascade = ormManyToOneMapping.getCascade();
- assertTrue(cascade.isAll());
- assertTrue(cascade.isMerge());
- assertTrue(cascade.isPersist());
- assertTrue(cascade.isRemove());
- assertTrue(cascade.isRefresh());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityManyToOneMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(3, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
-
- ormPersistentAttribute.makeSpecified(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- ormPersistentAttribute= ormPersistentType.specifiedAttributes().next();
-
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
- assertEquals("address", ormManyToOneMapping.getName());
- assertEquals(FetchType.EAGER, ormManyToOneMapping.getDefaultFetch());
- assertEquals(Boolean.TRUE, ormManyToOneMapping.getDefaultOptional());
- //TODO hmm, is this correct?
- assertEquals("test.Address", ormManyToOneMapping.getDefaultTargetEntity());
-
- //TODO default join columns in xml one-to-one
-// XmlJoinColumn ormJoinColumn = ormManyToOneMapping.specifiedJoinColumns().next();
-// //TODO java default columns name in JavaSingleRelationshipMapping.JoinColumnOwner
-// //assertEquals("address", ormJoinColumn.getSpecifiedName());
-// //assertEquals("address", ormJoinColumn.getSpecifiedReferencedColumnName());
-// assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedUnique());
-// assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedNullable());
-// assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedInsertable());
-// assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedUpdatable());
-// assertNull(ormJoinColumn.getColumnDefinition());
-// assertEquals(TYPE_NAME, ormJoinColumn.getSpecifiedTable());
-
- Cascade cascade = ormManyToOneMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
- }
-
- public void testSpecifiedMapping() throws Exception {
- createTestEntityManyToOneMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address");
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("address", ormManyToOneMapping.getName());
- assertNull(ormManyToOneMapping.getSpecifiedFetch());
- assertNull(ormManyToOneMapping.getSpecifiedOptional());
- assertNull(ormManyToOneMapping.getSpecifiedTargetEntity());
- assertEquals(FetchType.EAGER, ormManyToOneMapping.getFetch());
- assertEquals(Boolean.TRUE, ormManyToOneMapping.getOptional());
- assertEquals("test.Address", ormManyToOneMapping.getDefaultTargetEntity());
-
- assertFalse(ormManyToOneMapping.specifiedJoinColumns().hasNext());
-
- //TODO default join columns for specified xmlManyToOne mapping
-// XmlJoinColumn ormJoinColumn = ormManyToOneMapping.defaultJoinColumns().next();
-// assertNull(ormJoinColumn.getSpecifiedName());
-// assertNull(ormJoinColumn.getSpecifiedReferencedColumnName());
-// assertNull(ormJoinColumn.getSpecifiedUnique());
-// assertNull(ormJoinColumn.getSpecifiedNullable());
-// assertNull(ormJoinColumn.getSpecifiedInsertable());
-// assertNull(ormJoinColumn.getSpecifiedUpdatable());
-// assertNull(ormJoinColumn.getColumnDefinition());
-// assertNull(ormJoinColumn.getSpecifiedTable());
-//
-// assertEquals("address", ormJoinColumn.getDefaultName());
-// assertEquals("address", ormJoinColumn.getDefaultReferencedColumnName());
-// assertEquals(Boolean.FALSE, ormJoinColumn.getDefaultUnique());
-// assertEquals(Boolean.TRUE, ormJoinColumn.getDefaultNullable());
-// assertEquals(Boolean.TRUE, ormJoinColumn.getDefaultInsertable());
-// assertEquals(Boolean.TRUE, ormJoinColumn.getDefaultUpdatable());
-// assertEquals(null, ormJoinColumn.getColumnDefinition());
-// assertEquals(TYPE_NAME, ormJoinColumn.getDefaultTable());
-
- Cascade cascade = ormManyToOneMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
- }
-
- //3 things tested above
- //1. virtual mapping metadata complete=false - defaults are taken from the java annotations
- //2. virtual mapping metadata complete=true - defaults are taken from java defaults,annotations ignored
- //3. specified mapping (metadata complete=true/false - defaults are taken from java annotations
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmMappedSuperclassTests.java
deleted file mode 100644
index 176aa0c4b3..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmMappedSuperclassTests.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.orm.OrmEmbeddable;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddable;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.orm.XmlMappedSuperclass;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmMappedSuperclassTests extends ContextModelTestCase
-{
- public OrmMappedSuperclassTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testUpdateClass() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass mappedSuperclassResource = ormResource().getEntityMappings().getMappedSuperclasses().get(0);
- assertEquals("model.Foo", ormMappedSuperclass.getClass_());
- assertEquals("model.Foo", mappedSuperclassResource.getClassName());
-
- //set class in the resource model, verify context model updated
- mappedSuperclassResource.setClassName("com.Bar");
- assertEquals("com.Bar", ormMappedSuperclass.getClass_());
- assertEquals("com.Bar", mappedSuperclassResource.getClassName());
-
- //set class to null in the resource model
- mappedSuperclassResource.setClassName(null);
- assertNull(ormMappedSuperclass.getClass_());
- assertNull(mappedSuperclassResource.getClassName());
- }
-
- public void testModifyClass() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass mappedSuperclassResource = ormResource().getEntityMappings().getMappedSuperclasses().get(0);
- assertEquals("model.Foo", ormMappedSuperclass.getClass_());
- assertEquals("model.Foo", mappedSuperclassResource.getClassName());
-
- //set class in the context model, verify resource model modified
- ormMappedSuperclass.setClass("com.Bar");
- assertEquals("com.Bar", ormMappedSuperclass.getClass_());
- assertEquals("com.Bar", mappedSuperclassResource.getClassName());
-
- //set class to null in the context model
- ormMappedSuperclass.setClass(null);
- assertNull(ormMappedSuperclass.getClass_());
- assertNull(mappedSuperclassResource.getClassName());
- }
- //TODO add tests for setting the className when the package is set on entity-mappings
-
- public void testUpdateSpecifiedAccess() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass mappedSuperclassResource = ormResource().getEntityMappings().getMappedSuperclasses().get(0);
- assertNull(ormMappedSuperclass.getSpecifiedAccess());
- assertNull(mappedSuperclassResource.getAccess());
-
- //set access in the resource model, verify context model updated
- mappedSuperclassResource.setAccess(org.eclipse.jpt.core.resource.orm.AccessType.FIELD);
- assertEquals(AccessType.FIELD, ormMappedSuperclass.getSpecifiedAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.FIELD, mappedSuperclassResource.getAccess());
-
- //set access to null in the resource model
- mappedSuperclassResource.setAccess(null);
- assertNull(ormMappedSuperclass.getSpecifiedAccess());
- assertNull(mappedSuperclassResource.getAccess());
- }
-
- public void testModifySpecifiedAccess() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass mappedSuperclassResource = ormResource().getEntityMappings().getMappedSuperclasses().get(0);
- assertNull(ormMappedSuperclass.getSpecifiedAccess());
- assertNull(mappedSuperclassResource.getAccess());
-
- //set access in the context model, verify resource model modified
- ormMappedSuperclass.setSpecifiedAccess(AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, ormMappedSuperclass.getSpecifiedAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, mappedSuperclassResource.getAccess());
-
- //set access to null in the context model
- ormMappedSuperclass.setSpecifiedAccess(null);
- assertNull(ormMappedSuperclass.getSpecifiedAccess());
- assertNull(mappedSuperclassResource.getAccess());
- }
- //TODO test default access from
- //underlying java
- //persistence-unit-defaults
- //entity-mappings
- //with xml-mapping-metadata-complete set
-
- public void testUpdateSpecifiedMetadataComplete() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass mappedSuperclassResource = ormResource().getEntityMappings().getMappedSuperclasses().get(0);
- assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertNull(mappedSuperclassResource.getMetadataComplete());
-
- //set metadata-complete in the resource model, verify context model updated
- mappedSuperclassResource.setMetadataComplete(true);
- assertTrue(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertTrue(mappedSuperclassResource.getMetadataComplete());
-
- //set access to false in the resource model
- mappedSuperclassResource.setMetadataComplete(false);
- assertFalse(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertFalse(mappedSuperclassResource.getMetadataComplete());
-
- mappedSuperclassResource.setMetadataComplete(null);
- assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertNull(mappedSuperclassResource.getMetadataComplete());
- }
-
- public void testModifySpecifiedMetadataComplete() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass mappedSuperclassResource = ormResource().getEntityMappings().getMappedSuperclasses().get(0); assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertNull(mappedSuperclassResource.getMetadataComplete());
-
- //set access in the context model, verify resource model modified
- ormMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
- assertTrue(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertTrue(mappedSuperclassResource.getMetadataComplete());
-
- //set access to null in the context model
- ormMappedSuperclass.setSpecifiedMetadataComplete(Boolean.FALSE);
- assertFalse(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertFalse(mappedSuperclassResource.getMetadataComplete());
-
- ormMappedSuperclass.setSpecifiedMetadataComplete(null);
- assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertNull(mappedSuperclassResource.getMetadataComplete());
- }
-
- public void testUpdateDefaultMetadataComplete() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass mappedSuperclassResource = ormResource().getEntityMappings().getMappedSuperclasses().get(0);
- assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertFalse(ormMappedSuperclass.isDefaultMetadataComplete());
- assertNull(mappedSuperclassResource.getMetadataComplete());
-
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertTrue(ormMappedSuperclass.isDefaultMetadataComplete());
- assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertNull(mappedSuperclassResource.getMetadataComplete());
-
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertFalse(ormMappedSuperclass.isDefaultMetadataComplete());
- assertNull(mappedSuperclassResource.getMetadataComplete());
- }
-
- public void testUpdateMetadataComplete() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass mappedSuperclassResource = ormResource().getEntityMappings().getMappedSuperclasses().get(0);
- assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertFalse(ormMappedSuperclass.isMetadataComplete());
- assertNull(mappedSuperclassResource.getMetadataComplete());
-
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertTrue(ormMappedSuperclass.isMetadataComplete());
- assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertNull(mappedSuperclassResource.getMetadataComplete());
-
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertFalse(ormMappedSuperclass.isMetadataComplete());
- assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
- assertNull(mappedSuperclassResource.getMetadataComplete());
- }
-
-
- public void testMakeMappedSuperclassEntity() throws Exception {
- OrmPersistentType mappedSuperclassPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass mappedSuperclass = (OrmMappedSuperclass) mappedSuperclassPersistentType.getMapping();
- mappedSuperclass.setSpecifiedAccess(AccessType.PROPERTY);
- mappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- mappedSuperclassPersistentType.setMappingKey(MappingKeys.ENTITY_TYPE_MAPPING_KEY);
-
- XmlEntity entity = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals("model.Foo", entity.getClassName());
- assertEquals(Boolean.TRUE, entity.getMetadataComplete());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, entity.getAccess());
- assertNull(entity.getDiscriminatorValue());
- assertNull(entity.getName());
-
- OrmEntity ormEntity = (OrmEntity) mappedSuperclassPersistentType.getMapping();
- assertEquals("model.Foo", ormEntity.getClass_());
- assertEquals(Boolean.TRUE, ormEntity.getSpecifiedMetadataComplete());
- assertEquals(AccessType.PROPERTY, ormEntity.getSpecifiedAccess());
- }
-
- //test with 2 MappedSuperclasses, make the first one an Entity so it has to move to the end of the list
- public void testMakeMappedSuperclassEntity2() throws Exception {
- OrmPersistentType mappedSuperclassPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo2");
- OrmMappedSuperclass mappedSuperclass = (OrmMappedSuperclass) mappedSuperclassPersistentType.getMapping();
- mappedSuperclass.setSpecifiedAccess(AccessType.PROPERTY);
- mappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- mappedSuperclassPersistentType.setMappingKey(MappingKeys.ENTITY_TYPE_MAPPING_KEY);
-
- XmlEntity entity = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals("model.Foo", entity.getClassName());
- assertEquals(Boolean.TRUE, entity.getMetadataComplete());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, entity.getAccess());
- assertNull(entity.getDiscriminatorValue());
- assertNull(entity.getName());
-
- OrmEntity ormEntity = (OrmEntity) mappedSuperclassPersistentType.getMapping();
- assertEquals("model.Foo", ormEntity.getClass_());
- assertEquals(Boolean.TRUE, ormEntity.getSpecifiedMetadataComplete());
- assertEquals(AccessType.PROPERTY, ormEntity.getSpecifiedAccess());
-
- ListIterator<OrmPersistentType> persistentTypes = entityMappings().ormPersistentTypes();
- assertEquals(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
- assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
- }
-
- public void testMakeMappedSuperclassEmbeddable() throws Exception {
- OrmPersistentType mappedSuperclassPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass mappedSuperclass = (OrmMappedSuperclass) mappedSuperclassPersistentType.getMapping();
- mappedSuperclass.setSpecifiedAccess(AccessType.PROPERTY);
- mappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- mappedSuperclassPersistentType.setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
-
- XmlEmbeddable embeddable = ormResource().getEntityMappings().getEmbeddables().get(0);
- assertEquals("model.Foo", embeddable.getClassName());
- assertEquals(Boolean.TRUE, embeddable.getMetadataComplete());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, embeddable.getAccess());
-
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) mappedSuperclassPersistentType.getMapping();
- assertEquals("model.Foo", ormEmbeddable.getClass_());
- assertEquals(Boolean.TRUE, ormEmbeddable.getSpecifiedMetadataComplete());
- assertEquals(AccessType.PROPERTY, ormEmbeddable.getSpecifiedAccess());
- }
- //test with 2 MappedSuperclasses, make the first one an Embeddable so it has to move to the end of the list
- public void testMakeMappedSuperclassEmbeddable2() throws Exception {
- OrmPersistentType mappedSuperclassPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo2");
- OrmMappedSuperclass mappedSuperclass = (OrmMappedSuperclass) mappedSuperclassPersistentType.getMapping();
- mappedSuperclass.setSpecifiedAccess(AccessType.PROPERTY);
- mappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- mappedSuperclassPersistentType.setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
-
- XmlEmbeddable embeddable = ormResource().getEntityMappings().getEmbeddables().get(0);
- assertEquals("model.Foo", embeddable.getClassName());
- assertEquals(Boolean.TRUE, embeddable.getMetadataComplete());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, embeddable.getAccess());
-
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) mappedSuperclassPersistentType.getMapping();
- assertEquals("model.Foo", ormEmbeddable.getClass_());
- assertEquals(Boolean.TRUE, ormEmbeddable.getSpecifiedMetadataComplete());
- assertEquals(AccessType.PROPERTY, ormEmbeddable.getSpecifiedAccess());
-
- ListIterator<OrmPersistentType> persistentTypes = entityMappings().ormPersistentTypes();
- assertEquals(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
- assertEquals(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
- }
-
- public void testUpdateIdClass() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass mappedSuperclassResource = ormResource().getEntityMappings().getMappedSuperclasses().get(0); assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
-
- assertNull(ormMappedSuperclass.getIdClass());
- assertNull(mappedSuperclassResource.getIdClass());
-
- mappedSuperclassResource.setIdClass(OrmFactory.eINSTANCE.createXmlIdClass());
-
- assertNull(ormMappedSuperclass.getIdClass());
- assertNotNull(mappedSuperclassResource.getIdClass());
-
- mappedSuperclassResource.getIdClass().setClassName("model.Foo");
- assertEquals("model.Foo", ormMappedSuperclass.getIdClass());
- assertEquals("model.Foo", mappedSuperclassResource.getIdClass().getClassName());
-
- //test setting @IdClass value to null, id-class tag is not removed
- mappedSuperclassResource.getIdClass().setClassName(null);
- assertNull(ormMappedSuperclass.getIdClass());
- assertNotNull(mappedSuperclassResource.getIdClass());
-
- //reset @IdClass value and then remove id-class tag
- mappedSuperclassResource.setIdClass(OrmFactory.eINSTANCE.createXmlIdClass());
- mappedSuperclassResource.getIdClass().setClassName("model.Foo");
- mappedSuperclassResource.setIdClass(null);
-
- assertNull(ormMappedSuperclass.getIdClass());
- assertNull(mappedSuperclassResource.getIdClass());
- }
-
- public void testModifyIdClass() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass mappedSuperclassResource = ormResource().getEntityMappings().getMappedSuperclasses().get(0); assertNull(ormMappedSuperclass.getSpecifiedMetadataComplete());
-
- assertNull(ormMappedSuperclass.getIdClass());
- assertNull(mappedSuperclassResource.getIdClass());
-
- ormMappedSuperclass.setIdClass("model.Foo");
- assertEquals("model.Foo", mappedSuperclassResource.getIdClass().getClassName());
- assertEquals("model.Foo", ormMappedSuperclass.getIdClass());
-
- ormMappedSuperclass.setIdClass(null);
- assertNull(ormMappedSuperclass.getIdClass());
- assertNull(mappedSuperclassResource.getIdClass());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmNamedNativeQueryTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmNamedNativeQueryTests.java
deleted file mode 100644
index 84b6800528..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmNamedNativeQueryTests.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmNamedNativeQuery;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmQueryHint;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlNamedNativeQuery;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmNamedNativeQueryTests extends ContextModelTestCase
-{
- public OrmNamedNativeQueryTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedNativeQuery ormNamedNativeQuery = ormEntity.addNamedNativeQuery(0);
-
- XmlNamedNativeQuery namedNativeQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedNativeQueries().get(0);
-
- assertNull(ormNamedNativeQuery.getName());
- assertNull(namedNativeQueryResource.getName());
-
- //set name in the resource model, verify context model updated
- namedNativeQueryResource.setName("newName");
- assertEquals("newName", ormNamedNativeQuery.getName());
- assertEquals("newName", namedNativeQueryResource.getName());
-
- //set name to null in the resource model
- namedNativeQueryResource.setName(null);
- assertNull(ormNamedNativeQuery.getName());
- assertNull(namedNativeQueryResource.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedNativeQuery ormNamedNativeQuery = ormEntity.addNamedNativeQuery(0);
-
- XmlNamedNativeQuery namedNativeQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedNativeQueries().get(0);
-
- assertNull(ormNamedNativeQuery.getName());
- assertNull(namedNativeQueryResource.getName());
-
- //set name in the context model, verify resource model updated
- ormNamedNativeQuery.setName("newName");
- assertEquals("newName", ormNamedNativeQuery.getName());
- assertEquals("newName", namedNativeQueryResource.getName());
-
- //set name to null in the context model
- ormNamedNativeQuery.setName(null);
- assertNull(ormNamedNativeQuery.getName());
- assertNull(namedNativeQueryResource.getName());
- }
-
- public void testUpdateQuery() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedNativeQuery ormNamedNativeQuery = ormEntity.addNamedNativeQuery(0);
-
- XmlNamedNativeQuery namedNativeQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedNativeQueries().get(0);
-
- assertNull(ormNamedNativeQuery.getQuery());
- assertNull(namedNativeQueryResource.getQuery());
-
- //set name in the resource model, verify context model updated
- namedNativeQueryResource.setQuery("newName");
- assertEquals("newName", ormNamedNativeQuery.getQuery());
- assertEquals("newName", namedNativeQueryResource.getQuery());
-
- //set name to null in the resource model
- namedNativeQueryResource.setQuery(null);
- assertNull(ormNamedNativeQuery.getQuery());
- assertNull(namedNativeQueryResource.getQuery());
- }
-
- public void testModifyQuery() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedNativeQuery ormNamedNativeQuery = ormEntity.addNamedNativeQuery(0);
-
- XmlNamedNativeQuery namedNativeQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedNativeQueries().get(0);
-
- assertNull(ormNamedNativeQuery.getQuery());
- assertNull(namedNativeQueryResource.getQuery());
-
- //set name in the context model, verify resource model updated
- ormNamedNativeQuery.setQuery("newName");
- assertEquals("newName", ormNamedNativeQuery.getQuery());
- assertEquals("newName", namedNativeQueryResource.getQuery());
-
- //set name to null in the context model
- ormNamedNativeQuery.setQuery(null);
- assertNull(ormNamedNativeQuery.getQuery());
- assertNull(namedNativeQueryResource.getQuery());
- }
-
- public void testAddHint() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedNativeQuery ormNamedNativeQuery = ormEntity.addNamedNativeQuery(0);
-
- XmlNamedNativeQuery namedNativeQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedNativeQueries().get(0);
-
- OrmQueryHint queryHint = ormNamedNativeQuery.addHint(0);
- queryHint.setName("FOO");
-
- assertEquals("FOO", namedNativeQueryResource.getHints().get(0).getName());
-
- OrmQueryHint queryHint2 = ormNamedNativeQuery.addHint(0);
- queryHint2.setName("BAR");
-
- assertEquals("BAR", namedNativeQueryResource.getHints().get(0).getName());
- assertEquals("FOO", namedNativeQueryResource.getHints().get(1).getName());
-
- OrmQueryHint queryHint3 = ormNamedNativeQuery.addHint(1);
- queryHint3.setName("BAZ");
-
- assertEquals("BAR", namedNativeQueryResource.getHints().get(0).getName());
- assertEquals("BAZ", namedNativeQueryResource.getHints().get(1).getName());
- assertEquals("FOO", namedNativeQueryResource.getHints().get(2).getName());
-
- ListIterator<OrmQueryHint> queryHints = ormNamedNativeQuery.hints();
- assertEquals(queryHint2, queryHints.next());
- assertEquals(queryHint3, queryHints.next());
- assertEquals(queryHint, queryHints.next());
-
- queryHints = ormNamedNativeQuery.hints();
- assertEquals("BAR", queryHints.next().getName());
- assertEquals("BAZ", queryHints.next().getName());
- assertEquals("FOO", queryHints.next().getName());
- }
-
- public void testRemoveHint() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedNativeQuery ormNamedNativeQuery = ormEntity.addNamedNativeQuery(0);
-
- XmlNamedNativeQuery namedNativeQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedNativeQueries().get(0);
-
- ormNamedNativeQuery.addHint(0).setName("FOO");
- ormNamedNativeQuery.addHint(1).setName("BAR");
- ormNamedNativeQuery.addHint(2).setName("BAZ");
-
- assertEquals(3, namedNativeQueryResource.getHints().size());
-
- ormNamedNativeQuery.removeHint(0);
- assertEquals(2, namedNativeQueryResource.getHints().size());
- assertEquals("BAR", namedNativeQueryResource.getHints().get(0).getName());
- assertEquals("BAZ", namedNativeQueryResource.getHints().get(1).getName());
-
- ormNamedNativeQuery.removeHint(0);
- assertEquals(1, namedNativeQueryResource.getHints().size());
- assertEquals("BAZ", namedNativeQueryResource.getHints().get(0).getName());
-
- ormNamedNativeQuery.removeHint(0);
- assertEquals(0, namedNativeQueryResource.getHints().size());
- }
-
- public void testMoveHint() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedNativeQuery ormNamedNativeQuery = ormEntity.addNamedNativeQuery(0);
-
- XmlNamedNativeQuery namedNativeQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedNativeQueries().get(0);
-
- ormNamedNativeQuery.addHint(0).setName("FOO");
- ormNamedNativeQuery.addHint(1).setName("BAR");
- ormNamedNativeQuery.addHint(2).setName("BAZ");
-
- assertEquals(3, namedNativeQueryResource.getHints().size());
-
-
- ormNamedNativeQuery.moveHint(2, 0);
- ListIterator<OrmQueryHint> hints = ormNamedNativeQuery.hints();
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
-
- assertEquals("BAR", namedNativeQueryResource.getHints().get(0).getName());
- assertEquals("BAZ", namedNativeQueryResource.getHints().get(1).getName());
- assertEquals("FOO", namedNativeQueryResource.getHints().get(2).getName());
-
-
- ormNamedNativeQuery.moveHint(0, 1);
- hints = ormNamedNativeQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertEquals("BAR", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
-
- assertEquals("BAZ", namedNativeQueryResource.getHints().get(0).getName());
- assertEquals("BAR", namedNativeQueryResource.getHints().get(1).getName());
- assertEquals("FOO", namedNativeQueryResource.getHints().get(2).getName());
- }
-
- public void testUpdateHints() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedNativeQuery ormNamedNativeQuery = ormEntity.addNamedNativeQuery(0);
-
- XmlNamedNativeQuery namedNativeQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedNativeQueries().get(0);
-
- namedNativeQueryResource.getHints().add(OrmFactory.eINSTANCE.createXmlQueryHint());
- namedNativeQueryResource.getHints().add(OrmFactory.eINSTANCE.createXmlQueryHint());
- namedNativeQueryResource.getHints().add(OrmFactory.eINSTANCE.createXmlQueryHint());
-
- namedNativeQueryResource.getHints().get(0).setName("FOO");
- namedNativeQueryResource.getHints().get(1).setName("BAR");
- namedNativeQueryResource.getHints().get(2).setName("BAZ");
-
- ListIterator<OrmQueryHint> hints = ormNamedNativeQuery.hints();
- assertEquals("FOO", hints.next().getName());
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertFalse(hints.hasNext());
-
- namedNativeQueryResource.getHints().move(2, 0);
- hints = ormNamedNativeQuery.hints();
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- assertFalse(hints.hasNext());
-
- namedNativeQueryResource.getHints().move(0, 1);
- hints = ormNamedNativeQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertEquals("BAR", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- assertFalse(hints.hasNext());
-
- namedNativeQueryResource.getHints().remove(1);
- hints = ormNamedNativeQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- assertFalse(hints.hasNext());
-
- namedNativeQueryResource.getHints().remove(1);
- hints = ormNamedNativeQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertFalse(hints.hasNext());
-
- namedNativeQueryResource.getHints().remove(0);
- assertFalse(ormNamedNativeQuery.hints().hasNext());
- }
-
-
- public void testUpdateResultSetMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedNativeQuery ormNamedNativeQuery = ormEntity.addNamedNativeQuery(0);
-
- XmlNamedNativeQuery namedNativeQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedNativeQueries().get(0);
-
- assertEquals(null, namedNativeQueryResource.getResultSetMapping());
- assertEquals(null, ormNamedNativeQuery.getResultSetMapping());
-
- //set name in the resource model, verify context model updated
- namedNativeQueryResource.setResultSetMapping("foo");
- assertEquals("foo", namedNativeQueryResource.getResultSetMapping());
- assertEquals("foo", ormNamedNativeQuery.getResultSetMapping());
-
- //set name to null in the resource model
- namedNativeQueryResource.setResultSetMapping(null);
- assertNull(namedNativeQueryResource.getResultSetMapping());
- assertNull(ormNamedNativeQuery.getResultSetMapping());
- }
-
- public void testModifyResultSetMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedNativeQuery ormNamedNativeQuery = ormEntity.addNamedNativeQuery(0);
-
- XmlNamedNativeQuery namedNativeQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedNativeQueries().get(0);
-
- assertEquals(null, namedNativeQueryResource.getResultSetMapping());
- assertEquals(null, ormNamedNativeQuery.getResultSetMapping());
-
- //set name in the context model, verify resource model updated
- ormNamedNativeQuery.setResultSetMapping("foo");
- assertEquals("foo", namedNativeQueryResource.getResultSetMapping());
- assertEquals("foo", ormNamedNativeQuery.getResultSetMapping());
-
- //set name to null in the context model
- ormNamedNativeQuery.setResultSetMapping(null);
- assertNull(namedNativeQueryResource.getResultSetMapping());
- assertNull(ormNamedNativeQuery.getResultSetMapping());
- }
-
- public void testUpdateResultClass() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedNativeQuery ormNamedNativeQuery = ormEntity.addNamedNativeQuery(0);
-
- XmlNamedNativeQuery namedNativeQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedNativeQueries().get(0);
-
- assertEquals(null, namedNativeQueryResource.getResultClass());
- assertEquals(null, ormNamedNativeQuery.getResultClass());
-
- //set name in the resource model, verify context model updated
- namedNativeQueryResource.setResultClass("foo");
- assertEquals("foo", namedNativeQueryResource.getResultClass());
- assertEquals("foo", ormNamedNativeQuery.getResultClass());
-
- //set name to null in the resource model
- namedNativeQueryResource.setResultClass(null);
- assertNull(namedNativeQueryResource.getResultClass());
- assertNull(ormNamedNativeQuery.getResultClass());
- }
-
- public void testModifyResultClass() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedNativeQuery ormNamedNativeQuery = ormEntity.addNamedNativeQuery(0);
-
- XmlNamedNativeQuery namedNativeQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedNativeQueries().get(0);
-
- assertEquals(null, namedNativeQueryResource.getResultClass());
- assertEquals(null, ormNamedNativeQuery.getResultClass());
-
- //set name in the context model, verify resource model updated
- ormNamedNativeQuery.setResultClass("foo");
- assertEquals("foo", namedNativeQueryResource.getResultClass());
- assertEquals("foo", ormNamedNativeQuery.getResultClass());
-
- //set name to null in the context model
- ormNamedNativeQuery.setResultClass(null);
- assertNull(namedNativeQueryResource.getResultClass());
- assertNull(ormNamedNativeQuery.getResultClass());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmNamedQueryTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmNamedQueryTests.java
deleted file mode 100644
index 6825936f29..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmNamedQueryTests.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmNamedQuery;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmQueryHint;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlNamedQuery;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmNamedQueryTests extends ContextModelTestCase
-{
- public OrmNamedQueryTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedQuery ormNamedQuery = ormEntity.addNamedQuery(0);
-
- XmlNamedQuery namedQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedQueries().get(0);
-
- assertNull(ormNamedQuery.getName());
- assertNull(namedQueryResource.getName());
-
- //set name in the resource model, verify context model updated
- namedQueryResource.setName("newName");
- assertEquals("newName", ormNamedQuery.getName());
- assertEquals("newName", namedQueryResource.getName());
-
- //set name to null in the resource model
- namedQueryResource.setName(null);
- assertNull(ormNamedQuery.getName());
- assertNull(namedQueryResource.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedQuery ormNamedQuery = ormEntity.addNamedQuery(0);
-
- XmlNamedQuery namedQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedQueries().get(0);
-
- assertNull(ormNamedQuery.getName());
- assertNull(namedQueryResource.getName());
-
- //set name in the context model, verify resource model updated
- ormNamedQuery.setName("newName");
- assertEquals("newName", ormNamedQuery.getName());
- assertEquals("newName", namedQueryResource.getName());
-
- //set name to null in the context model
- ormNamedQuery.setName(null);
- assertNull(ormNamedQuery.getName());
- assertNull(namedQueryResource.getName());
- }
-
- public void testUpdateQuery() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedQuery ormNamedQuery = ormEntity.addNamedQuery(0);
-
- XmlNamedQuery namedQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedQueries().get(0);
-
- assertNull(ormNamedQuery.getQuery());
- assertNull(namedQueryResource.getQuery());
-
- //set name in the resource model, verify context model updated
- namedQueryResource.setQuery("newName");
- assertEquals("newName", ormNamedQuery.getQuery());
- assertEquals("newName", namedQueryResource.getQuery());
-
- //set name to null in the resource model
- namedQueryResource.setQuery(null);
- assertNull(ormNamedQuery.getQuery());
- assertNull(namedQueryResource.getQuery());
- }
-
- public void testModifyQuery() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedQuery ormNamedQuery = ormEntity.addNamedQuery(0);
-
- XmlNamedQuery namedQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedQueries().get(0);
-
- assertNull(ormNamedQuery.getQuery());
- assertNull(namedQueryResource.getQuery());
-
- //set name in the context model, verify resource model updated
- ormNamedQuery.setQuery("newName");
- assertEquals("newName", ormNamedQuery.getQuery());
- assertEquals("newName", namedQueryResource.getQuery());
-
- //set name to null in the context model
- ormNamedQuery.setQuery(null);
- assertNull(ormNamedQuery.getQuery());
- assertNull(namedQueryResource.getQuery());
- }
-
- public void testAddHint() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedQuery ormNamedQuery = ormEntity.addNamedQuery(0);
-
- XmlNamedQuery namedQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedQueries().get(0);
-
- OrmQueryHint queryHint = ormNamedQuery.addHint(0);
- queryHint.setName("FOO");
-
- assertEquals("FOO", namedQueryResource.getHints().get(0).getName());
-
- OrmQueryHint queryHint2 = ormNamedQuery.addHint(0);
- queryHint2.setName("BAR");
-
- assertEquals("BAR", namedQueryResource.getHints().get(0).getName());
- assertEquals("FOO", namedQueryResource.getHints().get(1).getName());
-
- OrmQueryHint queryHint3 = ormNamedQuery.addHint(1);
- queryHint3.setName("BAZ");
-
- assertEquals("BAR", namedQueryResource.getHints().get(0).getName());
- assertEquals("BAZ", namedQueryResource.getHints().get(1).getName());
- assertEquals("FOO", namedQueryResource.getHints().get(2).getName());
-
- ListIterator<OrmQueryHint> queryHints = ormNamedQuery.hints();
- assertEquals(queryHint2, queryHints.next());
- assertEquals(queryHint3, queryHints.next());
- assertEquals(queryHint, queryHints.next());
-
- queryHints = ormNamedQuery.hints();
- assertEquals("BAR", queryHints.next().getName());
- assertEquals("BAZ", queryHints.next().getName());
- assertEquals("FOO", queryHints.next().getName());
- }
-
- public void testRemoveHint() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedQuery ormNamedQuery = ormEntity.addNamedQuery(0);
-
- XmlNamedQuery namedQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedQueries().get(0);
-
- ormNamedQuery.addHint(0).setName("FOO");
- ormNamedQuery.addHint(1).setName("BAR");
- ormNamedQuery.addHint(2).setName("BAZ");
-
- assertEquals(3, namedQueryResource.getHints().size());
-
- ormNamedQuery.removeHint(0);
- assertEquals(2, namedQueryResource.getHints().size());
- assertEquals("BAR", namedQueryResource.getHints().get(0).getName());
- assertEquals("BAZ", namedQueryResource.getHints().get(1).getName());
-
- ormNamedQuery.removeHint(0);
- assertEquals(1, namedQueryResource.getHints().size());
- assertEquals("BAZ", namedQueryResource.getHints().get(0).getName());
-
- ormNamedQuery.removeHint(0);
- assertEquals(0, namedQueryResource.getHints().size());
- }
-
- public void testMoveHint() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedQuery ormNamedQuery = ormEntity.addNamedQuery(0);
-
- XmlNamedQuery namedQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedQueries().get(0);
-
- ormNamedQuery.addHint(0).setName("FOO");
- ormNamedQuery.addHint(1).setName("BAR");
- ormNamedQuery.addHint(2).setName("BAZ");
-
- assertEquals(3, namedQueryResource.getHints().size());
-
-
- ormNamedQuery.moveHint(2, 0);
- ListIterator<OrmQueryHint> hints = ormNamedQuery.hints();
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
-
- assertEquals("BAR", namedQueryResource.getHints().get(0).getName());
- assertEquals("BAZ", namedQueryResource.getHints().get(1).getName());
- assertEquals("FOO", namedQueryResource.getHints().get(2).getName());
-
-
- ormNamedQuery.moveHint(0, 1);
- hints = ormNamedQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertEquals("BAR", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
-
- assertEquals("BAZ", namedQueryResource.getHints().get(0).getName());
- assertEquals("BAR", namedQueryResource.getHints().get(1).getName());
- assertEquals("FOO", namedQueryResource.getHints().get(2).getName());
- }
-
- public void testUpdateHints() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmNamedQuery ormNamedQuery = ormEntity.addNamedQuery(0);
-
- XmlNamedQuery namedQueryResource = ormResource().getEntityMappings().getEntities().get(0).getNamedQueries().get(0);
-
- namedQueryResource.getHints().add(OrmFactory.eINSTANCE.createXmlQueryHint());
- namedQueryResource.getHints().add(OrmFactory.eINSTANCE.createXmlQueryHint());
- namedQueryResource.getHints().add(OrmFactory.eINSTANCE.createXmlQueryHint());
-
- namedQueryResource.getHints().get(0).setName("FOO");
- namedQueryResource.getHints().get(1).setName("BAR");
- namedQueryResource.getHints().get(2).setName("BAZ");
-
- ListIterator<OrmQueryHint> hints = ormNamedQuery.hints();
- assertEquals("FOO", hints.next().getName());
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertFalse(hints.hasNext());
-
- namedQueryResource.getHints().move(2, 0);
- hints = ormNamedQuery.hints();
- assertEquals("BAR", hints.next().getName());
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- assertFalse(hints.hasNext());
-
- namedQueryResource.getHints().move(0, 1);
- hints = ormNamedQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertEquals("BAR", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- assertFalse(hints.hasNext());
-
- namedQueryResource.getHints().remove(1);
- hints = ormNamedQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertEquals("FOO", hints.next().getName());
- assertFalse(hints.hasNext());
-
- namedQueryResource.getHints().remove(1);
- hints = ormNamedQuery.hints();
- assertEquals("BAZ", hints.next().getName());
- assertFalse(hints.hasNext());
-
- namedQueryResource.getHints().remove(0);
- assertFalse(ormNamedQuery.hints().hasNext());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToManyMappingTests.java
deleted file mode 100644
index 22225dfef0..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToManyMappingTests.java
+++ /dev/null
@@ -1,655 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmOneToManyMappingTests extends ContextModelTestCase
-{
- public OrmOneToManyMappingTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertEquals("oneToManyMapping", ormOneToManyMapping.getName());
- assertEquals("oneToManyMapping", oneToMany.getName());
-
- //set name in the resource model, verify context model updated
- oneToMany.setName("newName");
- assertEquals("newName", ormOneToManyMapping.getName());
- assertEquals("newName", oneToMany.getName());
-
- //set name to null in the resource model
- oneToMany.setName(null);
- assertNull(ormOneToManyMapping.getName());
- assertNull(oneToMany.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertEquals("oneToManyMapping", ormOneToManyMapping.getName());
- assertEquals("oneToManyMapping", oneToMany.getName());
-
- //set name in the context model, verify resource model updated
- ormOneToManyMapping.setName("newName");
- assertEquals("newName", ormOneToManyMapping.getName());
- assertEquals("newName", oneToMany.getName());
-
- //set name to null in the context model
- ormOneToManyMapping.setName(null);
- assertNull(ormOneToManyMapping.getName());
- assertNull(oneToMany.getName());
- }
-
- public void testUpdateTargetEntity() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getSpecifiedTargetEntity());
- assertNull(oneToMany.getTargetEntity());
-
- //set target entity in the resource model, verify context model updated
- oneToMany.setTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", ormOneToManyMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", oneToMany.getTargetEntity());
-
- //set target entity to null in the resource model
- oneToMany.setTargetEntity(null);
- assertNull(ormOneToManyMapping.getSpecifiedTargetEntity());
- assertNull(oneToMany.getTargetEntity());
- }
-
- public void testModifyTargetEntity() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getSpecifiedTargetEntity());
- assertNull(oneToMany.getTargetEntity());
-
- //set target entity in the context model, verify resource model updated
- ormOneToManyMapping.setSpecifiedTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", ormOneToManyMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", oneToMany.getTargetEntity());
-
- //set target entity to null in the context model
- ormOneToManyMapping.setSpecifiedTargetEntity(null);
- assertNull(ormOneToManyMapping.getSpecifiedTargetEntity());
- assertNull(oneToMany.getTargetEntity());
- }
-
- public void testUpdateSpecifiedFetch() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToManyResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getSpecifiedFetch());
- assertNull(oneToManyResource.getFetch());
-
- //set fetch in the resource model, verify context model updated
- oneToManyResource.setFetch(org.eclipse.jpt.core.resource.orm.FetchType.EAGER);
- assertEquals(FetchType.EAGER, ormOneToManyMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.EAGER, oneToManyResource.getFetch());
-
- oneToManyResource.setFetch(org.eclipse.jpt.core.resource.orm.FetchType.LAZY);
- assertEquals(FetchType.LAZY, ormOneToManyMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.LAZY, oneToManyResource.getFetch());
-
- //set fetch to null in the resource model
- oneToManyResource.setFetch(null);
- assertNull(ormOneToManyMapping.getSpecifiedFetch());
- assertNull(oneToManyResource.getFetch());
- }
-
- public void testModifySpecifiedFetch() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToManyResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getSpecifiedFetch());
- assertNull(oneToManyResource.getFetch());
-
- //set fetch in the context model, verify resource model updated
- ormOneToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.EAGER, oneToManyResource.getFetch());
- assertEquals(FetchType.EAGER, ormOneToManyMapping.getSpecifiedFetch());
-
- ormOneToManyMapping.setSpecifiedFetch(FetchType.LAZY);
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.LAZY, oneToManyResource.getFetch());
- assertEquals(FetchType.LAZY, ormOneToManyMapping.getSpecifiedFetch());
-
- //set fetch to null in the context model
- ormOneToManyMapping.setSpecifiedFetch(null);
- assertNull(oneToManyResource.getFetch());
- assertNull(ormOneToManyMapping.getSpecifiedFetch());
- }
-
- public void testUpdateMappedBy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getMappedBy());
- assertNull(oneToMany.getMappedBy());
-
- //set mappedBy in the resource model, verify context model updated
- oneToMany.setMappedBy("newMappedBy");
- assertEquals("newMappedBy", ormOneToManyMapping.getMappedBy());
- assertEquals("newMappedBy", oneToMany.getMappedBy());
-
- //setmappedBy to null in the resource model
- oneToMany.setMappedBy(null);
- assertNull(ormOneToManyMapping.getMappedBy());
- assertNull(oneToMany.getMappedBy());
- }
-
- public void testModifyMappedBy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getMappedBy());
- assertNull(oneToMany.getMappedBy());
-
- //set mappedBy in the context model, verify resource model updated
- ormOneToManyMapping.setMappedBy("newMappedBy");
- assertEquals("newMappedBy", ormOneToManyMapping.getMappedBy());
- assertEquals("newMappedBy", oneToMany.getMappedBy());
-
- //set mappedBy to null in the context model
- ormOneToManyMapping.setMappedBy(null);
- assertNull(ormOneToManyMapping.getMappedBy());
- assertNull(oneToMany.getMappedBy());
- }
-
-
- public void testUpdateMapKey() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getMapKey());
- assertNull(oneToMany.getMapKey());
-
- //set mapKey in the resource model, verify context model does not change
- oneToMany.setMapKey(OrmFactory.eINSTANCE.createMapKeyImpl());
- assertNull(ormOneToManyMapping.getMapKey());
- assertNotNull(oneToMany.getMapKey());
-
- //set mapKey name in the resource model, verify context model updated
- oneToMany.getMapKey().setName("myMapKey");
- assertEquals("myMapKey", ormOneToManyMapping.getMapKey());
- assertEquals("myMapKey", oneToMany.getMapKey().getName());
-
- //set mapKey name to null in the resource model
- oneToMany.getMapKey().setName(null);
- assertNull(ormOneToManyMapping.getMapKey());
- assertNull(oneToMany.getMapKey().getName());
-
- oneToMany.getMapKey().setName("myMapKey");
- oneToMany.setMapKey(null);
- assertNull(ormOneToManyMapping.getMapKey());
- assertNull(oneToMany.getMapKey());
- }
-
- public void testModifyMapKey() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getMapKey());
- assertNull(oneToMany.getMapKey());
-
- //set mapKey in the context model, verify resource model updated
- ormOneToManyMapping.setMapKey("myMapKey");
- assertEquals("myMapKey", ormOneToManyMapping.getMapKey());
- assertEquals("myMapKey", oneToMany.getMapKey().getName());
-
- //set mapKey to null in the context model
- ormOneToManyMapping.setMapKey(null);
- assertNull(ormOneToManyMapping.getMapKey());
- assertNull(oneToMany.getMapKey());
- }
-
- public void testUpdateOrderBy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getOrderBy());
- assertNull(oneToMany.getOrderBy());
-
- //set orderBy in the resource model, verify context model updated
- oneToMany.setOrderBy("newOrderBy");
- assertEquals("newOrderBy", ormOneToManyMapping.getOrderBy());
- assertEquals("newOrderBy", oneToMany.getOrderBy());
-
- //set orderBy to null in the resource model
- oneToMany.setOrderBy(null);
- assertNull(ormOneToManyMapping.getOrderBy());
- assertNull(oneToMany.getOrderBy());
- }
-
- public void testModifyOrderBy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getOrderBy());
- assertNull(oneToMany.getOrderBy());
-
- //set mappedBy in the context model, verify resource model updated
- ormOneToManyMapping.setOrderBy("newOrderBy");
- assertEquals("newOrderBy", ormOneToManyMapping.getOrderBy());
- assertEquals("newOrderBy", oneToMany.getOrderBy());
-
- //set mappedBy to null in the context model
- ormOneToManyMapping.setOrderBy(null);
- assertNull(ormOneToManyMapping.getOrderBy());
- assertNull(oneToMany.getOrderBy());
- }
-
- public void testIsNoOrdering() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
-
- assertTrue(ormOneToManyMapping.isNoOrdering());
-
- ormOneToManyMapping.setOrderBy("foo");
- assertFalse(ormOneToManyMapping.isNoOrdering());
-
- ormOneToManyMapping.setOrderBy(null);
- assertTrue(ormOneToManyMapping.isNoOrdering());
- }
-
- public void testSetNoOrdering() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
-
- assertTrue(ormOneToManyMapping.isNoOrdering());
-
- ormOneToManyMapping.setOrderBy("foo");
- assertFalse(ormOneToManyMapping.isNoOrdering());
-
- ormOneToManyMapping.setNoOrdering(true);
- assertTrue(ormOneToManyMapping.isNoOrdering());
- assertNull(ormOneToManyMapping.getOrderBy());
- }
-//TODO
-// public boolean isOrderByPk() {
-// return "".equals(getOrderBy());
-// }
-//
-// public void setOrderByPk() {
-// setOrderBy("");
-// }
-
- public void testIsCustomOrdering() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
-
- assertFalse(ormOneToManyMapping.isCustomOrdering());
-
- ormOneToManyMapping.setOrderBy("foo");
- assertTrue(ormOneToManyMapping.isCustomOrdering());
-
- ormOneToManyMapping.setOrderBy(null);
- assertFalse(ormOneToManyMapping.isCustomOrdering());
- }
-
- public void testOneToManyMorphToIdMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
-
- OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToManyMapping.isDefault());
- oneToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToManyMapping.setOrderBy("customOrder");
- oneToManyMapping.setMapKey("mapKey");
- oneToManyMapping.setMappedBy("mappedBy");
- oneToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = oneToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = oneToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(oneToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping);
- assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testOneToManyMorphToVersionMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
-
- OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToManyMapping.isDefault());
- oneToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToManyMapping.setOrderBy("customOrder");
- oneToManyMapping.setMapKey("mapKey");
- oneToManyMapping.setMappedBy("mappedBy");
- oneToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = oneToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = oneToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(oneToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping);
- assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testOneToManyMorphToTransientMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
-
- OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToManyMapping.isDefault());
- oneToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToManyMapping.setOrderBy("customOrder");
- oneToManyMapping.setMapKey("mapKey");
- oneToManyMapping.setMappedBy("mappedBy");
- oneToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = oneToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = oneToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(oneToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping);
- assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testOneToManyMorphToEmbeddedMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
-
- OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToManyMapping.isDefault());
- oneToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToManyMapping.setOrderBy("customOrder");
- oneToManyMapping.setMapKey("mapKey");
- oneToManyMapping.setMappedBy("mappedBy");
- oneToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = oneToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = oneToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(oneToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testOneToManyMorphToEmbeddedIdMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
-
- OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToManyMapping.isDefault());
- oneToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToManyMapping.setOrderBy("customOrder");
- oneToManyMapping.setMapKey("mapKey");
- oneToManyMapping.setMappedBy("mappedBy");
- oneToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = oneToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = oneToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(oneToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testOneToManyMorphToOneToOneMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
-
- OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToManyMapping.isDefault());
- oneToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToManyMapping.setOrderBy("customOrder");
- oneToManyMapping.setMapKey("mapKey");
- oneToManyMapping.setMappedBy("mappedBy");
- oneToManyMapping.getCascade().setAll(true);
- oneToManyMapping.getCascade().setMerge(true);
- oneToManyMapping.getCascade().setPersist(true);
- oneToManyMapping.getCascade().setRefresh(true);
- oneToManyMapping.getCascade().setRemove(true);
- oneToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = oneToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = oneToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(oneToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping);
- assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName());
- assertEquals(FetchType.EAGER, ((OneToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- assertEquals("TargetEntity", ((OneToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity());
- assertEquals("mappedBy", ((OneToOneMapping) ormPersistentAttribute.getMapping()).getMappedBy());
- assertTrue(((OneToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isAll());
- assertTrue(((OneToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isMerge());
- assertTrue(((OneToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isPersist());
- assertTrue(((OneToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isRefresh());
- assertTrue(((OneToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isRemove());
- }
-
- public void testOneToManyMorphToManyToManyMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
-
- OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToManyMapping.isDefault());
- oneToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToManyMapping.setOrderBy("customOrder");
- oneToManyMapping.setMapKey("mapKey");
- oneToManyMapping.setMappedBy("mappedBy");
- oneToManyMapping.getCascade().setAll(true);
- oneToManyMapping.getCascade().setMerge(true);
- oneToManyMapping.getCascade().setPersist(true);
- oneToManyMapping.getCascade().setRefresh(true);
- oneToManyMapping.getCascade().setRemove(true);
- oneToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = oneToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = oneToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(oneToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName());
- assertEquals(FetchType.EAGER, ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- assertEquals("TargetEntity", ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity());
- assertEquals("mappedBy", ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getMappedBy());
- assertTrue(((ManyToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isAll());
- assertTrue(((ManyToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isMerge());
- assertTrue(((ManyToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isPersist());
- assertTrue(((ManyToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isRefresh());
- assertTrue(((ManyToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isRemove());
- JoinTable joinTable = ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getJoinTable();
- assertEquals("MY_JOIN_TABLE", joinTable.getName());
- assertEquals("name", joinTable.joinColumns().next().getSpecifiedName());
- assertEquals("referenceName", joinTable.joinColumns().next().getSpecifiedReferencedColumnName());
- assertEquals("inverseName", joinTable.inverseJoinColumns().next().getSpecifiedName());
- assertEquals("inverseReferenceName", joinTable.inverseJoinColumns().next().getSpecifiedReferencedColumnName());
- }
-
- public void testOneToManyMorphToManyToOneMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
-
- OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToManyMapping.isDefault());
- oneToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToManyMapping.setOrderBy("customOrder");
- oneToManyMapping.setMapKey("mapKey");
- oneToManyMapping.setMappedBy("mappedBy");
- oneToManyMapping.getCascade().setAll(true);
- oneToManyMapping.getCascade().setMerge(true);
- oneToManyMapping.getCascade().setPersist(true);
- oneToManyMapping.getCascade().setRefresh(true);
- oneToManyMapping.getCascade().setRemove(true);
- oneToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = oneToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = oneToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(oneToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName());
- assertEquals(FetchType.EAGER, ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- assertEquals("TargetEntity", ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isAll());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isMerge());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isPersist());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isRefresh());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isRemove());
- }
-
- public void testOneToManyMorphToBasicMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
-
- OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToManyMapping.isDefault());
- oneToManyMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToManyMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToManyMapping.setOrderBy("customOrder");
- oneToManyMapping.setMapKey("mapKey");
- oneToManyMapping.setMappedBy("mappedBy");
- oneToManyMapping.getCascade().setAll(true);
- oneToManyMapping.getCascade().setMerge(true);
- oneToManyMapping.getCascade().setPersist(true);
- oneToManyMapping.getCascade().setRefresh(true);
- oneToManyMapping.getCascade().setRemove(true);
- oneToManyMapping.getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- JoinColumn joinColumn = oneToManyMapping.getJoinTable().addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- JoinColumn inverseJoinColumn = oneToManyMapping.getJoinTable().addSpecifiedInverseJoinColumn(0);
- inverseJoinColumn.setSpecifiedName("inverseName");
- inverseJoinColumn.setSpecifiedReferencedColumnName("inverseReferenceName");
- assertFalse(oneToManyMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping);
- assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName());
-//TODO assertEquals(FetchType.EAGER, ((IBasicMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToOneMappingTests.java
deleted file mode 100644
index 04ba55d9c3..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToOneMappingTests.java
+++ /dev/null
@@ -1,984 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.Cascade;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmOneToOneMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.XmlOneToOne;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmOneToOneMappingTests extends ContextModelTestCase
-{
- public OrmOneToOneMappingTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createOneToOneAnnotation() throws Exception{
- this.createAnnotationAndMembers("OneToOne",
- "Class targetEntity() default void.class;" +
- "CascadeType[] cascade() default {};" +
- "FetchType fetch() default EAGER;" +
- "boolean optional() default true;" +
- "String mappedBy() default \"\";");
- }
-
- private void createJoinColumnAnnotation() throws Exception{
- this.createAnnotationAndMembers("JoinColumn",
- "String name() default \"\";" +
- "String referencedColumnName() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";");
- }
-
- private IType createTestEntityOneToOneMapping() throws Exception {
- createEntityAnnotation();
- createOneToOneAnnotation();
- createJoinColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE, JPA.JOIN_COLUMN, JPA.FETCH_TYPE, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToOne(fetch=FetchType.LAZY, optional=false, targetEntity=Address.class, cascade={CascadeType.ALL, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH})");
- sb.append(CR);
- sb.append(" @JoinColumn(name=\"MY_COLUMN\", referencedColumnName=\"MY_REFERENCED_COLUMN\", unique=true, nullable=false, insertable=false, updatable=false, columnDefinition=\"COLUMN_DEFINITION\", table=\"MY_TABLE\")");
- sb.append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- sb.append(" @Id");
- }
- });
- }
-
- private IType createTestTargetEntityAddress() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int id;").append(CR);
- sb.append(CR);
- sb.append(" private String city;").append(CR);
- sb.append(CR);
- sb.append(" private String state;").append(CR);
- sb.append(CR);
- sb.append(" private int zip;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter);
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- assertEquals("oneToOneMapping", ormOneToOneMapping.getName());
- assertEquals("oneToOneMapping", oneToOne.getName());
-
- //set name in the resource model, verify context model updated
- oneToOne.setName("newName");
- assertEquals("newName", ormOneToOneMapping.getName());
- assertEquals("newName", oneToOne.getName());
-
- //set name to null in the resource model
- oneToOne.setName(null);
- assertNull(ormOneToOneMapping.getName());
- assertNull(oneToOne.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- assertEquals("oneToOneMapping", ormOneToOneMapping.getName());
- assertEquals("oneToOneMapping", oneToOne.getName());
-
- //set name in the context model, verify resource model updated
- ormOneToOneMapping.setName("newName");
- assertEquals("newName", ormOneToOneMapping.getName());
- assertEquals("newName", oneToOne.getName());
-
- //set name to null in the context model
- ormOneToOneMapping.setName(null);
- assertNull(ormOneToOneMapping.getName());
- assertNull(oneToOne.getName());
- }
-
- public void testUpdateSpecifiedTargetEntity() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- assertNull(ormOneToOneMapping.getSpecifiedTargetEntity());
- assertNull(oneToOne.getTargetEntity());
-
- //set target entity in the resource model, verify context model updated
- oneToOne.setTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", ormOneToOneMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", oneToOne.getTargetEntity());
-
- //set target entity to null in the resource model
- oneToOne.setTargetEntity(null);
- assertNull(ormOneToOneMapping.getSpecifiedTargetEntity());
- assertNull(oneToOne.getTargetEntity());
- }
-
- public void testModifySpecifiedTargetEntity() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- assertNull(ormOneToOneMapping.getSpecifiedTargetEntity());
- assertNull(oneToOne.getTargetEntity());
-
- //set target entity in the context model, verify resource model updated
- ormOneToOneMapping.setSpecifiedTargetEntity("newTargetEntity");
- assertEquals("newTargetEntity", ormOneToOneMapping.getSpecifiedTargetEntity());
- assertEquals("newTargetEntity", oneToOne.getTargetEntity());
-
- //set target entity to null in the context model
- ormOneToOneMapping.setSpecifiedTargetEntity(null);
- assertNull(ormOneToOneMapping.getSpecifiedTargetEntity());
- assertNull(oneToOne.getTargetEntity());
- }
-
- public void testUpdateSpecifiedFetch() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- assertNull(ormOneToOneMapping.getSpecifiedFetch());
- assertNull(oneToOneResource.getFetch());
-
- //set fetch in the resource model, verify context model updated
- oneToOneResource.setFetch(org.eclipse.jpt.core.resource.orm.FetchType.EAGER);
- assertEquals(FetchType.EAGER, ormOneToOneMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.EAGER, oneToOneResource.getFetch());
-
- oneToOneResource.setFetch(org.eclipse.jpt.core.resource.orm.FetchType.LAZY);
- assertEquals(FetchType.LAZY, ormOneToOneMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.LAZY, oneToOneResource.getFetch());
-
- //set fetch to null in the resource model
- oneToOneResource.setFetch(null);
- assertNull(ormOneToOneMapping.getSpecifiedFetch());
- assertNull(oneToOneResource.getFetch());
- }
-
- public void testModifySpecifiedFetch() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- assertNull(ormOneToOneMapping.getSpecifiedFetch());
- assertNull(oneToOneResource.getFetch());
-
- //set fetch in the context model, verify resource model updated
- ormOneToOneMapping.setSpecifiedFetch(FetchType.EAGER);
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.EAGER, oneToOneResource.getFetch());
- assertEquals(FetchType.EAGER, ormOneToOneMapping.getSpecifiedFetch());
-
- ormOneToOneMapping.setSpecifiedFetch(FetchType.LAZY);
- assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.LAZY, oneToOneResource.getFetch());
- assertEquals(FetchType.LAZY, ormOneToOneMapping.getSpecifiedFetch());
-
- //set fetch to null in the context model
- ormOneToOneMapping.setSpecifiedFetch(null);
- assertNull(oneToOneResource.getFetch());
- assertNull(ormOneToOneMapping.getSpecifiedFetch());
- }
-
- public void testUpdateMappedBy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- assertNull(ormOneToOneMapping.getMappedBy());
- assertNull(oneToOne.getMappedBy());
-
- //set mappedBy in the resource model, verify context model updated
- oneToOne.setMappedBy("newMappedBy");
- assertEquals("newMappedBy", ormOneToOneMapping.getMappedBy());
- assertEquals("newMappedBy", oneToOne.getMappedBy());
-
- //set mappedBy to null in the resource model
- oneToOne.setMappedBy(null);
- assertNull(ormOneToOneMapping.getMappedBy());
- assertNull(oneToOne.getMappedBy());
- }
-
- public void testModifyMappedBy() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOne = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- assertNull(ormOneToOneMapping.getMappedBy());
- assertNull(oneToOne.getMappedBy());
-
- //set mappedBy in the context model, verify resource model updated
- ormOneToOneMapping.setMappedBy("newMappedBy");
- assertEquals("newMappedBy", ormOneToOneMapping.getMappedBy());
- assertEquals("newMappedBy", oneToOne.getMappedBy());
-
- //set mappedBy to null in the context model
- ormOneToOneMapping.setMappedBy(null);
- assertNull(ormOneToOneMapping.getMappedBy());
- assertNull(oneToOne.getMappedBy());
- }
-
-
- public void testUpdateSpecifiedOptional() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- assertNull(ormOneToOneMapping.getSpecifiedOptional());
- assertNull(oneToOneResource.getOptional());
-
- //set optional in the resource model, verify context model updated
- oneToOneResource.setOptional(Boolean.TRUE);
- assertEquals(Boolean.TRUE, ormOneToOneMapping.getSpecifiedOptional());
- assertEquals(Boolean.TRUE, oneToOneResource.getOptional());
-
- oneToOneResource.setOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, ormOneToOneMapping.getSpecifiedOptional());
- assertEquals(Boolean.FALSE, oneToOneResource.getOptional());
-
- //set optional to null in the resource model
- oneToOneResource.setOptional(null);
- assertNull(ormOneToOneMapping.getSpecifiedOptional());
- assertNull(oneToOneResource.getOptional());
- }
-
- public void testModifySpecifiedOptional() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- assertNull(ormOneToOneMapping.getSpecifiedOptional());
- assertNull(oneToOneResource.getOptional());
-
- //set optional in the context model, verify resource model updated
- ormOneToOneMapping.setSpecifiedOptional(Boolean.TRUE);
- assertEquals(Boolean.TRUE, oneToOneResource.getOptional());
- assertEquals(Boolean.TRUE, ormOneToOneMapping.getSpecifiedOptional());
-
- ormOneToOneMapping.setSpecifiedOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, oneToOneResource.getOptional());
- assertEquals(Boolean.FALSE, ormOneToOneMapping.getSpecifiedOptional());
-
- //set optional to null in the context model
- ormOneToOneMapping.setSpecifiedOptional(null);
- assertNull(oneToOneResource.getOptional());
- assertNull(ormOneToOneMapping.getSpecifiedOptional());
- }
-
- public void testAddSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- OrmJoinColumn joinColumn = ormOneToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("FOO");
-
- assertEquals("FOO", oneToOneResource.getJoinColumns().get(0).getName());
-
- OrmJoinColumn joinColumn2 = ormOneToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", oneToOneResource.getJoinColumns().get(0).getName());
- assertEquals("FOO", oneToOneResource.getJoinColumns().get(1).getName());
-
- OrmJoinColumn joinColumn3 = ormOneToOneMapping.addSpecifiedJoinColumn(1);
- joinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", oneToOneResource.getJoinColumns().get(0).getName());
- assertEquals("BAZ", oneToOneResource.getJoinColumns().get(1).getName());
- assertEquals("FOO", oneToOneResource.getJoinColumns().get(2).getName());
-
- ListIterator<OrmJoinColumn> joinColumns = ormOneToOneMapping.specifiedJoinColumns();
- assertEquals(joinColumn2, joinColumns.next());
- assertEquals(joinColumn3, joinColumns.next());
- assertEquals(joinColumn, joinColumns.next());
-
- joinColumns = ormOneToOneMapping.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- }
-
- public void testRemoveSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- ormOneToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- ormOneToOneMapping.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- ormOneToOneMapping.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- assertEquals(3, oneToOneResource.getJoinColumns().size());
-
- ormOneToOneMapping.removeSpecifiedJoinColumn(0);
- assertEquals(2, oneToOneResource.getJoinColumns().size());
- assertEquals("BAR", oneToOneResource.getJoinColumns().get(0).getName());
- assertEquals("BAZ", oneToOneResource.getJoinColumns().get(1).getName());
-
- ormOneToOneMapping.removeSpecifiedJoinColumn(0);
- assertEquals(1, oneToOneResource.getJoinColumns().size());
- assertEquals("BAZ", oneToOneResource.getJoinColumns().get(0).getName());
-
- ormOneToOneMapping.removeSpecifiedJoinColumn(0);
- assertEquals(0, oneToOneResource.getJoinColumns().size());
- }
-
- public void testMoveSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- ormOneToOneMapping.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- ormOneToOneMapping.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- ormOneToOneMapping.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- assertEquals(3, oneToOneResource.getJoinColumns().size());
-
-
- ormOneToOneMapping.moveSpecifiedJoinColumn(2, 0);
- ListIterator<OrmJoinColumn> joinColumns = ormOneToOneMapping.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAR", oneToOneResource.getJoinColumns().get(0).getName());
- assertEquals("BAZ", oneToOneResource.getJoinColumns().get(1).getName());
- assertEquals("FOO", oneToOneResource.getJoinColumns().get(2).getName());
-
-
- ormOneToOneMapping.moveSpecifiedJoinColumn(0, 1);
- joinColumns = ormOneToOneMapping.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAZ", oneToOneResource.getJoinColumns().get(0).getName());
- assertEquals("BAR", oneToOneResource.getJoinColumns().get(1).getName());
- assertEquals("FOO", oneToOneResource.getJoinColumns().get(2).getName());
- }
-
- public void testOneToOneMappingNoUnderylingJavaAttribute() throws Exception {
- createTestEntityOneToOneMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "foo");
- assertEquals(3, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("foo", ormOneToOneMapping.getName());
-
- assertNull(ormOneToOneMapping.getSpecifiedFetch());
- assertNull(ormOneToOneMapping.getSpecifiedOptional());
- assertNull(ormOneToOneMapping.getSpecifiedTargetEntity());
- assertEquals(FetchType.EAGER, ormOneToOneMapping.getFetch());
- assertEquals(Boolean.TRUE, ormOneToOneMapping.getOptional());
- assertNull(ormOneToOneMapping.getTargetEntity());
-
-
- assertFalse(ormOneToOneMapping.specifiedJoinColumns().hasNext());
- //TODO default joinColumns
- //assertTrue(ormOneToOneMapping.defaultJoinColumns().hasNext());
-
-
- Cascade cascade = ormOneToOneMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
- }
-
-
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityOneToOneMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- assertEquals(3, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- assertEquals("address", ormOneToOneMapping.getName());
- assertEquals(FetchType.LAZY, ormOneToOneMapping.getSpecifiedFetch());
- assertEquals(Boolean.FALSE, ormOneToOneMapping.getSpecifiedOptional());
- assertEquals("Address", ormOneToOneMapping.getSpecifiedTargetEntity());
- assertNull(ormOneToOneMapping.getMappedBy());
-
- OrmJoinColumn ormJoinColumn = ormOneToOneMapping.specifiedJoinColumns().next();
- assertEquals("MY_COLUMN", ormJoinColumn.getSpecifiedName());
- assertEquals("MY_REFERENCED_COLUMN", ormJoinColumn.getSpecifiedReferencedColumnName());
- assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedUnique());
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedUpdatable());
- assertEquals("COLUMN_DEFINITION", ormJoinColumn.getColumnDefinition());
- assertEquals("MY_TABLE", ormJoinColumn.getSpecifiedTable());
-
- Cascade cascade = ormOneToOneMapping.getCascade();
- assertTrue(cascade.isAll());
- assertTrue(cascade.isMerge());
- assertTrue(cascade.isPersist());
- assertTrue(cascade.isRemove());
- assertTrue(cascade.isRefresh());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityOneToOneMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(3, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
-
- ormPersistentAttribute.makeSpecified(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- ormPersistentAttribute= ormPersistentType.specifiedAttributes().next();
-
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- assertEquals("address", ormOneToOneMapping.getName());
- assertEquals(FetchType.EAGER, ormOneToOneMapping.getFetch());
- assertEquals(Boolean.TRUE, ormOneToOneMapping.getOptional());
- assertEquals("test.Address", ormOneToOneMapping.getTargetEntity());
- assertNull(ormOneToOneMapping.getMappedBy());
-
- //TODO default join columns in xml one-to-one
-// XmlJoinColumn ormJoinColumn = ormOneToOneMapping.specifiedJoinColumns().next();
-// //TODO java default columns name in JavaSingleRelationshipMapping.JoinColumnOwner
-// //assertEquals("address", ormJoinColumn.getSpecifiedName());
-// //assertEquals("address", ormJoinColumn.getSpecifiedReferencedColumnName());
-// assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedUnique());
-// assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedNullable());
-// assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedInsertable());
-// assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedUpdatable());
-// assertNull(ormJoinColumn.getColumnDefinition());
-// assertEquals(TYPE_NAME, ormJoinColumn.getSpecifiedTable());
-
- Cascade cascade = ormOneToOneMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
- }
-
- public void testSpecifiedMapping() throws Exception {
- createTestEntityOneToOneMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address");
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("address", ormOneToOneMapping.getName());
- assertNull(ormOneToOneMapping.getSpecifiedFetch());
- assertNull(ormOneToOneMapping.getSpecifiedOptional());
- assertNull(ormOneToOneMapping.getSpecifiedTargetEntity());
- assertNull(ormOneToOneMapping.getMappedBy());
- assertEquals(FetchType.EAGER, ormOneToOneMapping.getFetch());
- assertEquals(Boolean.TRUE, ormOneToOneMapping.getOptional());
- //TODO default target entity in xml
- //assertEquals("test.Address", ormOneToOneMapping.getDefaultTargetEntity());
-
- assertFalse(ormOneToOneMapping.specifiedJoinColumns().hasNext());
-
- //TODO default join columns for specified xmlOneToOne mapping
-// XmlJoinColumn ormJoinColumn = ormOneToOneMapping.defaultJoinColumns().next();
-// assertNull(ormJoinColumn.getSpecifiedName());
-// assertNull(ormJoinColumn.getSpecifiedReferencedColumnName());
-// assertNull(ormJoinColumn.getSpecifiedUnique());
-// assertNull(ormJoinColumn.getSpecifiedNullable());
-// assertNull(ormJoinColumn.getSpecifiedInsertable());
-// assertNull(ormJoinColumn.getSpecifiedUpdatable());
-// assertNull(ormJoinColumn.getColumnDefinition());
-// assertNull(ormJoinColumn.getSpecifiedTable());
-//
-// assertEquals("address", ormJoinColumn.getDefaultName());
-// assertEquals("address", ormJoinColumn.getDefaultReferencedColumnName());
-// assertEquals(Boolean.FALSE, ormJoinColumn.getDefaultUnique());
-// assertEquals(Boolean.TRUE, ormJoinColumn.getDefaultNullable());
-// assertEquals(Boolean.TRUE, ormJoinColumn.getDefaultInsertable());
-// assertEquals(Boolean.TRUE, ormJoinColumn.getDefaultUpdatable());
-// assertEquals(null, ormJoinColumn.getColumnDefinition());
-// assertEquals(TYPE_NAME, ormJoinColumn.getDefaultTable());
-
- Cascade cascade = ormOneToOneMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
- }
-
-
- public void testOneToOneMorphToIdMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToOneMapping.isDefault());
- oneToOneMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToOneMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToOneMapping.setMappedBy("mappedBy");
- oneToOneMapping.getCascade().setAll(true);
- oneToOneMapping.getCascade().setMerge(true);
- oneToOneMapping.getCascade().setPersist(true);
- oneToOneMapping.getCascade().setRefresh(true);
- oneToOneMapping.getCascade().setRemove(true);
- JoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- assertFalse(oneToOneMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testOneToOneMorphToVersionMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToOneMapping.isDefault());
- oneToOneMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToOneMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToOneMapping.setMappedBy("mappedBy");
- oneToOneMapping.getCascade().setAll(true);
- oneToOneMapping.getCascade().setMerge(true);
- oneToOneMapping.getCascade().setPersist(true);
- oneToOneMapping.getCascade().setRefresh(true);
- oneToOneMapping.getCascade().setRemove(true);
- JoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- assertFalse(oneToOneMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testOneToOneMorphToTransientMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToOneMapping.isDefault());
- oneToOneMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToOneMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToOneMapping.setMappedBy("mappedBy");
- oneToOneMapping.getCascade().setAll(true);
- oneToOneMapping.getCascade().setMerge(true);
- oneToOneMapping.getCascade().setPersist(true);
- oneToOneMapping.getCascade().setRefresh(true);
- oneToOneMapping.getCascade().setRemove(true);
- JoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- assertFalse(oneToOneMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testOneToOneMorphToEmbeddedMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToOneMapping.isDefault());
- oneToOneMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToOneMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToOneMapping.setMappedBy("mappedBy");
- oneToOneMapping.getCascade().setAll(true);
- oneToOneMapping.getCascade().setMerge(true);
- oneToOneMapping.getCascade().setPersist(true);
- oneToOneMapping.getCascade().setRefresh(true);
- oneToOneMapping.getCascade().setRemove(true);
- JoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- assertFalse(oneToOneMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testOneToOneMorphToEmbeddedIdMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToOneMapping.isDefault());
- oneToOneMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToOneMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToOneMapping.setMappedBy("mappedBy");
- oneToOneMapping.getCascade().setAll(true);
- oneToOneMapping.getCascade().setMerge(true);
- oneToOneMapping.getCascade().setPersist(true);
- oneToOneMapping.getCascade().setRefresh(true);
- oneToOneMapping.getCascade().setRemove(true);
- JoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- assertFalse(oneToOneMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testOneToOneMorphToManyToManyMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToOneMapping.isDefault());
- oneToOneMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToOneMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToOneMapping.setMappedBy("mappedBy");
- oneToOneMapping.getCascade().setAll(true);
- oneToOneMapping.getCascade().setMerge(true);
- oneToOneMapping.getCascade().setPersist(true);
- oneToOneMapping.getCascade().setRefresh(true);
- oneToOneMapping.getCascade().setRemove(true);
- JoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- assertFalse(oneToOneMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- assertEquals(FetchType.EAGER, ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- assertEquals("TargetEntity", ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity());
- assertEquals("mappedBy", ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getMappedBy());
- assertTrue(((ManyToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isAll());
- assertTrue(((ManyToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isMerge());
- assertTrue(((ManyToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isPersist());
- assertTrue(((ManyToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isRefresh());
- assertTrue(((ManyToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isRemove());
- }
-
- public void testOneToOneMorphToOneToManyMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToOneMapping.isDefault());
- oneToOneMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToOneMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToOneMapping.setMappedBy("mappedBy");
- oneToOneMapping.getCascade().setAll(true);
- oneToOneMapping.getCascade().setMerge(true);
- oneToOneMapping.getCascade().setPersist(true);
- oneToOneMapping.getCascade().setRefresh(true);
- oneToOneMapping.getCascade().setRemove(true);
- JoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- assertFalse(oneToOneMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- assertEquals(FetchType.EAGER, ((OneToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- assertEquals("TargetEntity", ((OneToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity());
- assertEquals("mappedBy", ((OneToManyMapping) ormPersistentAttribute.getMapping()).getMappedBy());
- assertTrue(((OneToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isAll());
- assertTrue(((OneToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isMerge());
- assertTrue(((OneToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isPersist());
- assertTrue(((OneToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isRefresh());
- assertTrue(((OneToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isRemove());
- }
-
- public void testOneToOneMorphToManyToOneMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToOneMapping.isDefault());
- oneToOneMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToOneMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToOneMapping.setMappedBy("mappedBy");
- oneToOneMapping.getCascade().setAll(true);
- oneToOneMapping.getCascade().setMerge(true);
- oneToOneMapping.getCascade().setPersist(true);
- oneToOneMapping.getCascade().setRefresh(true);
- oneToOneMapping.getCascade().setRemove(true);
- JoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- assertFalse(oneToOneMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- assertEquals(FetchType.EAGER, ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- assertEquals("TargetEntity", ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isAll());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isMerge());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isPersist());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isRefresh());
- assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isRemove());
-
- joinColumn = ((ManyToOneMapping) ormPersistentAttribute.getMapping()).specifiedJoinColumns().next();
- assertEquals("name", joinColumn.getName());
- assertEquals("referenceName", joinColumn.getReferencedColumnName());
- }
-
- public void testOneToOneMorphToBasicMapping() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping();
- assertFalse(oneToOneMapping.isDefault());
- oneToOneMapping.setSpecifiedFetch(FetchType.EAGER);
- oneToOneMapping.setSpecifiedTargetEntity("TargetEntity");
- oneToOneMapping.setMappedBy("mappedBy");
- oneToOneMapping.getCascade().setAll(true);
- oneToOneMapping.getCascade().setMerge(true);
- oneToOneMapping.getCascade().setPersist(true);
- oneToOneMapping.getCascade().setRefresh(true);
- oneToOneMapping.getCascade().setRemove(true);
- JoinColumn joinColumn = oneToOneMapping.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("name");
- joinColumn.setSpecifiedReferencedColumnName("referenceName");
- assertFalse(oneToOneMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
-//TODO assertEquals(FetchType.EAGER, ((IBasicMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- }
-
-
-
-
-
- public void testAddPrimaryKeyJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- OrmPrimaryKeyJoinColumn joinColumn = ormOneToOneMapping.addPrimaryKeyJoinColumn(0);
- joinColumn.setSpecifiedName("FOO");
-
- assertEquals("FOO", oneToOneResource.getPrimaryKeyJoinColumns().get(0).getName());
-
- OrmPrimaryKeyJoinColumn joinColumn2 = ormOneToOneMapping.addPrimaryKeyJoinColumn(0);
- joinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", oneToOneResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("FOO", oneToOneResource.getPrimaryKeyJoinColumns().get(1).getName());
-
- OrmPrimaryKeyJoinColumn joinColumn3 = ormOneToOneMapping.addPrimaryKeyJoinColumn(1);
- joinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", oneToOneResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("BAZ", oneToOneResource.getPrimaryKeyJoinColumns().get(1).getName());
- assertEquals("FOO", oneToOneResource.getPrimaryKeyJoinColumns().get(2).getName());
-
- ListIterator<OrmPrimaryKeyJoinColumn> joinColumns = ormOneToOneMapping.primaryKeyJoinColumns();
- assertEquals(joinColumn2, joinColumns.next());
- assertEquals(joinColumn3, joinColumns.next());
- assertEquals(joinColumn, joinColumns.next());
-
- joinColumns = ormOneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- }
-
- public void testRemovePrimaryKeyJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- ormOneToOneMapping.addPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- ormOneToOneMapping.addPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- ormOneToOneMapping.addPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- assertEquals(3, oneToOneResource.getPrimaryKeyJoinColumns().size());
-
- ormOneToOneMapping.removePrimaryKeyJoinColumn(0);
- assertEquals(2, oneToOneResource.getPrimaryKeyJoinColumns().size());
- assertEquals("BAR", oneToOneResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("BAZ", oneToOneResource.getPrimaryKeyJoinColumns().get(1).getName());
-
- ormOneToOneMapping.removePrimaryKeyJoinColumn(0);
- assertEquals(1, oneToOneResource.getPrimaryKeyJoinColumns().size());
- assertEquals("BAZ", oneToOneResource.getPrimaryKeyJoinColumns().get(0).getName());
-
- ormOneToOneMapping.removePrimaryKeyJoinColumn(0);
- assertEquals(0, oneToOneResource.getPrimaryKeyJoinColumns().size());
- }
-
- public void testMovePrimaryKeyJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlOneToOne oneToOneResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- ormOneToOneMapping.addPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- ormOneToOneMapping.addPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- ormOneToOneMapping.addPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- assertEquals(3, oneToOneResource.getPrimaryKeyJoinColumns().size());
-
-
- ormOneToOneMapping.movePrimaryKeyJoinColumn(2, 0);
- ListIterator<OrmPrimaryKeyJoinColumn> joinColumns = ormOneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAR", oneToOneResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("BAZ", oneToOneResource.getPrimaryKeyJoinColumns().get(1).getName());
- assertEquals("FOO", oneToOneResource.getPrimaryKeyJoinColumns().get(2).getName());
-
-
- ormOneToOneMapping.movePrimaryKeyJoinColumn(0, 1);
- joinColumns = ormOneToOneMapping.primaryKeyJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAZ", oneToOneResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("BAR", oneToOneResource.getPrimaryKeyJoinColumns().get(1).getName());
- assertEquals("FOO", oneToOneResource.getPrimaryKeyJoinColumns().get(2).getName());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPersistentAttributeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPersistentAttributeTests.java
deleted file mode 100644
index 56cac10e77..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPersistentAttributeTests.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.internal.context.orm.GenericOrmIdMapping;
-import org.eclipse.jpt.core.internal.context.orm.GenericOrmNullAttributeMapping;
-import org.eclipse.jpt.core.internal.context.orm.GenericOrmOneToOneMapping;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmPersistentAttributeTests extends ContextModelTestCase
-{
- public OrmPersistentAttributeTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private IType createTestTypeNullAttributeMapping() throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("Column", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- }
-
- private void createOneToOneAnnotation() throws Exception {
- this.createAnnotationAndMembers("OneToOne", "");
- }
-
- private IType createTestEntityIdMapping() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
- createColumnAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- sb.append("@Column(name=\"FOO\")");
- }
- });
- }
-
- private IType createTestEntityOneToOneMapping() throws Exception {
- createEntityAnnotation();
- createOneToOneAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne");
- sb.append(" private Address address;");
- }
- });
- }
-
- public void testMakeSpecified() throws Exception {
- createTestType();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("id", ormPersistentAttribute.getName());
- assertTrue(ormPersistentAttribute.isVirtual());
- ormPersistentAttribute.makeSpecified();
-
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- assertEquals("id", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
-
- ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- ormPersistentAttribute.makeSpecified();
-
- assertEquals(0, ormPersistentType.virtualAttributesSize());
- assertEquals(2, ormPersistentType.specifiedAttributesSize());
- ListIterator<OrmPersistentAttribute> specifiedAttributes = ormPersistentType.specifiedAttributes();
- specifiedOrmPersistentAttribute = specifiedAttributes.next();
- assertEquals("id", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
-
- specifiedOrmPersistentAttribute = specifiedAttributes.next();
- assertEquals("name", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
- }
-
- public void testMakeSpecifiedMappingKey() throws Exception {
- createTestTypeNullAttributeMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(3, ormPersistentType.virtualAttributesSize());
-
- //take a virtual mapping with a mapping type and make it specified
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("address", ormPersistentAttribute.getName());
- assertTrue(ormPersistentAttribute.isVirtual());
- assertTrue(ormPersistentAttribute.getMapping() instanceof GenericOrmNullAttributeMapping);
- ormPersistentAttribute.makeSpecified(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
-
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- assertEquals("address", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
- assertTrue(specifiedOrmPersistentAttribute.getMapping() instanceof GenericOrmOneToOneMapping);
-
-
- ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- ormPersistentAttribute.makeSpecified(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
-
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(2, ormPersistentType.specifiedAttributesSize());
- ListIterator<OrmPersistentAttribute> specifiedAttributes = ormPersistentType.specifiedAttributes();
-
- specifiedOrmPersistentAttribute = specifiedAttributes.next();
- assertEquals("id", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
- assertTrue(specifiedOrmPersistentAttribute.getMapping() instanceof GenericOrmIdMapping);
-
- specifiedOrmPersistentAttribute = specifiedAttributes.next();
- assertEquals("address", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
- }
-
- public void testMakeVirtual() throws Exception {
- createTestType();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- ormPersistentType.virtualAttributes().next().makeSpecified();
- ormPersistentType.virtualAttributes().next().makeSpecified();
-
- assertEquals(0, ormPersistentType.virtualAttributesSize());
- assertEquals(2, ormPersistentType.specifiedAttributesSize());
- OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- assertEquals("id", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
-
- specifiedOrmPersistentAttribute.makeVirtual();
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
-
- specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- specifiedOrmPersistentAttribute.makeVirtual();
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- assertEquals(0, ormPersistentType.specifiedAttributesSize());
-
- ListIterator<OrmPersistentAttribute> virtualAttributes = ormPersistentType.virtualAttributes();
- OrmPersistentAttribute virtualAttribute = virtualAttributes.next();
- assertEquals("id", virtualAttribute.getName());
- virtualAttribute = virtualAttributes.next();
- assertEquals("name", virtualAttribute.getName());
- }
-
- public void testMakeVirtualNoUnderlyingJavaAttribute() throws Exception {
- createTestType();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- ormPersistentType.virtualAttributes().next().makeSpecified();
- ormPersistentType.virtualAttributes().next().makeSpecified();
-
-
- ormPersistentType.specifiedAttributes().next().getMapping().setName("noJavaAttribute");
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(2, ormPersistentType.specifiedAttributesSize());
-
-
- OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- specifiedOrmPersistentAttribute.makeVirtual();
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
-
- assertEquals("id", ormPersistentType.virtualAttributes().next().getName());
- assertEquals("name", ormPersistentType.specifiedAttributes().next().getName());
- }
-
- public void testVirtualMappingTypeWhenMetadataComplete() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("id", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
- assertEquals("FOO", ((IdMapping) ormPersistentAttribute.getMapping()).getColumn().getName());
-
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
-
- ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("id", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
- assertEquals("id", ((BasicMapping) ormPersistentAttribute.getMapping()).getColumn().getName());
- }
-
- public void testVirtualMappingTypeWhenMetadataComplete2() throws Exception {
- createTestEntityOneToOneMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("address", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
-
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
-
- ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("address", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPersistentTypeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPersistentTypeTests.java
deleted file mode 100644
index c29d9de9e3..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPersistentTypeTests.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.orm.XmlBasicImpl;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddedIdImpl;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddedImpl;
-import org.eclipse.jpt.core.resource.orm.XmlIdImpl;
-import org.eclipse.jpt.core.resource.orm.XmlManyToManyImpl;
-import org.eclipse.jpt.core.resource.orm.XmlManyToOneImpl;
-import org.eclipse.jpt.core.resource.orm.XmlOneToManyImpl;
-import org.eclipse.jpt.core.resource.orm.XmlOneToOneImpl;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlTransientImpl;
-import org.eclipse.jpt.core.resource.orm.XmlVersionImpl;
-import org.eclipse.jpt.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.core.resource.orm.XmlEmbedded;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.orm.XmlId;
-import org.eclipse.jpt.core.resource.orm.XmlTransient;
-import org.eclipse.jpt.core.resource.orm.XmlVersion;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmPersistentTypeTests extends ContextModelTestCase
-{
- public OrmPersistentTypeTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
-// public void testUpdateXmlTypeMapping() throws Exception {
-// assertFalse(entityMappings().ormPersistentTypes().hasNext());
-// assertTrue(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
-// assertTrue(ormResource().getEntityMappings().getEntities().isEmpty());
-// assertTrue(ormResource().getEntityMappings().getEmbeddables().isEmpty());
-//
-// //add embeddable in the resource model, verify context model updated
-// Embeddable embeddable = OrmFactory.eINSTANCE.createEmbeddable();
-// ormResource().getEntityMappings().getEmbeddables().add(embeddable);
-// embeddable.setClassName("model.Foo");
-// assertTrue(entityMappings().ormPersistentTypes().hasNext());
-// assertEquals("model.Foo", entityMappings().ormPersistentTypes().next().getMapping().getClass_());
-// assertTrue(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
-// assertTrue(ormResource().getEntityMappings().getEntities().isEmpty());
-// assertFalse(ormResource().getEntityMappings().getEmbeddables().isEmpty());
-// assertEquals("model.Foo", ormResource().getEntityMappings().getEmbeddables().get(0).getClassName());
-//
-// //add entity in the resource model, verify context model updated
-// Entity entity = OrmFactory.eINSTANCE.createEntity();
-// ormResource().getEntityMappings().getEntities().add(entity);
-// entity.setClassName("model.Foo2");
-// assertTrue(entityMappings().ormPersistentTypes().hasNext());
-// assertEquals("model.Foo2", entityMappings().ormPersistentTypes().next().getMapping().getClass_());
-// assertTrue(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
-// assertFalse(ormResource().getEntityMappings().getEntities().isEmpty());
-// assertFalse(ormResource().getEntityMappings().getEmbeddables().isEmpty());
-// assertEquals("model.Foo2", ormResource().getEntityMappings().getEntities().get(0).getClassName());
-//
-// //add mapped-superclass in the resource model, verify context model updated
-// MappedSuperclass mappedSuperclass = OrmFactory.eINSTANCE.createMappedSuperclass();
-// ormResource().getEntityMappings().getMappedSuperclasses().add(mappedSuperclass);
-// mappedSuperclass.setClassName("model.Foo3");
-// assertTrue(entityMappings().ormPersistentTypes().hasNext());
-// assertEquals("model.Foo3", entityMappings().ormPersistentTypes().next().getMapping().getClass_());
-// assertFalse(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
-// assertFalse(ormResource().getEntityMappings().getEntities().isEmpty());
-// assertFalse(ormResource().getEntityMappings().getEmbeddables().isEmpty());
-// assertEquals("model.Foo3", ormResource().getEntityMappings().getMappedSuperclasses().get(0).getClassName());
-// }
-//
-
- public void testMorphXmlTypeMapping() throws Exception {
- assertFalse(entityMappings().ormPersistentTypes().hasNext());
- assertTrue(ormResource().getEntityMappings().getMappedSuperclasses().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEntities().isEmpty());
- assertTrue(ormResource().getEntityMappings().getEmbeddables().isEmpty());
-
- OrmPersistentType embeddablePersistentType = entityMappings().addOrmPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
- OrmPersistentType mappedSuperclassPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo3");
-
- OrmPersistentType ormPersistentType = entityMappings().ormPersistentTypes().next();
- assertEquals(mappedSuperclassPersistentType, ormPersistentType);
- assertEquals(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, ormPersistentType.getMapping().getKey());
-
- ormPersistentType.setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
- assertEquals(0, ormResource().getEntityMappings().getMappedSuperclasses().size());
- assertEquals(1, ormResource().getEntityMappings().getEntities().size());
- assertEquals(2, ormResource().getEntityMappings().getEmbeddables().size());
-
- Iterator<OrmPersistentType> ormPersistentTypes = entityMappings().ormPersistentTypes();
- //the same OrmPersistentTypes should still be in the context model
- assertEquals(ormPersistentTypes.next(), entityPersistentType);
- assertEquals(ormPersistentTypes.next(), embeddablePersistentType);
- assertEquals(ormPersistentTypes.next(), mappedSuperclassPersistentType);
-
- assertEquals("model.Foo", ormResource().getEntityMappings().getEmbeddables().get(0).getClassName());
- assertEquals("model.Foo3", ormResource().getEntityMappings().getEmbeddables().get(1).getClassName());
- }
-
- public void testAddSpecifiedPersistentAttribute() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
-
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicAttribute");
-
- XmlEntity entity = ormResource().getEntityMappings().getEntities().get(0);
- XmlBasic basic = entity.getAttributes().getBasics().get(0);
- assertEquals("basicAttribute", basic.getName());
-
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedAttribute");
-
- XmlEmbedded embedded = entity.getAttributes().getEmbeddeds().get(0);
- assertEquals("embeddedAttribute", embedded.getName());
-
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transientAttribute");
-
- XmlTransient transientResource = entity.getAttributes().getTransients().get(0);
- assertEquals("transientAttribute", transientResource.getName());
-
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionAttribute");
-
- XmlVersion version = entity.getAttributes().getVersions().get(0);
- assertEquals("versionAttribute", version.getName());
-
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idAttribute");
-
- XmlId id = entity.getAttributes().getIds().get(0);
- assertEquals("idAttribute", id.getName());
-
-
- ListIterator<OrmPersistentAttribute> persistentAttributes = entityPersistentType.specifiedAttributes();
- assertEquals("idAttribute", persistentAttributes.next().getName());
- assertEquals("basicAttribute", persistentAttributes.next().getName());
- assertEquals("versionAttribute", persistentAttributes.next().getName());
- assertEquals("embeddedAttribute", persistentAttributes.next().getName());
- assertEquals("transientAttribute", persistentAttributes.next().getName());
- assertFalse(persistentAttributes.hasNext());
- }
-
- public void testRemoveSpecifiedPersistentAttribute() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
-
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicAttribute");
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedAttribute");
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionAttribute");
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idAttribute");
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transientAttribute");
-
- XmlEntity entity = ormResource().getEntityMappings().getEntities().get(0);
- assertEquals("basicAttribute", entity.getAttributes().getBasics().get(0).getName());
- assertEquals("embeddedAttribute", entity.getAttributes().getEmbeddeds().get(0).getName());
- assertEquals("versionAttribute", entity.getAttributes().getVersions().get(0).getName());
- assertEquals("idAttribute", entity.getAttributes().getIds().get(0).getName());
- assertEquals("transientAttribute", entity.getAttributes().getTransients().get(0).getName());
-
- entityPersistentType.removeSpecifiedPersistentAttribute(entityPersistentType.getAttributeNamed("basicAttribute"));
- assertEquals("embeddedAttribute", entity.getAttributes().getEmbeddeds().get(0).getName());
- assertEquals("versionAttribute", entity.getAttributes().getVersions().get(0).getName());
- assertEquals("idAttribute", entity.getAttributes().getIds().get(0).getName());
- assertEquals("transientAttribute", entity.getAttributes().getTransients().get(0).getName());
-
- entityPersistentType.removeSpecifiedPersistentAttribute(entityPersistentType.getAttributeNamed("embeddedAttribute"));
- assertEquals("versionAttribute", entity.getAttributes().getVersions().get(0).getName());
- assertEquals("idAttribute", entity.getAttributes().getIds().get(0).getName());
- assertEquals("transientAttribute", entity.getAttributes().getTransients().get(0).getName());
-
- entityPersistentType.removeSpecifiedPersistentAttribute(entityPersistentType.getAttributeNamed("versionAttribute"));
- assertEquals("idAttribute", entity.getAttributes().getIds().get(0).getName());
- assertEquals("transientAttribute", entity.getAttributes().getTransients().get(0).getName());
-
- entityPersistentType.removeSpecifiedPersistentAttribute(entityPersistentType.getAttributeNamed("idAttribute"));
- assertEquals("transientAttribute", entity.getAttributes().getTransients().get(0).getName());
-
- entityPersistentType.removeSpecifiedPersistentAttribute(entityPersistentType.getAttributeNamed("transientAttribute"));
- assertNull(entity.getAttributes());
- }
-
- public void testRemoveId() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
- XmlEntity entity = ormResource().getEntityMappings().getEntities().get(0);
-
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idAttribute");
- assertEquals("idAttribute", entity.getAttributes().getIds().get(0).getName());
-
- entityPersistentType.removeSpecifiedPersistentAttribute(entityPersistentType.getAttributeNamed("idAttribute"));
- assertNull(entity.getAttributes());
- }
-
- public void testRemoveBasic() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
- XmlEntity entity = ormResource().getEntityMappings().getEntities().get(0);
-
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicAttribute");
- assertEquals("basicAttribute", entity.getAttributes().getBasics().get(0).getName());
-
- entityPersistentType.removeSpecifiedPersistentAttribute(entityPersistentType.getAttributeNamed("basicAttribute"));
- assertNull(entity.getAttributes());
- }
-
- public void testRemoveVersion() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
- XmlEntity entity = ormResource().getEntityMappings().getEntities().get(0);
-
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionAttribute");
- assertEquals("versionAttribute", entity.getAttributes().getVersions().get(0).getName());
-
- entityPersistentType.removeSpecifiedPersistentAttribute(entityPersistentType.getAttributeNamed("versionAttribute"));
- assertNull(entity.getAttributes());
- }
-
- public void testRemoveEmbedded() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
- XmlEntity entity = ormResource().getEntityMappings().getEntities().get(0);
-
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedAttribute");
- assertEquals("embeddedAttribute", entity.getAttributes().getEmbeddeds().get(0).getName());
-
- entityPersistentType.removeSpecifiedPersistentAttribute(entityPersistentType.getAttributeNamed("embeddedAttribute"));
- assertNull(entity.getAttributes());
- }
-
- public void testRemoveTransient() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
- XmlEntity entity = ormResource().getEntityMappings().getEntities().get(0);
-
- entityPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transientAttribute");
- assertEquals("transientAttribute", entity.getAttributes().getTransients().get(0).getName());
-
- entityPersistentType.removeSpecifiedPersistentAttribute(entityPersistentType.getAttributeNamed("transientAttribute"));
- assertNull(entity.getAttributes());
- }
-
- public void testUpdateSpecifiedPersistentAttributes() throws Exception {
- OrmPersistentType entityPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
- XmlEntity entity = ormResource().getEntityMappings().getEntities().get(0);
-
- entity.setAttributes(OrmFactory.eINSTANCE.createAttributes());
- XmlBasicImpl basic = OrmFactory.eINSTANCE.createXmlBasicImpl();
- entity.getAttributes().getBasics().add(basic);
- basic.setName("basicAttribute");
-
- OrmPersistentAttribute ormPersistentAttribute = entityPersistentType.attributes().next();
- assertEquals("basicAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
-
- XmlEmbeddedImpl embedded = OrmFactory.eINSTANCE.createXmlEmbeddedImpl();
- entity.getAttributes().getEmbeddeds().add(embedded);
- embedded.setName("embeddedAttribute");
-
- ListIterator<OrmPersistentAttribute> attributes = entityPersistentType.attributes();
- ormPersistentAttribute = attributes.next();
- assertEquals("basicAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("embeddedAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- assertFalse(attributes.hasNext());
-
- XmlVersionImpl version = OrmFactory.eINSTANCE.createXmlVersionImpl();
- entity.getAttributes().getVersions().add(version);
- version.setName("versionAttribute");
-
- attributes = entityPersistentType.attributes();
- ormPersistentAttribute = attributes.next();
- assertEquals("basicAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("versionAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("embeddedAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- assertFalse(attributes.hasNext());
-
- XmlIdImpl id = OrmFactory.eINSTANCE.createXmlIdImpl();
- entity.getAttributes().getIds().add(id);
- id.setName("idAttribute");
-
- attributes = entityPersistentType.attributes();
- ormPersistentAttribute = attributes.next();
- assertEquals("idAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("basicAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("versionAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("embeddedAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- assertFalse(attributes.hasNext());
-
- XmlTransientImpl transientResource = OrmFactory.eINSTANCE.createXmlTransientImpl();
- entity.getAttributes().getTransients().add(transientResource);
- transientResource.setName("transientAttribute");
-
- attributes = entityPersistentType.attributes();
- ormPersistentAttribute = attributes.next();
- assertEquals("idAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("basicAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("versionAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("embeddedAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("transientAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- assertFalse(attributes.hasNext());
-
- XmlManyToOneImpl manyToOneResource = OrmFactory.eINSTANCE.createXmlManyToOneImpl();
- entity.getAttributes().getManyToOnes().add(manyToOneResource);
- manyToOneResource.setName("manyToOneAttribute");
-
- attributes = entityPersistentType.attributes();
- ormPersistentAttribute = attributes.next();
- assertEquals("idAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("basicAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("versionAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("manyToOneAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("embeddedAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("transientAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- assertFalse(attributes.hasNext());
-
- XmlManyToManyImpl manyToManyResource = OrmFactory.eINSTANCE.createXmlManyToManyImpl();
- entity.getAttributes().getManyToManys().add(manyToManyResource);
- manyToManyResource.setName("manyToManyAttribute");
-
- attributes = entityPersistentType.attributes();
- ormPersistentAttribute = attributes.next();
- assertEquals("idAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("basicAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("versionAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("manyToOneAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("manyToManyAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("embeddedAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("transientAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- assertFalse(attributes.hasNext());
-
- XmlOneToManyImpl oneToManyResource = OrmFactory.eINSTANCE.createXmlOneToManyImpl();
- entity.getAttributes().getOneToManys().add(oneToManyResource);
- oneToManyResource.setName("oneToManyAttribute");
-
- attributes = entityPersistentType.attributes();
- ormPersistentAttribute = attributes.next();
- assertEquals("idAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("basicAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("versionAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("manyToOneAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("oneToManyAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("manyToManyAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("embeddedAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("transientAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- assertFalse(attributes.hasNext());
-
- XmlOneToOneImpl oneToOneResource = OrmFactory.eINSTANCE.createXmlOneToOneImpl();
- entity.getAttributes().getOneToOnes().add(oneToOneResource);
- oneToOneResource.setName("oneToOneAttribute");
-
- attributes = entityPersistentType.attributes();
- ormPersistentAttribute = attributes.next();
- assertEquals("idAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("basicAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("versionAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("manyToOneAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("oneToManyAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("oneToOneAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("manyToManyAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("embeddedAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("transientAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- assertFalse(attributes.hasNext());
-
-
- XmlEmbeddedIdImpl embeddedIdResource = OrmFactory.eINSTANCE.createXmlEmbeddedIdImpl();
- entity.getAttributes().getEmbeddedIds().add(embeddedIdResource);
- embeddedIdResource.setName("embeddedIdAttribute");
-
- attributes = entityPersistentType.attributes();
- ormPersistentAttribute = attributes.next();
- assertEquals("idAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("embeddedIdAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("basicAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("versionAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("manyToOneAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("oneToManyAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("oneToOneAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("manyToManyAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("embeddedAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute = attributes.next();
- assertEquals("transientAttribute", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMapping().getKey());
- assertFalse(attributes.hasNext());
-
- entity.getAttributes().getBasics().remove(0);
- entity.getAttributes().getEmbeddeds().remove(0);
- entity.getAttributes().getTransients().remove(0);
- entity.getAttributes().getIds().remove(0);
- entity.getAttributes().getVersions().remove(0);
- entity.getAttributes().getManyToOnes().remove(0);
- entity.getAttributes().getManyToManys().remove(0);
- entity.getAttributes().getOneToManys().remove(0);
- entity.getAttributes().getOneToOnes().remove(0);
- entity.getAttributes().getEmbeddedIds().remove(0);
- assertFalse(entityPersistentType.attributes().hasNext());
- assertNotNull(entity.getAttributes());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPrimaryKeyJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPrimaryKeyJoinColumnTests.java
deleted file mode 100644
index 9f2b87d7d5..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPrimaryKeyJoinColumnTests.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmPrimaryKeyJoinColumnTests extends ContextModelTestCase
-{
- public OrmPrimaryKeyJoinColumnTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- public void testUpdateSpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmPrimaryKeyJoinColumn ormPrimaryKeyJoinColumn = ormEntity.addSpecifiedPrimaryKeyJoinColumn(0);
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlPrimaryKeyJoinColumn primaryKeyJoinColumnResource = entityResource.getPrimaryKeyJoinColumns().get(0);
-
- assertNull(ormPrimaryKeyJoinColumn.getSpecifiedName());
- assertNull(primaryKeyJoinColumnResource.getName());
-
- //set name in the resource model, verify context model updated
- primaryKeyJoinColumnResource.setName("FOO");
- assertEquals("FOO", ormPrimaryKeyJoinColumn.getSpecifiedName());
- assertEquals("FOO", primaryKeyJoinColumnResource.getName());
-
- //set name to null in the resource model
- primaryKeyJoinColumnResource.setName(null);
- assertNull(ormPrimaryKeyJoinColumn.getSpecifiedName());
- assertNull(primaryKeyJoinColumnResource.getName());
-
- primaryKeyJoinColumnResource.setName("FOO");
- assertEquals("FOO", ormPrimaryKeyJoinColumn.getSpecifiedName());
- assertEquals("FOO", primaryKeyJoinColumnResource.getName());
-
- entityResource.getPrimaryKeyJoinColumns().remove(0);
- assertFalse(ormEntity.primaryKeyJoinColumns().hasNext());
- assertTrue(entityResource.getPrimaryKeyJoinColumns().isEmpty());
- }
-
- public void testModifySpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmPrimaryKeyJoinColumn ormPrimaryKeyJoinColumn = ormEntity.addSpecifiedPrimaryKeyJoinColumn(0);
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlPrimaryKeyJoinColumn primaryKeyJoinColumnResource = entityResource.getPrimaryKeyJoinColumns().get(0);
-
- assertNull(ormPrimaryKeyJoinColumn.getSpecifiedName());
- assertNull(primaryKeyJoinColumnResource.getName());
-
- //set name in the context model, verify resource model modified
- ormPrimaryKeyJoinColumn.setSpecifiedName("foo");
- assertEquals("foo", ormPrimaryKeyJoinColumn.getSpecifiedName());
- assertEquals("foo", primaryKeyJoinColumnResource.getName());
-
- //set name to null in the context model
- ormPrimaryKeyJoinColumn.setSpecifiedName(null);
- assertNull(ormPrimaryKeyJoinColumn.getSpecifiedName());
- assertNull(entityResource.getPrimaryKeyJoinColumns().get(0).getName());
- }
-
- public void testUpdateSpecifiedReferencedColumnName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmPrimaryKeyJoinColumn ormPrimaryKeyJoinColumn = ormEntity.addSpecifiedPrimaryKeyJoinColumn(0);
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlPrimaryKeyJoinColumn primaryKeyJoinColumnResource = entityResource.getPrimaryKeyJoinColumns().get(0);
-
- assertNull(ormPrimaryKeyJoinColumn.getSpecifiedReferencedColumnName());
- assertNull(primaryKeyJoinColumnResource.getReferencedColumnName());
-
- //set name in the resource model, verify context model updated
- primaryKeyJoinColumnResource.setReferencedColumnName("FOO");
- assertEquals("FOO", ormPrimaryKeyJoinColumn.getSpecifiedReferencedColumnName());
- assertEquals("FOO", primaryKeyJoinColumnResource.getReferencedColumnName());
-
- //set name to null in the resource model
- primaryKeyJoinColumnResource.setReferencedColumnName(null);
- assertNull(ormPrimaryKeyJoinColumn.getSpecifiedReferencedColumnName());
- assertNull(primaryKeyJoinColumnResource.getReferencedColumnName());
-
- primaryKeyJoinColumnResource.setReferencedColumnName("FOO");
- assertEquals("FOO", ormPrimaryKeyJoinColumn.getSpecifiedReferencedColumnName());
- assertEquals("FOO", primaryKeyJoinColumnResource.getReferencedColumnName());
-
- entityResource.getPrimaryKeyJoinColumns().remove(0);
- assertFalse(ormEntity.primaryKeyJoinColumns().hasNext());
- assertTrue(entityResource.getPrimaryKeyJoinColumns().isEmpty());
- }
-
- public void testModifySpecifiedReferencedColumnName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmPrimaryKeyJoinColumn ormPrimaryKeyJoinColumn = ormEntity.addSpecifiedPrimaryKeyJoinColumn(0);
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlPrimaryKeyJoinColumn primaryKeyJoinColumnResource = entityResource.getPrimaryKeyJoinColumns().get(0);
-
- assertNull(ormPrimaryKeyJoinColumn.getSpecifiedReferencedColumnName());
- assertNull(primaryKeyJoinColumnResource.getReferencedColumnName());
-
- //set name in the context model, verify resource model modified
- ormPrimaryKeyJoinColumn.setSpecifiedReferencedColumnName("foo");
- assertEquals("foo", ormPrimaryKeyJoinColumn.getSpecifiedReferencedColumnName());
- assertEquals("foo", primaryKeyJoinColumnResource.getReferencedColumnName());
-
- //set name to null in the context model
- ormPrimaryKeyJoinColumn.setSpecifiedReferencedColumnName(null);
- assertNull(ormPrimaryKeyJoinColumn.getSpecifiedReferencedColumnName());
- assertNull(entityResource.getPrimaryKeyJoinColumns().get(0).getReferencedColumnName());
- }
-
-// public void testUpdateDefaultNameFromJavaTable() throws Exception {
-// createTestEntity();
-//
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// XmlEntity ormEntity = (XmlEntity) ormPersistentType.getMapping();
-// assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-//
-// ormEntity.javaEntity().getTable().setSpecifiedName("Foo");
-// assertEquals("Foo", ormEntity.getTable().getDefaultName());
-//
-// ormEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-// assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-//
-// ormEntity.entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
-// ormEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
-// assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-//
-// ormEntity.setSpecifiedMetadataComplete(null);
-// assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-//
-// ormEntity.entityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
-// assertEquals("Foo", ormEntity.getTable().getDefaultName());
-//
-// ormEntity.getTable().setSpecifiedName("Bar");
-// assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-// }
-//
-// public void testUpdateDefaultNameNoJava() throws Exception {
-// createTestEntity();
-//
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlEntity ormEntity = (XmlEntity) ormPersistentType.getMapping();
-// assertEquals("Foo", ormEntity.getTable().getDefaultName());
-// }
-//
-// public void testUpdateDefaultNameFromParent() throws Exception {
-// createTestEntity();
-// createTestSubType();
-//
-// OrmPersistentType parentOrmPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// OrmPersistentType childOrmPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
-// XmlEntity parentXmlEntity = (XmlEntity) parentOrmPersistentType.getMapping();
-// XmlEntity childXmlEntity = (XmlEntity) childOrmPersistentType.getMapping();
-//
-// assertEquals(TYPE_NAME, parentXmlEntity.getTable().getDefaultName());
-// assertEquals(TYPE_NAME, childXmlEntity.getTable().getDefaultName());
-//
-// parentXmlEntity.getTable().setSpecifiedName("FOO");
-// assertEquals(TYPE_NAME, parentXmlEntity.getTable().getDefaultName());
-// assertEquals("FOO", childXmlEntity.getTable().getDefaultName());
-//
-// parentXmlEntity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
-// assertEquals(TYPE_NAME, parentXmlEntity.getTable().getDefaultName());
-// assertEquals("AnnotationTestTypeChild", childXmlEntity.getTable().getDefaultName());
-// }
-
-
- public void testUpdateSpecifiedColumnDefinition() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmPrimaryKeyJoinColumn ormPrimaryKeyJoinColumn = ormEntity.addSpecifiedPrimaryKeyJoinColumn(0);
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlPrimaryKeyJoinColumn primaryKeyJoinColumnResource = entityResource.getPrimaryKeyJoinColumns().get(0);
-
- assertNull(ormPrimaryKeyJoinColumn.getColumnDefinition());
- assertNull(primaryKeyJoinColumnResource.getColumnDefinition());
-
- //set name in the resource model, verify context model updated
- primaryKeyJoinColumnResource.setColumnDefinition("FOO");
- assertEquals("FOO", ormPrimaryKeyJoinColumn.getColumnDefinition());
- assertEquals("FOO", primaryKeyJoinColumnResource.getColumnDefinition());
-
- //set name to null in the resource model
- primaryKeyJoinColumnResource.setColumnDefinition(null);
- assertNull(ormPrimaryKeyJoinColumn.getColumnDefinition());
- assertNull(primaryKeyJoinColumnResource.getColumnDefinition());
-
- primaryKeyJoinColumnResource.setColumnDefinition("FOO");
- assertEquals("FOO", ormPrimaryKeyJoinColumn.getColumnDefinition());
- assertEquals("FOO", primaryKeyJoinColumnResource.getColumnDefinition());
-
- entityResource.getPrimaryKeyJoinColumns().remove(0);
- assertFalse(ormEntity.primaryKeyJoinColumns().hasNext());
- assertTrue(entityResource.getPrimaryKeyJoinColumns().isEmpty());
- }
-
- public void testModifySpecifiedColumnDefinition() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmPrimaryKeyJoinColumn ormPrimaryKeyJoinColumn = ormEntity.addSpecifiedPrimaryKeyJoinColumn(0);
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlPrimaryKeyJoinColumn primaryKeyJoinColumnResource = entityResource.getPrimaryKeyJoinColumns().get(0);
-
- assertNull(ormPrimaryKeyJoinColumn.getColumnDefinition());
- assertNull(primaryKeyJoinColumnResource.getColumnDefinition());
-
- //set name in the context model, verify resource model modified
- ormPrimaryKeyJoinColumn.setColumnDefinition("foo");
- assertEquals("foo", ormPrimaryKeyJoinColumn.getColumnDefinition());
- assertEquals("foo", primaryKeyJoinColumnResource.getColumnDefinition());
-
- //set name to null in the context model
- ormPrimaryKeyJoinColumn.setColumnDefinition(null);
- assertNull(ormPrimaryKeyJoinColumn.getColumnDefinition());
- assertNull(entityResource.getPrimaryKeyJoinColumns().get(0).getColumnDefinition());
- }
-
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmQueryHintTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmQueryHintTests.java
deleted file mode 100644
index 1323d381d3..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmQueryHintTests.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmQueryHint;
-import org.eclipse.jpt.core.resource.orm.XmlQueryHint;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmQueryHintTests extends ContextModelTestCase
-{
- public OrmQueryHintTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmQueryHint ormQueryHint = ormEntity.addNamedQuery(0).addHint(0);
-
- XmlQueryHint queryHintResource = ormResource().getEntityMappings().getEntities().get(0).getNamedQueries().get(0).getHints().get(0);
-
- assertNull(ormQueryHint.getName());
- assertNull(queryHintResource.getName());
-
- //set name in the resource model, verify context model updated
- queryHintResource.setName("newName");
- assertEquals("newName", ormQueryHint.getName());
- assertEquals("newName", queryHintResource.getName());
-
- //set name to null in the resource model
- queryHintResource.setName(null);
- assertNull(ormQueryHint.getName());
- assertNull(queryHintResource.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmQueryHint ormQueryHint = ormEntity.addNamedQuery(0).addHint(0);
-
- XmlQueryHint queryHintResource = ormResource().getEntityMappings().getEntities().get(0).getNamedQueries().get(0).getHints().get(0);
-
- assertNull(ormQueryHint.getName());
- assertNull(queryHintResource.getName());
-
- //set name in the context model, verify resource model updated
- ormQueryHint.setName("newName");
- assertEquals("newName", ormQueryHint.getName());
- assertEquals("newName", queryHintResource.getName());
-
- //set name to null in the context model
- ormQueryHint.setName(null);
- assertNull(ormQueryHint.getName());
- assertNull(queryHintResource.getName());
- }
-
- public void testUpdateValue() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmQueryHint ormQueryHint = ormEntity.addNamedQuery(0).addHint(0);
-
- XmlQueryHint queryHintResource = ormResource().getEntityMappings().getEntities().get(0).getNamedQueries().get(0).getHints().get(0);
-
- assertNull(ormQueryHint.getValue());
- assertNull(queryHintResource.getValue());
-
- //set name in the resource model, verify context model updated
- queryHintResource.setValue("newName");
- assertEquals("newName", ormQueryHint.getValue());
- assertEquals("newName", queryHintResource.getValue());
-
- //set name to null in the resource model
- queryHintResource.setValue(null);
- assertNull(ormQueryHint.getValue());
- assertNull(queryHintResource.getValue());
- }
-
- public void testModifyValue() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmQueryHint ormQueryHint = ormEntity.addNamedQuery(0).addHint(0);
-
- XmlQueryHint queryHintResource = ormResource().getEntityMappings().getEntities().get(0).getNamedQueries().get(0).getHints().get(0);
-
- assertNull(ormQueryHint.getValue());
- assertNull(queryHintResource.getValue());
-
- //set name in the context model, verify resource model updated
- ormQueryHint.setValue("newName");
- assertEquals("newName", ormQueryHint.getValue());
- assertEquals("newName", queryHintResource.getValue());
-
- //set name to null in the context model
- ormQueryHint.setValue(null);
- assertNull(ormQueryHint.getValue());
- assertNull(queryHintResource.getValue());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSecondaryTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSecondaryTableTests.java
deleted file mode 100644
index ebada5c7eb..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSecondaryTableTests.java
+++ /dev/null
@@ -1,775 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.InheritanceType;
-import org.eclipse.jpt.core.context.SecondaryTable;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.context.java.JavaSecondaryTable;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmSecondaryTable;
-import org.eclipse.jpt.core.context.orm.OrmUniqueConstraint;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.orm.XmlSecondaryTable;
-import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmSecondaryTableTests extends ContextModelTestCase
-{
- public OrmSecondaryTableTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- public void testUpdateSpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- //set name in the resource model, verify context model updated
- entityResource.getSecondaryTables().add(OrmFactory.eINSTANCE.createXmlSecondaryTableImpl());
- entityResource.getSecondaryTables().get(0).setName("FOO");
- OrmSecondaryTable secondaryTable = ormEntity.specifiedSecondaryTables().next();
- assertEquals("FOO", secondaryTable.getSpecifiedName());
- assertEquals("FOO", entityResource.getSecondaryTables().get(0).getName());
-
- //set name to null in the resource model
- entityResource.getSecondaryTables().get(0).setName(null);
- assertNull(secondaryTable.getSpecifiedName());
- assertNull(entityResource.getSecondaryTables().get(0).getName());
-
- entityResource.getSecondaryTables().remove(0);
- assertFalse(ormEntity.specifiedSecondaryTables().hasNext());
- assertEquals(0, entityResource.getSecondaryTables().size());
- }
-
- public void testModifySpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- //set name in the context model, verify resource model modified
- OrmSecondaryTable secondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- secondaryTable.setSpecifiedName("foo");
-
- assertEquals("foo", secondaryTable.getSpecifiedName());
- assertEquals("foo", entityResource.getSecondaryTables().get(0).getName());
-
- //set name to null in the context model
- secondaryTable.setSpecifiedName(null);
- assertNull(secondaryTable.getSpecifiedName());
- assertNull(entityResource.getSecondaryTables().get(0).getName());
-
- ormEntity.removeSpecifiedSecondaryTable(0);
- assertFalse(ormEntity.specifiedSecondaryTables().hasNext());
- assertEquals(0, entityResource.getSecondaryTables().size());
- }
-
- public void testUpdateDefaultNameFromJavaTable() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- ormEntity.getJavaEntity().addSpecifiedSecondaryTable(0).setSpecifiedName("FOO");
-
- OrmSecondaryTable ormSecondaryTable = ormEntity.virtualSecondaryTables().next();
- assertEquals("FOO", ormSecondaryTable.getSpecifiedName());
-
- ormEntity.getJavaEntity().specifiedSecondaryTables().next().setSpecifiedName("BAZ");
- assertEquals("BAZ", ormSecondaryTable.getSpecifiedName());
-
- ormEntity.setSecondaryTablesDefinedInXml(true);
- assertNull(ormEntity.specifiedSecondaryTables().next().getDefaultName());
- assertEquals("BAZ", ormEntity.specifiedSecondaryTables().next().getSpecifiedName());
-
- }
-
- public void testUpdateSpecifiedSchema() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- //set schema in the resource model, verify context model updated
- entityResource.getSecondaryTables().add(OrmFactory.eINSTANCE.createXmlSecondaryTableImpl());
- entityResource.getSecondaryTables().get(0).setSchema("FOO");
- OrmSecondaryTable secondaryTable = ormEntity.specifiedSecondaryTables().next();
- assertEquals("FOO", secondaryTable.getSpecifiedSchema());
- assertEquals("FOO", entityResource.getSecondaryTables().get(0).getSchema());
-
- //set schema to null in the resource model
- entityResource.getSecondaryTables().get(0).setSchema(null);
- assertNull(secondaryTable.getSpecifiedSchema());
- assertNull(entityResource.getSecondaryTables().get(0).getSchema());
-
- entityResource.getSecondaryTables().remove(0);
- assertFalse(ormEntity.specifiedSecondaryTables().hasNext());
- assertEquals(0, entityResource.getSecondaryTables().size());
- }
-
- public void testModifySpecifiedSchema() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- //set schema in the context model, verify resource model modified
- OrmSecondaryTable secondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- secondaryTable.setSpecifiedSchema("foo");
-
- assertEquals("foo", secondaryTable.getSpecifiedSchema());
- assertEquals("foo", entityResource.getSecondaryTables().get(0).getSchema());
-
- //set schema to null in the context model
- secondaryTable.setSpecifiedSchema(null);
- assertNull(secondaryTable.getSpecifiedSchema());
- assertNull(entityResource.getSecondaryTables().get(0).getSchema());
-
- ormEntity.removeSpecifiedSecondaryTable(0);
- assertFalse(ormEntity.specifiedSecondaryTables().hasNext());
- assertEquals(0, entityResource.getSecondaryTables().size());
- }
-
- public void testUpdateDefaultSchemaFromJavaTable() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-
- SecondaryTable javaSecondaryTable = ormEntity.getJavaEntity().addSpecifiedSecondaryTable(0);
- javaSecondaryTable.setSpecifiedName("FOO");
- javaSecondaryTable.setSpecifiedSchema("BAR");
-
- OrmSecondaryTable ormSecondaryTable = ormEntity.virtualSecondaryTables().next();
- assertEquals("BAR", ormSecondaryTable.getSpecifiedSchema());
-
- javaSecondaryTable.setSpecifiedSchema("BAZ");
- assertEquals("BAZ", ormSecondaryTable.getSpecifiedSchema());
-
-
- ormEntity.setSecondaryTablesDefinedInXml(true);
- assertNull(ormEntity.specifiedSecondaryTables().next().getDefaultSchema());
- assertEquals("BAZ", ormEntity.specifiedSecondaryTables().next().getSpecifiedSchema());
- }
-
- public void testUpdateDefaultSchemaFromParent() throws Exception {
- createTestEntity();
- createTestSubType();
-
- OrmPersistentType parentOrmPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentType childOrmPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
- OrmEntity parentOrmEntity = (OrmEntity) parentOrmPersistentType.getMapping();
- OrmEntity childOrmEntity = (OrmEntity) childOrmPersistentType.getMapping();
-
- assertNull(parentOrmEntity.getTable().getDefaultSchema());
- assertNull(childOrmEntity.getTable().getDefaultSchema());
-
- parentOrmEntity.getTable().setSpecifiedSchema("FOO");
- assertNull(parentOrmEntity.getTable().getDefaultSchema());
- assertEquals("FOO", childOrmEntity.getTable().getDefaultSchema());
-
- parentOrmEntity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- assertNull(parentOrmEntity.getTable().getDefaultSchema());
- assertNull(childOrmEntity.getTable().getDefaultSchema());
- }
-
- public void testUpdateDefaultSchemaFromPersistenceUnitDefaults() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- ormSecondaryTable.setSpecifiedName("FOO");
- assertNull(ormSecondaryTable.getDefaultSchema());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedSchema("FOO");
- assertEquals("FOO", ormSecondaryTable.getDefaultSchema());
-
- ormEntity.getEntityMappings().setSpecifiedSchema("BAR");
- assertEquals("BAR", ormSecondaryTable.getDefaultSchema());
-
- SecondaryTable javaSecondaryTable = ormEntity.getJavaEntity().addSpecifiedSecondaryTable(0);
- javaSecondaryTable.setSpecifiedName("FOO");
- javaSecondaryTable.setSpecifiedSchema("JAVA_SCHEMA");
- assertEquals("BAR", ormSecondaryTable.getDefaultSchema()); //schema is not defaulted from underlying java
-
- ormEntity.getEntityMappings().setSpecifiedSchema(null);
- assertEquals("FOO", ormSecondaryTable.getDefaultSchema());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedSchema(null);
- assertNull(ormSecondaryTable.getDefaultSchema());
- }
-
- public void testUpdateSpecifiedCatalog() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- //set catalog in the resource model, verify context model updated
- entityResource.getSecondaryTables().add(OrmFactory.eINSTANCE.createXmlSecondaryTableImpl());
- entityResource.getSecondaryTables().get(0).setCatalog("FOO");
- OrmSecondaryTable secondaryTable = ormEntity.specifiedSecondaryTables().next();
- assertEquals("FOO", secondaryTable.getSpecifiedCatalog());
- assertEquals("FOO", entityResource.getSecondaryTables().get(0).getCatalog());
-
- //set catalog to null in the resource model
- entityResource.getSecondaryTables().get(0).setCatalog(null);
- assertNull(secondaryTable.getSpecifiedCatalog());
- assertNull(entityResource.getSecondaryTables().get(0).getCatalog());
-
- entityResource.getSecondaryTables().remove(0);
- assertFalse(ormEntity.specifiedSecondaryTables().hasNext());
- assertEquals(0, entityResource.getSecondaryTables().size());
- }
-
- public void testModifySpecifiedCatalog() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-
- //set catalog in the context model, verify resource model modified
- OrmSecondaryTable secondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- secondaryTable.setSpecifiedCatalog("foo");
-
- assertEquals("foo", secondaryTable.getSpecifiedCatalog());
- assertEquals("foo", entityResource.getSecondaryTables().get(0).getCatalog());
-
- //set catalog to null in the context model
- secondaryTable.setSpecifiedCatalog(null);
- assertNull(secondaryTable.getSpecifiedCatalog());
- assertNull(entityResource.getSecondaryTables().get(0).getCatalog());
-
- ormEntity.removeSpecifiedSecondaryTable(0);
- assertFalse(ormEntity.specifiedSecondaryTables().hasNext());
- assertEquals(0, entityResource.getSecondaryTables().size());
- }
-
- public void testUpdateDefaultCatalogFromJavaTable() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-
- SecondaryTable javaSecondaryTable = ormEntity.getJavaEntity().addSpecifiedSecondaryTable(0);
- javaSecondaryTable.setSpecifiedName("FOO");
- javaSecondaryTable.setSpecifiedCatalog("BAR");
-
- OrmSecondaryTable ormSecondaryTable = ormEntity.virtualSecondaryTables().next();
- assertEquals("BAR", ormSecondaryTable.getSpecifiedCatalog());
-
- javaSecondaryTable.setSpecifiedCatalog("BAZ");
- assertEquals("BAZ", ormSecondaryTable.getSpecifiedCatalog());
-
- ormEntity.setSecondaryTablesDefinedInXml(true);
- assertNull(ormEntity.specifiedSecondaryTables().next().getDefaultCatalog());
- assertEquals("BAZ", ormEntity.specifiedSecondaryTables().next().getSpecifiedCatalog());
- }
-
- public void testUpdateDefaultCatalogFromPersistenceUnitDefaults() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- ormSecondaryTable.setSpecifiedName("FOO");
- assertNull(ormSecondaryTable.getDefaultCatalog());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedCatalog("FOO");
- assertEquals("FOO", ormSecondaryTable.getDefaultCatalog());
-
- ormEntity.getEntityMappings().setSpecifiedCatalog("BAR");
- assertEquals("BAR", ormSecondaryTable.getDefaultCatalog());
-
- SecondaryTable javaSecondaryTable = ormEntity.getJavaEntity().addSpecifiedSecondaryTable(0);
- javaSecondaryTable.setSpecifiedName("FOO");
- javaSecondaryTable.setSpecifiedCatalog("JAVA_CATALOG");
- assertEquals("BAR", ormSecondaryTable.getDefaultCatalog()); //schema is not defaulted from underlying java
-
- ormEntity.getEntityMappings().setSpecifiedCatalog(null);
- assertEquals("FOO", ormSecondaryTable.getDefaultCatalog());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedCatalog(null);
- assertNull(ormSecondaryTable.getDefaultCatalog());
- }
-
- public void testAddSpecifiedPrimaryKeyJoinColumn() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlSecondaryTable secondaryTableResource = entityResource.getSecondaryTables().get(0);
-
- OrmPrimaryKeyJoinColumn primaryKeyJoinColumn = ormSecondaryTable.addSpecifiedPrimaryKeyJoinColumn(0);
- primaryKeyJoinColumn.setSpecifiedName("FOO");
-
- assertEquals("FOO", secondaryTableResource.getPrimaryKeyJoinColumns().get(0).getName());
-
- OrmPrimaryKeyJoinColumn primaryKeyJoinColumn2 = ormSecondaryTable.addSpecifiedPrimaryKeyJoinColumn(0);
- primaryKeyJoinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", secondaryTableResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("FOO", secondaryTableResource.getPrimaryKeyJoinColumns().get(1).getName());
-
- OrmPrimaryKeyJoinColumn primaryKeyJoinColumn3 = ormSecondaryTable.addSpecifiedPrimaryKeyJoinColumn(1);
- primaryKeyJoinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", secondaryTableResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("BAZ", secondaryTableResource.getPrimaryKeyJoinColumns().get(1).getName());
- assertEquals("FOO", secondaryTableResource.getPrimaryKeyJoinColumns().get(2).getName());
-
- ListIterator<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns = ormSecondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals(primaryKeyJoinColumn2, primaryKeyJoinColumns.next());
- assertEquals(primaryKeyJoinColumn3, primaryKeyJoinColumns.next());
- assertEquals(primaryKeyJoinColumn, primaryKeyJoinColumns.next());
-
- primaryKeyJoinColumns = ormSecondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- }
-
- public void testRemoveSpecifiedPrimaryKeyJoinColumn() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlSecondaryTable secondaryTableResource = entityResource.getSecondaryTables().get(0);
-
- ormSecondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- ormSecondaryTable.addSpecifiedPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- ormSecondaryTable.addSpecifiedPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- assertEquals(3, secondaryTableResource.getPrimaryKeyJoinColumns().size());
-
- ormSecondaryTable.removeSpecifiedPrimaryKeyJoinColumn(0);
- assertEquals(2, secondaryTableResource.getPrimaryKeyJoinColumns().size());
- assertEquals("BAR", secondaryTableResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("BAZ", secondaryTableResource.getPrimaryKeyJoinColumns().get(1).getName());
-
- ormSecondaryTable.removeSpecifiedPrimaryKeyJoinColumn(0);
- assertEquals(1, secondaryTableResource.getPrimaryKeyJoinColumns().size());
- assertEquals("BAZ", secondaryTableResource.getPrimaryKeyJoinColumns().get(0).getName());
-
- ormSecondaryTable.removeSpecifiedPrimaryKeyJoinColumn(0);
- assertEquals(0, secondaryTableResource.getPrimaryKeyJoinColumns().size());
- }
-
- public void testMoveSpecifiedPrimaryKeyJoinColumn() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlSecondaryTable secondaryTableResource = entityResource.getSecondaryTables().get(0);
-
- ormSecondaryTable.addSpecifiedPrimaryKeyJoinColumn(0).setSpecifiedName("FOO");
- ormSecondaryTable.addSpecifiedPrimaryKeyJoinColumn(1).setSpecifiedName("BAR");
- ormSecondaryTable.addSpecifiedPrimaryKeyJoinColumn(2).setSpecifiedName("BAZ");
-
- assertEquals(3, secondaryTableResource.getPrimaryKeyJoinColumns().size());
-
-
- ormSecondaryTable.moveSpecifiedPrimaryKeyJoinColumn(2, 0);
- ListIterator<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns = ormSecondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
-
- assertEquals("BAR", secondaryTableResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("BAZ", secondaryTableResource.getPrimaryKeyJoinColumns().get(1).getName());
- assertEquals("FOO", secondaryTableResource.getPrimaryKeyJoinColumns().get(2).getName());
-
-
- ormSecondaryTable.moveSpecifiedPrimaryKeyJoinColumn(0, 1);
- primaryKeyJoinColumns = ormSecondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
-
- assertEquals("BAZ", secondaryTableResource.getPrimaryKeyJoinColumns().get(0).getName());
- assertEquals("BAR", secondaryTableResource.getPrimaryKeyJoinColumns().get(1).getName());
- assertEquals("FOO", secondaryTableResource.getPrimaryKeyJoinColumns().get(2).getName());
- }
-
- public void testUpdatePrimaryKeyJoinColumns() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlSecondaryTable secondaryTableResource = entityResource.getSecondaryTables().get(0);
-
- secondaryTableResource.getPrimaryKeyJoinColumns().add(OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl());
- secondaryTableResource.getPrimaryKeyJoinColumns().add(OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl());
- secondaryTableResource.getPrimaryKeyJoinColumns().add(OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl());
-
- secondaryTableResource.getPrimaryKeyJoinColumns().get(0).setName("FOO");
- secondaryTableResource.getPrimaryKeyJoinColumns().get(1).setName("BAR");
- secondaryTableResource.getPrimaryKeyJoinColumns().get(2).setName("BAZ");
-
- ListIterator<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns = ormSecondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- secondaryTableResource.getPrimaryKeyJoinColumns().move(2, 0);
- primaryKeyJoinColumns = ormSecondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- secondaryTableResource.getPrimaryKeyJoinColumns().move(0, 1);
- primaryKeyJoinColumns = ormSecondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("BAR", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- secondaryTableResource.getPrimaryKeyJoinColumns().remove(1);
- primaryKeyJoinColumns = ormSecondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertEquals("FOO", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- secondaryTableResource.getPrimaryKeyJoinColumns().remove(1);
- primaryKeyJoinColumns = ormSecondaryTable.specifiedPrimaryKeyJoinColumns();
- assertEquals("BAZ", primaryKeyJoinColumns.next().getName());
- assertFalse(primaryKeyJoinColumns.hasNext());
-
- secondaryTableResource.getPrimaryKeyJoinColumns().remove(0);
- assertFalse(ormSecondaryTable.specifiedPrimaryKeyJoinColumns().hasNext());
- }
-
-
- public void testUniqueConstraints() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlSecondaryTable secondaryTableResource = entityResource.getSecondaryTables().get(0);
-
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- secondaryTableResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "foo");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- secondaryTableResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "bar");
-
- uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("bar", uniqueConstraints.next().columnNames().next());
- assertEquals("foo", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testUniqueConstraintsSize() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlSecondaryTable secondaryTableResource = entityResource.getSecondaryTables().get(0);
-
- assertEquals(0, ormSecondaryTable.uniqueConstraintsSize());
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- secondaryTableResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "foo");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- secondaryTableResource.getUniqueConstraints().add(1, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "bar");
-
- assertEquals(2, ormSecondaryTable.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlSecondaryTable secondaryTableResource = entityResource.getSecondaryTables().get(0);
-
- ormSecondaryTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- ormSecondaryTable.addUniqueConstraint(0).addColumnName(0, "BAR");
- ormSecondaryTable.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- ListIterator<XmlUniqueConstraint> uniqueConstraints = secondaryTableResource.getUniqueConstraints().listIterator();
-
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().get(0));
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testAddUniqueConstraint2() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlSecondaryTable secondaryTableResource = entityResource.getSecondaryTables().get(0);
-
- ormSecondaryTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- ormSecondaryTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- ormSecondaryTable.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- ListIterator<XmlUniqueConstraint> uniqueConstraints = secondaryTableResource.getUniqueConstraints().listIterator();
-
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().get(0));
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlSecondaryTable secondaryTableResource = entityResource.getSecondaryTables().get(0);
-
- ormSecondaryTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- ormSecondaryTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- ormSecondaryTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- assertEquals(3, secondaryTableResource.getUniqueConstraints().size());
-
- ormSecondaryTable.removeUniqueConstraint(1);
-
- ListIterator<XmlUniqueConstraint> uniqueConstraintResources = secondaryTableResource.getUniqueConstraints().listIterator();
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertFalse(uniqueConstraintResources.hasNext());
-
- Iterator<OrmUniqueConstraint> uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- ormSecondaryTable.removeUniqueConstraint(1);
- uniqueConstraintResources = secondaryTableResource.getUniqueConstraints().listIterator();
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- assertFalse(uniqueConstraintResources.hasNext());
-
- uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- ormSecondaryTable.removeUniqueConstraint(0);
- uniqueConstraintResources = secondaryTableResource.getUniqueConstraints().listIterator();
- assertFalse(uniqueConstraintResources.hasNext());
- uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlSecondaryTable secondaryTableResource = entityResource.getSecondaryTables().get(0);
-
- ormSecondaryTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- ormSecondaryTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- ormSecondaryTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- assertEquals(3, secondaryTableResource.getUniqueConstraints().size());
-
-
- ormSecondaryTable.moveUniqueConstraint(2, 0);
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- ListIterator<XmlUniqueConstraint> uniqueConstraintResources = secondaryTableResource.getUniqueConstraints().listIterator();
- assertEquals("BAR", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
-
-
- ormSecondaryTable.moveUniqueConstraint(0, 1);
- uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- uniqueConstraintResources = secondaryTableResource.getUniqueConstraints().listIterator();
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- }
-
- public void testUpdateUniqueConstraints() throws Exception {
- OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
- OrmSecondaryTable ormSecondaryTable = ormEntity.addSpecifiedSecondaryTable(0);
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlSecondaryTable secondaryTableResource = entityResource.getSecondaryTables().get(0);
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- secondaryTableResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "FOO");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- secondaryTableResource.getUniqueConstraints().add(1, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "BAR");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- secondaryTableResource.getUniqueConstraints().add(2, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "BAZ");
-
-
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- secondaryTableResource.getUniqueConstraints().move(2, 0);
- uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- secondaryTableResource.getUniqueConstraints().move(0, 1);
- uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- secondaryTableResource.getUniqueConstraints().remove(1);
- uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- secondaryTableResource.getUniqueConstraints().remove(1);
- uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- secondaryTableResource.getUniqueConstraints().remove(0);
- uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
-
- public void testUniqueConstraintsFromJava() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- JavaEntity javaEntity = (JavaEntity) ormPersistentType.getJavaPersistentType().getMapping();
- JavaSecondaryTable javaSecondaryTable = javaEntity.addSpecifiedSecondaryTable(0);
- javaSecondaryTable.setSpecifiedName("SECONDARY");
-
- OrmSecondaryTable ormSecondaryTable = ormEntity.secondaryTables().next();
- assertTrue(ormSecondaryTable.isVirtual());
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
-
- javaSecondaryTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- javaSecondaryTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- javaSecondaryTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- uniqueConstraints = ormSecondaryTable.uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- ormEntity.setSecondaryTablesDefinedInXml(true);
- OrmSecondaryTable ormSecondaryTable2 = ormEntity.secondaryTables().next();
- ormSecondaryTable2.setSpecifiedName("SECONDARY");
-
- assertEquals("SECONDARY", ormSecondaryTable.getSpecifiedName());
- assertFalse(ormSecondaryTable2.isVirtual());
- assertEquals(0, ormSecondaryTable2.uniqueConstraintsSize());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSequenceGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSequenceGeneratorTests.java
deleted file mode 100644
index 3a0b529be4..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSequenceGeneratorTests.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.SequenceGenerator;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmSequenceGeneratorTests extends ContextModelTestCase
-{
- public OrmSequenceGeneratorTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- public void testUpdateSpecifiedName() throws Exception {
- SequenceGenerator sequenceGenerator = entityMappings().addSequenceGenerator(0);
- XmlSequenceGenerator sequenceGeneratorResource = ormResource().getEntityMappings().getSequenceGenerators().get(0);
-
- //set name in the resource model, verify context model updated
- sequenceGeneratorResource.setName("FOO");
- assertEquals("FOO", sequenceGenerator.getName());
- assertEquals("FOO", sequenceGeneratorResource.getName());
-
- //set name to null in the resource model
- sequenceGeneratorResource.setName(null);
- assertNull(sequenceGenerator.getName());
- assertNull(sequenceGeneratorResource.getName());
- }
-
- public void testModifySpecifiedName() throws Exception {
- SequenceGenerator sequenceGenerator = entityMappings().addSequenceGenerator(0);
- XmlSequenceGenerator sequenceGeneratorResource = ormResource().getEntityMappings().getSequenceGenerators().get(0);
-
- //set name in the context model, verify resource model modified
- sequenceGenerator.setName("FOO");
- assertEquals("FOO", sequenceGeneratorResource.getName());
- assertEquals("FOO", sequenceGenerator.getName());
-
- //set name to null in the context model
- sequenceGenerator.setName(null);
- assertNull(sequenceGeneratorResource.getName());
- assertNull(sequenceGenerator.getName());
- }
-
- public void testUpdateSpecifiedSequenceName() throws Exception {
- SequenceGenerator sequenceGenerator = entityMappings().addSequenceGenerator(0);
- XmlSequenceGenerator sequenceGeneratorResource = ormResource().getEntityMappings().getSequenceGenerators().get(0);
-
- //set name in the resource model, verify context model updated
- sequenceGeneratorResource.setSequenceName("FOO");
- assertEquals("FOO", sequenceGenerator.getSpecifiedSequenceName());
- assertEquals("FOO", sequenceGeneratorResource.getSequenceName());
-
- //set name to null in the resource model
- sequenceGeneratorResource.setSequenceName(null);
- assertNull(sequenceGenerator.getSpecifiedSequenceName());
- assertNull(sequenceGeneratorResource.getSequenceName());
- }
-
- public void testModifySpecifiedSequenceName() throws Exception {
- SequenceGenerator sequenceGenerator = entityMappings().addSequenceGenerator(0);
- XmlSequenceGenerator sequenceGeneratorResource = ormResource().getEntityMappings().getSequenceGenerators().get(0);
-
- //set name in the context model, verify resource model modified
- sequenceGenerator.setSpecifiedSequenceName("FOO");
- assertEquals("FOO", sequenceGeneratorResource.getSequenceName());
- assertEquals("FOO", sequenceGenerator.getSpecifiedSequenceName());
-
- //set name to null in the context model
- sequenceGenerator.setSpecifiedSequenceName(null);
- assertNull(sequenceGeneratorResource.getSequenceName());
- assertNull(sequenceGenerator.getSpecifiedSequenceName());
- }
-
- public void testUpdateSpecifiedInitialValue() throws Exception {
- SequenceGenerator sequenceGenerator = entityMappings().addSequenceGenerator(0);
- XmlSequenceGenerator sequenceGeneratorResource = ormResource().getEntityMappings().getSequenceGenerators().get(0);
-
- //set initial value in the resource model, verify context model updated
- sequenceGeneratorResource.setInitialValue(Integer.valueOf(10));
- assertEquals(Integer.valueOf(10), sequenceGenerator.getSpecifiedInitialValue());
- assertEquals(Integer.valueOf(10), sequenceGeneratorResource.getInitialValue());
-
- //set initial value to 1, which happens to be the default, in the resource model
- sequenceGeneratorResource.setInitialValue(Integer.valueOf(1));
- assertEquals(Integer.valueOf(1), sequenceGenerator.getSpecifiedInitialValue());
- assertEquals(Integer.valueOf(1), sequenceGeneratorResource.getInitialValue());
-
- //set initial value to null in the resource model
- sequenceGeneratorResource.setInitialValue(null);
- assertNull(sequenceGenerator.getSpecifiedInitialValue());
- assertNull(sequenceGeneratorResource.getInitialValue());
- }
-
- public void testModifySpecifiedInitialValue() throws Exception {
- SequenceGenerator sequenceGenerator = entityMappings().addSequenceGenerator(0);
- XmlSequenceGenerator sequenceGeneratorResource = ormResource().getEntityMappings().getSequenceGenerators().get(0);
-
- //set initial value in the context model, verify resource model modified
- sequenceGenerator.setSpecifiedInitialValue(Integer.valueOf(10));
- assertEquals(Integer.valueOf(10), sequenceGeneratorResource.getInitialValue());
- assertEquals(Integer.valueOf(10), sequenceGenerator.getSpecifiedInitialValue());
-
- sequenceGenerator.setSpecifiedInitialValue(Integer.valueOf(1));
- assertEquals(Integer.valueOf(1), sequenceGeneratorResource.getInitialValue());
- assertEquals(Integer.valueOf(1), sequenceGenerator.getSpecifiedInitialValue());
-
- //set initial value to null in the context model
- sequenceGenerator.setSpecifiedInitialValue(null);
- assertNull(sequenceGeneratorResource.getInitialValue());
- assertNull(sequenceGenerator.getSpecifiedInitialValue());
- }
-
- public void testUpdateSpecifiedAllocationSize() throws Exception {
- SequenceGenerator sequenceGenerator = entityMappings().addSequenceGenerator(0);
- XmlSequenceGenerator sequenceGeneratorResource = ormResource().getEntityMappings().getSequenceGenerators().get(0);
-
- //set allocation size in the resource model, verify context model updated
- sequenceGeneratorResource.setAllocationSize(Integer.valueOf(10));
- assertEquals(Integer.valueOf(10), sequenceGenerator.getSpecifiedAllocationSize());
- assertEquals(Integer.valueOf(10), sequenceGeneratorResource.getAllocationSize());
-
- //set allocation size to 50, which happens to be the default, in the resource model
- sequenceGeneratorResource.setAllocationSize(Integer.valueOf(1));
- assertEquals(Integer.valueOf(1), sequenceGenerator.getSpecifiedAllocationSize());
- assertEquals(Integer.valueOf(1), sequenceGeneratorResource.getAllocationSize());
-
- //set allocation size to null in the resource model
- sequenceGeneratorResource.setAllocationSize(null);
- assertNull(sequenceGenerator.getSpecifiedAllocationSize());
- assertNull(sequenceGeneratorResource.getAllocationSize());
- }
-
- public void testModifySpecifiedAllocationSize() throws Exception {
- SequenceGenerator sequenceGenerator = entityMappings().addSequenceGenerator(0);
- XmlSequenceGenerator sequenceGeneratorResource = ormResource().getEntityMappings().getSequenceGenerators().get(0);
-
- //set allocation size in the context model, verify resource model modified
- sequenceGenerator.setSpecifiedAllocationSize(Integer.valueOf(10));
- assertEquals(Integer.valueOf(10), sequenceGeneratorResource.getAllocationSize());
- assertEquals(Integer.valueOf(10), sequenceGenerator.getSpecifiedAllocationSize());
-
- sequenceGenerator.setSpecifiedAllocationSize(Integer.valueOf(50));
- assertEquals(Integer.valueOf(50), sequenceGeneratorResource.getAllocationSize());
- assertEquals(Integer.valueOf(50), sequenceGenerator.getSpecifiedAllocationSize());
-
- //set allocation size to null in the context model
- sequenceGenerator.setSpecifiedAllocationSize(null);
- assertNull(sequenceGeneratorResource.getAllocationSize());
- assertNull(sequenceGenerator.getSpecifiedAllocationSize());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableGeneratorTests.java
deleted file mode 100644
index 9603ba7da0..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableGeneratorTests.java
+++ /dev/null
@@ -1,622 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.TableGenerator;
-import org.eclipse.jpt.core.context.UniqueConstraint;
-import org.eclipse.jpt.core.context.java.JavaIdMapping;
-import org.eclipse.jpt.core.context.java.JavaTableGenerator;
-import org.eclipse.jpt.core.context.orm.OrmIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmTableGenerator;
-import org.eclipse.jpt.core.context.orm.OrmUniqueConstraint;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlTableGenerator;
-import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmTableGeneratorTests extends ContextModelTestCase
-{
- public OrmTableGeneratorTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- public void testUpdateSpecifiedName() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the resource model, verify context model updated
- tableGeneratorResource.setName("FOO");
- assertEquals("FOO", tableGenerator.getName());
- assertEquals("FOO", tableGeneratorResource.getName());
-
- //set name to null in the resource model
- tableGeneratorResource.setName(null);
- assertNull(tableGenerator.getName());
- assertNull(tableGeneratorResource.getName());
- }
-
- public void testModifySpecifiedName() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the context model, verify resource model modified
- tableGenerator.setName("FOO");
- assertEquals("FOO", tableGeneratorResource.getName());
- assertEquals("FOO", tableGenerator.getName());
-
- //set name to null in the context model
- tableGenerator.setName(null);
- assertNull(tableGeneratorResource.getName());
- assertNull(tableGenerator.getName());
- }
-
- public void testUpdateSpecifiedInitialValue() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set initial value in the resource model, verify context model updated
- tableGeneratorResource.setInitialValue(Integer.valueOf(10));
- assertEquals(Integer.valueOf(10), tableGenerator.getSpecifiedInitialValue());
- assertEquals(Integer.valueOf(10), tableGeneratorResource.getInitialValue());
-
- //set initial value to 1, which happens to be the default, in the resource model
- tableGeneratorResource.setInitialValue(Integer.valueOf(1));
- assertEquals(Integer.valueOf(1), tableGenerator.getSpecifiedInitialValue());
- assertEquals(Integer.valueOf(1), tableGeneratorResource.getInitialValue());
-
- //set initial value to null in the resource model
- tableGeneratorResource.setInitialValue(null);
- assertNull(tableGenerator.getSpecifiedInitialValue());
- assertNull(tableGeneratorResource.getInitialValue());
- }
-
- public void testModifySpecifiedInitialValue() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set initial value in the context model, verify resource model modified
- tableGenerator.setSpecifiedInitialValue(Integer.valueOf(10));
- assertEquals(Integer.valueOf(10), tableGeneratorResource.getInitialValue());
- assertEquals(Integer.valueOf(10), tableGenerator.getSpecifiedInitialValue());
-
- tableGenerator.setSpecifiedInitialValue(Integer.valueOf(1));
- assertEquals(Integer.valueOf(1), tableGeneratorResource.getInitialValue());
- assertEquals(Integer.valueOf(1), tableGenerator.getSpecifiedInitialValue());
-
- //set initial value to null in the context model
- tableGenerator.setSpecifiedInitialValue(null);
- assertNull(tableGeneratorResource.getInitialValue());
- assertNull(tableGenerator.getSpecifiedInitialValue());
- }
-
- public void testUpdateSpecifiedAllocationSize() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set allocation size in the resource model, verify context model updated
- tableGeneratorResource.setAllocationSize(Integer.valueOf(10));
- assertEquals(Integer.valueOf(10), tableGenerator.getSpecifiedAllocationSize());
- assertEquals(Integer.valueOf(10), tableGeneratorResource.getAllocationSize());
-
- //set allocation size to 50, which happens to be the default, in the resource model
- tableGeneratorResource.setAllocationSize(Integer.valueOf(1));
- assertEquals(Integer.valueOf(1), tableGenerator.getSpecifiedAllocationSize());
- assertEquals(Integer.valueOf(1), tableGeneratorResource.getAllocationSize());
-
- //set allocation size to null in the resource model
- tableGeneratorResource.setAllocationSize(null);
- assertNull(tableGenerator.getSpecifiedAllocationSize());
- assertNull(tableGeneratorResource.getAllocationSize());
- }
-
- public void testModifySpecifiedAllocationSize() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set allocation size in the context model, verify resource model modified
- tableGenerator.setSpecifiedAllocationSize(Integer.valueOf(10));
- assertEquals(Integer.valueOf(10), tableGeneratorResource.getAllocationSize());
- assertEquals(Integer.valueOf(10), tableGenerator.getSpecifiedAllocationSize());
-
- tableGenerator.setSpecifiedAllocationSize(Integer.valueOf(50));
- assertEquals(Integer.valueOf(50), tableGeneratorResource.getAllocationSize());
- assertEquals(Integer.valueOf(50), tableGenerator.getSpecifiedAllocationSize());
-
- //set allocation size to null in the context model
- tableGenerator.setSpecifiedAllocationSize(null);
- assertNull(tableGeneratorResource.getAllocationSize());
- assertNull(tableGenerator.getSpecifiedAllocationSize());
- }
-
- public void testUpdateSpecifiedTable() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the resource model, verify context model updated
- tableGeneratorResource.setTable("FOO");
- assertEquals("FOO", tableGenerator.getSpecifiedTable());
- assertEquals("FOO", tableGeneratorResource.getTable());
-
- //set name to null in the resource model
- tableGeneratorResource.setTable(null);
- assertNull(tableGenerator.getSpecifiedTable());
- assertNull(tableGeneratorResource.getTable());
- }
-
- public void testModifySpecifiedTable() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the context model, verify resource model modified
- tableGenerator.setSpecifiedTable("FOO");
- assertEquals("FOO", tableGeneratorResource.getTable());
- assertEquals("FOO", tableGenerator.getSpecifiedTable());
-
- //set name to null in the context model
- tableGenerator.setSpecifiedTable(null);
- assertNull(tableGeneratorResource.getTable());
- assertNull(tableGenerator.getSpecifiedTable());
- }
-
- public void testUpdateSpecifiedSchema() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the resource model, verify context model updated
- tableGeneratorResource.setSchema("FOO");
- assertEquals("FOO", tableGenerator.getSpecifiedSchema());
- assertEquals("FOO", tableGeneratorResource.getSchema());
-
- //set name to null in the resource model
- tableGeneratorResource.setSchema(null);
- assertNull(tableGenerator.getSpecifiedSchema());
- assertNull(tableGeneratorResource.getSchema());
- }
-
- public void testModifySpecifiedSchema() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the context model, verify resource model modified
- tableGenerator.setSpecifiedSchema("FOO");
- assertEquals("FOO", tableGeneratorResource.getSchema());
- assertEquals("FOO", tableGenerator.getSpecifiedSchema());
-
- //set name to null in the context model
- tableGenerator.setSpecifiedSchema(null);
- assertNull(tableGeneratorResource.getSchema());
- assertNull(tableGenerator.getSpecifiedSchema());
- }
-
- public void testUpdateSpecifiedCatalog() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the resource model, verify context model updated
- tableGeneratorResource.setCatalog("FOO");
- assertEquals("FOO", tableGenerator.getSpecifiedCatalog());
- assertEquals("FOO", tableGeneratorResource.getCatalog());
-
- //set name to null in the resource model
- tableGeneratorResource.setCatalog(null);
- assertNull(tableGenerator.getSpecifiedCatalog());
- assertNull(tableGeneratorResource.getCatalog());
- }
-
- public void testModifySpecifiedCatalog() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the context model, verify resource model modified
- tableGenerator.setSpecifiedCatalog("FOO");
- assertEquals("FOO", tableGeneratorResource.getCatalog());
- assertEquals("FOO", tableGenerator.getSpecifiedCatalog());
-
- //set name to null in the context model
- tableGenerator.setSpecifiedCatalog(null);
- assertNull(tableGeneratorResource.getCatalog());
- assertNull(tableGenerator.getSpecifiedCatalog());
- }
-
- public void testUpdateSpecifiedPkColumnName() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the resource model, verify context model updated
- tableGeneratorResource.setPkColumnName("FOO");
- assertEquals("FOO", tableGenerator.getSpecifiedPkColumnName());
- assertEquals("FOO", tableGeneratorResource.getPkColumnName());
-
- //set name to null in the resource model
- tableGeneratorResource.setPkColumnName(null);
- assertNull(tableGenerator.getSpecifiedPkColumnName());
- assertNull(tableGeneratorResource.getPkColumnName());
- }
-
- public void testModifySpecifiedPkColumnName() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the context model, verify resource model modified
- tableGenerator.setSpecifiedPkColumnName("FOO");
- assertEquals("FOO", tableGeneratorResource.getPkColumnName());
- assertEquals("FOO", tableGenerator.getSpecifiedPkColumnName());
-
- //set name to null in the context model
- tableGenerator.setSpecifiedPkColumnName(null);
- assertNull(tableGeneratorResource.getPkColumnName());
- assertNull(tableGenerator.getSpecifiedPkColumnName());
- }
-
- public void testUpdateSpecifiedValueColumnName() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the resource model, verify context model updated
- tableGeneratorResource.setValueColumnName("FOO");
- assertEquals("FOO", tableGenerator.getSpecifiedValueColumnName());
- assertEquals("FOO", tableGeneratorResource.getValueColumnName());
-
- //set name to null in the resource model
- tableGeneratorResource.setValueColumnName(null);
- assertNull(tableGenerator.getSpecifiedValueColumnName());
- assertNull(tableGeneratorResource.getValueColumnName());
- }
-
- public void testModifySpecifiedValueColumnName() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the context model, verify resource model modified
- tableGenerator.setSpecifiedValueColumnName("FOO");
- assertEquals("FOO", tableGeneratorResource.getValueColumnName());
- assertEquals("FOO", tableGenerator.getSpecifiedValueColumnName());
-
- //set name to null in the context model
- tableGenerator.setSpecifiedValueColumnName(null);
- assertNull(tableGeneratorResource.getValueColumnName());
- assertNull(tableGenerator.getSpecifiedValueColumnName());
- }
-
- public void testUpdateSpecifiedPkColumnValue() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the resource model, verify context model updated
- tableGeneratorResource.setPkColumnValue("FOO");
- assertEquals("FOO", tableGenerator.getSpecifiedPkColumnValue());
- assertEquals("FOO", tableGeneratorResource.getPkColumnValue());
-
- //set name to null in the resource model
- tableGeneratorResource.setPkColumnValue(null);
- assertNull(tableGenerator.getSpecifiedPkColumnValue());
- assertNull(tableGeneratorResource.getPkColumnValue());
- }
-
- public void testModifySpecifiedPkColumnValue() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- //set name in the context model, verify resource model modified
- tableGenerator.setSpecifiedPkColumnValue("FOO");
- assertEquals("FOO", tableGeneratorResource.getPkColumnValue());
- assertEquals("FOO", tableGenerator.getSpecifiedPkColumnValue());
-
- //set name to null in the context model
- tableGenerator.setSpecifiedPkColumnValue(null);
- assertNull(tableGeneratorResource.getPkColumnValue());
- assertNull(tableGenerator.getSpecifiedPkColumnValue());
- }
-
-
- public void testUniqueConstraints() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- ListIterator<OrmUniqueConstraint> uniqueConstraints = tableGenerator.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableGeneratorResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "foo");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableGeneratorResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "bar");
-
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("bar", uniqueConstraints.next().columnNames().next());
- assertEquals("foo", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testUniqueConstraintsSize() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- assertEquals(0, tableGenerator.uniqueConstraintsSize());
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableGeneratorResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "foo");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableGeneratorResource.getUniqueConstraints().add(1, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "bar");
-
- assertEquals(2, tableGenerator.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "FOO");
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "BAR");
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- ListIterator<XmlUniqueConstraint> uniqueConstraints = tableGeneratorResource.getUniqueConstraints().listIterator();
-
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().get(0));
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testAddUniqueConstraint2() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "FOO");
- tableGenerator.addUniqueConstraint(1).addColumnName(0, "BAR");
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- ListIterator<XmlUniqueConstraint> uniqueConstraints = tableGeneratorResource.getUniqueConstraints().listIterator();
-
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().get(0));
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "FOO");
- tableGenerator.addUniqueConstraint(1).addColumnName(0, "BAR");
- tableGenerator.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- assertEquals(3, tableGeneratorResource.getUniqueConstraints().size());
-
- tableGenerator.removeUniqueConstraint(1);
-
- ListIterator<XmlUniqueConstraint> uniqueConstraintResources = tableGeneratorResource.getUniqueConstraints().listIterator();
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertFalse(uniqueConstraintResources.hasNext());
-
- Iterator<UniqueConstraint> uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- tableGenerator.removeUniqueConstraint(1);
- uniqueConstraintResources = tableGeneratorResource.getUniqueConstraints().listIterator();
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- assertFalse(uniqueConstraintResources.hasNext());
-
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- tableGenerator.removeUniqueConstraint(0);
- uniqueConstraintResources = tableGeneratorResource.getUniqueConstraints().listIterator();
- assertFalse(uniqueConstraintResources.hasNext());
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- tableGenerator.addUniqueConstraint(0).addColumnName(0, "FOO");
- tableGenerator.addUniqueConstraint(1).addColumnName(0, "BAR");
- tableGenerator.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- assertEquals(3, tableGeneratorResource.getUniqueConstraints().size());
-
-
- tableGenerator.moveUniqueConstraint(2, 0);
- ListIterator<UniqueConstraint> uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- ListIterator<XmlUniqueConstraint> uniqueConstraintResources = tableGeneratorResource.getUniqueConstraints().listIterator();
- assertEquals("BAR", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
-
-
- tableGenerator.moveUniqueConstraint(0, 1);
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- uniqueConstraintResources = tableGeneratorResource.getUniqueConstraints().listIterator();
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- }
-
- public void testUpdateUniqueConstraints() throws Exception {
- TableGenerator tableGenerator = entityMappings().addTableGenerator(0);
- XmlTableGenerator tableGeneratorResource = ormResource().getEntityMappings().getTableGenerators().get(0);
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableGeneratorResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "FOO");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableGeneratorResource.getUniqueConstraints().add(1, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "BAR");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableGeneratorResource.getUniqueConstraints().add(2, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "BAZ");
-
-
- ListIterator<UniqueConstraint> uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableGeneratorResource.getUniqueConstraints().move(2, 0);
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableGeneratorResource.getUniqueConstraints().move(0, 1);
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableGeneratorResource.getUniqueConstraints().remove(1);
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableGeneratorResource.getUniqueConstraints().remove(1);
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableGeneratorResource.getUniqueConstraints().remove(0);
- uniqueConstraints = tableGenerator.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testUniqueConstraintsFromJava() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentType.attributes().next().getMapping();
-
- JavaIdMapping javaIdMapping = (JavaIdMapping) ormPersistentType.getJavaPersistentType().attributes().next().getMapping();
- JavaTableGenerator javaTableGenerator = javaIdMapping.addTableGenerator();
- javaTableGenerator.setName("TABLE_GENERATOR");
-
- OrmTableGenerator ormTableGenerator = ormIdMapping.getTableGenerator();
- assertTrue(ormTableGenerator.isVirtual());
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormTableGenerator.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
-
- javaTableGenerator.addUniqueConstraint(0).addColumnName(0, "FOO");
- javaTableGenerator.addUniqueConstraint(1).addColumnName(0, "BAR");
- javaTableGenerator.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- uniqueConstraints = ormTableGenerator.uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- ormIdMapping.getPersistentAttribute().makeSpecified();
- ormIdMapping = (OrmIdMapping) ormPersistentType.attributes().next().getMapping();
-
- OrmTableGenerator ormTableGenerator2 = ormIdMapping.addTableGenerator();
- ormTableGenerator2.setName("TABLE_GENERATOR");
-
- assertFalse(ormTableGenerator2.isVirtual());
- assertEquals(0, ormTableGenerator2.uniqueConstraintsSize());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableTests.java
deleted file mode 100644
index 6a47bf6518..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableTests.java
+++ /dev/null
@@ -1,760 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.InheritanceType;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmTable;
-import org.eclipse.jpt.core.context.orm.OrmUniqueConstraint;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.orm.XmlTable;
-import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmTableTests extends ContextModelTestCase
-{
- public OrmTableTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createIdAnnotation() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
- createIdAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ENTITY);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- public void testUpdateSpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmTable ormTable = ormEntity.getTable();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormTable.getSpecifiedName());
- assertNull(entityResource.getTable());
-
- //set name in the resource model, verify context model updated
- entityResource.setTable(OrmFactory.eINSTANCE.createXmlTable());
- entityResource.getTable().setName("FOO");
- assertEquals("FOO", ormTable.getSpecifiedName());
- assertEquals("FOO", entityResource.getTable().getName());
-
- //set name to null in the resource model
- entityResource.getTable().setName(null);
- assertNull(ormTable.getSpecifiedName());
- assertNull(entityResource.getTable().getName());
-
- entityResource.getTable().setName("FOO");
- assertEquals("FOO", ormTable.getSpecifiedName());
- assertEquals("FOO", entityResource.getTable().getName());
-
- entityResource.setTable(null);
- assertNull(ormTable.getSpecifiedName());
- assertNull(entityResource.getTable());
- }
-
- public void testModifySpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmTable ormTable = ((OrmEntity) ormPersistentType.getMapping()).getTable();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormTable.getSpecifiedName());
- assertNull(entityResource.getTable());
-
- //set name in the context model, verify resource model modified
- ormTable.setSpecifiedName("foo");
- assertEquals("foo", ormTable.getSpecifiedName());
- assertEquals("foo", entityResource.getTable().getName());
-
- //set name to null in the context model
- ormTable.setSpecifiedName(null);
- assertNull(ormTable.getSpecifiedName());
- assertNull(entityResource.getTable());
- }
-
- public void testUpdateDefaultNameFromJavaTable() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-
- ormEntity.getJavaEntity().getTable().setSpecifiedName("Foo");
- assertEquals("Foo", ormEntity.getTable().getDefaultName());
-
- ormEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- ormEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
- assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-
- ormEntity.setSpecifiedMetadataComplete(null);
- assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertEquals("Foo", ormEntity.getTable().getDefaultName());
-
- ormEntity.getTable().setSpecifiedName("Bar");
- assertEquals(TYPE_NAME, ormEntity.getTable().getDefaultName());
- }
-
- public void testUpdateDefaultNameNoJava() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertEquals("Foo", ormEntity.getTable().getDefaultName());
- }
-
- public void testUpdateDefaultNameFromParent() throws Exception {
- createTestEntity();
- createTestSubType();
-
- OrmPersistentType parentOrmPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentType childOrmPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
- OrmEntity parentXmlEntity = (OrmEntity) parentOrmPersistentType.getMapping();
- OrmEntity childXmlEntity = (OrmEntity) childOrmPersistentType.getMapping();
-
- assertEquals(TYPE_NAME, parentXmlEntity.getTable().getDefaultName());
- assertEquals(TYPE_NAME, childXmlEntity.getTable().getDefaultName());
-
- parentXmlEntity.getTable().setSpecifiedName("FOO");
- assertEquals(TYPE_NAME, parentXmlEntity.getTable().getDefaultName());
- assertEquals("FOO", childXmlEntity.getTable().getDefaultName());
-
- parentXmlEntity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- assertEquals(TYPE_NAME, parentXmlEntity.getTable().getDefaultName());
- assertEquals("AnnotationTestTypeChild", childXmlEntity.getTable().getDefaultName());
- }
-
- public void testUpdateSpecifiedSchema() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmTable ormTable = ormEntity.getTable();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormTable.getSpecifiedSchema());
- assertNull(entityResource.getTable());
-
- //set schema in the resource model, verify context model updated
- entityResource.setTable(OrmFactory.eINSTANCE.createXmlTable());
- entityResource.getTable().setSchema("FOO");
- assertEquals("FOO", ormTable.getSpecifiedSchema());
- assertEquals("FOO", entityResource.getTable().getSchema());
-
- //set Schema to null in the resource model
- entityResource.getTable().setSchema(null);
- assertNull(ormTable.getSpecifiedSchema());
- assertNull(entityResource.getTable().getSchema());
-
- entityResource.getTable().setSchema("FOO");
- assertEquals("FOO", ormTable.getSpecifiedSchema());
- assertEquals("FOO", entityResource.getTable().getSchema());
-
- entityResource.setTable(null);
- assertNull(ormTable.getSpecifiedSchema());
- assertNull(entityResource.getTable());
- }
-
- public void testUpdateDefaultSchemaFromJavaTable() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertNull(ormEntity.getTable().getDefaultSchema());
-
- ormEntity.getJavaEntity().getTable().setSpecifiedSchema("Foo");
- assertEquals("Foo", ormEntity.getTable().getDefaultSchema());
-
- ormEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
- assertNull(ormEntity.getTable().getDefaultSchema());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- ormEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
- assertNull(ormEntity.getTable().getDefaultSchema());
-
- ormEntity.setSpecifiedMetadataComplete(null);
- assertNull(ormEntity.getTable().getDefaultSchema());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertEquals("Foo", ormEntity.getTable().getDefaultSchema());
-
- ormEntity.getTable().setSpecifiedName("Bar");
- assertNull(ormEntity.getTable().getDefaultSchema());
- }
-
- public void testUpdateDefaultSchemaNoJava() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertNull(ormEntity.getTable().getDefaultSchema());
- }
-
- public void testUpdateDefaultSchemaFromParent() throws Exception {
- createTestEntity();
- createTestSubType();
-
- OrmPersistentType parentOrmPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentType childOrmPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
- OrmEntity parentXmlEntity = (OrmEntity) parentOrmPersistentType.getMapping();
- OrmEntity childXmlEntity = (OrmEntity) childOrmPersistentType.getMapping();
-
- assertNull(parentXmlEntity.getTable().getDefaultSchema());
- assertNull(childXmlEntity.getTable().getDefaultSchema());
-
- parentXmlEntity.getTable().setSpecifiedSchema("FOO");
- assertNull(parentXmlEntity.getTable().getDefaultSchema());
- assertEquals("FOO", childXmlEntity.getTable().getDefaultSchema());
-
- parentXmlEntity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- assertNull(parentXmlEntity.getTable().getDefaultSchema());
- assertNull(childXmlEntity.getTable().getDefaultSchema());
- }
-
- public void testUpdateDefaultSchemaFromPersistenceUnitDefaults() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertNull(ormEntity.getTable().getDefaultSchema());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedSchema("FOO");
- assertEquals("FOO", ormEntity.getTable().getDefaultSchema());
-
- ormEntity.getEntityMappings().setSpecifiedSchema("BAR");
- assertEquals("BAR", ormEntity.getTable().getDefaultSchema());
-
- ormEntity.getJavaEntity().getTable().setSpecifiedSchema("JAVA_SCHEMA");
- assertEquals("JAVA_SCHEMA", ormEntity.getTable().getDefaultSchema());
-
- ormEntity.getTable().setSpecifiedName("BLAH");
- //xml entity now has a table element so default schema is not taken from java
- assertEquals("BAR", ormEntity.getTable().getDefaultSchema());
-
-
- ormEntity.getEntityMappings().setSpecifiedSchema(null);
- assertEquals("FOO", ormEntity.getTable().getDefaultSchema());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedSchema(null);
- assertNull(ormEntity.getTable().getDefaultSchema());
-
- ormEntity.getTable().setSpecifiedName(null);
- assertEquals("JAVA_SCHEMA", ormEntity.getTable().getDefaultSchema());
- }
-
- public void testModifySpecifiedSchema() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmTable ormTable = ormEntity.getTable();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormTable.getSpecifiedSchema());
- assertNull(entityResource.getTable());
-
- //set Schema in the context model, verify resource model modified
- ormTable.setSpecifiedSchema("foo");
- assertEquals("foo", ormTable.getSpecifiedSchema());
- assertEquals("foo", entityResource.getTable().getSchema());
-
- //set Schema to null in the context model
- ormTable.setSpecifiedSchema(null);
- assertNull(ormTable.getSpecifiedSchema());
- assertNull(entityResource.getTable());
- }
-
- public void testUpdateSpecifiedCatalog() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmTable ormTable = ormEntity.getTable();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormTable.getSpecifiedCatalog());
- assertNull(entityResource.getTable());
-
- //set Catalog in the resource model, verify context model updated
- entityResource.setTable(OrmFactory.eINSTANCE.createXmlTable());
- entityResource.getTable().setCatalog("FOO");
- assertEquals("FOO", ormTable.getSpecifiedCatalog());
- assertEquals("FOO", entityResource.getTable().getCatalog());
-
- //set Catalog to null in the resource model
- entityResource.getTable().setCatalog(null);
- assertNull(ormTable.getSpecifiedCatalog());
- assertNull(entityResource.getTable().getCatalog());
-
- entityResource.getTable().setCatalog("FOO");
- assertEquals("FOO", ormTable.getSpecifiedCatalog());
- assertEquals("FOO", entityResource.getTable().getCatalog());
-
- entityResource.setTable(null);
- assertNull(ormTable.getSpecifiedCatalog());
- assertNull(entityResource.getTable());
- }
-
- public void testModifySpecifiedCatalog() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmTable ormTable = ormEntity.getTable();
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- assertNull(ormTable.getSpecifiedCatalog());
- assertNull(entityResource.getTable());
-
- //set Catalog in the context model, verify resource model modified
- ormTable.setSpecifiedCatalog("foo");
- assertEquals("foo", ormTable.getSpecifiedCatalog());
- assertEquals("foo", entityResource.getTable().getCatalog());
-
- //set Catalog to null in the context model
- ormTable.setSpecifiedCatalog(null);
- assertNull(ormTable.getSpecifiedCatalog());
- assertNull(entityResource.getTable());
- }
-
- public void testUpdateDefaultCatalogFromJavaTable() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertNull(ormEntity.getTable().getDefaultCatalog());
-
- ormEntity.getJavaEntity().getTable().setSpecifiedCatalog("Foo");
- assertEquals("Foo", ormEntity.getTable().getDefaultCatalog());
-
- ormEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
- assertNull(ormEntity.getTable().getDefaultCatalog());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- ormEntity.setSpecifiedMetadataComplete(Boolean.FALSE);
- assertNull(ormEntity.getTable().getDefaultCatalog());
-
- ormEntity.setSpecifiedMetadataComplete(null);
- assertNull(ormEntity.getTable().getDefaultCatalog());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertEquals("Foo", ormEntity.getTable().getDefaultCatalog());
-
- ormEntity.getTable().setSpecifiedName("Bar");
- assertNull(ormEntity.getTable().getDefaultCatalog());
- }
-
- public void testUpdateDefaultCatalogNoJava() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertNull(ormEntity.getTable().getDefaultCatalog());
- }
-
- public void testUpdateDefaultCatalogFromParent() throws Exception {
- createTestEntity();
- createTestSubType();
-
- OrmPersistentType parentOrmPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentType childOrmPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
- OrmEntity parentXmlEntity = (OrmEntity) parentOrmPersistentType.getMapping();
- OrmEntity childXmlEntity = (OrmEntity) childOrmPersistentType.getMapping();
-
- assertNull(parentXmlEntity.getTable().getDefaultCatalog());
- assertNull(childXmlEntity.getTable().getDefaultCatalog());
-
- parentXmlEntity.getTable().setSpecifiedCatalog("FOO");
- assertNull(parentXmlEntity.getTable().getDefaultCatalog());
- assertEquals("FOO", childXmlEntity.getTable().getDefaultCatalog());
-
- parentXmlEntity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED);
- assertNull(parentXmlEntity.getTable().getDefaultCatalog());
- assertNull(childXmlEntity.getTable().getDefaultCatalog());
- }
-
- public void testUpdateDefaultCatalogFromPersistenceUnitDefaults() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- assertNull(ormEntity.getTable().getDefaultCatalog());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedCatalog("FOO");
- assertEquals("FOO", ormEntity.getTable().getDefaultCatalog());
-
- ormEntity.getEntityMappings().setSpecifiedCatalog("BAR");
- assertEquals("BAR", ormEntity.getTable().getDefaultCatalog());
-
- ormEntity.getJavaEntity().getTable().setSpecifiedCatalog("JAVA_CATALOG");
- assertEquals("JAVA_CATALOG", ormEntity.getTable().getDefaultCatalog());
-
- ormEntity.getTable().setSpecifiedName("BLAH");
- //xml entity now has a table element so default schema is not taken from java
- assertEquals("BAR", ormEntity.getTable().getDefaultCatalog());
-
-
- ormEntity.getEntityMappings().setSpecifiedCatalog(null);
- assertEquals("FOO", ormEntity.getTable().getDefaultCatalog());
-
- ormEntity.getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedCatalog(null);
- assertNull(ormEntity.getTable().getDefaultCatalog());
-
- ormEntity.getTable().setSpecifiedName(null);
- assertEquals("JAVA_CATALOG", ormEntity.getTable().getDefaultCatalog());
-}
-
-//
-// public void testUpdateName() throws Exception {
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
-// XmlEntity ormEntity = (XmlEntity) ormPersistentType.getMapping();
-// Entity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-// assertEquals("Foo", ormEntity.getName());
-//
-// //set class in the resource model, verify context model updated
-// entityResource.setClassName("com.Bar");
-// assertEquals("Bar", ormEntity.getName());
-//
-// entityResource.setName("Baz");
-// assertEquals("Baz", ormEntity.getName());
-//
-// //set class to null in the resource model
-// entityResource.setClassName(null);
-// assertEquals("Baz", ormEntity.getName());
-//
-// entityResource.setName(null);
-// assertNull(ormEntity.getName());
-// }
-
- public void testUniqueConstraints() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormEntity.getTable().uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlTable tableResource = OrmFactory.eINSTANCE.createXmlTable();
- entityResource.setTable(tableResource);
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "foo");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "bar");
-
- uniqueConstraints = ormEntity.getTable().uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("bar", uniqueConstraints.next().columnNames().next());
- assertEquals("foo", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testUniqueConstraintsSize() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- assertEquals(0, ormEntity.getTable().uniqueConstraintsSize());
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlTable tableResource = OrmFactory.eINSTANCE.createXmlTable();
- entityResource.setTable(tableResource);
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "foo");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableResource.getUniqueConstraints().add(1, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "bar");
-
- assertEquals(2, ormEntity.getTable().uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- OrmTable table = ormEntity.getTable();
- table.addUniqueConstraint(0).addColumnName(0, "FOO");
- table.addUniqueConstraint(0).addColumnName(0, "BAR");
- table.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlTable tableResource = entityResource.getTable();
-
- ListIterator<XmlUniqueConstraint> uniqueConstraints = tableResource.getUniqueConstraints().listIterator();
-
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().get(0));
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testAddUniqueConstraint2() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- OrmTable table = ormEntity.getTable();
- table.addUniqueConstraint(0).addColumnName(0, "FOO");
- table.addUniqueConstraint(1).addColumnName(0, "BAR");
- table.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlTable tableResource = entityResource.getTable();
-
- ListIterator<XmlUniqueConstraint> uniqueConstraints = tableResource.getUniqueConstraints().listIterator();
-
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().get(0));
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- OrmTable table = ormEntity.getTable();
- table.addUniqueConstraint(0).addColumnName(0, "FOO");
- table.addUniqueConstraint(1).addColumnName(0, "BAR");
- table.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlTable tableResource = entityResource.getTable();
-
- assertEquals(3, tableResource.getUniqueConstraints().size());
-
- table.removeUniqueConstraint(1);
-
- ListIterator<XmlUniqueConstraint> uniqueConstraintResources = tableResource.getUniqueConstraints().listIterator();
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertFalse(uniqueConstraintResources.hasNext());
-
- Iterator<OrmUniqueConstraint> uniqueConstraints = table.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- table.removeUniqueConstraint(1);
- uniqueConstraintResources = tableResource.getUniqueConstraints().listIterator();
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- assertFalse(uniqueConstraintResources.hasNext());
-
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- table.removeUniqueConstraint(0);
- uniqueConstraintResources = tableResource.getUniqueConstraints().listIterator();
- assertFalse(uniqueConstraintResources.hasNext());
- uniqueConstraints = table.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- OrmTable table = ormEntity.getTable();
- table.addUniqueConstraint(0).addColumnName(0, "FOO");
- table.addUniqueConstraint(1).addColumnName(0, "BAR");
- table.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlTable tableResource = entityResource.getTable();
-
- assertEquals(3, tableResource.getUniqueConstraints().size());
-
-
- table.moveUniqueConstraint(2, 0);
- ListIterator<OrmUniqueConstraint> uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- ListIterator<XmlUniqueConstraint> uniqueConstraintResources = tableResource.getUniqueConstraints().listIterator();
- assertEquals("BAR", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
-
-
- table.moveUniqueConstraint(0, 1);
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-
- uniqueConstraintResources = tableResource.getUniqueConstraints().listIterator();
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- }
-
- public void testUpdateUniqueConstraints() throws Exception {
- createTestEntity();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- OrmTable table = ormEntity.getTable();
-
- XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
- XmlTable tableResource = OrmFactory.eINSTANCE.createXmlTable();
- entityResource.setTable(tableResource);
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableResource.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "FOO");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableResource.getUniqueConstraints().add(1, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "BAR");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl();
- tableResource.getUniqueConstraints().add(2, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "BAZ");
-
-
- ListIterator<OrmUniqueConstraint> uniqueConstraints = table.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableResource.getUniqueConstraints().move(2, 0);
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableResource.getUniqueConstraints().move(0, 1);
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableResource.getUniqueConstraints().remove(1);
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableResource.getUniqueConstraints().remove(1);
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
-
- tableResource.getUniqueConstraints().remove(0);
- uniqueConstraints = table.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
-//TODO not yet supporting unique constriants from java
-// public void testUniqueConstraintsFromJava() throws Exception {
-// createTestEntity();
-//
-// OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-//
-// ListIterator<OrmUniqueConstraint> uniqueConstraints = ormEntity.getTable().uniqueConstraints();
-// assertFalse(uniqueConstraints.hasNext());
-//
-// JavaEntity javaEntity = (JavaEntity) ormPersistentType.getJavaPersistentType().getMapping();
-// javaEntity.getTable().addUniqueConstraint(0).addColumnName(0, "FOO");
-// javaEntity.getTable().addUniqueConstraint(1).addColumnName(0, "BAR");
-// javaEntity.getTable().addUniqueConstraint(2).addColumnName(0, "BAZ");
-//
-//
-// XmlEntity entityResource = ormResource().getEntityMappings().getEntities().get(0);
-// assertNull(entityResource.getTable());
-//
-// uniqueConstraints = ormEntity.getTable().uniqueConstraints();
-// assertTrue(uniqueConstraints.hasNext());
-// assertEquals("FOO", uniqueConstraints.next().columnNames().next());
-// assertEquals("BAR", uniqueConstraints.next().columnNames().next());
-// assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
-// assertFalse(uniqueConstraints.hasNext());
-//
-// entityResource.setTable(OrmFactory.eINSTANCE.createXmlTableImpl());
-// assertEquals(0, ormEntity.getTable().uniqueConstraintsSize());
-// }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTransientMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTransientMappingTests.java
deleted file mode 100644
index 4707112d17..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTransientMappingTests.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmTransientMapping;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.XmlTransient;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmTransientMappingTests extends ContextModelTestCase
-{
- public OrmTransientMappingTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createTransientAnnotation() throws Exception{
- this.createAnnotationAndMembers("Transient", "");
- }
-
-
- private IType createTestEntityTransientMapping() throws Exception {
- createEntityAnnotation();
- createTransientAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.TRANSIENT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Transient");
- }
- });
- }
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transientMapping");
- OrmTransientMapping xmlTransientnMapping = (OrmTransientMapping) ormPersistentAttribute.getMapping();
- XmlTransient transientResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getTransients().get(0);
-
- assertEquals("transientMapping", xmlTransientnMapping.getName());
- assertEquals("transientMapping", transientResource.getName());
-
- //set name in the resource model, verify context model updated
- transientResource.setName("newName");
- assertEquals("newName", xmlTransientnMapping.getName());
- assertEquals("newName", transientResource.getName());
-
- //set name to null in the resource model
- transientResource.setName(null);
- assertNull(xmlTransientnMapping.getName());
- assertNull(transientResource.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transientMapping");
- OrmTransientMapping xmlTransientnMapping = (OrmTransientMapping) ormPersistentAttribute.getMapping();
- XmlTransient transientResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getTransients().get(0);
-
- assertEquals("transientMapping", xmlTransientnMapping.getName());
- assertEquals("transientMapping", transientResource.getName());
-
- //set name in the context model, verify resource model updated
- xmlTransientnMapping.setName("newName");
- assertEquals("newName", xmlTransientnMapping.getName());
- assertEquals("newName", transientResource.getName());
-
- //set name to null in the context model
- xmlTransientnMapping.setName(null);
- assertNull(xmlTransientnMapping.getName());
- assertNull(transientResource.getName());
- }
-
-
- public void testTransientMappingNoUnderylingJavaAttribute() throws Exception {
- createTestEntityTransientMapping();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "foo");
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmTransientMapping ormTransientMapping = (OrmTransientMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("foo", ormTransientMapping.getName());
- }
-
- //@Basic(fetch=FetchType.LAZY, optional=false)
- //@Column(name="MY_COLUMN", unique=true, nullable=false, insertable=false, updatable=false,
- // columnDefinition="COLUMN_DEFINITION", table="MY_TABLE", length=5, precision=6, scale=7)");
- //@Column(
- //@Lob
- //@Temporal(TemporalType.TIMESTAMP)
- //@Enumerated(EnumType.STRING)
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityTransientMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- OrmTransientMapping ormTransientMapping = (OrmTransientMapping) ormPersistentAttribute.getMapping();
- assertEquals("id", ormTransientMapping.getName());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityTransientMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
-
- ormPersistentAttribute.makeSpecified(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- ormPersistentAttribute= ormPersistentType.specifiedAttributes().next();
-
- OrmTransientMapping ormTransientMapping = (OrmTransientMapping) ormPersistentAttribute.getMapping();
- assertEquals("id", ormTransientMapping.getName());
- }
-
- public void testSpecifiedMapping() throws Exception {
- createTestEntityTransientMapping();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "id");
- assertEquals(1, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmTransientMapping ormTransientMapping = (OrmTransientMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("id", ormTransientMapping.getName());
- }
-
- public void testTransientMorphToIdMapping() throws Exception {
- createTestEntityTransientMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient");
-
- TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping);
- assertEquals("transient", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testTransientMorphToVersionMapping() throws Exception {
- createTestEntityTransientMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient");
-
- TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping);
- assertEquals("transient", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testTransientMorphToTransientMapping() throws Exception {
- createTestEntityTransientMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient");
-
- TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping);
- assertEquals("transient", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testTransientMorphToEmbeddedMapping() throws Exception {
- createTestEntityTransientMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient");
-
- TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertEquals("transient", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testTransientMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityTransientMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient");
-
- TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertEquals("transient", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testTransientMorphToOneToOneMapping() throws Exception {
- createTestEntityTransientMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient");
-
- TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping);
- assertEquals("transient", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testTransientMorphToOneToManyMapping() throws Exception {
- createTestEntityTransientMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient");
-
- TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping);
- assertEquals("transient", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testTransientMorphToManyToOneMapping() throws Exception {
- createTestEntityTransientMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient");
-
- TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertEquals("transient", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testTransientMorphToManyToManyMapping() throws Exception {
- createTestEntityTransientMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient");
-
- TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping();
- assertFalse(transientMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertEquals("transient", ormPersistentAttribute.getMapping().getName());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmVersionMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmVersionMappingTests.java
deleted file mode 100644
index 9d29f2cfe8..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmVersionMappingTests.java
+++ /dev/null
@@ -1,505 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.core.context.EmbeddedMapping;
-import org.eclipse.jpt.core.context.IdMapping;
-import org.eclipse.jpt.core.context.ManyToManyMapping;
-import org.eclipse.jpt.core.context.ManyToOneMapping;
-import org.eclipse.jpt.core.context.OneToManyMapping;
-import org.eclipse.jpt.core.context.OneToOneMapping;
-import org.eclipse.jpt.core.context.TemporalType;
-import org.eclipse.jpt.core.context.TransientMapping;
-import org.eclipse.jpt.core.context.VersionMapping;
-import org.eclipse.jpt.core.context.orm.OrmColumn;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmVersionMapping;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.XmlVersion;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrmVersionMappingTests extends ContextModelTestCase
-{
- public OrmVersionMappingTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createVersionAnnotation() throws Exception{
- this.createAnnotationAndMembers("Version", "");
- }
-
- private void createColumnAnnotation() throws Exception{
- this.createAnnotationAndMembers("Column",
- "String name() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";" +
- "int length() default 255;" +
- "int precision() default 0;" +
- "int scale() default 0;");
- }
-
- private void createTemporalAnnotation() throws Exception{
- this.createAnnotationAndMembers("Temporal", "TemporalType value();");
- }
-
- private IType createTestEntityVersionMapping() throws Exception {
- createEntityAnnotation();
- createVersionAnnotation();
- createColumnAnnotation();
- createTemporalAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.VERSION, JPA.COLUMN, JPA.TEMPORAL, JPA.TEMPORAL_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Version");
- sb.append(CR);
- sb.append(" @Column(name=\"MY_COLUMN\", unique=true, nullable=false, insertable=false, updatable=false, columnDefinition=\"COLUMN_DEFINITION\", table=\"MY_TABLE\", length=5, precision=6, scale=7)");
- sb.append(CR);
- sb.append(" @Temporal(TemporalType.TIMESTAMP)");
- }
- });
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionMapping");
- OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping();
- XmlVersion versionResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getVersions().get(0);
-
- assertEquals("versionMapping", ormVersionMapping.getName());
- assertEquals("versionMapping", versionResource.getName());
-
- //set name in the resource model, verify context model updated
- versionResource.setName("newName");
- assertEquals("newName", ormVersionMapping.getName());
- assertEquals("newName", versionResource.getName());
-
- //set name to null in the resource model
- versionResource.setName(null);
- assertNull(ormVersionMapping.getName());
- assertNull(versionResource.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionMapping");
- OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping();
- XmlVersion versionResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getVersions().get(0);
-
- assertEquals("versionMapping", ormVersionMapping.getName());
- assertEquals("versionMapping", versionResource.getName());
-
- //set name in the context model, verify resource model updated
- ormVersionMapping.setName("newName");
- assertEquals("newName", ormVersionMapping.getName());
- assertEquals("newName", versionResource.getName());
-
- //set name to null in the context model
- ormVersionMapping.setName(null);
- assertNull(ormVersionMapping.getName());
- assertNull(versionResource.getName());
- }
-
- public void testUpdateTemporal() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionMapping");
- OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping();
- XmlVersion versionResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getVersions().get(0);
-
- assertNull(ormVersionMapping.getTemporal());
- assertNull(versionResource.getTemporal());
-
- //set temporal in the resource model, verify context model updated
- versionResource.setTemporal(org.eclipse.jpt.core.resource.orm.TemporalType.DATE);
- assertEquals(TemporalType.DATE, ormVersionMapping.getTemporal());
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.DATE, versionResource.getTemporal());
-
- versionResource.setTemporal(org.eclipse.jpt.core.resource.orm.TemporalType.TIME);
- assertEquals(TemporalType.TIME, ormVersionMapping.getTemporal());
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.TIME, versionResource.getTemporal());
-
- versionResource.setTemporal(org.eclipse.jpt.core.resource.orm.TemporalType.TIMESTAMP);
- assertEquals(TemporalType.TIMESTAMP, ormVersionMapping.getTemporal());
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.TIMESTAMP, versionResource.getTemporal());
-
- //set temporal to null in the resource model
- versionResource.setTemporal(null);
- assertNull(ormVersionMapping.getTemporal());
- assertNull(versionResource.getTemporal());
- }
-
- public void testModifyTemporal() throws Exception {
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionMapping");
- OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping();
- XmlVersion versionResource = ormResource().getEntityMappings().getEntities().get(0).getAttributes().getVersions().get(0);
-
- assertNull(ormVersionMapping.getTemporal());
- assertNull(versionResource.getTemporal());
-
- //set temporal in the context model, verify resource model updated
- ormVersionMapping.setTemporal(TemporalType.DATE);
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.DATE, versionResource.getTemporal());
- assertEquals(TemporalType.DATE, ormVersionMapping.getTemporal());
-
- ormVersionMapping.setTemporal(TemporalType.TIME);
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.TIME, versionResource.getTemporal());
- assertEquals(TemporalType.TIME, ormVersionMapping.getTemporal());
-
- ormVersionMapping.setTemporal(TemporalType.TIMESTAMP);
- assertEquals(org.eclipse.jpt.core.resource.orm.TemporalType.TIMESTAMP, versionResource.getTemporal());
- assertEquals(TemporalType.TIMESTAMP, ormVersionMapping.getTemporal());
-
- //set temporal to null in the context model
- ormVersionMapping.setTemporal(null);
- assertNull(versionResource.getTemporal());
- assertNull(ormVersionMapping.getTemporal());
- }
-
- //TODO test defaults
- //TODO test overriding java mapping with a different mapping type in xml
-
- public void testVersionMappingNoUnderylingJavaAttribute() throws Exception {
- createTestEntityVersionMapping();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "foo");
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("foo", ormVersionMapping.getName());
- assertNull(ormVersionMapping.getTemporal());
-
-
- OrmColumn ormColumn = ormVersionMapping.getColumn();
- assertNull(ormColumn.getSpecifiedName());
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(ormColumn.getColumnDefinition());
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(ormColumn.getSpecifiedPrecision());
- assertNull(ormColumn.getSpecifiedScale());
-
- assertEquals("foo", ormColumn.getDefaultName());
- assertEquals(Boolean.FALSE, ormColumn.getDefaultUnique());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultNullable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultUpdatable());
- assertEquals(null, ormColumn.getColumnDefinition());
- assertEquals(TYPE_NAME, ormColumn.getDefaultTable());
- assertEquals(Integer.valueOf(255), ormColumn.getDefaultLength());
- assertEquals(Integer.valueOf(0), ormColumn.getDefaultPrecision());
- assertEquals(Integer.valueOf(0), ormColumn.getDefaultScale());
- }
-
- //@Basic(fetch=FetchType.LAZY, optional=false)
- //@Column(name="MY_COLUMN", unique=true, nullable=false, insertable=false, updatable=false,
- // columnDefinition="COLUMN_DEFINITION", table="MY_TABLE", length=5, precision=6, scale=7)");
- //@Column(
- //@Lob
- //@Temporal(TemporalType.TIMESTAMP)
- //@Enumerated(EnumType.STRING)
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityVersionMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping();
- assertEquals("id", ormVersionMapping.getName());
- assertEquals(TemporalType.TIMESTAMP, ormVersionMapping.getTemporal());
-
- OrmColumn ormColumn = ormVersionMapping.getColumn();
- assertEquals("MY_COLUMN", ormColumn.getSpecifiedName());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUnique());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUpdatable());
- assertEquals("COLUMN_DEFINITION", ormColumn.getColumnDefinition());
- assertEquals("MY_TABLE", ormColumn.getSpecifiedTable());
- assertEquals(Integer.valueOf(5), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(6), ormColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(7), ormColumn.getSpecifiedScale());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityVersionMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
-
- ormPersistentAttribute.makeSpecified(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- ormPersistentAttribute= ormPersistentType.specifiedAttributes().next();
-
- OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping();
- assertEquals("id", ormVersionMapping.getName());
- assertNull(ormVersionMapping.getTemporal());
-
- OrmColumn ormColumn = ormVersionMapping.getColumn();
- assertEquals("id", ormColumn.getName());
- assertEquals(Boolean.FALSE, ormColumn.getUnique());
- assertEquals(Boolean.TRUE, ormColumn.getNullable());
- assertEquals(Boolean.TRUE, ormColumn.getInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getUpdatable());
- assertNull(ormColumn.getColumnDefinition());
- assertEquals(TYPE_NAME, ormColumn.getTable());
- assertEquals(Integer.valueOf(255), ormColumn.getLength());
- assertEquals(Integer.valueOf(0), ormColumn.getPrecision());
- assertEquals(Integer.valueOf(0), ormColumn.getScale());
- }
-
- public void testSpecifiedMapping() throws Exception {
- createTestEntityVersionMapping();
-
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "id");
- assertEquals(1, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping();
-
- assertEquals("id", ormVersionMapping.getName());
- assertNull(ormVersionMapping.getTemporal());
-
- OrmColumn ormColumn = ormVersionMapping.getColumn();
- assertNull(ormColumn.getSpecifiedName());
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(ormColumn.getColumnDefinition());
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(ormColumn.getSpecifiedPrecision());
- assertNull(ormColumn.getSpecifiedScale());
-
- assertEquals("id", ormColumn.getDefaultName());
- assertEquals(Boolean.FALSE, ormColumn.getDefaultUnique());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultNullable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultInsertable());
- assertEquals(Boolean.TRUE, ormColumn.getDefaultUpdatable());
- assertEquals(null, ormColumn.getColumnDefinition());
- assertEquals(TYPE_NAME, ormColumn.getDefaultTable());
- assertEquals(Integer.valueOf(255), ormColumn.getDefaultLength());
- assertEquals(Integer.valueOf(0), ormColumn.getDefaultPrecision());
- assertEquals(Integer.valueOf(0), ormColumn.getDefaultScale());
- }
-
- public void testVersionMorphToIdMapping() throws Exception {
- createTestEntityVersionMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version");
-
- VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping);
- assertEquals("version", ormPersistentAttribute.getMapping().getName());
- assertEquals(TemporalType.TIME, ((IdMapping) ormPersistentAttribute.getMapping()).getTemporal());
- assertEquals("FOO", ((IdMapping) ormPersistentAttribute.getMapping()).getColumn().getSpecifiedName());
- }
-
- public void testVersionMorphToBasicMapping() throws Exception {
- createTestEntityVersionMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version");
-
- VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping);
- assertEquals("version", ormPersistentAttribute.getMapping().getName());
- assertEquals(TemporalType.TIME, ((BasicMapping) ormPersistentAttribute.getMapping()).getTemporal());
- assertEquals("FOO", ((BasicMapping) ormPersistentAttribute.getMapping()).getColumn().getSpecifiedName());
- }
-
- public void testVersionMorphToTransientMapping() throws Exception {
- createTestEntityVersionMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version");
-
- VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping);
- assertEquals("version", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testVersionMorphToEmbeddedMapping() throws Exception {
- createTestEntityVersionMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version");
-
- VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertEquals("version", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testVersionMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityVersionMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version");
-
- VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertEquals("version", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testVersionMorphToOneToOneMapping() throws Exception {
- createTestEntityVersionMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version");
-
- VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping);
- assertEquals("version", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testVersionMorphToOneToManyMapping() throws Exception {
- createTestEntityVersionMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version");
-
- VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping);
- assertEquals("version", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testVersionMorphToManyToOneMapping() throws Exception {
- createTestEntityVersionMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version");
-
- VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertEquals("version", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testVersionMorphToManyToManyMapping() throws Exception {
- createTestEntityVersionMapping();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedPersistentAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version");
-
- VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping();
- assertFalse(versionMapping.isDefault());
- versionMapping.getColumn().setSpecifiedName("FOO");
- versionMapping.setTemporal(TemporalType.TIME);
- assertFalse(versionMapping.isDefault());
-
- ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertEquals("version", ormPersistentAttribute.getMapping().getName());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmXmlTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmXmlTests.java
deleted file mode 100644
index c210d14c5d..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmXmlTests.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.orm.OrmXml;
-import org.eclipse.jpt.core.context.persistence.PersistenceXml;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.OrmResource;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class OrmXmlTests extends ContextModelTestCase
-{
- public OrmXmlTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- xmlPersistenceUnit().setName("foo");
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- protected PersistenceXml persistenceXml() {
- return rootContext().getPersistenceXml();
- }
-
- protected OrmXml ormXml() {
- return persistenceUnit().mappingFileRefs().next().getOrmXml();
- }
-
- public void testUpdateAddEntityMappings() throws Exception {
- OrmResource ormResource = ormResource();
- ormResource.getContents().clear();
- ormResource.save(null);
-
- assertNull(ormXml().getEntityMappings());
-
- ormResource.getContents().add(OrmFactory.eINSTANCE.createXmlEntityMappings());
-
- assertNotNull(ormXml().getEntityMappings());
-
- }
-
- public void testModifyAddEntityMappings() {
- OrmResource ormResource = ormResource();
- ormResource.getContents().remove(ormResource.getEntityMappings());
- assertNull(ormResource.getEntityMappings());
-
- OrmXml ormXml = ormXml();
- assertNull(ormXml.getEntityMappings());
-
- ormXml.addEntityMappings();
-
- assertNotNull(ormXml.getEntityMappings());
-
- boolean exceptionThrown = false;
- try {
- ormXml.addEntityMappings();
- }
- catch (IllegalStateException ise) {
- exceptionThrown = true;
- }
-
- assertTrue("IllegalStateException was not thrown", exceptionThrown);
- }
-
- public void testUpdateRemoveEntityMappings() throws Exception {
- OrmResource ormResource = ormResource();
-
- assertNotNull(ormXml().getEntityMappings());
-
- ormResource.getContents().clear();
-
- assertNull(ormXml().getEntityMappings());
- }
-
- public void testModifyRemoveEntityMappings() {
- OrmXml ormXml = ormXml();
-
- assertNotNull(ormXml.getEntityMappings());
-
- ormXml.removeEntityMappings();
-
- assertNull(ormXml.getEntityMappings());
-
- boolean exceptionThrown = false;
- try {
- ormXml.removeEntityMappings();
- }
- catch (IllegalStateException ise) {
- exceptionThrown = true;
- }
-
- assertTrue("IllegalStateException was not thrown", exceptionThrown);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/PersistenceUnitDefaultsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/PersistenceUnitDefaultsTests.java
deleted file mode 100644
index 0abf9ffcf9..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/PersistenceUnitDefaultsTests.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.orm.PersistenceUnitDefaults;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlPersistenceUnitMetadata;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class PersistenceUnitDefaultsTests extends ContextModelTestCase
-{
- public PersistenceUnitDefaultsTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- protected PersistenceUnitDefaults persistenceUnitDefaults() {
- return entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults();
- }
-
- public void testIsAllFeaturesUnset() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- XmlPersistenceUnitMetadata persistenceUnitMetadata = OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata();
- ormResource().getEntityMappings().setPersistenceUnitMetadata(persistenceUnitMetadata);
- assertTrue(persistenceUnitMetadata.isAllFeaturesUnset());
-
- org.eclipse.jpt.core.resource.orm.XmlPersistenceUnitDefaults persistenceUnitDefaultsResource = OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults();
- persistenceUnitMetadata.setPersistenceUnitDefaults(persistenceUnitDefaultsResource);
- assertTrue(persistenceUnitDefaultsResource.isAllFeaturesUnset());
-
- persistenceUnitDefaultsResource.setCascadePersist(true);
- assertFalse(persistenceUnitDefaultsResource.isAllFeaturesUnset());
-
- persistenceUnitDefaultsResource.setCascadePersist(false);
- assertTrue(persistenceUnitDefaultsResource.isAllFeaturesUnset());
-
- persistenceUnitDefaultsResource.setSchema("asdf");
- assertFalse(persistenceUnitDefaultsResource.isAllFeaturesUnset());
-
- persistenceUnitDefaultsResource.setSchema(null);
- assertTrue(persistenceUnitDefaultsResource.isAllFeaturesUnset());
-
- persistenceUnitDefaultsResource.setCatalog("asdf");
- assertFalse(persistenceUnitDefaultsResource.isAllFeaturesUnset());
-
- persistenceUnitDefaultsResource.setCatalog(null);
- assertTrue(persistenceUnitDefaultsResource.isAllFeaturesUnset());
-
-
- persistenceUnitDefaultsResource.setAccess(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY);
- assertFalse(persistenceUnitDefaultsResource.isAllFeaturesUnset());
-
- persistenceUnitDefaultsResource.setAccess(org.eclipse.jpt.core.resource.orm.AccessType.FIELD);
- assertFalse(persistenceUnitDefaultsResource.isAllFeaturesUnset());
-
- persistenceUnitDefaultsResource.setAccess(null);
- assertTrue(persistenceUnitDefaultsResource.isAllFeaturesUnset());
- }
-
- public void testUpdateSchema() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set schema in the resource model, verify context model updated
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSchema("MY_SCHEMA");
- assertEquals("MY_SCHEMA", persistenceUnitDefaults.getSchema());
- assertEquals("MY_SCHEMA", ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
-
- //set schema to null in the resource model
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSchema(null);
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
- }
-
- public void testModifySchema() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set schema in the context model, verify resource model modified
- persistenceUnitDefaults.setSpecifiedSchema("MY_SCHEMA");
- assertEquals("MY_SCHEMA", persistenceUnitDefaults.getSchema());
- assertEquals("MY_SCHEMA", ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
-
- //set schema to null in the context model
- persistenceUnitDefaults.setSpecifiedSchema(null);
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
- }
-
- public void testModifySchema2() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set schema in the context model, verify resource model modified
- persistenceUnitDefaults.setSpecifiedSchema("MY_SCHEMA");
- assertEquals("MY_SCHEMA", persistenceUnitDefaults.getSchema());
- assertEquals("MY_SCHEMA", ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
-
- //set another element on the persistence-unit-defaults element so it doesn't get removed
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCatalog("MY_CATALOG");
- //set schema to null in the context model
- persistenceUnitDefaults.setSpecifiedSchema(null);
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
- }
-
- public void testModifySchema3() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
- //set another element on the persistence-unit-metadata element so only persistence-unit-defaults element gets removed
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
-
- //set schema in the context model, verify resource model modified
- persistenceUnitDefaults.setSpecifiedSchema("MY_SCHEMA");
- assertEquals("MY_SCHEMA", persistenceUnitDefaults.getSchema());
- assertEquals("MY_SCHEMA", ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
-
- //set schema to null in the context model
- persistenceUnitDefaults.setSpecifiedSchema(null);
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults());
- }
-
- public void testUpdateCatalog() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set catalog in the resource model, verify context model updated
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCatalog("MY_CATALOG");
- assertEquals("MY_CATALOG", persistenceUnitDefaults.getCatalog());
- assertEquals("MY_CATALOG", ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
-
- //set catalog to null in the resource model
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCatalog(null);
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
- }
-
- public void testModifyCatalog() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set catalog in the context model, verify resource model modified
- persistenceUnitDefaults.setSpecifiedCatalog("MY_CATALOG");
- assertEquals("MY_CATALOG", persistenceUnitDefaults.getCatalog());
- assertEquals("MY_CATALOG", ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
-
- //set catalog to null in the context model
- persistenceUnitDefaults.setSpecifiedCatalog(null);
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
- }
-
- public void testModifyCatalog2() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set catalog in the context model, verify resource model modified
- persistenceUnitDefaults.setSpecifiedCatalog("MY_CATALOG");
- assertEquals("MY_CATALOG", persistenceUnitDefaults.getCatalog());
- assertEquals("MY_CATALOG", ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
-
- //set another element on the persistence-unit-defaults element so it doesn't get removed
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSchema("MY_SCHEMA");
- //set catalog to null in the context model
- persistenceUnitDefaults.setSpecifiedCatalog(null);
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
- }
-
- public void testModifyCatalog3() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
- //set another element on the persistence-unit-metadata element so only persistence-unit-defaults element gets removed
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
-
- //set catalog in the context model, verify resource model modified
- persistenceUnitDefaults.setSpecifiedCatalog("MY_CATALOG");
- assertEquals("MY_CATALOG", persistenceUnitDefaults.getCatalog());
- assertEquals("MY_CATALOG", ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
-
- //set catalog to null in the context model
- persistenceUnitDefaults.setSpecifiedCatalog(null);
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults());
- }
-
- public void testUpdateCascadePersist() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set cascadePersist in the resource model, verify context model updated
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCascadePersist(true);
- assertTrue(persistenceUnitDefaults.isCascadePersist());
- assertTrue(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().isCascadePersist());
-
- //set cascadePersist to null in the resource model, persistence-unit-defaults tag not removed
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCascadePersist(false);
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertFalse(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().isCascadePersist());
- }
-
- public void testModifyCascadePersist() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set cascadePersist in the context model, verify resource model modified
- persistenceUnitDefaults.setCascadePersist(true);
- assertTrue(persistenceUnitDefaults.isCascadePersist());
- assertTrue(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().isCascadePersist());
-
- //set cascadePersist to null in the context model
- persistenceUnitDefaults.setCascadePersist(false);
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
- }
-
- public void testModifyCascadePersist2() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set cascadePersist in the context model, verify resource model modified
- persistenceUnitDefaults.setCascadePersist(true);
- assertTrue(persistenceUnitDefaults.isCascadePersist());
- assertTrue(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().isCascadePersist());
-
- //set another element on the persistence-unit-defaults element so it doesn't get removed
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCatalog("MY_CATALOG");
- //set cascadePersist to null in the context model
- persistenceUnitDefaults.setCascadePersist(false);
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertFalse(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().isCascadePersist());
- }
-
- public void testModifyCascadePersist3() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
- //set another element on the persistence-unit-metadata element so only persistence-unit-defaults element gets removed
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
-
- //set cascadePersist in the context model, verify resource model modified
- persistenceUnitDefaults.setCascadePersist(true);
- assertTrue(persistenceUnitDefaults.isCascadePersist());
- assertTrue(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().isCascadePersist());
-
- //set cascadePersist to null in the context model
- persistenceUnitDefaults.setCascadePersist(false);
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults());
- }
-
-
- public void testUpdateAccess() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set access in the resource model, verify context model updated
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(org.eclipse.jpt.core.resource.orm.AccessType.FIELD);
- assertEquals(AccessType.FIELD, persistenceUnitDefaults.getAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.FIELD, ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getAccess());
-
- //set access to null in the resource model
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(null);
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getAccess());
- }
-
- public void testModifyAccess() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set access in the context model, verify resource model modified
- persistenceUnitDefaults.setAccess(AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, persistenceUnitDefaults.getAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY, ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getAccess());
-
- //set access to null in the context model
- persistenceUnitDefaults.setAccess(null);
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
- }
-
- public void testModifyAccess2() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set access in the context model, verify resource model modified
- persistenceUnitDefaults.setAccess(AccessType.FIELD);
- assertEquals(AccessType.FIELD, persistenceUnitDefaults.getAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.FIELD, ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getAccess());
-
- //set another element on the persistence-unit-defaults element so it doesn't get removed
- ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCascadePersist(true);
- //set access to null in the context model
- persistenceUnitDefaults.setAccess(null);
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getAccess());
- }
-
- public void testModifyAccess3() throws Exception {
- PersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
- //set another element on the persistence-unit-metadata element so only persistence-unit-defaults element gets removed
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
-
- //set access in the context model, verify resource model modified
- persistenceUnitDefaults.setAccess(AccessType.FIELD);
- assertEquals(AccessType.FIELD, persistenceUnitDefaults.getAccess());
- assertEquals(org.eclipse.jpt.core.resource.orm.AccessType.FIELD, ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getAccess());
-
- //set access to null in the context model
- persistenceUnitDefaults.setAccess(null);
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/PersistenceUnitMetadataTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/PersistenceUnitMetadataTests.java
deleted file mode 100644
index feada5432d..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/PersistenceUnitMetadataTests.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.orm;
-
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.orm.PersistenceUnitMetadata;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class PersistenceUnitMetadataTests extends ContextModelTestCase
-{
- public PersistenceUnitMetadataTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- protected PersistenceUnitMetadata persistenceUnitMetadata() {
- return entityMappings().getPersistenceUnitMetadata();
- }
-
- public void testIsAllFeaturesUnset() throws Exception {
- org.eclipse.jpt.core.resource.orm.XmlPersistenceUnitMetadata persistenceUnitMetadata = OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata();
- ormResource().getEntityMappings().setPersistenceUnitMetadata(persistenceUnitMetadata);
- assertTrue(persistenceUnitMetadata.isAllFeaturesUnset());
-
- persistenceUnitMetadata.setXmlMappingMetadataComplete(true);
- assertFalse(persistenceUnitMetadata.isAllFeaturesUnset());
-
- persistenceUnitMetadata.setXmlMappingMetadataComplete(false);
- assertTrue(persistenceUnitMetadata.isAllFeaturesUnset());
-
- persistenceUnitMetadata.setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- assertFalse(persistenceUnitMetadata.isAllFeaturesUnset());
- }
-
- public void testUpdateXmlMappingMetadataComplete() throws Exception {
- PersistenceUnitMetadata persistenceUnitMetadata = entityMappings().getPersistenceUnitMetadata();
- assertFalse(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set xmlMappingMetadataComplete in the resource model, verify context model updated
- ormResource().getEntityMappings().setPersistenceUnitMetadata(OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertTrue(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertTrue(ormResource().getEntityMappings().getPersistenceUnitMetadata().isXmlMappingMetadataComplete());
-
- //set xmlMappingMetadataComplete to null in the resource model
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertFalse(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertFalse(ormResource().getEntityMappings().getPersistenceUnitMetadata().isXmlMappingMetadataComplete());
- }
-
- public void testModifyXmlMappingMetadataComplete() throws Exception {
- PersistenceUnitMetadata persistenceUnitMetadata = entityMappings().getPersistenceUnitMetadata();
- assertFalse(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set xmlMappingMetadataComplete in the context model, verify resource model modified
- persistenceUnitMetadata.setXmlMappingMetadataComplete(true);
- assertTrue(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertTrue(ormResource().getEntityMappings().getPersistenceUnitMetadata().isXmlMappingMetadataComplete());
-
- //set xmlMappingMetadataComplete to null in the context model
- persistenceUnitMetadata.setXmlMappingMetadataComplete(false);
- assertFalse(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
- }
-
- public void testModifyXmlMappingMetadataComplete2() throws Exception {
- PersistenceUnitMetadata persistenceUnitMetadata = entityMappings().getPersistenceUnitMetadata();
- assertFalse(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertNull(ormResource().getEntityMappings().getPersistenceUnitMetadata());
-
- //set xmlMappingMetadataComplete in the context model, verify resource model modified
- persistenceUnitMetadata.setXmlMappingMetadataComplete(true);
- assertTrue(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertTrue(ormResource().getEntityMappings().getPersistenceUnitMetadata().isXmlMappingMetadataComplete());
-
- //set xmlMappingMetadataComplete to null in the context model
- //set another element on the persistence-unit-metadata element so it doesn't get removed
- ormResource().getEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- persistenceUnitMetadata.setXmlMappingMetadataComplete(false);
- assertFalse(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertFalse(ormResource().getEntityMappings().getPersistenceUnitMetadata().isXmlMappingMetadataComplete());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/ClassRefTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/ClassRefTests.java
deleted file mode 100644
index fdf5a60c78..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/ClassRefTests.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.persistence;
-
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlJavaClassRef;
-import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class ClassRefTests extends ContextModelTestCase
-{
- public ClassRefTests(String name) {
- super(name);
- }
-
- public void testUpdateClassName() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add class ref
- XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- xmlClassRef.setJavaClass("com.foo.Bar");
- xmlPersistenceUnit.getClasses().add(xmlClassRef);
- ClassRef classRef = persistenceUnit.specifiedClassRefs().next();
-
- // test that class names are initially equal
- assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
-
- // set xml class name to different name, test equality
- xmlClassRef.setJavaClass("com.bar.Foo");
-
- assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
-
- // set class name to empty string, test equality
- xmlClassRef.setJavaClass("");
-
- assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
-
- // set class name to null, test equality
- xmlClassRef.setJavaClass(null);
-
- assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
-
- // set name back to non-null, test equality
- xmlClassRef.setJavaClass("com.foo.Bar");
-
- assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
- }
-
- public void testModifyClassName() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add class ref
- XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- xmlClassRef.setJavaClass("com.foo.Bar");
- xmlPersistenceUnit.getClasses().add(xmlClassRef);
- ClassRef classRef = persistenceUnit.specifiedClassRefs().next();
-
- // test that class names are initially equal
- assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
-
- // set context class name to different name, test equality
- classRef.setClassName("com.bar.Foo");
-
- assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
-
- // set class name to empty string, test equality
- classRef.setClassName("");
-
- assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
-
- // set class name to null, test equality
- classRef.setClassName(null);
-
- assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
-
- // set name back to non-null, test equality
- classRef.setClassName("com.foo.Bar");
-
- assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
- }
-
-
- public void testGetPersistentType() throws Exception {
- createTestType();
-
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
-
- XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- xmlClassRef.setJavaClass(FULLY_QUALIFIED_TYPE_NAME);
- xmlPersistenceUnit.getClasses().add(xmlClassRef);
-
- ClassRef classRef = classRef();
-
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, classRef.getJavaPersistentType().getName());
-
- //test setting to a class that does not exist in the project
- xmlClassRef.setJavaClass("com.foo.Bar");
-
- classRef = classRef();
- assertNull(classRef.getJavaPersistentType());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/JptCorePersistenceContextModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/JptCorePersistenceContextModelTests.java
deleted file mode 100644
index 5dd87d2a34..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/JptCorePersistenceContextModelTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.persistence;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JptCorePersistenceContextModelTests extends TestCase
-{
- public static Test suite() {
- return suite(true);
- }
-
- public static Test suite(boolean all) {
- TestSuite suite = new TestSuite(JptCorePersistenceContextModelTests.class.getName());
- suite.addTestSuite(RootContextTests.class);
- suite.addTestSuite(PersistenceXmlTests.class);
- suite.addTestSuite(PersistenceTests.class);
- suite.addTestSuite(PersistenceUnitTests.class);
- suite.addTestSuite(MappingFileRefTests.class);
- suite.addTestSuite(ClassRefTests.class);
- return suite;
- }
-
- private JptCorePersistenceContextModelTests() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/MappingFileRefTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/MappingFileRefTests.java
deleted file mode 100644
index 1854a15312..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/MappingFileRefTests.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.persistence;
-
-import org.eclipse.jpt.core.context.persistence.MappingFileRef;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class MappingFileRefTests extends ContextModelTestCase
-{
- public MappingFileRefTests(String name) {
- super(name);
- }
-
- protected MappingFileRef mappingFileRef() {
- return persistenceUnit().mappingFileRefs().next();
- }
-
- public void testUpdateFileName() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add mapping file ref
- XmlMappingFileRef xmlFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- xmlFileRef.setFileName("foo.xml");
- xmlPersistenceUnit.getMappingFiles().add(xmlFileRef);
- MappingFileRef fileRef = persistenceUnit.specifiedMappingFileRefs().next();
-
- // test that file names are initially equal
- assertEquals(fileRef.getFileName(), xmlFileRef.getFileName());
-
- // set xml to different file name, test equality
- xmlFileRef.setFileName("bar.xml");
-
- assertEquals(fileRef.getFileName(), xmlFileRef.getFileName());
-
- // set file name to empty string, test equality
- xmlFileRef.setFileName("");
-
- assertEquals(fileRef.getFileName(), xmlFileRef.getFileName());
-
- // set file name to null, test equality
- xmlFileRef.setFileName(null);
-
- assertEquals(fileRef.getFileName(), xmlFileRef.getFileName());
-
- // set file name back to non-null, test equality
- xmlFileRef.setFileName("baz.xml");
-
- assertEquals(fileRef.getFileName(), xmlFileRef.getFileName());
- }
-
- public void testModifyFileName() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add mapping file ref
- XmlMappingFileRef xmlFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- xmlFileRef.setFileName("foo.xml");
- xmlPersistenceUnit.getMappingFiles().add(xmlFileRef);
- MappingFileRef fileRef = persistenceUnit.specifiedMappingFileRefs().next();
-
- // test that file names are initially equal
- assertEquals(fileRef.getFileName(), xmlFileRef.getFileName());
-
- // set context to different file name, test equality
- fileRef.setFileName("bar.xml");
-
- assertEquals(fileRef.getFileName(), xmlFileRef.getFileName());
-
- // set file name to empty string, test equality
- fileRef.setFileName("");
-
- assertEquals(fileRef.getFileName(), xmlFileRef.getFileName());
-
- // set file name to null, test equality
- fileRef.setFileName(null);
-
- assertEquals(fileRef.getFileName(), xmlFileRef.getFileName());
-
- // set file name back to non-null, test equality
- fileRef.setFileName("baz.xml");
-
- assertEquals(fileRef.getFileName(), xmlFileRef.getFileName());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceTests.java
deleted file mode 100644
index 4dc384a858..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceTests.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.persistence;
-
-import org.eclipse.jpt.core.context.persistence.Persistence;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.PersistenceResource;
-import org.eclipse.jpt.core.resource.persistence.XmlPersistence;
-import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class PersistenceTests extends ContextModelTestCase
-{
- public PersistenceTests(String name) {
- super(name);
- }
-
- protected Persistence persistence() {
- return rootContext().getPersistenceXml().getPersistence();
- }
-
- public void testUpdateAddPersistenceUnit() throws Exception {
- PersistenceResource prm = persistenceResource();
- XmlPersistence xmlPersistence = prm.getPersistence();
- Persistence persistence = rootContext().getPersistenceXml().getPersistence();
-
- // clear xml persistence units, test that it's clear in context
- xmlPersistence.getPersistenceUnits().clear();
-
- assertEquals(0, persistence.persistenceUnitsSize());
-
- // add xml persistence unit, test that it's added to context
- XmlPersistenceUnit xmlPersistenceUnit = PersistenceFactory.eINSTANCE.createXmlPersistenceUnit();
- xmlPersistenceUnit.setName("test");
- xmlPersistence.getPersistenceUnits().add(xmlPersistenceUnit);
-
- assertEquals(1, persistence.persistenceUnitsSize());
-
- // add another, test that it *isn't* add to context
- xmlPersistenceUnit = PersistenceFactory.eINSTANCE.createXmlPersistenceUnit();
- xmlPersistenceUnit.setName("test2");
- xmlPersistence.getPersistenceUnits().add(xmlPersistenceUnit);
-
- assertEquals(1, persistence.persistenceUnitsSize());
- }
-
- public void testModifyAddPersistencUnit() {
- XmlPersistence xmlPersistence = xmlPersistence();
- Persistence persistence = persistence();
-
- // clear xml persistence units, test that it's clear in context
- xmlPersistence.getPersistenceUnits().clear();
- assertEquals(0, persistence.persistenceUnitsSize());
-
- // add persistence unit, test that it's added to resource
- persistence.addPersistenceUnit();
-
- assertEquals(1, persistence.persistenceUnitsSize());
-
- // add another, test that we get an exception
- boolean exception = false;
- try {
- persistence.addPersistenceUnit();
- }
- catch (IllegalStateException e) {
- exception = true;
- }
-
- assertTrue(exception);
- }
-
- public void testUpdateRemovePersistenceUnit() throws Exception {
- PersistenceResource prm = persistenceResource();
- XmlPersistence xmlPersistence = prm.getPersistence();
- Persistence persistence = rootContext().getPersistenceXml().getPersistence();
-
- // add a persistence unit and test that there are two existing xml and
- // one context persistence unit
- XmlPersistenceUnit xmlPersistenceUnit = PersistenceFactory.eINSTANCE.createXmlPersistenceUnit();
- xmlPersistenceUnit.setName("test");
- xmlPersistence.getPersistenceUnits().add(xmlPersistenceUnit);
-
- assertEquals(2, xmlPersistence.getPersistenceUnits().size());
- assertEquals(1, persistence.persistenceUnitsSize());
-
- // remove persistence unit from xml, test that context remains unchanged
- xmlPersistenceUnit = xmlPersistence.getPersistenceUnits().get(0);
- xmlPersistence.getPersistenceUnits().remove(xmlPersistenceUnit);
-
- assertEquals(1, xmlPersistence.getPersistenceUnits().size());
- assertEquals(1, persistence.persistenceUnitsSize());
-
- // remove another one from xml, text that it's now removed from context
- xmlPersistenceUnit = xmlPersistence.getPersistenceUnits().get(0);
- xmlPersistence.getPersistenceUnits().remove(xmlPersistenceUnit);
-
- assertEquals(0, xmlPersistence.getPersistenceUnits().size());
- assertEquals(0, persistence.persistenceUnitsSize());
- }
-
- public void testModifyRemovePersistenceUnit() {
- XmlPersistence xmlPersistence = xmlPersistence();
- Persistence persistence = persistence();
-
- // add a persistence unit and test that there are two existing xml and
- // one context persistence unit
- XmlPersistenceUnit xmlPersistenceUnit = PersistenceFactory.eINSTANCE.createXmlPersistenceUnit();
- xmlPersistenceUnit.setName("test");
- xmlPersistence.getPersistenceUnits().add(xmlPersistenceUnit);
-
- assertEquals(2, xmlPersistence.getPersistenceUnits().size());
- assertEquals(1, persistence.persistenceUnitsSize());
-
- // remove persistence unit, test that it's removed from resource and that
- // a *new* persistence unit representing the previously unrepresented one
- // is present
- persistence.removePersistenceUnit(0);
-
- assertEquals(1, xmlPersistence.getPersistenceUnits().size());
- assertEquals(1, persistence.persistenceUnitsSize());
-
- // remove new persistence unit, test that it's removed from resource and
- // context
- persistence.removePersistenceUnit(0);
-
- assertEquals(0, xmlPersistence.getPersistenceUnits().size());
- assertEquals(0, persistence.persistenceUnitsSize());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java
deleted file mode 100644
index 0a0ab95523..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java
+++ /dev/null
@@ -1,1123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.persistence;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnitTransactionType;
-import org.eclipse.jpt.core.context.persistence.Property;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.OrmResource;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlJavaClassRef;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
-import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnitTransactionType;
-import org.eclipse.jpt.core.resource.persistence.XmlProperties;
-import org.eclipse.jpt.core.resource.persistence.XmlProperty;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class PersistenceUnitTests extends ContextModelTestCase
-{
-
- protected static final String INNER_CLASS_NAME = "InnerAnnotationTestType";
- protected static final String FULLY_QUALIFIED_INNER_CLASS_NAME = PACKAGE_NAME + "." + TYPE_NAME + "." + INNER_CLASS_NAME;
-
- public PersistenceUnitTests(String name) {
- super(name);
- }
-
- public void testUpdateName() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test that names are initially equal
- assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
-
- // set name to different name, test equality
- xmlPersistenceUnit.setName("newName");
-
- assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
-
- // set name to empty string, test equality
- xmlPersistenceUnit.setName("");
-
- assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
-
- // set name to null, test equality
- xmlPersistenceUnit.setName(null);
-
- assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
-
- // set name back to non-null, test equality
- xmlPersistenceUnit.setName("newName");
-
- assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
- }
-
- public void testModifyName() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test that names are initially equal
- assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
-
- // set name to different name, test equality
- persistenceUnit.setName("newName");
-
- assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
-
- // set name to empty string, test equality
- persistenceUnit.setName("");
-
- assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
-
- // set name to null, test equality
- persistenceUnit.setName(null);
-
- assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
-
- // set name back to non-null, test equality
- persistenceUnit.setName("newName");
-
- assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
- }
-
- public void testUpdateTransactionType() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // 1 - initial value is default
- assertNull(xmlPersistenceUnit.getTransactionType());
- assertNull(persistenceUnit.getSpecifiedTransactionType());
-
- // 2 - set value, context changed
- xmlPersistenceUnit.setTransactionType(XmlPersistenceUnitTransactionType.JTA);
-
- assertEquals(PersistenceUnitTransactionType.JTA, persistenceUnit.getSpecifiedTransactionType());
-
- xmlPersistenceUnit.setTransactionType(XmlPersistenceUnitTransactionType.RESOURCE_LOCAL);
-
- assertEquals(PersistenceUnitTransactionType.RESOURCE_LOCAL, persistenceUnit.getSpecifiedTransactionType());
-
- // 3 - unset value, context changed
- xmlPersistenceUnit.setTransactionType(null);
-
- assertNull(persistenceUnit.getSpecifiedTransactionType());
- }
-
- public void testModifyTransactionType() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // 1 - initial value is default
- assertNull(xmlPersistenceUnit.getTransactionType());
- assertNull(persistenceUnit.getSpecifiedTransactionType());
-
- // 2 - set context value, resource changed
- persistenceUnit.setSpecifiedTransactionType(PersistenceUnitTransactionType.JTA);
-
- assertEquals(XmlPersistenceUnitTransactionType.JTA, xmlPersistenceUnit.getTransactionType());
-
- persistenceUnit.setSpecifiedTransactionType(PersistenceUnitTransactionType.RESOURCE_LOCAL);
-
- assertEquals(XmlPersistenceUnitTransactionType.RESOURCE_LOCAL, xmlPersistenceUnit.getTransactionType());
-
- // 3 - set context value to default, resource unset
- persistenceUnit.setSpecifiedTransactionType(null);
-
- assertNull(persistenceUnit.getSpecifiedTransactionType());
- assertNull(xmlPersistenceUnit.getTransactionType());
- }
-
- public void testUpdateDescription() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test that descriptions are initially equal
- assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
-
- // set description to different description, test equality
- xmlPersistenceUnit.setDescription("newDescription");
-
- assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
-
- // set description to empty string, test equality
- xmlPersistenceUnit.setDescription("");
-
- assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
-
- // set description to null, test equality
- xmlPersistenceUnit.setDescription(null);
-
- assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
-
- // set description back to non-null, test equality
- xmlPersistenceUnit.setDescription("newDescription");
-
- assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
- }
-
- public void testModifyDescription() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test that descriptions are initially equal
- assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
-
- // set description to different description, test equality
- persistenceUnit.setDescription("newDescription");
-
- assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
-
- // set description to empty string, test equality
- persistenceUnit.setDescription("");
-
- assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
-
- // set description to null, test equality
- persistenceUnit.setDescription(null);
-
- assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
-
- // set description back to non-null, test equality
- persistenceUnit.setDescription("newDescription");
-
- assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
- }
-
- public void testUpdateProvider() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test that providers are initially equal
- assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
-
- // set provider to different provider, test equality
- xmlPersistenceUnit.setProvider("newProvider");
-
- assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
-
- // set provider to empty string, test equality
- xmlPersistenceUnit.setProvider("");
-
- assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
-
- // set provider to null, test equality
- xmlPersistenceUnit.setProvider(null);
-
- assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
-
- // set provider back to non-null, test equality
- xmlPersistenceUnit.setProvider("newProvider");
-
- assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
- }
-
- public void testModifyProvider() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test that providers are initially equal
- assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
-
- // set provider to different provider, test equality
- persistenceUnit.setProvider("newProvider");
-
- assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
-
- // set provider to empty string, test equality
- persistenceUnit.setProvider("");
-
- assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
-
- // set provider to null, test equality
- persistenceUnit.setProvider(null);
-
- assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
-
- // set provider back to non-null, test equality
- persistenceUnit.setProvider("newProvider");
-
- assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
- }
-
- public void testUpdateJtaDataSource() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test that jtaDataSources are initially equal
- assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
-
- // set jtaDataSource to different jtaDataSource, test equality
- xmlPersistenceUnit.setJtaDataSource("newJtaDataSource");
-
- assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
-
- // set jtaDataSource to empty string, test equality
- xmlPersistenceUnit.setJtaDataSource("");
-
- assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
-
- // set jtaDataSource to null, test equality
- xmlPersistenceUnit.setJtaDataSource(null);
-
- assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
-
- // set jtaDataSource back to non-null, test equality
- xmlPersistenceUnit.setJtaDataSource("newJtaDataSource");
-
- assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
- }
-
- public void testModifyJtaDataSource() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test that jtaDataSources are initially equal
- assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
-
- // set jtaDataSource to different jtaDataSource, test equality
- persistenceUnit.setJtaDataSource("newJtaDataSource");
-
- assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
-
- // set jtaDataSource to empty string, test equality
- persistenceUnit.setJtaDataSource("");
-
- assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
-
- // set jtaDataSource to null, test equality
- persistenceUnit.setJtaDataSource(null);
-
- assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
-
- // set jtaDataSource back to non-null, test equality
- persistenceUnit.setJtaDataSource("newJtaDataSource");
-
- assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
- }
-
- public void testUpdateNonJtaDataSource() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test that nonJtaDataSources are initially equal
- assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
-
- // set nonJtaDataSource to different nonJtaDataSource, test equality
- xmlPersistenceUnit.setNonJtaDataSource("newNonJtaDataSource");
-
- assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
-
- // set nonJtaDataSource to empty string, test equality
- xmlPersistenceUnit.setNonJtaDataSource("");
-
- assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
-
- // set nonJtaDataSource to null, test equality
- xmlPersistenceUnit.setNonJtaDataSource(null);
-
- assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
-
- // set nonJtaDataSource back to non-null, test equality
- xmlPersistenceUnit.setNonJtaDataSource("newNonJtaDataSource");
-
- assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
- }
-
- public void testModifyNonJtaDataSource() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test that nonJtaDataSources are initially equal
- assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
-
- // set nonJtaDataSource to different nonJtaDataSource, test equality
- persistenceUnit.setNonJtaDataSource("newNonJtaDataSource");
-
- assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
-
- // set nonJtaDataSource to empty string, test equality
- persistenceUnit.setNonJtaDataSource("");
-
- assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
-
- // set nonJtaDataSource to null, test equality
- persistenceUnit.setNonJtaDataSource(null);
-
- assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
-
- // set nonJtaDataSource back to non-null, test equality
- persistenceUnit.setNonJtaDataSource("newNonJtaDataSource");
-
- assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
- }
-
- public void testUpdateJarFileRefs1() {
- // TODO
- }
-
- public void testUpdateJarFileRefs2() {
- // TODO
- }
-
- public void testUpdateImpliedMappingFileRef1() throws Exception {
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test that there is one initially
- OrmResource ormResource = ormResource();
- assertTrue(ormResource.exists());
- assertNotNull(persistenceUnit.getImpliedMappingFileRef());
-
- // remove orm.xml
- deleteResource(ormResource);
-
- assertFalse(ormResource.exists());
- assertNull(persistenceUnit.getImpliedMappingFileRef());
- }
-
- public void testUpdateImpliedMappingFileRef2() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test that there is one initially
- OrmResource ormResource = ormResource();
- assertTrue(ormResource.exists());
- assertNotNull(persistenceUnit.getImpliedMappingFileRef());
-
- // add specified orm.xml
- XmlMappingFileRef xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- xmlMappingFileRef.setFileName("META-INF/orm.xml");
- xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
-
- assertEquals(1, CollectionTools.size(persistenceUnit.specifiedMappingFileRefs()));
-
- assertTrue(ormResource.exists());
- assertNull(persistenceUnit.getImpliedMappingFileRef());
- }
-
- public void testUpdateSpecifiedMappingFileRefs1() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test there are none initially
- assertEquals(0, xmlPersistenceUnit.getMappingFiles().size());
- assertEquals(0, persistenceUnit.specifiedMappingFileRefsSize());
-
- // add mapping file ref, test that it's added to context
- XmlMappingFileRef xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- xmlMappingFileRef.setFileName("orm.xml");
- xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
-
- assertEquals(1, CollectionTools.size(persistenceUnit.specifiedMappingFileRefs()));
-
- // add another ...
- xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- xmlMappingFileRef.setFileName("orm2.xml");
- xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
-
- assertEquals(2, CollectionTools.size(persistenceUnit.specifiedMappingFileRefs()));
- }
-
- public void testUpdateSpecifiedMappingFileRefs2() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add two mapping file refs and test that there are two existing in xml and context
- XmlMappingFileRef xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- xmlMappingFileRef.setFileName("orm.xml");
- xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
- xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- xmlMappingFileRef.setFileName("orm2.xml");
- xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
-
- assertEquals(xmlPersistenceUnit.getMappingFiles().size(), 2);
- assertEquals(2, CollectionTools.size(persistenceUnit.specifiedMappingFileRefs()));
-
- // remove mapping file ref from xml, test that it's removed from context
- xmlMappingFileRef = xmlPersistenceUnit.getMappingFiles().get(0);
- xmlPersistenceUnit.getMappingFiles().remove(xmlMappingFileRef);
-
- assertEquals(1, CollectionTools.size(persistenceUnit.specifiedMappingFileRefs()));
-
- // remove another one ...
- xmlMappingFileRef = xmlPersistenceUnit.getMappingFiles().get(0);
- xmlPersistenceUnit.getMappingFiles().remove(xmlMappingFileRef);
-
- assertEquals(0, CollectionTools.size(persistenceUnit.specifiedMappingFileRefs()));
- }
-
- public void testModifySpecifiedMappingFileRefs1() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test there are none initially
- assertEquals(0, xmlPersistenceUnit.getMappingFiles().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.specifiedMappingFileRefs()));
-
- // add mapping file ref, test that it's added to resource
- persistenceUnit.addSpecifiedMappingFileRef().setFileName("foo");
-
- assertEquals(1, xmlPersistenceUnit.getMappingFiles().size());
- assertEquals("foo", xmlPersistenceUnit.getMappingFiles().get(0).getFileName());
-
- // add another ...
- persistenceUnit.addSpecifiedMappingFileRef().setFileName("bar");
- assertEquals("foo", xmlPersistenceUnit.getMappingFiles().get(0).getFileName());
- assertEquals("bar", xmlPersistenceUnit.getMappingFiles().get(1).getFileName());
-
- assertEquals(2, xmlPersistenceUnit.getMappingFiles().size());
-
- // add another, testing order
- persistenceUnit.addSpecifiedMappingFileRef(0).setFileName("baz");
- assertEquals(3, xmlPersistenceUnit.getMappingFiles().size());
- assertEquals("baz", xmlPersistenceUnit.getMappingFiles().get(0).getFileName());
- assertEquals("foo", xmlPersistenceUnit.getMappingFiles().get(1).getFileName());
- assertEquals("bar", xmlPersistenceUnit.getMappingFiles().get(2).getFileName());
- }
-
- public void testModifySpecifiedMappingFileRefs2() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add two mapping file refs and test that there are two existing in xml and context
- XmlMappingFileRef xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- xmlMappingFileRef.setFileName("orm.xml");
- xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
- xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- xmlMappingFileRef.setFileName("orm2.xml");
- xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
-
- assertEquals(2, xmlPersistenceUnit.getMappingFiles().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.specifiedMappingFileRefs()));
-
- // remove mapping file ref from context, test that it's removed from xml
- persistenceUnit.removeSpecifiedMappingFileRef(0);
-
- assertEquals(1, xmlPersistenceUnit.getMappingFiles().size());
-
- // remove another one ...
- persistenceUnit.removeSpecifiedMappingFileRef(0);
-
- assertEquals(0, xmlPersistenceUnit.getMappingFiles().size());
- }
-
- public void testUpdateClassRefs1() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test there are none initially
- assertEquals(0, xmlPersistenceUnit.getClasses().size());
- assertEquals(0, persistenceUnit.specifiedClassRefsSize());
-
- // add mapping file ref, test that it's added to context
- XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- xmlClassRef.setJavaClass("com.foo.Bar");
- xmlPersistenceUnit.getClasses().add(xmlClassRef);
-
- assertEquals(1, persistenceUnit.specifiedClassRefsSize());
-
- // add another ...
- xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- xmlClassRef.setJavaClass("com.foo.Baz");
- xmlPersistenceUnit.getClasses().add(xmlClassRef);
-
- assertEquals(2, persistenceUnit.specifiedClassRefsSize());
- }
-
- public void testUpdateClassRefs2() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add two class refs and test that there are two existing in xml and context
- XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- xmlClassRef.setJavaClass("com.foo.Bar");
- xmlPersistenceUnit.getClasses().add(xmlClassRef);
- xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- xmlClassRef.setJavaClass("com.foo.Baz");
- xmlPersistenceUnit.getClasses().add(xmlClassRef);
-
- assertEquals(2, xmlPersistenceUnit.getClasses().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.specifiedClassRefs()));
-
- // remove class ref from xml, test that it's removed from context
- xmlClassRef = xmlPersistenceUnit.getClasses().get(0);
- xmlPersistenceUnit.getClasses().remove(xmlClassRef);
-
- assertEquals(1, CollectionTools.size(persistenceUnit.specifiedClassRefs()));
-
- // remove another one ...
- xmlClassRef = xmlPersistenceUnit.getClasses().get(0);
- xmlPersistenceUnit.getClasses().remove(xmlClassRef);
-
- assertEquals(0, CollectionTools.size(persistenceUnit.specifiedClassRefs()));
- }
-
- public void testModifyClassRefs1() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test there are none initially
- assertEquals(0, xmlPersistenceUnit.getClasses().size());
- assertEquals(0, persistenceUnit.specifiedClassRefsSize());
-
- // add class ref, test that it's added to context
- persistenceUnit.addSpecifiedClassRef().setClassName("Foo");
-
- try {
- persistenceResource().save(null);
- }
- catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- assertEquals(1, xmlPersistenceUnit.getClasses().size());
- assertEquals("Foo", xmlPersistenceUnit.getClasses().get(0).getJavaClass());
-
- // add another ...
- persistenceUnit.addSpecifiedClassRef().setClassName("Bar");
-
- assertEquals(2, xmlPersistenceUnit.getClasses().size());
- assertEquals("Foo", xmlPersistenceUnit.getClasses().get(0).getJavaClass());
- assertEquals("Bar", xmlPersistenceUnit.getClasses().get(1).getJavaClass());
-
-
- persistenceUnit.addSpecifiedClassRef(0).setClassName("Baz");
-
- assertEquals(3, xmlPersistenceUnit.getClasses().size());
- assertEquals("Baz", xmlPersistenceUnit.getClasses().get(0).getJavaClass());
- assertEquals("Foo", xmlPersistenceUnit.getClasses().get(1).getJavaClass());
- assertEquals("Bar", xmlPersistenceUnit.getClasses().get(2).getJavaClass());
- }
-
- public void testModifyClassRefs2() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add two class refs and test that there are two existing in xml and context
- XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- xmlClassRef.setJavaClass("com.foo.Bar");
- xmlPersistenceUnit.getClasses().add(xmlClassRef);
- xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- xmlClassRef.setJavaClass("com.foo.Baz");
- xmlPersistenceUnit.getClasses().add(xmlClassRef);
-
- assertEquals(2, xmlPersistenceUnit.getClasses().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.specifiedClassRefs()));
-
- // remove class ref from context, test that it's removed from xml
- persistenceUnit.removeSpecifiedClassRef(0);
-
- assertEquals(1, xmlPersistenceUnit.getClasses().size());
-
- // remove another one ...
- persistenceUnit.removeSpecifiedClassRef(0);
-
- assertEquals(0, xmlPersistenceUnit.getClasses().size());
- }
-
- public void testImpliedClassRefs() throws Exception {
- createTestEntityWithPersistentInnerClass();
- assertFalse(persistenceUnit().impliedClassRefs().hasNext());
-
- jpaProject().setDiscoversAnnotatedClasses(true);
- ListIterator<ClassRef> classRefs = persistenceUnit().impliedClassRefs();
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, classRefs.next().getClassName());
- assertEquals(FULLY_QUALIFIED_INNER_CLASS_NAME, classRefs.next().getClassName());
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- classRefs = persistenceUnit().impliedClassRefs();
- assertEquals(FULLY_QUALIFIED_INNER_CLASS_NAME, classRefs.next().getClassName());
- assertFalse(classRefs.hasNext());
-
-
- removeXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- classRefs = persistenceUnit().impliedClassRefs();
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, classRefs.next().getClassName());
- assertEquals(FULLY_QUALIFIED_INNER_CLASS_NAME, classRefs.next().getClassName());
-
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- classRefs = persistenceUnit().impliedClassRefs();
- assertEquals(FULLY_QUALIFIED_INNER_CLASS_NAME, classRefs.next().getClassName());
- assertFalse(classRefs.hasNext());
-
- addXmlClassRef(FULLY_QUALIFIED_INNER_CLASS_NAME);
- classRefs = persistenceUnit().impliedClassRefs();
- assertFalse(classRefs.hasNext());
-
- removeXmlClassRef(FULLY_QUALIFIED_INNER_CLASS_NAME);
- classRefs = persistenceUnit().impliedClassRefs();
- assertEquals(FULLY_QUALIFIED_INNER_CLASS_NAME, classRefs.next().getClassName());
- assertFalse(classRefs.hasNext());
-
- entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_INNER_CLASS_NAME);
- classRefs = persistenceUnit().impliedClassRefs();
- assertFalse(classRefs.hasNext());
- }
-
- public void testUpdateExcludeUnlistedClasses() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // 1 - initial value is default
- assertNull(persistenceUnit.getSpecifiedExcludeUnlistedClasses());
- assertFalse(persistenceUnit.isExcludeUnlistedClasses());
- assertNull(xmlPersistenceUnit.getExcludeUnlistedClasses());
-
- // 2 - set value, context changed
- xmlPersistenceUnit.setExcludeUnlistedClasses(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, persistenceUnit.getSpecifiedExcludeUnlistedClasses());
- assertTrue(persistenceUnit.isExcludeUnlistedClasses());
- assertEquals(Boolean.TRUE, xmlPersistenceUnit.getExcludeUnlistedClasses());
-
- xmlPersistenceUnit.setExcludeUnlistedClasses(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, persistenceUnit.getSpecifiedExcludeUnlistedClasses());
- assertFalse(persistenceUnit.isExcludeUnlistedClasses());
- assertEquals(Boolean.FALSE, xmlPersistenceUnit.getExcludeUnlistedClasses());
-
- // 3 - unset value, context changed
- xmlPersistenceUnit.setExcludeUnlistedClasses(null);
-
- assertNull(persistenceUnit.getSpecifiedExcludeUnlistedClasses());
- assertFalse(persistenceUnit.isExcludeUnlistedClasses());
- assertNull(xmlPersistenceUnit.getExcludeUnlistedClasses());
- }
-
- public void testModifyExcludeUnlistedClasses() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // 1 - initial value is default
- assertNull(persistenceUnit.getSpecifiedExcludeUnlistedClasses());
- assertFalse(persistenceUnit.isExcludeUnlistedClasses());
- assertNull(xmlPersistenceUnit.getExcludeUnlistedClasses());
-
- // 2 - set value, resource changed
- persistenceUnit.setSpecifiedExcludeUnlistedClasses(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, persistenceUnit.getSpecifiedExcludeUnlistedClasses());
- assertTrue(persistenceUnit.isExcludeUnlistedClasses());
- assertEquals(Boolean.TRUE, xmlPersistenceUnit.getExcludeUnlistedClasses());
-
- persistenceUnit.setSpecifiedExcludeUnlistedClasses(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, persistenceUnit.getSpecifiedExcludeUnlistedClasses());
- assertFalse(persistenceUnit.isExcludeUnlistedClasses());
- assertEquals(Boolean.FALSE, xmlPersistenceUnit.getExcludeUnlistedClasses());
-
- // 3 - set context to default, resource unset
- persistenceUnit.setSpecifiedExcludeUnlistedClasses(null);
-
- assertNull(persistenceUnit.getSpecifiedExcludeUnlistedClasses());
- assertFalse(persistenceUnit.isExcludeUnlistedClasses());
- assertNull(xmlPersistenceUnit.getExcludeUnlistedClasses());
- }
-
- public void testUpdateProperties1() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test there are none initially
- assertNull(xmlPersistenceUnit.getProperties());
- assertEquals(0, CollectionTools.size(persistenceUnit.properties()));
-
- // add "properties", test that there's no real change to context
- XmlProperties xmlProperties = PersistenceFactory.eINSTANCE.createXmlProperties();
- xmlPersistenceUnit.setProperties(xmlProperties);
- assertEquals(0, CollectionTools.size(persistenceUnit.properties()));
-
- // add property, test that it's added to context
- XmlProperty xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
- xmlProperty.setName("foo");
- xmlProperty.setValue("bar");
- xmlProperties.getProperties().add(xmlProperty);
-
- assertEquals(1, CollectionTools.size(persistenceUnit.properties()));
-
- // add another ...
- xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
- xmlProperty.setName("FOO");
- xmlProperty.setValue("BAR");
- xmlProperties.getProperties().add(xmlProperty);
-
- assertEquals(2, CollectionTools.size(persistenceUnit.properties()));
- }
-
- public void testUpdateProperties2() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add two properties and test that there are two existing in xml and context
- XmlProperties xmlProperties = PersistenceFactory.eINSTANCE.createXmlProperties();
- xmlPersistenceUnit.setProperties(xmlProperties);
- XmlProperty xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
- xmlProperty.setName("foo");
- xmlProperty.setValue("bar");
- xmlProperties.getProperties().add(xmlProperty);
- xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
- xmlProperty.setName("FOO");
- xmlProperty.setValue("BAR");
- xmlProperties.getProperties().add(xmlProperty);
-
- assertEquals(2, xmlPersistenceUnit.getProperties().getProperties().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.properties()));
-
- // remove property from xml, test that it's removed from context
- xmlProperty = xmlProperties.getProperties().get(0);
- xmlProperties.getProperties().remove(xmlProperty);
-
- assertEquals(1, CollectionTools.size(persistenceUnit.properties()));
-
- // remove another one ...
- xmlProperty = xmlProperties.getProperties().get(0);
- xmlProperties.getProperties().remove(xmlProperty);
-
- assertEquals(0, CollectionTools.size(persistenceUnit.properties()));
- }
-
- public void testModifyProperties1() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // test there are none initially
- assertNull(xmlPersistenceUnit.getProperties());
- assertEquals(0, persistenceUnit.propertiesSize());
-
- // add property, test that it's added to resource
- persistenceUnit.addProperty().setName("foo");
-
- assertNotNull(xmlPersistenceUnit.getProperties());
- assertEquals(1, xmlPersistenceUnit.getProperties().getProperties().size());
- assertEquals("foo", xmlPersistenceUnit.getProperties().getProperties().get(0).getName());
-
- // add another ...
- persistenceUnit.addProperty().setName("bar");
-
- assertEquals(2, xmlPersistenceUnit.getProperties().getProperties().size());
- assertEquals("foo", xmlPersistenceUnit.getProperties().getProperties().get(0).getName());
- assertEquals("bar", xmlPersistenceUnit.getProperties().getProperties().get(1).getName());
-
- // add another testing order
- persistenceUnit.addProperty(0).setName("baz");
-
- assertEquals(3, xmlPersistenceUnit.getProperties().getProperties().size());
- assertEquals("baz", xmlPersistenceUnit.getProperties().getProperties().get(0).getName());
- assertEquals("foo", xmlPersistenceUnit.getProperties().getProperties().get(1).getName());
- assertEquals("bar", xmlPersistenceUnit.getProperties().getProperties().get(2).getName());
- }
-
- public void testModifyProperties2() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add two properties and test that there are two existing in xml and context
- XmlProperties xmlProperties = PersistenceFactory.eINSTANCE.createXmlProperties();
- xmlPersistenceUnit.setProperties(xmlProperties);
- XmlProperty xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
- xmlProperty.setName("foo");
- xmlProperty.setValue("bar");
- xmlProperties.getProperties().add(xmlProperty);
- xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
- xmlProperty.setName("FOO");
- xmlProperty.setValue("BAR");
- xmlProperties.getProperties().add(xmlProperty);
-
- assertEquals(2, xmlPersistenceUnit.getProperties().getProperties().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.properties()));
-
- // remove property from context, test that it's removed from resource
- persistenceUnit.removeProperty("foo");
-
- assertEquals(1, xmlPersistenceUnit.getProperties().getProperties().size());
-
- // remove another one. test that properties object is nulled
- persistenceUnit.removeProperty("FOO", "BAR");
-
- assertNull(xmlPersistenceUnit.getProperties());
- }
-
- public void testModifyProperties3() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add two properties and test that there are two existing in xml and context
- persistenceUnit.putProperty("foo", "bar", false);
- persistenceUnit.putProperty("FOO", "BAR", false);
-
- assertEquals(2, xmlPersistenceUnit.getProperties().getProperties().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.properties()));
-
- // remove property from context, test that it's removed from resource
- persistenceUnit.removeProperty("foo", "bar");
-
- assertEquals(1, xmlPersistenceUnit.getProperties().getProperties().size());
-
- // remove another one, test that properties object is nulled
- persistenceUnit.removeProperty("FOO");
-
- assertNull(xmlPersistenceUnit.getProperties());
- }
-
- public void testModifyProperties4() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add two properties and test that there are two existing in xml and context
- persistenceUnit.putProperty("foo", "bar", false);
- persistenceUnit.putProperty("FOO", "BAR", false);
-
- assertEquals(2, xmlPersistenceUnit.getProperties().getProperties().size());
- assertEquals(2, persistenceUnit.propertiesSize());
-
- // modify a property, test its value
- persistenceUnit.putProperty("foo", "", false);
- assertEquals("", persistenceUnit.getProperty("foo").getValue());
-
- persistenceUnit.putProperty("foo", "BAR", false);
- assertEquals("BAR", persistenceUnit.getProperty("foo").getValue());
-
- // remove property that doesn't from context, test that the resource is unchanged
- persistenceUnit.removeProperty("notExist");
- assertEquals(2, xmlPersistenceUnit.getProperties().getProperties().size());
-
- // remove property from context, test that it's removed from resource
- persistenceUnit.removeProperty("FOO");
- assertNull(persistenceUnit.getProperty("FOO"));
- assertEquals(1, xmlPersistenceUnit.getProperties().getProperties().size());
-
- // remove by setting value to null, test that properties object is nulled
- persistenceUnit.putProperty("notExist", null, false);
- assertNull(persistenceUnit.getProperty("notExist"));
-
- persistenceUnit.putProperty("foo", null, false);
- assertNull(persistenceUnit.getProperty("foo"));
- assertNull(xmlPersistenceUnit.getProperties());
- }
-
- public void testModifyProperties5() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // testing duplicate keys, add four properties and test that there are four existing in xml and context
- persistenceUnit.putProperty("FOO", "BAR", false);
- persistenceUnit.putProperty("foo", "bar 3", true);
- persistenceUnit.putProperty("foo", "bar 2", true);
- persistenceUnit.putProperty("foo", "bar 1", true);
-
- assertEquals(4, xmlPersistenceUnit.getProperties().getProperties().size());
- assertEquals(4, CollectionTools.size(persistenceUnit.properties()));
-
- // modify a property, test its value
- persistenceUnit.replacePropertyValue("foo", "bar 2", "bar two");
-
- Property property = persistenceUnit.getProperty("foo", "bar two");
- assertEquals("bar two", property.getValue());
-
- // remove a property, test that there are four existing in xml and context
- persistenceUnit.removeProperty("foo", "bar 1");
- assertEquals(3, xmlPersistenceUnit.getProperties().getProperties().size());
- assertEquals(3, CollectionTools.size(persistenceUnit.properties()));
- }
-
- public void testAccessProperty() {
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add two properties and try to access it.
- persistenceUnit.putProperty("foo", "bar", false);
- persistenceUnit.putProperty("FOO", "BAR", false);
-
- Property property = persistenceUnit.getProperty("foo");
- assertNotNull(property);
- assertEquals("bar", property.getValue());
- assertTrue(persistenceUnit.containsProperty("FOO"));
- assertEquals("BAR", persistenceUnit.getProperty("FOO").getValue());
- assertNull(persistenceUnit.getProperty("notExist"));
- }
-
- public void testUpdatePropertyName() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add property for testing
- XmlProperties xmlProperties = PersistenceFactory.eINSTANCE.createXmlProperties();
- xmlPersistenceUnit.setProperties(xmlProperties);
- XmlProperty xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
- xmlProperties.getProperties().add(xmlProperty);
- Property property = persistenceUnit.properties().next();
-
- // test that names are initially equal
- assertEquals(xmlProperty.getName(), property.getName());
-
- // set name to different name, test equality
- xmlProperty.setName("newName");
-
- assertEquals(xmlProperty.getName(), property.getName());
-
- // set name to empty string, test equality
- xmlProperty.setName("");
-
- assertEquals(xmlProperty.getName(), property.getName());
-
- // set name to null, test equality
- xmlProperty.setName(null);
-
- assertEquals(xmlProperty.getName(), property.getName());
-
- // set name back to non-null, test equality
- xmlProperty.setName("newName");
-
- assertEquals(xmlProperty.getName(), property.getName());
- }
-
- public void testUpdatePropertyValue() {
- XmlPersistenceUnit xmlPersistenceUnit = xmlPersistenceUnit();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- // add property for testing
- XmlProperties xmlProperties = PersistenceFactory.eINSTANCE.createXmlProperties();
- xmlPersistenceUnit.setProperties(xmlProperties);
- XmlProperty xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
- xmlProperties.getProperties().add(xmlProperty);
- Property property = persistenceUnit.properties().next();
-
- // test that values are initially equal
- assertEquals(xmlProperty.getValue(), property.getValue());
-
- // set value to different value, test equality
- xmlProperty.setValue("newValue");
-
- assertEquals(xmlProperty.getValue(), property.getValue());
-
- // set value to empty string, test equality
- xmlProperty.setValue("");
-
- assertEquals(xmlProperty.getValue(), property.getValue());
-
- // set value to null, test equality
- xmlProperty.setValue(null);
-
- assertEquals(xmlProperty.getValue(), property.getValue());
-
- // set value back to non-null, test equality
- xmlProperty.setValue("newValue");
-
- assertEquals(xmlProperty.getValue(), property.getValue());
- }
-
-
- public void testGetDefaultAccess() throws Exception {
- createOrmXmlFile();
- PersistenceUnit persistenceUnit = persistenceUnit();
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, persistenceUnit.getDefaultAccess());
-
- entityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(AccessType.FIELD);
- assertEquals(AccessType.FIELD, persistenceUnit.getDefaultAccess());
- }
-
- protected void createOrmXmlFile() throws Exception {
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
- xmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- persistenceResource().save(null);
- }
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
- });
- }
-
- private IType createTestEntityWithPersistentInnerClass() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendMemberTypeTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append(" public static class " + INNER_CLASS_NAME + " {}").append(CR);
- }
- });
- }
-
- public void testPersistentType() throws Exception {
- PersistenceUnit persistenceUnit = persistenceUnit();
- createTestEntity();
-
- //persistentType not listed in persistence.xml and discoverAnnotatedClasses is false
- assertFalse(jpaProject().discoversAnnotatedClasses());
- assertNull(persistenceUnit.getPersistentType(FULLY_QUALIFIED_TYPE_NAME));
-
- //test persistentType not listed in persistence.xml, discover annotated classes set to true
- jpaProject().setDiscoversAnnotatedClasses(true);
- assertNotNull(persistenceUnit.getPersistentType(FULLY_QUALIFIED_TYPE_NAME));
-
- //test persistentType list as class in persistence.xml
- jpaProject().setDiscoversAnnotatedClasses(false);
- XmlJavaClassRef classRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- classRef.setJavaClass(FULLY_QUALIFIED_TYPE_NAME);
- xmlPersistenceUnit().getClasses().add(classRef);
- assertNotNull(persistenceUnit.getPersistentType(FULLY_QUALIFIED_TYPE_NAME));
-
-
- //test persistentType from orm.xml file that is specified in the persistence.xml
- createOrmXmlFile();
- OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- assertNotNull(persistenceUnit.getPersistentType("model.Foo"));
- assertEquals(ormPersistentType, persistenceUnit.getPersistentType("model.Foo"));
-
- //test persistentType from orm.xml file that is implied(not specified) in the persistence.xml
- xmlPersistenceUnit().getMappingFiles().remove(0);
- assertNotNull(persistenceUnit.getPersistentType("model.Foo"));
- }
-
-//TODO
-// String getDefaultSchema();
-// String getDefaultCatalog();
-// AccessType getDefaultAccess();
-// boolean getDefaultCascadePersist();
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceXmlTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceXmlTests.java
deleted file mode 100644
index 343f7f2ca6..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceXmlTests.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.persistence;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceXml;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.PersistenceResource;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class PersistenceXmlTests extends ContextModelTestCase
-{
- public PersistenceXmlTests(String name) {
- super(name);
- }
-
- protected PersistenceXml persistenceXml() {
- return rootContext().getPersistenceXml();
- }
-
- public void testUpdateAddPersistence() throws Exception {
- PersistenceResource prm = persistenceResource();
- prm.getContents().clear();
- prm.save(null);
-
- assertNull(persistenceXml().getPersistence());
-
- prm.getContents().add(PersistenceFactory.eINSTANCE.createXmlPersistence());
-
- assertNotNull(persistenceXml().getPersistence());
-
- }
-
- public void testModifyAddPersistence() {
- PersistenceResource prm = persistenceResource();
- prm.getContents().remove(prm.getPersistence());
- assertNull(prm.getPersistence());
-
- PersistenceXml persistenceXml = persistenceXml();
-
- persistenceXml.addPersistence();
-
- assertNotNull(persistenceXml.getPersistence());
-
- boolean exceptionThrown = false;
- try {
- persistenceXml.addPersistence();
- }
- catch (IllegalStateException ise) {
- exceptionThrown = true;
- }
-
- assertTrue(exceptionThrown);
- }
-
- public void testUpdateRemovePersistence() throws Exception {
- PersistenceResource prm = persistenceResource();
-
- assertNotNull(persistenceXml().getPersistence());
-
- prm.getContents().clear();
-
- assertNull(persistenceXml().getPersistence());
- }
-
- public void testModifyRemovePersistence() {
- PersistenceXml persistenceXml = persistenceXml();
-
- assertNotNull(persistenceXml.getPersistence());
-
- persistenceXml.removePersistence();
-
- assertNull(persistenceXml.getPersistence());
-
- boolean exceptionThrown = false;
- try {
- persistenceXml.removePersistence();
- }
- catch (IllegalStateException ise) {
- exceptionThrown = true;
- }
-
- assertTrue(exceptionThrown);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/RootContextTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/RootContextTests.java
deleted file mode 100644
index 6e719084f2..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/RootContextTests.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.context.persistence;
-
-import org.eclipse.jpt.core.context.JpaRootContextNode;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.PersistenceResource;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-
-public class RootContextTests extends ContextModelTestCase
-{
- public RootContextTests(String name) {
- super(name);
- }
-
- public void testModifyAddPersistenceXml() throws Exception {
- PersistenceResource pr = persistenceResource();
- deleteResource(pr);
-
- assertFalse(pr.exists());
-
- JpaRootContextNode baseJpaContent = getJavaProject().getJpaProject().getRootContext();
- assertNull(baseJpaContent.getPersistenceXml());
-
- baseJpaContent.addPersistenceXml();
-
- assertNotNull(baseJpaContent.getPersistenceXml());
-
- boolean exceptionThrown = false;
- try {
- baseJpaContent.addPersistenceXml();
- }
- catch (IllegalStateException ise) {
- exceptionThrown = true;
- }
-
- assertTrue(exceptionThrown);
- }
-
- public void testModifyRemovePersistenceXml() throws Exception {
- JpaRootContextNode baseJpaContent = getJavaProject().getJpaProject().getRootContext();
-
- assertNotNull(baseJpaContent.getPersistenceXml());
-
- baseJpaContent.removePersistenceXml();
- waitForWorkspaceJobs();
-
- assertNull(baseJpaContent.getPersistenceXml());
-
- boolean exceptionThrown = false;
- try {
- baseJpaContent.removePersistenceXml();
- }
- catch (IllegalStateException ise) {
- exceptionThrown = true;
- }
-
- assertTrue(exceptionThrown);
- }
-
- public void testUpdateAddPersistenceXml() throws Exception {
- PersistenceResource pr = persistenceResource();
- deleteResource(pr);
-
- assertFalse(pr.exists());
-
- JpaRootContextNode baseJpaContent = getJavaProject().getJpaProject().getRootContext();
- assertNull(baseJpaContent.getPersistenceXml());
-
- pr.getContents().add(PersistenceFactory.eINSTANCE.createXmlPersistence());
- pr.save(null);
- assertNotNull(baseJpaContent.getPersistenceXml());
- }
-
- public void testUpdateRemovePersistenceXml() throws Exception {
- PersistenceResource pr = persistenceResource();
- JpaRootContextNode baseJpaContent = getJavaProject().getJpaProject().getRootContext();
-
- assertNotNull(baseJpaContent.getPersistenceXml());
-
- deleteResource(pr);
-
- assertNull(baseJpaContent.getPersistenceXml());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaModelTests.java
deleted file mode 100644
index 84a5d4998f..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaModelTests.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.model;
-
-import junit.framework.TestCase;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.internal.GenericJpaModel;
-import org.eclipse.jpt.core.internal.JpaModelManager;
-import org.eclipse.jpt.core.tests.internal.ProjectUtility;
-import org.eclipse.jpt.core.tests.internal.projects.TestFacetedProject;
-import org.eclipse.jpt.core.tests.internal.projects.TestPlatformProject;
-import org.eclipse.jpt.utility.internal.ClassTools;
-
-public class JpaModelTests extends TestCase {
-
- /** carriage return */
- public static final String CR = System.getProperty("line.separator");
-
- public JpaModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- if (this.debug()) {
- this.printName();
- }
- ProjectUtility.deleteAllProjects();
- }
-
- private boolean debug() {
- Boolean debug = (Boolean) ClassTools.staticFieldValue(JpaModelManager.class, "DEBUG");
- return debug.booleanValue();
- }
-
- private void printName() {
- String name = this.getName();
- System.out.println();
- System.out.println();
- this.printNameBorder(name);
- System.out.println(name);
- this.printNameBorder(name);
- }
-
- private void printNameBorder(String name) {
- for (int i = name.length(); i-- > 0; ) {
- System.out.print('=');
- }
- System.out.println();
- }
-
- @Override
- protected void tearDown() throws Exception {
- ProjectUtility.deleteAllProjects();
- super.tearDown();
- }
-
- /**
- * Builds a project with the java and utility facets installed, and with
- * pre-existing entities added.
- */
- private TestFacetedProject buildTestProject() throws Exception {
- TestFacetedProject testProject = TestFacetedProject.buildFacetedProject(ClassTools.shortClassNameForObject(this), true);
- testProject.installFacet("jst.java", "5.0");
- testProject.installFacet("jst.utility", "1.0");
- testProject.createFile(
- new Path("src/test.pkg/TestEntity.java"),
- "package test.pkg; @Entity public class TestEntity {}");
- testProject.createFile(
- new Path("src/test.pkg/TestEntity2.java"),
- "package test.pkg; @Entity public class TestEntity2 {}");
- return testProject;
- }
-
- private IFile file(TestPlatformProject p, String path) {
- return p.getProject().getFile(new Path(path));
- }
-
- public void testJpaModel() {
- assertNotNull(JptCorePlugin.getJpaModel());
- }
-
- public void testFacetInstallUninstall() throws Exception {
- TestFacetedProject testProject = this.buildTestProject();
- assertNull(JptCorePlugin.getJpaProject(testProject.getProject()));
-
- testProject.installFacet("jpt.jpa", "1.0");
- assertEquals(1, JptCorePlugin.getJpaModel().jpaProjectsSize());
- JpaProject jpaProject = JptCorePlugin.getJpaProject(testProject.getProject());
- assertNotNull(jpaProject);
-// assertEquals(4, jpaProject.jpaFilesSize());
- assertNotNull(jpaProject.getJpaFile(this.file(testProject, "src/test.pkg/TestEntity.java")));
- assertNotNull(jpaProject.getJpaFile(this.file(testProject, "src/test.pkg/TestEntity2.java")));
- // persistence.xml and orm.xml are created in the background, so they probably
- // won't be there yet...
-// assertNotNull(jpaProject.jpaFile(this.file(testProject, "src/META-INF/persistence.xml")));
-// assertNotNull(jpaProject.jpaFile(this.file(testProject, "src/META-INF/orm.xml")));
-
- testProject.uninstallFacet("jpt.jpa", "1.0");
- assertEquals(0, JptCorePlugin.getJpaModel().jpaProjectsSize());
- jpaProject = JptCorePlugin.getJpaProject(testProject.getProject());
- assertNull(jpaProject);
- }
-
- public void testProjectCloseReopen() throws Exception {
- TestFacetedProject testProject = this.buildTestProject();
- testProject.installFacet("jpt.jpa", "1.0");
-
- testProject.getProject().close(null);
- assertFalse(testProject.getProject().isOpen());
- JpaProject jpaProject = JptCorePlugin.getJpaProject(testProject.getProject());
- assertNull(jpaProject);
-
- testProject.getProject().open(null);
- jpaProject = JptCorePlugin.getJpaProject(testProject.getProject());
- assertNotNull(jpaProject);
-// assertEquals(4, jpaProject.jpaFilesSize());
- assertNotNull(jpaProject.getJpaFile(this.file(testProject, "src/test.pkg/TestEntity.java")));
- assertNotNull(jpaProject.getJpaFile(this.file(testProject, "src/test.pkg/TestEntity2.java")));
- // persistence.xml and orm.xml are created in the background, so they probably
- // won't be there yet...
-// assertNotNull(jpaProject.jpaFile(this.file(testProject, "src/META-INF/persistence.xml")));
-// assertNotNull(jpaProject.jpaFile(this.file(testProject, "src/META-INF/orm.xml")));
- }
-
- public void testProjectDeleteReimport() throws Exception {
- TestFacetedProject testProject = this.buildTestProject();
- testProject.installFacet("jpt.jpa", "1.0");
- JpaProject jpaProject = JptCorePlugin.getJpaProject(testProject.getProject());
- assertNotNull(jpaProject);
- assertEquals(1, JptCorePlugin.getJpaModel().jpaProjectsSize());
-
- testProject.getProject().delete(false, true, null);
- jpaProject = JptCorePlugin.getJpaProject(testProject.getProject());
- assertNull(jpaProject);
- assertEquals(0, JptCorePlugin.getJpaModel().jpaProjectsSize());
- assertEquals(0, ResourcesPlugin.getWorkspace().getRoot().getProjects().length);
-
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(testProject.getProject().getName());
- project.create(null);
- assertEquals(1, ResourcesPlugin.getWorkspace().getRoot().getProjects().length);
- project.open(null);
-
- assertTrue(project.isOpen());
- assertTrue(JptCorePlugin.projectHasJpaFacet(project));
- jpaProject = JptCorePlugin.getJpaProject(project);
- assertNotNull(jpaProject);
-// assertEquals(4, jpaProject.jpaFilesSize());
- assertNotNull(jpaProject.getJpaFile(this.file(testProject, "src/test.pkg/TestEntity.java")));
- assertNotNull(jpaProject.getJpaFile(this.file(testProject, "src/test.pkg/TestEntity2.java")));
- // persistence.xml and orm.xml are created in the background, so they probably
- // won't be there yet...
-// assertNotNull(jpaProject.jpaFile(this.file(testProject, "src/META-INF/persistence.xml")));
-// assertNotNull(jpaProject.jpaFile(this.file(testProject, "src/META-INF/orm.xml")));
- }
-
- //TODO - Commented out this test, since it was failing in the I-Build and we're not sure why.
- //See bug 221757
-// public void testEditFacetSettingsFile() throws Exception {
-// TestFacetedProject testProject = this.buildTestProject();
-// assertNull(JptCorePlugin.jpaProject(testProject.getProject()));
-//
-// // add the JPA facet by modifying the facet settings file directly
-// IFile facetSettingsFile = this.file(testProject, ".settings/org.eclipse.wst.common.project.facet.core.xml");
-// InputStream inStream = new BufferedInputStream(facetSettingsFile.getContents());
-// int fileSize = inStream.available();
-// byte[] buf = new byte[fileSize];
-// inStream.read(buf);
-// inStream.close();
-//
-// String oldDocument = new String(buf);
-// String oldString = "<installed facet=\"jst.utility\" version=\"1.0\"/>";
-// String newString = oldString + CR + " " + "<installed facet=\"jpt.jpa\" version=\"1.0\"/>";
-// String newDocument = oldDocument.replaceAll(oldString, newString);
-//
-// facetSettingsFile.setContents(new ByteArrayInputStream(newDocument.getBytes()), false, false, null);
-//
-// assertEquals(1, JptCorePlugin.jpaModel().jpaProjectsSize());
-// JpaProject jpaProject = JptCorePlugin.jpaProject(testProject.getProject());
-// assertNotNull(jpaProject);
-// // persistence.xml and orm.xml do not get created in this situation (?)
-// assertEquals(2, jpaProject.jpaFilesSize());
-// assertNotNull(jpaProject.jpaFile(this.file(testProject, "src/test.pkg/TestEntity.java")));
-// assertNotNull(jpaProject.jpaFile(this.file(testProject, "src/test.pkg/TestEntity2.java")));
-// // assertNotNull(jpaProject.jpaFile(this.file(testProject, "src/META-INF/persistence.xml")));
-// // assertNotNull(jpaProject.jpaFile(this.file(testProject, "src/META-INF/orm.xml")));
-//
-// // now remove the JPA facet
-// facetSettingsFile.setContents(new ByteArrayInputStream(oldDocument.getBytes()), false, false, null);
-//// TODO moved this stuff to the error console until we can figure out why it fails intermittently ~bjv
-//// assertEquals(0, JptCorePlugin.jpaModel().jpaProjectsSize());
-//// jpaProject = JptCorePlugin.jpaProject(testProject.getProject());
-//// assertNull(jpaProject);
-// int size = JptCorePlugin.jpaModel().jpaProjectsSize();
-// if (size != 0) {
-// System.err.println("bogus size: " + size);
-// System.err.println("bogus project: " + JptCorePlugin.jpaProject(testProject.getProject()));
-// }
-// }
-
- /**
- * make sure the DEBUG constants are 'false' before checking in the code
- */
- public void testDEBUG() {
- this.verifyDEBUG(JpaModelManager.class);
- this.verifyDEBUG(GenericJpaModel.class);
- }
-
- private void verifyDEBUG(Class<?> clazz) {
- assertFalse("Recompile with \"DEBUG = false\": " + clazz.getName(),
- ((Boolean) ClassTools.staticFieldValue(clazz, "DEBUG")).booleanValue());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JptCoreModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JptCoreModelTests.java
deleted file mode 100644
index 59be1a1135..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JptCoreModelTests.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.model;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptCoreModelTests {
-
- public static Test suite() {
- return suite(true);
- }
-
- public static Test suite(boolean all) {
- TestSuite suite = new TestSuite(JptCoreModelTests.class.getPackage().getName());
- suite.addTestSuite(JpaModelTests.class);
- return suite;
- }
-
- private JptCoreModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/BaseJpaPlatformTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/BaseJpaPlatformTests.java
deleted file mode 100644
index 07c4967a77..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/BaseJpaPlatformTests.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.eclipse.jpt.core.tests.internal.platform;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.core.tests.internal.ProjectUtility;
-import org.eclipse.jpt.core.tests.internal.projects.TestJpaProject;
-
-public class BaseJpaPlatformTests extends TestCase
-{
- protected TestJpaProject jpaProject;
-
- protected static final String PROJECT_NAME = "PlatformTestProject";
- protected static final String PACKAGE_NAME = "platform.test";
- protected static final String PERSISTENCE_XML_LOCATION = "src/META-INF/persistence.xml";
- protected static final String ORM_XML_LOCATION = "src/META-INF/orm.xml";
-
-
- public BaseJpaPlatformTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- ProjectUtility.deleteAllProjects();
- jpaProject = this.buildJpaProject(PROJECT_NAME, false); // false = no auto-build
- }
-
- protected TestJpaProject buildJpaProject(String projectName, boolean autoBuild) throws Exception {
- return new TestJpaProject(projectName, autoBuild); // false = no auto-build
- }
-
- @Override
- protected void tearDown() throws Exception {
- ProjectUtility.deleteAllProjects();
- jpaProject = null;
- super.tearDown();
- }
-
-// public void testPersistentTypes() throws CoreException, IOException {
-// IFile persistenceXmlIFile = jpaProject.getProject().getFile(PERSISTENCE_XML_LOCATION);
-// IJpaFile persistenceXmlJpaFile = jpaProject.getJpaProject().getJpaFile(persistenceXmlIFile);
-// PersistenceXmlRootContentNode persistenceRoot = (PersistenceXmlRootContentNode) persistenceXmlJpaFile.getContent();
-// XmlPersistence persistence = persistenceRoot.getPersistence();
-//
-// IFile ormXmlIFile = jpaProject.getProject().getFile(ORM_XML_LOCATION);
-// IJpaFile ormXmlJpaFile = jpaProject.getJpaProject().getJpaFile(ormXmlIFile);
-// XmlRootContentNode ormRoot = (XmlRootContentNode) ormXmlJpaFile.getContent();
-// EntityMappingsInternal entityMappings = ormRoot.getEntityMappings();
-//
-// // add xml persistent type
-// XmlEntityInternal xmlEntity = OrmFactory.eINSTANCE.createXmlEntityInternal();
-// xmlEntity.setSpecifiedName("XmlEntity");
-// entityMappings.getTypeMappings().add(xmlEntity);
-// entityMappings.eResource().save(null);
-// assertEquals(1, CollectionTools.size(jpaProject.getJpaProject().getPlatform().persistentTypes(PROJECT_NAME)));
-//
-// // add java persistent type
-// jpaProject.createType(PACKAGE_NAME, "JavaEntity.java",
-// "@Entity public class JavaEntity {}"
-// );
-// XmlJavaClassRef javaClassRef = PersistenceFactory.eINSTANCE.createJavaClassRef();
-// javaClassRef.setJavaClass(PACKAGE_NAME + ".JavaEntity");
-// persistence.getPersistenceUnits().get(0).getClasses().add(javaClassRef);
-// persistence.eResource().save(null);
-//
-// assertEquals(2, CollectionTools.size(jpaProject.getJpaProject().getPlatform().persistentTypes(PROJECT_NAME)));
-// }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformExtensionTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformExtensionTests.java
deleted file mode 100644
index a00f2df01d..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformExtensionTests.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.platform;
-
-import junit.framework.TestCase;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.internal.platform.JpaPlatformRegistry;
-import org.eclipse.jpt.core.tests.extension.resource.ExtensionTestPlugin;
-import org.eclipse.jpt.core.tests.extension.resource.TestJpaPlatform;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-public class JpaPlatformExtensionTests extends TestCase
-{
- public static final String TEST_PLATFORM_ID = TestJpaPlatform.ID;
- public static final String TEST_PLATFORM_LABEL = "Test Jpa Platform";
-
- public JpaPlatformExtensionTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- verifyExtensionTestProjectExists();
- }
-
- public static void verifyExtensionTestProjectExists() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint =
- registry.getExtensionPoint(JptCorePlugin.PLUGIN_ID, "jpaPlatform");
- IExtension[] extensions = extensionPoint.getExtensions();
- boolean extensionFound = false;
- for (IExtension extension : extensions) {
- if (extension.getContributor().getName().equals(ExtensionTestPlugin.PLUGIN_ID)) {
- extensionFound = true;
- }
- }
- if (!extensionFound) {
- throw new RuntimeException("Missing Extension " + TEST_PLATFORM_ID + ". The ExtensionTestProject plugin must be in your testing workspace.");
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testAllJpaPlatformIds() {
- assertTrue(CollectionTools.size(JpaPlatformRegistry.instance().jpaPlatformIds()) >= 2);
- }
-
- public void testJpaPlatformLabel() {
- assertEquals(TEST_PLATFORM_LABEL, JpaPlatformRegistry.instance().getJpaPlatformLabel(TEST_PLATFORM_ID));
- }
-
- public void testJpaPlatform() {
- assertNotNull(JpaPlatformRegistry.instance().getJpaPlatform(TEST_PLATFORM_ID));
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformTests.java
deleted file mode 100644
index 8a41824528..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformTests.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.platform;
-
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JpaPlatform;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.core.internal.facet.JpaFacetDataModelProperties;
-import org.eclipse.jpt.core.internal.facet.JpaFacetDataModelProvider;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.tests.extension.resource.ExtensionTestPlugin;
-import org.eclipse.jpt.core.tests.extension.resource.JavaTestAttributeMapping;
-import org.eclipse.jpt.core.tests.extension.resource.JavaTestAttributeMappingProvider;
-import org.eclipse.jpt.core.tests.extension.resource.JavaTestTypeMapping;
-import org.eclipse.jpt.core.tests.extension.resource.JavaTestTypeMappingProvider;
-import org.eclipse.jpt.core.tests.extension.resource.TestJavaBasicMapping;
-import org.eclipse.jpt.core.tests.extension.resource.TestJavaEntity;
-import org.eclipse.jpt.core.tests.extension.resource.TestJpaFactory;
-import org.eclipse.jpt.core.tests.extension.resource.TestJpaPlatform;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject;
-import org.eclipse.jpt.core.tests.internal.projects.TestJpaProject;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.IActionConfigFactory;
-
-public class JpaPlatformTests extends ContextModelTestCase
-{
- protected TestJpaProject testProject;
-
- protected static final String PROJECT_NAME = "ExtensionTestProject";
- protected static final String PACKAGE_NAME = "extension.test";
-
- public static final String TEST_PLUGIN_CLASS = ExtensionTestPlugin.class.getName();
- public static final String TEST_PLUGIN_ID = "org.eclipse.jpt.core.tests.extension.resource";
-
- public static final String TEST_PLATFORM_CLASS_NAME = TestJpaPlatform.class.getName();
- public static final String TEST_PLATFORM_LABEL = "Test Jpa Platform";
- public static final String TEST_JPA_FACTORY = TestJpaFactory.class.getName();
- public static final String TEST_TYPE_MAPPING_PROVIDER_CLASS = JavaTestTypeMappingProvider.class.getName();
- public static final String TEST_ATTRIBUTE_MAPPING_PROVIDER_CLASS = JavaTestAttributeMappingProvider.class.getName();
-
- public JpaPlatformTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- JpaPlatformExtensionTests.verifyExtensionTestProjectExists();
- }
-
- @Override
- protected TestJavaProject buildJavaProject(boolean autoBuild) throws Exception {
- return super.buildJpaProject(PROJECT_NAME, autoBuild, this.buildConfig());
- }
-
- protected IDataModel buildConfig() throws Exception {
- IActionConfigFactory configFactory = new JpaFacetDataModelProvider();
- IDataModel config = (IDataModel) configFactory.create();
- config.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, TestJpaPlatform.ID);
- return config;
- }
-
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
- });
- }
-
-
- protected JpaPlatform jpaPlatform() {
- return this.jpaProject().getJpaPlatform();
- }
-
- public void testJpaFactory() {
- assertTrue(jpaPlatform().getJpaFactory().getClass().getName().equals(TEST_JPA_FACTORY));
- }
-
- public void testBuildJavaTypeMappingFromMappingKey() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaTypeMapping javaTypeMapping = jpaProject().getJpaPlatform().buildJavaTypeMappingFromMappingKey(JavaTestTypeMapping.TEST_TYPE_MAPPING_KEY, javaPersistentType());
- assertTrue(javaTypeMapping instanceof JavaTestTypeMapping);
-
- javaTypeMapping = jpaPlatform().buildJavaTypeMappingFromMappingKey(MappingKeys.ENTITY_TYPE_MAPPING_KEY, javaPersistentType());
- assertTrue(javaTypeMapping instanceof TestJavaEntity);
- }
-
- public void testBuildJavaAttributeMappingFromMappingKey() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaAttributeMapping javaAttributeMapping = jpaProject().getJpaPlatform().buildJavaAttributeMappingFromMappingKey(JavaTestAttributeMapping.TEST_ATTRIBUTE_MAPPING_KEY, javaPersistentType().getAttributeNamed("name"));
- assertTrue(javaAttributeMapping instanceof JavaTestAttributeMapping);
-
- javaAttributeMapping = jpaPlatform().buildJavaAttributeMappingFromMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, javaPersistentType().getAttributeNamed("name"));
- assertTrue(javaAttributeMapping instanceof TestJavaBasicMapping);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java
deleted file mode 100644
index 4517f2b67a..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.projects;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-
-/**
- * This builds and holds a "faceted" project.
- * Support for installing facets.
- */
-public class TestFacetedProject extends TestPlatformProject {
- private final IFacetedProject facetedProject;
-
-
- // ********** builders *****************************
-
- public static TestFacetedProject buildFacetedProject(String baseProjectName, boolean autoBuild)
- throws CoreException {
- return new TestFacetedProject(uniqueProjectName(baseProjectName), autoBuild);
- }
-
-
- // ********** constructors/initialization **********
-
- public TestFacetedProject(String projectName) throws CoreException {
- this(projectName, true);
- }
-
- public TestFacetedProject(String projectName, boolean autoBuild) throws CoreException {
- super(projectName, autoBuild);
- this.facetedProject = this.createFacetedProject();
- }
-
- private IFacetedProject createFacetedProject() throws CoreException {
- return ProjectFacetsManager.create(this.getProject(), true, null); // true = "convert if necessary"
- }
-
-
- // ********** public methods **********
-
- public IFacetedProject getFacetedProject() {
- return this.facetedProject;
- }
-
- public void installFacet(String facetName, String versionName) throws CoreException {
- this.installFacet(facetName, versionName, null);
- }
-
- public void uninstallFacet(String facetName, String versionName) throws CoreException {
- this.uninstallFacet(facetName, versionName, null);
- }
-
- /**
- * if 'config' is null, the JPA project will be built with the defaults
- * defined in JpaFacetDataModelProvider#getDefaultProperty(String)
- */
- public void installFacet(String facetName, String versionName, IDataModel config) throws CoreException {
- this.facetedProject.installProjectFacet(this.facetVersion(facetName, versionName), config, null);
- }
-
- public void uninstallFacet(String facetName, String versionName, IDataModel config) throws CoreException {
- this.facetedProject.uninstallProjectFacet(this.facetVersion(facetName, versionName), config, null);
- }
-
- private IProjectFacetVersion facetVersion(String facetName, String versionName) {
- return ProjectFacetsManager.getProjectFacet(facetName).getVersion(versionName);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java
deleted file mode 100644
index 29f7c6a648..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.projects;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-/**
- * This builds and holds a "Java" project.
- * Support for adding packages and types.
- *
- * "Java" projects aren't required to be "faceted" projects, but for JPA
- * testing they are.
- */
-public class TestJavaProject extends TestFacetedProject {
- private final IJavaProject javaProject;
- private final IPackageFragmentRoot sourceFolder;
-
-
- // ********** builders *****************************
-
- public static TestJavaProject buildJavaProject(String baseProjectName, boolean autoBuild)
- throws CoreException {
- return new TestJavaProject(uniqueProjectName(baseProjectName), autoBuild);
- }
-
-
- // ********** constructors/initialization **********
-
- public TestJavaProject(String projectName) throws CoreException {
- this(projectName, false);
- }
-
- public TestJavaProject(String projectName, boolean autoBuild) throws CoreException {
- super(projectName, autoBuild);
- this.installFacet("jst.java", "5.0");
- this.javaProject = JavaCore.create(this.getProject());
- this.sourceFolder = this.javaProject.getPackageFragmentRoot(this.getProject().getFolder("src"));
- }
-
- protected void addJar(String jarPath) throws JavaModelException {
- this.addClasspathEntry(JavaCore.newLibraryEntry(new Path(jarPath), null, null));
- }
-
- private void addClasspathEntry(IClasspathEntry entry) throws JavaModelException {
- this.javaProject.setRawClasspath(CollectionTools.add(this.javaProject.getRawClasspath(), entry), null);
- }
-
-
- // ********** public methods **********
-
- public IPackageFragment createPackage(String packageName) throws CoreException {
- return this.sourceFolder.createPackageFragment(packageName, false, null); // false = "no force"
- }
-
- /**
- * The source should NOT contain a package declaration;
- * it will be added here.
- */
- public IType createType(String packageName, String compilationUnitName, String source) throws CoreException {
- return this.createType(this.createPackage(packageName), compilationUnitName, new SimpleSourceWriter(source));
- }
-
- /**
- * The source should NOT contain a package declaration;
- * it will be added here.
- */
- public IType createType(String packageName, String compilationUnitName, SourceWriter sourceWriter) throws CoreException {
- return this.createType(this.createPackage(packageName), compilationUnitName, sourceWriter);
- }
-
- /**
- * The source should NOT contain a package declaration;
- * it will be added here.
- */
- public IType createType(IPackageFragment packageFragment, String compilationUnitName, SourceWriter sourceWriter) throws CoreException {
- StringBuilder sb = new StringBuilder(2000);
- sb.append("package ").append(packageFragment.getElementName()).append(";").append(CR);
- sb.append(CR);
- sourceWriter.appendSourceTo(sb);
- String source = sb.toString();
- ICompilationUnit cu = packageFragment.createCompilationUnit(compilationUnitName, source, false, null); // false = "no force"
- return cu.findPrimaryType();
- }
-
- public IType findType(String fullyQualifiedName) throws JavaModelException {
- return this.javaProject.findType(fullyQualifiedName);
- }
-
-
- // ********** member classes **********
-
- public interface SourceWriter {
- void appendSourceTo(StringBuilder sb);
- }
-
- public class SimpleSourceWriter implements SourceWriter {
- private final String source;
- public SimpleSourceWriter(String source) {
- super();
- this.source = source;
- }
- public void appendSourceTo(StringBuilder sb) {
- sb.append(source);
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJpaProject.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJpaProject.java
deleted file mode 100644
index d9622a4101..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJpaProject.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.projects;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.internal.SynchronousJpaProjectUpdater;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-/**
- * This builds and holds a "JPA" project.
- * Support for adding packages and types.
- *
- * The JPA project's settings (platform, database connection, etc.) can be
- * controlled by building a data model and passing it into the constructor.
- */
-public class TestJpaProject extends TestJavaProject {
- private final JpaProject jpaProject;
-
- public static final String JAR_NAME_SYSTEM_PROPERTY = "org.eclipse.jpt.jpa.jar";
-
-
- // ********** builders **********
-
- public static TestJpaProject buildJpaProject(String baseProjectName, boolean autoBuild, IDataModel jpaConfig)
- throws CoreException {
- return new TestJpaProject(uniqueProjectName(baseProjectName), autoBuild, jpaConfig);
- }
-
- public static TestJpaProject buildJpaProject(String baseProjectName, boolean autoBuild)
- throws CoreException {
- return buildJpaProject(baseProjectName, autoBuild, null);
- }
-
- // ********** constructors/initialization **********
-
- public TestJpaProject(String projectName) throws CoreException {
- this(projectName, false);
- }
-
- public TestJpaProject(String projectName, boolean autoBuild) throws CoreException {
- this(projectName, autoBuild, null);
- }
-
- public TestJpaProject(String projectName, boolean autoBuild, IDataModel jpaConfig) throws CoreException {
- super(projectName, autoBuild);
- this.installFacet("jst.utility", "1.0");
- this.installFacet("jpt.jpa", "1.0", jpaConfig);
- this.addJar(this.jarName());
- this.jpaProject = JptCorePlugin.getJpaProject(this.getProject());
- this.jpaProject.setUpdater(new SynchronousJpaProjectUpdater(this.jpaProject));
- }
-
- protected String jarName() {
- String jarName = System.getProperty(JAR_NAME_SYSTEM_PROPERTY);
- if (jarName == null) {
- throw new RuntimeException("missing Java system property: \"" + JAR_NAME_SYSTEM_PROPERTY + "\"");
- }
- return jarName;
- }
-
-
- // ********** public methods **********
-
- public JpaProject getJpaProject() {
- return this.jpaProject;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestPlatformProject.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestPlatformProject.java
deleted file mode 100644
index c19eae05a5..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestPlatformProject.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.projects;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-/**
- * This builds and holds a "general" Eclipse project.
- * Support for adding natures, folders, and files.
- */
-public class TestPlatformProject {
- private final IProject project;
-
- /** carriage return */
- public static final String CR = System.getProperty("line.separator");
-
-
- // ********** builders **********
-
- public static TestPlatformProject buildPlatformProject(String baseProjectName, boolean autoBuild)
- throws CoreException {
- return new TestPlatformProject(uniqueProjectName(baseProjectName), autoBuild);
- }
-
- public static String uniqueProjectName(String baseProjectName) {
- return baseProjectName + String.valueOf(System.currentTimeMillis()).substring(7);
- }
-
-
- // ********** constructors/initialization **********
-
- public TestPlatformProject(String projectName, boolean autoBuild) throws CoreException {
- super();
- this.setAutoBuild(autoBuild); // workspace-wide setting
- this.project = this.buildPlatformProject(projectName);
- }
-
- private void setAutoBuild(boolean autoBuild) throws CoreException {
- IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription();
- description.setAutoBuilding(autoBuild);
- ResourcesPlugin.getWorkspace().setDescription(description);
- }
-
- private IProject buildPlatformProject(String projectName) throws CoreException {
- IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- p.create(null);
- p.open(null);
- return p;
- }
-
-
- // ********** public methods **********
-
- public IProject getProject() {
- return this.project;
- }
-
- public void addProjectNature(String natureID) throws CoreException {
- IProjectDescription description = this.project.getDescription();
- description.setNatureIds(CollectionTools.add(description.getNatureIds(), natureID));
- this.project.setDescription(description, null);
- }
-
- public void removeProjectNature(String natureID) throws CoreException {
- IProjectDescription description = this.project.getDescription();
- description.setNatureIds(CollectionTools.removeAllOccurrences(description.getNatureIds(), natureID));
- this.project.setDescription(description, null);
- }
-
- /**
- * Create a folder with the specified name directly under the project.
- */
- public IFolder createFolder(String folderName) throws CoreException {
- return this.createFolder(this.project, new Path(folderName));
- }
-
- /**
- * Create a folder in the specified container with the specified name.
- */
- public IFolder createFolder(IContainer container, String folderName) throws CoreException {
- return this.createFolder(container, new Path(folderName));
- }
-
- /**
- * Create a folder in the specified container with the specified path.
- */
- public IFolder createFolder(IContainer container, IPath folderPath) throws CoreException {
- IFolder folder = container.getFolder(folderPath);
- if ( ! folder.exists()) {
- folder.create(false, true, null); // false = "no force"; true = "local"
- }
- return folder;
- }
-
- /**
- * Create a file with the specified name and content directly under the project.
- */
- public IFile createFile(String fileName, String content) throws CoreException {
- return this.createFile(this.project, fileName, content);
- }
-
- /**
- * Create a file in the specified container with the specified name and content.
- */
- public IFile createFile(IContainer container, String fileName, String content) throws CoreException {
- return createFile(container, new Path(fileName), content);
- }
-
- /**
- * Create a file in the project with the specified [relative] path
- * and content.
- */
- public IFile createFile(IPath filePath, String content) throws CoreException {
- return this.createFile(this.project, filePath, content);
- }
-
- /**
- * Create a file in the specified container with the specified path and content.
- */
- public IFile createFile(IContainer container, IPath filePath, String content) throws CoreException {
- return this.createFile(container, filePath, new ByteArrayInputStream(content.getBytes()));
- }
-
- /**
- * Create a file in the specified container with the specified path and contents.
- */
- public IFile createFile(IContainer container, IPath filePath, InputStream content) throws CoreException {
- int pathCount = filePath.segmentCount() - 1;
- for (int i = 0; i < pathCount; i++) {
- container = container.getFolder(new Path(filePath.segment(i)));
- if ( ! container.exists()) {
- ((IFolder) container).create(true, true, null); // true = "force"; true = "local"
- }
- }
-
- IFile file = container.getFile(new Path(filePath.lastSegment()));
- if (file.exists()) {
- file.delete(true, null); // true = "force"
- }
- file.create(content, true, null); // true = "force"
- return file;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/JptCoreResourceModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/JptCoreResourceModelTests.java
deleted file mode 100644
index ccc705abd2..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/JptCoreResourceModelTests.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.core.tests.internal.resource.java.JptJavaResourceTests;
-
-public class JptCoreResourceModelTests extends TestCase
-{
- public static Test suite() {
- return suite(true);
- }
-
- public static Test suite(boolean all) {
- TestSuite suite = new TestSuite(JptCoreResourceModelTests.class.getName());
- suite.addTest(JptJavaResourceTests.suite(all));
- if (all) {
- suite.addTestSuite(OrmModelTests.class);
- suite.addTestSuite(PersistenceModelTests.class);
- }
- return suite;
- }
-
- private JptCoreResourceModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/OrmModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/OrmModelTests.java
deleted file mode 100644
index 9268643cf9..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/OrmModelTests.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.eclipse.jpt.core.tests.internal.resource;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.core.resource.orm.OrmArtifactEdit;
-import org.eclipse.jpt.core.resource.orm.OrmResource;
-import org.eclipse.jpt.core.tests.internal.ProjectUtility;
-import org.eclipse.jpt.core.tests.internal.projects.TestJpaProject;
-
-public class OrmModelTests extends TestCase
-{
- static final String BASE_PROJECT_NAME = OrmModelTests.class.getSimpleName();
-
- TestJpaProject jpaProject;
-
-
- public OrmModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- ProjectUtility.deleteAllProjects();
- jpaProject = TestJpaProject.buildJpaProject(BASE_PROJECT_NAME, false); // false = no auto-build
- }
-
- @Override
- protected void tearDown() throws Exception {
- jpaProject = null;
- super.tearDown();
- }
-
- public void testModelLoad() {
- OrmArtifactEdit artifactEdit = OrmArtifactEdit.getArtifactEditForRead(jpaProject.getProject());
- assertNotNull(artifactEdit);
- OrmResource resource = artifactEdit.getResource("META-INF/orm.xml");
- assertNotNull(resource);
- }
-
- public void testModelLoad2() {
- OrmArtifactEdit artifactEdit = OrmArtifactEdit.getArtifactEditForRead(jpaProject.getProject());
- assertNotNull(artifactEdit);
- OrmResource resource = artifactEdit.getResource("META-INF/orm.xml");
- assertNotNull(resource);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/PersistenceModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/PersistenceModelTests.java
deleted file mode 100644
index 72896e825e..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/PersistenceModelTests.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.eclipse.jpt.core.tests.internal.resource;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.core.resource.persistence.PersistenceArtifactEdit;
-import org.eclipse.jpt.core.resource.persistence.PersistenceResource;
-import org.eclipse.jpt.core.tests.internal.ProjectUtility;
-import org.eclipse.jpt.core.tests.internal.projects.TestJpaProject;
-
-public class PersistenceModelTests extends TestCase
-{
- static final String BASE_PROJECT_NAME = PersistenceModelTests.class.getSimpleName();
-
- TestJpaProject jpaProject;
-
-
- public PersistenceModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- ProjectUtility.deleteAllProjects();
- jpaProject = TestJpaProject.buildJpaProject(BASE_PROJECT_NAME, false); // false = no auto-build
- }
-
- @Override
- protected void tearDown() throws Exception {
- jpaProject = null;
- super.tearDown();
- }
-
- public void testModelLoad() {
- PersistenceArtifactEdit artifactEdit = PersistenceArtifactEdit.getArtifactEditForRead(jpaProject.getProject());
- assertNotNull(artifactEdit);
- PersistenceResource resource = artifactEdit.getResource("META-INF/persistence.xml");
- assertNotNull(resource);
- }
-
- public void testModelLoad2() {
- PersistenceArtifactEdit artifactEdit = PersistenceArtifactEdit.getArtifactEditForRead(jpaProject.getProject());
- assertNotNull(artifactEdit);
- PersistenceResource resource = artifactEdit.getResource("META-INF/persistence.xml");
- assertNotNull(resource);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverrideTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverrideTests.java
deleted file mode 100644
index 5077b6b715..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverrideTests.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class AssociationOverrideTests extends JavaResourceModelTestCase {
-
- private static final String ASSOCIATION_OVERRIDE_NAME = "MY_ASSOCIATION_OVERRIDE";
-
- public AssociationOverrideTests(String name) {
- super(name);
- }
-
- private void createAssociationOverrideAnnotation() throws Exception {
- createJoinColumnAnnotation();
- this.createAnnotationAndMembers("AssociationOverride",
- "String name(); " +
- "JoinColumn[] joinColumns(); ");
- }
-
- private void createJoinColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name() default \"\";" +
- "String referencedColumnName() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";");
- }
-
- private IType createTestAssociationOverrideOnField() throws Exception {
- createAssociationOverrideAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ASSOCIATION_OVERRIDE, JPA.COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\")");
- }
- });
- }
-
- private IType createTestAssociationOverrideWithJoinColumns() throws Exception {
- createAssociationOverrideAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ASSOCIATION_OVERRIDE, JPA.JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"BAR\"), @JoinColumn})");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestAssociationOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- assertNotNull(associationOverride);
- assertEquals(ASSOCIATION_OVERRIDE_NAME, associationOverride.getName());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestAssociationOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- assertNotNull(associationOverride);
- assertEquals(ASSOCIATION_OVERRIDE_NAME, associationOverride.getName());
-
- associationOverride.setName("Foo");
- assertEquals("Foo", associationOverride.getName());
- assertSourceContains("@AssociationOverride(name=\"Foo\")");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestAssociationOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- assertEquals(ASSOCIATION_OVERRIDE_NAME, associationOverride.getName());
-
- associationOverride.setName(null);
- assertNull(associationOverride.getName());
-
- assertSourceDoesNotContain("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\")");
- assertSourceContains("@AssociationOverride");
- }
-
-
- public void testJoinColumns() throws Exception {
- IType testType = this.createTestAssociationOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- assertEquals(0, associationOverride.joinColumnsSize());
- }
-
- public void testJoinColumns2() throws Exception {
- IType testType = this.createTestAssociationOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
-
- associationOverride.addJoinColumn(0);
- associationOverride.addJoinColumn(1);
-
- assertEquals(2, associationOverride.joinColumnsSize());
- }
-
- public void testJoinColumns3() throws Exception {
- IType testType = this.createTestAssociationOverrideWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- assertEquals(2, associationOverride.joinColumnsSize());
- }
-
- public void testAddJoinColumn() throws Exception {
- IType testType = this.createTestAssociationOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- associationOverride.addJoinColumn(0).setName("FOO");
- associationOverride.addJoinColumn(1);
- associationOverride.addJoinColumn(0).setName("BAR");
-
- assertEquals("BAR", associationOverride.joinColumnAt(0).getName());
- assertEquals("FOO", associationOverride.joinColumnAt(1).getName());
- assertNull(associationOverride.joinColumnAt(2).getName());
-
- assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns = {@JoinColumn(name=\"BAR\"),@JoinColumn(name=\"FOO\"), @JoinColumn})");
- }
-
- public void testRemoveJoinColumn() throws Exception {
- IType testType = this.createTestAssociationOverrideWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
- associationOverride.addJoinColumn(0).setName("FOO");
-
- Iterator<JoinColumnAnnotation> joinColumns = associationOverride.joinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertNull(joinColumns.next().getName());
- assertEquals(false, joinColumns.hasNext());
- assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\"), @JoinColumn})");
-
- associationOverride.removeJoinColumn(1);
- joinColumns = associationOverride.joinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertNull(joinColumns.next().getName());
- assertEquals(false, joinColumns.hasNext());
- assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn})");
-
- associationOverride.removeJoinColumn(0);
- joinColumns = associationOverride.joinColumns();
- assertNull(joinColumns.next().getName());
- assertEquals(false, joinColumns.hasNext());
- assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns=@JoinColumn)");
-
-
- associationOverride.setName(null);
- associationOverride.removeJoinColumn(0);
- assertSourceDoesNotContain("@AssociationOverride");
- }
-
- public void testMoveJoinColumn() throws Exception {
- IType testType = this.createTestAssociationOverrideWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
- JoinColumnAnnotation joinColumn = associationOverride.joinColumnAt(0);
- joinColumn.setReferencedColumnName("REF_NAME");
- joinColumn.setUnique(Boolean.FALSE);
- joinColumn.setNullable(Boolean.FALSE);
- joinColumn.setInsertable(Boolean.FALSE);
- joinColumn.setUpdatable(Boolean.FALSE);
- joinColumn.setColumnDefinition("COLUMN_DEF");
- joinColumn.setTable("TABLE");
- associationOverride.addJoinColumn(0).setName("FOO");
-
- assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn})");
-
- associationOverride.moveJoinColumn(2, 0);
- assertEquals("BAR", associationOverride.joinColumnAt(0).getName());
- assertNull(associationOverride.joinColumnAt(1).getName());
- assertEquals("FOO", associationOverride.joinColumnAt(2).getName());
- assertEquals(3, associationOverride.joinColumnsSize());
- assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn, @JoinColumn(name=\"FOO\")})");
- }
-
- public void testMoveJoinColumn2() throws Exception {
- IType testType = this.createTestAssociationOverrideWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- JoinColumnAnnotation joinColumn = associationOverride.joinColumnAt(0);
- joinColumn.setReferencedColumnName("REF_NAME");
- joinColumn.setUnique(Boolean.FALSE);
- joinColumn.setNullable(Boolean.FALSE);
- joinColumn.setInsertable(Boolean.FALSE);
- joinColumn.setUpdatable(Boolean.FALSE);
- joinColumn.setColumnDefinition("COLUMN_DEF");
- joinColumn.setTable("TABLE");
- associationOverride.addJoinColumn(0).setName("FOO");
-
- assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn})");
-
- associationOverride.moveJoinColumn(0, 2);
- assertNull(associationOverride.joinColumnAt(0).getName());
- assertEquals("FOO", associationOverride.joinColumnAt(1).getName());
- assertEquals("BAR", associationOverride.joinColumnAt(2).getName());
- assertEquals(3, associationOverride.joinColumnsSize());
- assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn, @JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\")})");
- }
-
- public void testSetJoinColumnName() throws Exception {
- IType testType = this.createTestAssociationOverrideWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE);
-
- assertEquals(2, associationOverride.joinColumnsSize());
-
- JoinColumnAnnotation joinColumn = associationOverride.joinColumns().next();
-
- assertEquals("BAR", joinColumn.getName());
-
- joinColumn.setName("foo");
- assertEquals("foo", joinColumn.getName());
-
- assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"foo\"), @JoinColumn})");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverridesTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverridesTests.java
deleted file mode 100644
index 2f10c668d0..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverridesTests.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.AssociationOverridesAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class AssociationOverridesTests extends JavaResourceModelTestCase {
-
- private static final String ASSOCIATION_OVERRIDE_NAME = "MY_ASSOCIATION_OVERRIDE";
-
- public AssociationOverridesTests(String name) {
- super(name);
- }
-
- private void createAssociationOverrideAnnotation() throws Exception {
- createJoinColumnAnnotation();
- this.createAnnotationAndMembers("AssociationOverride",
- "String name(); " +
- "Column column(); ");
- }
-
- private void createAssociationOverridesAnnotation() throws Exception {
- createAssociationOverrideAnnotation();
- this.createAnnotationAndMembers("AssociationOverrides",
- "AssociationOverride[] value();");
- }
-
- private void createJoinColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name() default \"\";" +
- "String referencedColumnName() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";");
-
- }
-
- private IType createTestAssociationOverrideOnField() throws Exception {
- createAssociationOverridesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\"))");
- }
- });
- }
- private IType createTestAssociationOverrideWithJoinColumns() throws Exception {
- createAssociationOverridesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES, JPA.JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"BAR\"), @JoinColumn}))");
- }
- });
- }
-
- private IType createTestAssociationOverride() throws Exception {
- createAssociationOverridesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ASSOCIATION_OVERRIDE, JPA.JOIN_COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append(CR);
- sb.append("@AssociationOverride(name=\"FOO\", joinColumns=@JoinColumn(name=\"FOO\", columnDefinition=\"BAR\", referencedColumnName=\"BAZ\"))");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestAssociationOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AssociationOverridesAnnotation associationOverrides = (AssociationOverridesAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDES);
- AssociationOverrideAnnotation associationOverride = associationOverrides.nestedAnnotations().next();
-
- assertNotNull(associationOverride);
- assertEquals(ASSOCIATION_OVERRIDE_NAME, associationOverride.getName());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestAssociationOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AssociationOverridesAnnotation associationOverrides = (AssociationOverridesAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDES);
- AssociationOverrideAnnotation associationOverride = associationOverrides.nestedAnnotations().next();
-
- assertNotNull(associationOverride);
- assertEquals(ASSOCIATION_OVERRIDE_NAME, associationOverride.getName());
-
- associationOverride.setName("Foo");
- assertEquals("Foo", associationOverride.getName());
- assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"Foo\"))");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestAssociationOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AssociationOverridesAnnotation associationOverrides = (AssociationOverridesAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDES);
- AssociationOverrideAnnotation associationOverride = associationOverrides.nestedAnnotations().next();
- assertEquals(ASSOCIATION_OVERRIDE_NAME, associationOverride.getName());
-
- associationOverride.setName(null);
- assertNull(associationOverride.getName());
-
- assertSourceDoesNotContain("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\")");
- assertSourceContains("@AssociationOverride");
- assertSourceContains("@AssociationOverrides");
- }
-
- public void testAddAssociationOverrideCopyExisting() throws Exception {
- IType jdtType = createTestAssociationOverride();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("BAR");
- assertSourceContains("@AssociationOverrides({@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\")),@AssociationOverride(name=\"BAR\")})");
-
- assertNull(typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE));
- assertNotNull(typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDES));
- assertEquals(2, CollectionTools.size(typeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES)));
- }
-
- public void testAddAssociationOverrideToBeginningOfList() throws Exception {
- IType jdtType = createTestAssociationOverride();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("BAR");
- assertSourceContains("@AssociationOverrides({@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\")),@AssociationOverride(name=\"BAR\")})");
-
- associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("BAZ");
- assertSourceContains("@AssociationOverrides({@AssociationOverride(name=\"BAZ\"),@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\")), @AssociationOverride(name=\"BAR\")})");
-
- Iterator<JavaResourceNode> associationOverrides = typeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- assertEquals("BAZ", ((AssociationOverrideAnnotation) associationOverrides.next()).getName());
- assertEquals("FOO", ((AssociationOverrideAnnotation) associationOverrides.next()).getName());
- assertEquals("BAR", ((AssociationOverrideAnnotation) associationOverrides.next()).getName());
-
- assertNull(typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE));
- assertNotNull(typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDES));
- assertEquals(3, CollectionTools.size(typeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES)));
- }
-
- public void testRemoveAssociationOverrideCopyExisting() throws Exception {
- IType jdtType = createTestAssociationOverride();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("BAR");
- assertSourceContains("@AssociationOverrides({@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\")),@AssociationOverride(name=\"BAR\")})");
-
- typeResource.removeAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- assertSourceContains("@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\"))");
- }
-
- public void testJoinColumns() throws Exception {
- IType testType = this.createTestAssociationOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next();
-
- assertEquals(0, associationOverride.joinColumnsSize());
- }
-
- public void testJoinColumns2() throws Exception {
- IType testType = this.createTestAssociationOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next();
-
- associationOverride.addJoinColumn(0);
- associationOverride.addJoinColumn(1);
-
- assertEquals(2, associationOverride.joinColumnsSize());
- }
-
- public void testJoinColumns3() throws Exception {
- IType testType = this.createTestAssociationOverrideWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next();
-
- assertEquals(2, associationOverride.joinColumnsSize());
- }
-
- public void testAddJoinColumn() throws Exception {
- IType testType = this.createTestAssociationOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next();
-
- associationOverride.addJoinColumn(0).setName("FOO");
- associationOverride.addJoinColumn(1);
- associationOverride.addJoinColumn(0).setName("BAR");
-
-
- Iterator<JoinColumnAnnotation> joinColumns = associationOverride.joinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertNull(joinColumns.next().getName());
-
- assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns = {@JoinColumn(name=\"BAR\"),@JoinColumn(name=\"FOO\"), @JoinColumn}))");
- }
-
- public void testRemoveJoinColumn() throws Exception {
- IType testType = this.createTestAssociationOverrideWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next();
- associationOverride.addJoinColumn(0).setName("FOO");
-
- Iterator<JoinColumnAnnotation> joinColumns = associationOverride.joinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertNull(joinColumns.next().getName());
- assertEquals(false, joinColumns.hasNext());
- assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\"), @JoinColumn}))");
-
- associationOverride.removeJoinColumn(1);
- joinColumns = associationOverride.joinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertNull(joinColumns.next().getName());
- assertEquals(false, joinColumns.hasNext());
- assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn}))");
-
- associationOverride.removeJoinColumn(0);
- joinColumns = associationOverride.joinColumns();
- assertNull(joinColumns.next().getName());
- assertEquals(false, joinColumns.hasNext());
- assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns=@JoinColumn))");
-
-
- associationOverride.setName(null);
- associationOverride.removeJoinColumn(0);
- assertSourceDoesNotContain("@AssociationOverride");
- }
-
- public void testMoveJoinColumn() throws Exception {
- IType testType = this.createTestAssociationOverrideWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next();
- JoinColumnAnnotation joinColumn = associationOverride.joinColumnAt(0);
- joinColumn.setReferencedColumnName("REF_NAME");
- joinColumn.setUnique(Boolean.FALSE);
- joinColumn.setNullable(Boolean.FALSE);
- joinColumn.setInsertable(Boolean.FALSE);
- joinColumn.setUpdatable(Boolean.FALSE);
- joinColumn.setColumnDefinition("COLUMN_DEF");
- joinColumn.setTable("TABLE");
- associationOverride.addJoinColumn(0).setName("FOO");
- assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn}))");
-
- associationOverride.moveJoinColumn(2, 0);
- assertEquals("BAR", associationOverride.joinColumnAt(0).getName());
- assertNull(associationOverride.joinColumnAt(1).getName());
- assertEquals("FOO", associationOverride.joinColumnAt(2).getName());
- assertEquals(3, associationOverride.joinColumnsSize());
- assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn, @JoinColumn(name=\"FOO\")}))");
- }
-
- public void testMoveJoinColumn2() throws Exception {
- IType testType = this.createTestAssociationOverrideWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next();
-
- JoinColumnAnnotation joinColumn = associationOverride.joinColumnAt(0);
- joinColumn.setReferencedColumnName("REF_NAME");
- joinColumn.setUnique(Boolean.FALSE);
- joinColumn.setNullable(Boolean.FALSE);
- joinColumn.setInsertable(Boolean.FALSE);
- joinColumn.setUpdatable(Boolean.FALSE);
- joinColumn.setColumnDefinition("COLUMN_DEF");
- joinColumn.setTable("TABLE");
- associationOverride.addJoinColumn(0).setName("FOO");
-
- assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn}))");
- associationOverride.moveJoinColumn(0, 2);
- assertNull(associationOverride.joinColumnAt(0).getName());
- assertEquals("FOO", associationOverride.joinColumnAt(1).getName());
- assertEquals("BAR", associationOverride.joinColumnAt(2).getName());
- assertEquals(3, associationOverride.joinColumnsSize());
- assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn, @JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\")}))");
- }
-
- public void testSetJoinColumnName() throws Exception {
- IType testType = this.createTestAssociationOverrideWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next();
-
- assertEquals(2, associationOverride.joinColumnsSize());
-
- JoinColumnAnnotation joinColumn = associationOverride.joinColumns().next();
-
- assertEquals("BAR", joinColumn.getName());
-
- joinColumn.setName("foo");
- assertEquals("foo", joinColumn.getName());
-
- assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"foo\"), @JoinColumn}))");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverrideTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverrideTests.java
deleted file mode 100644
index a85f4f021d..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverrideTests.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class AttributeOverrideTests extends JavaResourceModelTestCase {
-
- private static final String COLUMN_NAME = "MY_COLUMN";
- private static final String ATTRIBUTE_OVERRIDE_NAME = "MY_ATTRIBUTE_OVERRIDE";
-
- public AttributeOverrideTests(String name) {
- super(name);
- }
-
- private void createAttributeOverrideAnnotation() throws Exception {
- this.createAnnotationAndMembers("AttributeOverride",
- "String name(); " +
- "Column column(); ");
- }
-
- private void createColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("Column",
- "String name() default \"\"; " +
- "boolean unique() default false; " +
- "boolean nullable() default true; " +
- "boolean insertable() default true; " +
- "boolean updatable() default true; " +
- "String columnDefinition() default \"\"; " +
- "String table() default \"\"; " +
- "int length() default 255; " +
- "int precision() default 0; " +
- "int scale() default 0;");
- }
-
- private IType createTestAttributeOverrideOnField() throws Exception {
- createAttributeOverrideAnnotation();
- createColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ATTRIBUTE_OVERRIDE, JPA.COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")");
- }
- });
- }
-
- private IType createTestAttributeOverrideWithColumnOnField() throws Exception {
- createAttributeOverrideAnnotation();
- createColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ATTRIBUTE_OVERRIDE, JPA.COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\", column = @Column(name=\"" + COLUMN_NAME + "\"))");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestAttributeOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
-
- assertNotNull(attributeOverride);
- assertEquals(ATTRIBUTE_OVERRIDE_NAME, attributeOverride.getName());
- }
-
- public void testGetNullColumn() throws Exception {
- IType testType = this.createTestAttributeOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
- ColumnAnnotation column = attributeOverride.getColumn();
- assertNotNull(attributeOverride);
- assertNull(column);
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestAttributeOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
-
- assertNotNull(attributeOverride);
- assertEquals(ATTRIBUTE_OVERRIDE_NAME, attributeOverride.getName());
-
- attributeOverride.setName("Foo");
- assertEquals("Foo", attributeOverride.getName());
- assertSourceContains("@AttributeOverride(name=\"Foo\")");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestAttributeOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
-
- assertEquals(ATTRIBUTE_OVERRIDE_NAME, attributeOverride.getName());
-
- attributeOverride.setName(null);
- assertNull(attributeOverride.getName());
-
- assertSourceDoesNotContain("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")");
- assertSourceContains("@AttributeOverride");
- }
-
- public void testColumnGetName() throws Exception {
- IType testType = this.createTestAttributeOverrideWithColumnOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
- ColumnAnnotation column = attributeOverride.getColumn();
- assertEquals(COLUMN_NAME, column.getName());
- }
-
- public void testColumnSetName() throws Exception {
- IType testType = this.createTestAttributeOverrideWithColumnOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
- ColumnAnnotation column = attributeOverride.getColumn();
- assertEquals(COLUMN_NAME, column.getName());
-
- column.setName("Foo");
-
- assertSourceContains("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\", column = @Column(name=\"Foo\"))");
-
- column.setName(null);
- assertNull(attributeOverride.getColumn());
- assertSourceContains("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")");
- }
-
- public void testAddColumn() throws Exception {
- IType testType = this.createTestAttributeOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
- ColumnAnnotation column = attributeOverride.getColumn();
- assertNull(column);
- }
-
- public void testRemoveColumn() throws Exception {
- IType testType = this.createTestAttributeOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE);
- ColumnAnnotation column = attributeOverride.getColumn();
- assertNull(column);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverridesTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverridesTests.java
deleted file mode 100644
index ff1da40ebc..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverridesTests.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.AttributeOverridesAnnotation;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class AttributeOverridesTests extends JavaResourceModelTestCase {
-
- private static final String COLUMN_NAME = "MY_COLUMN";
- private static final String ATTRIBUTE_OVERRIDE_NAME = "MY_ATTRIBUTE_OVERRIDE";
-
- public AttributeOverridesTests(String name) {
- super(name);
- }
-
- private void createAttributeOverrideAnnotation() throws Exception {
- createColumnAnnotation();
- this.createAnnotationAndMembers("AttributeOverride",
- "String name(); " +
- "Column column(); ");
- }
-
- private void createAttributeOverridesAnnotation() throws Exception {
- createAttributeOverrideAnnotation();
- this.createAnnotationAndMembers("AttributeOverrides",
- "AttributeOverride[] value();");
- }
-
- private void createColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("Column",
- "String name() default \"\"; " +
- "boolean unique() default false; " +
- "boolean nullable() default true; " +
- "boolean insertable() default true; " +
- "boolean updatable() default true; " +
- "String columnDefinition() default \"\"; " +
- "String table() default \"\"; " +
- "int length() default 255; " +
- "int precision() default 0; " +
- "int scale() default 0;");
- }
-
- private IType createTestAttributeOverrideOnField() throws Exception {
- createAttributeOverridesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES, JPA.COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@AttributeOverrides(@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\"))");
- }
- });
- }
-
- private IType createTestAttributeOverrideWithColumnOnField() throws Exception {
- createAttributeOverridesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES, JPA.COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@AttributeOverrides(@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\", column = @Column(name=\"" + COLUMN_NAME + "\")))");
- }
- });
- }
-
- private IType createTestAttributeOverride() throws Exception {
- createAttributeOverridesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ATTRIBUTE_OVERRIDE, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append(CR);
- sb.append("@AttributeOverride(name=\"FOO\", column=@Column(name=\"FOO\", columnDefinition=\"BAR\", table=\"BAZ\", unique=false, nullable=false, insertable=false, updatable=false, length=1, precision=1, scale=1))");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestAttributeOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverridesAnnotation attributeOverrides = (AttributeOverridesAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES);
- AttributeOverrideAnnotation attributeOverride = attributeOverrides.nestedAnnotations().next();
-
- assertNotNull(attributeOverride);
- assertEquals(ATTRIBUTE_OVERRIDE_NAME, attributeOverride.getName());
- }
-
- public void testGetNullColumn() throws Exception {
- IType testType = this.createTestAttributeOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverridesAnnotation attributeOverrides = (AttributeOverridesAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES);
- AttributeOverrideAnnotation attributeOverride = attributeOverrides.nestedAnnotations().next();
- ColumnAnnotation column = attributeOverride.getColumn();
- assertNotNull(attributeOverride);
- assertNull(column);
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestAttributeOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverridesAnnotation attributeOverrides = (AttributeOverridesAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES);
- AttributeOverrideAnnotation attributeOverride = attributeOverrides.nestedAnnotations().next();
-
- assertNotNull(attributeOverride);
- assertEquals(ATTRIBUTE_OVERRIDE_NAME, attributeOverride.getName());
-
- attributeOverride.setName("Foo");
- assertEquals("Foo", attributeOverride.getName());
- assertSourceContains("@AttributeOverrides(@AttributeOverride(name=\"Foo\"))");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestAttributeOverrideOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverridesAnnotation attributeOverrides = (AttributeOverridesAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES);
- AttributeOverrideAnnotation attributeOverride = attributeOverrides.nestedAnnotations().next();
- assertEquals(ATTRIBUTE_OVERRIDE_NAME, attributeOverride.getName());
-
- attributeOverride.setName(null);
- assertNull(attributeOverride.getName());
-
- assertSourceDoesNotContain("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")");
- assertSourceContains("@AttributeOverride");
- assertSourceContains("@AttributeOverrides");
- }
-
- public void testColumnGetName() throws Exception {
- IType testType = this.createTestAttributeOverrideWithColumnOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverridesAnnotation attributeOverrides = (AttributeOverridesAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES);
- AttributeOverrideAnnotation attributeOverride = attributeOverrides.nestedAnnotations().next();
-
- ColumnAnnotation column = attributeOverride.getColumn();
- assertEquals(COLUMN_NAME, column.getName());
- }
-
- public void testColumnSetName() throws Exception {
- IType testType = this.createTestAttributeOverrideWithColumnOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES).next();
-
- ColumnAnnotation column = attributeOverride.getColumn();
-
- assertEquals(COLUMN_NAME, column.getName());
-
- column.setName("Foo");
-
- assertSourceContains("@AttributeOverrides(@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\", column = @Column(name=\"Foo\")))");
-
- column.setName(null);
- assertNull(attributeOverride.getColumn());
- assertSourceContains("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")");
- }
-
- public void testAddAttributeOverrideCopyExisting() throws Exception {
- IType jdtType = createTestAttributeOverride();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1)),@AttributeOverride(name=\"BAR\")})");
-
- assertNull(typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE));
- assertNotNull(typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES));
- assertEquals(2, CollectionTools.size(typeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES)));
- }
-
- public void testAddAttributeOverrideToBeginningOfList() throws Exception {
- IType jdtType = createTestAttributeOverride();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1)),@AttributeOverride(name=\"BAR\")})");
-
- attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAZ");
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAZ\"),@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1)), @AttributeOverride(name=\"BAR\")})");
-
- Iterator<JavaResourceNode> attributeOverrides = typeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertEquals("BAZ", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("FOO", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("BAR", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
-
- assertNull(typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE));
- assertNotNull(typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES));
- assertEquals(3, CollectionTools.size(typeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES)));
- }
-
- public void testRemoveAttributeOverrideCopyExisting() throws Exception {
- IType jdtType = createTestAttributeOverride();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1)),@AttributeOverride(name=\"BAR\")})");
-
- typeResource.removeAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertSourceContains("@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1))");
- }
- //not sure i want to test this api, how can we keep ContainerAnnotation.add, move, remove from being public?
- //users should go throught AbstractJavapersistenceResource. this gets confusing because you would handle it differently
- //for non top-level annotations
-// public void testAdd() throws Exception {
-// IType testType = this.createTestType();
-// JavaPersistentTypeResource typeResource = buildJavaTypeResource(testType);
-// JavaPersistentAttributeResource attributeResource = typeResource.fields().next();
-// AttributeOverrides attributeOverrides = (AttributeOverrides) attributeResource.annotation(JPA.ATTRIBUTE_OVERRIDES);
-// assertNull(attributeOverrides);
-//
-// attributeResource.addAnnotation(JPA.ATTRIBUTE_OVERRIDES);
-// attributeOverrides = (AttributeOverrides) attributeResource.annotation(JPA.ATTRIBUTE_OVERRIDES);
-// assertNotNull(attributeOverrides);
-//
-// assertSourceContains("@AttributeOverrides");
-//
-// AttributeOverride fooAttributeOverride = attributeOverrides.add(0);
-// fooAttributeOverride.setName("Foo");
-//
-// assertSourceContains("@AttributeOverrides(@AttributeOverride(name=\"Foo\"))");
-//
-// AttributeOverride barAttributeOverride = attributeOverrides.add(0);
-// barAttributeOverride.setName("Bar");
-//
-// assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"Bar\"), @AttributeOverride(name=\"Foo\")})");
-//
-// }
-//
-// public void testMove() throws Exception {
-// IType testType = this.createTestAttributeOverrideWithColumnOnField();
-// JavaPersistentTypeResource typeResource = buildJavaTypeResource(testType);
-// JavaPersistentAttributeResource attributeResource = typeResource.fields().next();
-// AttributeOverrides attributeOverrides = (AttributeOverrides) attributeResource.annotation(JPA.ATTRIBUTE_OVERRIDES);
-//
-// AttributeOverride fooAttributeOverride = attributeOverrides.add(1);
-// fooAttributeOverride.setName("Foo");
-//
-// assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\"), @AttributeOverride(name=\"Foo\")})");
-//
-// attributeOverrides.move(0, 1);
-//
-// assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"Foo\"), @AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")})");
-// }
-//
-// public void testRemove() throws Exception {
-// IType testType = this.createTestAttributeOverrideWithColumnOnField();
-// JavaPersistentTypeResource typeResource = buildJavaTypeResource(testType);
-// JavaPersistentAttributeResource attributeResource = typeResource.fields().next();
-// AttributeOverrides attributeOverrides = (AttributeOverrides) attributeResource.annotation(JPA.ATTRIBUTE_OVERRIDES);
-//
-// AttributeOverride fooAttributeOverride = attributeOverrides.add(1);
-// fooAttributeOverride.setName("Foo");
-//
-// assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\"), @AttributeOverride(name=\"Foo\")})");
-//
-// attributeOverrides.remove(0);
-//
-// assertSourceContains("@AttributeOverrides(@AttributeOverride(name=\"Foo\"))");
-//
-// attributeOverrides.remove(0);
-//
-// assertSourceContains("@AttributeOverrides()");
-//
-// }
-
-
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/BasicTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/BasicTests.java
deleted file mode 100644
index 5fe9534b62..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/BasicTests.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.FetchType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class BasicTests extends JavaResourceModelTestCase {
-
- public BasicTests(String name) {
- super(name);
- }
-
- private IType createTestBasic() throws Exception {
- this.createAnnotationAndMembers("Basic", "boolean optional() default true;");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.BASIC);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic");
- }
- });
- }
-
- private IType createTestBasicWithOptional() throws Exception {
- this.createAnnotationAndMembers("Basic", "boolean optional() default true;");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.BASIC);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic(optional=true)");
- }
- });
- }
-
- private IType createTestBasicWithFetch() throws Exception {
- this.createAnnotationAndMembers("Basic", "boolean optional() default true; FetchType fetch() default FetchType.EAGER;");
- this.createEnumAndMembers("FetchType", "EAGER, LAZY");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.BASIC, JPA.FETCH_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic(fetch=FetchType.EAGER)");
- }
- });
- }
-
- public void testBasic() throws Exception {
- IType testType = this.createTestBasic();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
- assertNotNull(basic);
- }
-
- public void testGetOptional() throws Exception {
- IType testType = this.createTestBasicWithOptional();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
- assertTrue(basic.getOptional());
- }
-
- public void testSetOptional() throws Exception {
- IType testType = this.createTestBasicWithOptional();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
- assertTrue(basic.getOptional());
-
- basic.setOptional(false);
- assertFalse(basic.getOptional());
-
- assertSourceContains("@Basic(optional=false)");
- }
-
- public void testSetOptionalNull() throws Exception {
- IType testType = this.createTestBasicWithOptional();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
- assertTrue(basic.getOptional());
-
- basic.setOptional(null);
- assertNull(basic.getOptional());
-
- assertSourceContains("@Basic");
- assertSourceDoesNotContain("optional");
- }
-
- public void testGetFetch() throws Exception {
- IType testType = this.createTestBasicWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
- assertEquals(FetchType.EAGER, basic.getFetch());
- }
-
- public void testSetFetch() throws Exception {
- IType testType = this.createTestBasicWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
- assertEquals(FetchType.EAGER, basic.getFetch());
-
- basic.setFetch(FetchType.LAZY);
- assertEquals(FetchType.LAZY, basic.getFetch());
-
- assertSourceContains("@Basic(fetch=LAZY)");
- }
-
- public void testSetFetchNull() throws Exception {
- IType testType = this.createTestBasicWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC);
- assertEquals(FetchType.EAGER, basic.getFetch());
-
- basic.setFetch(null);
- assertNull(basic.getFetch());
-
- assertSourceContains("@Basic");
- assertSourceDoesNotContain("fetch");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ColumnTests.java
deleted file mode 100644
index e14b86a18d..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ColumnTests.java
+++ /dev/null
@@ -1,423 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class ColumnTests extends JavaResourceModelTestCase {
-
- private static final String COLUMN_NAME = "MY_COLUMN";
- private static final String COLUMN_TABLE = "MY_TABLE";
- private static final String COLUMN_COLUMN_DEFINITION = "COLUMN_DEFINITION";
-
- public ColumnTests(String name) {
- super(name);
- }
-
- private void createColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("Column",
- "String name() default \"\"; " +
- "boolean unique() default false; " +
- "boolean nullable() default true; " +
- "boolean insertable() default true; " +
- "boolean updatable() default true; " +
- "String columnDefinition() default \"\"; " +
- "String table() default \"\"; " +
- "int length() default 255; " +
- "int precision() default 0; " +
- "int scale() default 0;");
- }
-
- private IType createTestColumn() throws Exception {
- createColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Column");
- }
- });
- }
-
- private IType createTestColumnWithName() throws Exception {
- createColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Column(name=\"" + COLUMN_NAME + "\")");
- }
- });
- }
-
- private IType createTestColumnWithTable() throws Exception {
- createColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Column(table=\"" + COLUMN_TABLE + "\")");
- }
- });
- }
-
- private IType createTestColumnWithColumnDefinition() throws Exception {
- createColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Column(columnDefinition=\"" + COLUMN_COLUMN_DEFINITION + "\")");
- }
- });
- }
-
- private IType createTestColumnWithBooleanElement(final String booleanElement) throws Exception {
- createColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Column(" + booleanElement + "=true)");
- }
- });
- }
-
- private IType createTestColumnWithIntElement(final String intElement) throws Exception {
- createColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Column(" + intElement + "=5)");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestColumnWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
- assertNotNull(column);
- assertEquals(COLUMN_NAME, column.getName());
- }
-
- public void testGetNull() throws Exception {
- IType testType = this.createTestColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
- assertNotNull(column);
- assertNull(column.getName());
- assertNull(column.getNullable());
- assertNull(column.getInsertable());
- assertNull(column.getUnique());
- assertNull(column.getUpdatable());
- assertNull(column.getTable());
- assertNull(column.getColumnDefinition());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertNotNull(column);
- assertNull(column.getName());
-
- column.setName("Foo");
- assertEquals("Foo", column.getName());
-
- assertSourceContains("@Column(name=\"Foo\")");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestColumnWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(COLUMN_NAME, column.getName());
-
- column.setName(null);
- assertNull(column.getName());
-
- assertSourceDoesNotContain("@Column");
- }
-
- public void testGetTable() throws Exception {
- IType testType = this.createTestColumnWithTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
- assertEquals(COLUMN_TABLE, column.getTable());
- }
-
- public void testSetTable() throws Exception {
- IType testType = this.createTestColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertNotNull(column);
- assertNull(column.getTable());
-
- column.setTable("Foo");
- assertEquals("Foo", column.getTable());
-
- assertSourceContains("@Column(table=\"Foo\")");
-
-
- column.setTable(null);
- assertSourceDoesNotContain("@Column");
- }
-
- public void testGetColumnDefinition() throws Exception {
- IType testType = this.createTestColumnWithColumnDefinition();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
- assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition());
- }
-
- public void testSetColumnDefinition() throws Exception {
- IType testType = this.createTestColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertNotNull(column);
- assertNull(column.getColumnDefinition());
-
- column.setColumnDefinition("Foo");
- assertEquals("Foo", column.getColumnDefinition());
-
- assertSourceContains("@Column(columnDefinition=\"Foo\")");
-
-
- column.setColumnDefinition(null);
- assertSourceDoesNotContain("@Column");
- }
-
- public void testGetUnique() throws Exception {
- IType testType = this.createTestColumnWithBooleanElement("unique");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Boolean.TRUE, column.getUnique());
- }
-
- public void testSetUnique() throws Exception {
- IType testType = this.createTestColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertNotNull(column);
- assertNull(column.getUnique());
-
- column.setUnique(Boolean.FALSE);
- assertEquals(Boolean.FALSE, column.getUnique());
-
- assertSourceContains("@Column(unique=false)");
-
- column.setUnique(null);
- assertSourceDoesNotContain("@Column");
- }
-
- public void testGetNullable() throws Exception {
- IType testType = this.createTestColumnWithBooleanElement("nullable");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Boolean.TRUE, column.getNullable());
- }
-
- public void testSetNullable() throws Exception {
- IType testType = this.createTestColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertNotNull(column);
- assertNull(column.getNullable());
-
- column.setNullable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, column.getNullable());
-
- assertSourceContains("@Column(nullable=false)");
-
- column.setNullable(null);
- assertSourceDoesNotContain("@Column");
- }
-
- public void testGetInsertable() throws Exception {
- IType testType = this.createTestColumnWithBooleanElement("insertable");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Boolean.TRUE, column.getInsertable());
- }
-
- public void testSetInsertable() throws Exception {
- IType testType = this.createTestColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertNotNull(column);
- assertNull(column.getInsertable());
-
- column.setInsertable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, column.getInsertable());
-
- assertSourceContains("@Column(insertable=false)");
-
- column.setInsertable(null);
- assertSourceDoesNotContain("@Column");
- }
-
- public void testGetUpdatable() throws Exception {
- IType testType = this.createTestColumnWithBooleanElement("updatable");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Boolean.TRUE, column.getUpdatable());
- }
-
- public void testSetUpdatable() throws Exception {
- IType testType = this.createTestColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertNotNull(column);
- assertNull(column.getUpdatable());
-
- column.setUpdatable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, column.getUpdatable());
-
- assertSourceContains("@Column(updatable=false)");
-
- column.setUpdatable(null);
- assertSourceDoesNotContain("@Column");
- }
-
- public void testGetLength() throws Exception {
- IType testType = this.createTestColumnWithIntElement("length");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Integer.valueOf(5), column.getLength());
- }
-
- public void testSetLength() throws Exception {
- IType testType = this.createTestColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertNotNull(column);
- assertNull(column.getLength());
-
- column.setLength(Integer.valueOf(5));
- assertEquals(Integer.valueOf(5), column.getLength());
-
- assertSourceContains("@Column(length=5)");
-
- column.setLength(null);
- assertSourceDoesNotContain("@Column");
- }
-
- public void testGetPrecision() throws Exception {
- IType testType = this.createTestColumnWithIntElement("precision");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Integer.valueOf(5), column.getPrecision());
- }
-
- public void testSetPrecision() throws Exception {
- IType testType = this.createTestColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertNotNull(column);
- assertEquals(null, column.getPrecision());
-
- column.setPrecision(Integer.valueOf(5));
- assertEquals(Integer.valueOf(5), column.getPrecision());
-
- assertSourceContains("@Column(precision=5)");
-
- column.setPrecision(null);
- assertSourceDoesNotContain("@Column");
- }
-
- public void testGetScale() throws Exception {
- IType testType = this.createTestColumnWithIntElement("scale");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertEquals(Integer.valueOf(5), column.getScale());
- }
-
- public void testSetScale() throws Exception {
- IType testType = this.createTestColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
-
- assertNotNull(column);
- assertNull(column.getScale());
-
- column.setScale(Integer.valueOf(5));
- assertEquals(Integer.valueOf(5), column.getScale());
-
- assertSourceContains("@Column(scale=5)");
-
- column.setScale(null);
- assertSourceDoesNotContain("@Column");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorColumnTests.java
deleted file mode 100644
index 2dc79a48ac..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorColumnTests.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.DiscriminatorType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class DiscriminatorColumnTests extends JavaResourceModelTestCase {
-
- private static final String COLUMN_NAME = "MY_COLUMN";
- private static final String COLUMN_COLUMN_DEFINITION = "COLUMN_DEFINITION";
-
- public DiscriminatorColumnTests(String name) {
- super(name);
- }
-
- private void createDiscriminatorColumnAnnotation() throws Exception {
- this.createEnumAndMembers("DiscriminatorType", "STRING, CHAR, INTEGER");
- this.createAnnotationAndMembers("DiscriminatorColumn",
- "String name() default \"DTYPE\"; " +
- "DiscriminatorType discriminatorType() default STRING; " +
- "String columnDefinition() default \"\"; " +
- "int length() default 31;");
- }
-
- private IType createTestDiscriminatorColumn() throws Exception {
- createDiscriminatorColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.DISCRIMINATOR_COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@DiscriminatorColumn");
- }
- });
- }
-
- private IType createTestDiscriminatorColumnWithName() throws Exception {
- createDiscriminatorColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.DISCRIMINATOR_COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@DiscriminatorColumn(name=\"" + COLUMN_NAME + "\")");
- }
- });
- }
-
- private IType createTestDiscriminatorColumnWithColumnDefinition() throws Exception {
- createDiscriminatorColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.DISCRIMINATOR_COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@DiscriminatorColumn(columnDefinition=\"" + COLUMN_COLUMN_DEFINITION + "\")");
- }
- });
- }
-
- private IType createTestDiscriminatorColumnWithDiscriminatorType() throws Exception {
- createDiscriminatorColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.DISCRIMINATOR_COLUMN, JPA.DISCRIMINATOR_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@DiscriminatorColumn(discriminatorType=DiscriminatorType.CHAR)");
- }
- });
- }
-
- private IType createTestColumnWithIntElement(final String intElement) throws Exception {
- createDiscriminatorColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.DISCRIMINATOR_COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@DiscriminatorColumn(" + intElement + "=5)");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestDiscriminatorColumnWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
- assertNotNull(column);
- assertEquals(COLUMN_NAME, column.getName());
- }
-
- public void testGetNull() throws Exception {
- IType testType = this.createTestDiscriminatorColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
- assertNotNull(column);
- assertNull(column.getName());
- assertNull(column.getDiscriminatorType());
- assertNull(column.getColumnDefinition());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestDiscriminatorColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getName());
-
- column.setName("Foo");
- assertEquals("Foo", column.getName());
-
- assertSourceContains("@DiscriminatorColumn(name=\"Foo\")");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestDiscriminatorColumnWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- assertEquals(COLUMN_NAME, column.getName());
-
- column.setName(null);
- assertNull(column.getName());
-
- assertSourceDoesNotContain("@DiscriminatorColumn");
- }
-
- public void testGetColumnDefinition() throws Exception {
- IType testType = this.createTestDiscriminatorColumnWithColumnDefinition();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
- assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition());
- }
-
- public void testSetColumnDefinition() throws Exception {
- IType testType = this.createTestDiscriminatorColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getColumnDefinition());
-
- column.setColumnDefinition("Foo");
- assertEquals("Foo", column.getColumnDefinition());
-
- assertSourceContains("@DiscriminatorColumn(columnDefinition=\"Foo\")");
-
-
- column.setColumnDefinition(null);
- assertSourceDoesNotContain("@DiscriminatorColumn");
- }
-
- public void testGetLength() throws Exception {
- IType testType = this.createTestColumnWithIntElement("length");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- assertEquals(Integer.valueOf(5), column.getLength());
- }
-
- public void testSetLength() throws Exception {
- IType testType = this.createTestDiscriminatorColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getLength());
-
- column.setLength(Integer.valueOf(5));
- assertEquals(Integer.valueOf(5), column.getLength());
-
- assertSourceContains("@DiscriminatorColumn(length=5)");
-
- column.setLength(null);
- assertSourceDoesNotContain("@DiscriminatorColumn");
- }
-
- public void testGetDiscriminatorType() throws Exception {
- IType testType = this.createTestDiscriminatorColumnWithDiscriminatorType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
- assertEquals(DiscriminatorType.CHAR, column.getDiscriminatorType());
- }
-
- public void testSetDiscriminatorType() throws Exception {
- IType testType = this.createTestDiscriminatorColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN);
-
- assertNull(column.getDiscriminatorType());
-
- column.setDiscriminatorType(DiscriminatorType.INTEGER);
- assertEquals(DiscriminatorType.INTEGER, column.getDiscriminatorType());
-
- assertSourceContains("@DiscriminatorColumn(discriminatorType=INTEGER)");
-
- column.setDiscriminatorType(null);
- assertSourceDoesNotContain("@DiscriminatorColumn");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorValueTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorValueTests.java
deleted file mode 100644
index a2e1f17f36..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorValueTests.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class DiscriminatorValueTests extends JavaResourceModelTestCase {
-
- public DiscriminatorValueTests(String name) {
- super(name);
- }
-
- private IType createTestDiscriminatorValue() throws Exception {
- this.createAnnotationAndMembers("DiscriminatorValue", "String value() default \"\";");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.DISCRIMINATOR_VALUE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@DiscriminatorValue");
- }
- });
- }
-
- private IType createTestDiscriminatorValueWithValue() throws Exception {
- this.createAnnotationAndMembers("DiscriminatorValue", "String value() default \"\";");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.DISCRIMINATOR_VALUE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@DiscriminatorValue(value=\"discriminator\")");
- }
- });
- }
-
- public void testDiscriminatorValue() throws Exception {
- IType testType = this.createTestDiscriminatorValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- DiscriminatorValueAnnotation discriminatorValue = (DiscriminatorValueAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_VALUE);
- assertNotNull(discriminatorValue);
- }
-
- public void testGetValue() throws Exception {
- IType testType = this.createTestDiscriminatorValueWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- DiscriminatorValueAnnotation discriminatorValue = (DiscriminatorValueAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_VALUE);
- assertEquals("discriminator", discriminatorValue.getValue());
- }
-
- public void testSetValue() throws Exception {
- IType testType = this.createTestDiscriminatorValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- DiscriminatorValueAnnotation discriminatorValue = (DiscriminatorValueAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_VALUE);
-
- discriminatorValue.setValue("foo");
-
- assertSourceContains("@DiscriminatorValue(\"foo\")");
-
- discriminatorValue.setValue(null);
-
- assertSourceDoesNotContain("@DiscriminatorValue");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddableTests.java
deleted file mode 100644
index d4aaab7bea..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddableTests.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation;
-import org.eclipse.jpt.core.resource.java.EntityAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class EmbeddableTests extends JavaResourceModelTestCase {
-
- public EmbeddableTests(String name) {
- super(name);
- }
-
- private IType createTestEmbeddable() throws Exception {
- this.createAnnotationAndMembers("Embeddable", "");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Embeddable");
- }
- });
- }
-
- private IType createTestEmbeddableAndEntity() throws Exception {
- this.createAnnotationAndMembers("Embeddable", "");
- this.createAnnotationAndMembers("Entity", "");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDABLE, JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append("@Embeddable");
- }
- });
- }
-
- public void testEmbeddable() throws Exception {
- IType testType = this.createTestEmbeddable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- JavaResourceNode mappingAnnotation = typeResource.getMappingAnnotation();
- assertTrue(mappingAnnotation instanceof EmbeddableAnnotation);
- }
-
- public void testEmbeddableAndEntity() throws Exception {
- IType testType = this.createTestEmbeddableAndEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- JavaResourceNode mappingAnnotation = typeResource.getMappingAnnotation();
- assertTrue(mappingAnnotation instanceof EmbeddableAnnotation);
-
- EntityAnnotation entity = (EntityAnnotation) typeResource.getMappingAnnotation(JPA.ENTITY);
- assertNotNull(entity);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedIdTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedIdTests.java
deleted file mode 100644
index b3991c59cf..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedIdTests.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class EmbeddedIdTests extends JavaResourceModelTestCase {
-
- public EmbeddedIdTests(String name) {
- super(name);
- }
-
- private IType createTestEmbeddedId() throws Exception {
- this.createAnnotationAndMembers("EmbeddedId", "");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDED_ID);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@EmbeddedId");
- }
- });
- }
-
- public void testEmbeddedId() throws Exception {
- IType testType = this.createTestEmbeddedId();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JavaResourceNode mappingAnnotation = attributeResource.getMappingAnnotation();
- assertTrue(mappingAnnotation instanceof EmbeddedIdAnnotation);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedTests.java
deleted file mode 100644
index e604022105..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedTests.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class EmbeddedTests extends JavaResourceModelTestCase {
-
- public EmbeddedTests(String name) {
- super(name);
- }
-
- private IType createTestEmbedded() throws Exception {
- this.createAnnotationAndMembers("Embedded", "");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDED);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Embedded");
- }
- });
- }
-
- public void testEmbedded() throws Exception {
- IType testType = this.createTestEmbedded();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JavaResourceNode mappingAnnotation = attributeResource.getMappingAnnotation();
- assertTrue(mappingAnnotation instanceof EmbeddedAnnotation);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EntityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EntityTests.java
deleted file mode 100644
index fc365053ac..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EntityTests.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.EntityAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class EntityTests extends JavaResourceModelTestCase {
-
- private static final String ENTITY_NAME = "Foo";
-
- public EntityTests(String name) {
- super(name);
- }
-
- private IType createTestEntity() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private IType createTestEntityWithName() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity(name=\"" + ENTITY_NAME + "\")");
- }
- });
- }
-
- private IType createTestMappedSuperclassAndEntity() throws Exception {
- this.createAnnotationAndMembers("MappedSuperclass", "");
- this.createAnnotationAndMembers("Entity", "String name();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass");
- sb.append("@Entity");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestEntityWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- EntityAnnotation entity = (EntityAnnotation) typeResource.getMappingAnnotation(JPA.ENTITY);
- assertTrue(entity != null);
- assertEquals(ENTITY_NAME, entity.getName());
- }
-
- public void testGetNameNull() throws Exception {
- IType testType = this.createTestEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- EntityAnnotation entity = (EntityAnnotation) typeResource.getMappingAnnotation(JPA.ENTITY);
- assertTrue(entity != null);
- assertNull(entity.getName());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- EntityAnnotation entity = (EntityAnnotation) typeResource.getMappingAnnotation(JPA.ENTITY);
- assertNull(entity.getName());
- entity.setName("Foo");
- assertEquals("Foo", entity.getName());
-
- assertSourceContains("@Entity(name=\"Foo\")");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestEntityWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- EntityAnnotation entity = (EntityAnnotation) typeResource.getMappingAnnotation(JPA.ENTITY);
- assertEquals(ENTITY_NAME, entity.getName());
-
- entity.setName(null);
- assertNull(entity.getName());
-
- assertSourceContains("@Entity");
- assertSourceDoesNotContain("@Entity(name=\"Foo\")");
- }
-
- public void testMappedSuperclassAndEntity() throws Exception {
- IType testType = this.createTestMappedSuperclassAndEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- JavaResourceNode mappingAnnotation = typeResource.getMappingAnnotation();
- assertTrue(mappingAnnotation instanceof EntityAnnotation);
-
- MappedSuperclassAnnotation mappedSuperclass = (MappedSuperclassAnnotation) typeResource.getMappingAnnotation(JPA.MAPPED_SUPERCLASS);
- assertNotNull(mappedSuperclass);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EnumeratedTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EnumeratedTests.java
deleted file mode 100644
index e4cfc2c24b..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EnumeratedTests.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.EnumType;
-import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class EnumeratedTests extends JavaResourceModelTestCase {
-
- public EnumeratedTests(String name) {
- super(name);
- }
-
- private IType createTestEnumerated() throws Exception {
- this.createAnnotationAndMembers("Enumerated", "EnumType value();");
- this.createEnumAndMembers("EnumType", "ORDINAL, STRING");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENUMERATED);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Enumerated");
- }
- });
- }
-
- private IType createTestEnumeratedWithValue() throws Exception {
- this.createAnnotationAndMembers("Enumerated", "EnumType value();");
- this.createEnumAndMembers("EnumType", "ORDINAL, STRING");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENUMERATED, JPA.ENUM_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Enumerated(EnumType.ORDINAL)");
- }
- });
- }
-
- public void testEnumerated() throws Exception {
- IType testType = this.createTestEnumerated();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EnumeratedAnnotation enumerated = (EnumeratedAnnotation) attributeResource.getAnnotation(JPA.ENUMERATED);
- assertNotNull(enumerated);
- }
-
- public void testGetValue() throws Exception {
- IType testType = this.createTestEnumeratedWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EnumeratedAnnotation enumerated = (EnumeratedAnnotation) attributeResource.getAnnotation(JPA.ENUMERATED);
- assertEquals(EnumType.ORDINAL, enumerated.getValue());
- }
-
- public void testSetValue() throws Exception {
- IType testType = this.createTestEnumerated();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EnumeratedAnnotation enumerated = (EnumeratedAnnotation) attributeResource.getAnnotation(JPA.ENUMERATED);
-
- enumerated.setValue(EnumType.STRING);
-
- assertSourceContains("@Enumerated(STRING)");
-
- enumerated.setValue(null);
-
- assertSourceDoesNotContain("@Enumerated");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/GeneratedValueTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/GeneratedValueTests.java
deleted file mode 100644
index b59f1cf80b..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/GeneratedValueTests.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation;
-import org.eclipse.jpt.core.resource.java.GenerationType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class GeneratedValueTests extends JavaResourceModelTestCase {
-
- private static final String GENERATOR = "MY_GENERATOR";
- public GeneratedValueTests(String name) {
- super(name);
- }
-
- private void createGenerationTypeEnum() throws Exception {
- this.createEnumAndMembers("GenerationType", "TABLE, SEQUENCE, IDENTITY, AUTO;");
- }
-
- private void createGeneratedValueAnnotation() throws Exception {
- this.createAnnotationAndMembers("GeneratedValue", "GenerationType strategy() default AUTO; String generator() default \"\"");
- createGenerationTypeEnum();
- }
-
- private IType createTestGeneratedValue() throws Exception {
- createGeneratedValueAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.GENERATED_VALUE, JPA.GENERATION_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@GeneratedValue");
- }
- });
- }
-
- private IType createTestGeneratedValueWithGenerator() throws Exception {
- createGeneratedValueAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.GENERATED_VALUE, JPA.GENERATION_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@GeneratedValue(generator=\"" + GENERATOR + "\")");
- }
- });
- }
-
- private IType createTestGeneratedValueWithStrategy() throws Exception {
- createGeneratedValueAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.GENERATED_VALUE, JPA.GENERATION_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@GeneratedValue(strategy=GenerationType.SEQUENCE)");
- }
- });
- }
-
- public void testGeneratedValue() throws Exception {
- IType testType = this.createTestGeneratedValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE);
- assertNotNull(generatedValue);
- }
-
- public void testGetGenerator() throws Exception {
- IType testType = this.createTestGeneratedValueWithGenerator();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE);
- assertEquals(GENERATOR, generatedValue.getGenerator());
- }
-
- public void testSetGenerator() throws Exception {
- IType testType = this.createTestGeneratedValueWithGenerator();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE);
- assertEquals(GENERATOR, generatedValue.getGenerator());
-
- generatedValue.setGenerator("foo");
- assertEquals("foo", generatedValue.getGenerator());
-
- assertSourceContains("@GeneratedValue(generator=\"foo\")");
-
- generatedValue.setGenerator(null);
- assertNull(generatedValue.getGenerator());
-
- assertSourceDoesNotContain("generator");
- assertSourceContains("@GeneratedValue");
- }
-
- public void testGetStrategy() throws Exception {
- IType testType = this.createTestGeneratedValueWithStrategy();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE);
- assertEquals(GenerationType.SEQUENCE, generatedValue.getStrategy());
- }
-
- public void testSetStrategy() throws Exception {
- IType testType = this.createTestGeneratedValueWithStrategy();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE);
- assertEquals(GenerationType.SEQUENCE, generatedValue.getStrategy());
-
- generatedValue.setStrategy(GenerationType.TABLE);
- assertEquals(GenerationType.TABLE, generatedValue.getStrategy());
-
- assertSourceContains("@GeneratedValue(strategy=TABLE)");
-
- generatedValue.setStrategy(null);
- assertNull(generatedValue.getStrategy());
- assertSourceDoesNotContain("strategy");
- assertSourceContains("@GeneratedValue");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdClassTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdClassTests.java
deleted file mode 100644
index 4dc9f56b6f..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdClassTests.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.IdClassAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class IdClassTests extends JavaResourceModelTestCase {
-
- private static final String ID_CLASS_VALUE = "MyClass";
-
- public IdClassTests(String name) {
- super(name);
- }
-
- private void createIdClassAnnotation() throws Exception {
- this.createAnnotationAndMembers("IdClass", "Class value();");
- }
-
- private IType createTestIdClass() throws Exception {
- createIdClassAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ID_CLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@IdClass");
- }
- });
- }
-
- private IType createTestIdClassWithValue() throws Exception {
- createIdClassAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ID_CLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@IdClass(" + ID_CLASS_VALUE + ".class)");
- }
- });
- }
-
- public void testIdClass() throws Exception {
- IType testType = this.createTestIdClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- IdClassAnnotation idClass = (IdClassAnnotation) typeResource.getAnnotation(JPA.ID_CLASS);
- assertNotNull(idClass);
- assertNull(idClass.getValue());
- }
-
- public void testGetValue() throws Exception {
- IType testType = this.createTestIdClassWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- IdClassAnnotation idClass = (IdClassAnnotation) typeResource.getAnnotation(JPA.ID_CLASS);
- assertEquals(ID_CLASS_VALUE, idClass.getValue());
- }
-
- public void testSetValue() throws Exception {
- IType testType = this.createTestIdClassWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- IdClassAnnotation idClass = (IdClassAnnotation) typeResource.getAnnotation(JPA.ID_CLASS);
- assertEquals(ID_CLASS_VALUE, idClass.getValue());
-
- idClass.setValue("foo");
- assertEquals("foo", idClass.getValue());
-
- assertSourceContains("@IdClass(foo.class)");
-
- idClass.setValue(null);
-
- assertSourceDoesNotContain("@IdClass");
-
- idClass = (IdClassAnnotation) typeResource.getAnnotation(JPA.ID_CLASS);
- assertNull(idClass);
- }
-
- public void testGetFullyQualifiedClass() throws Exception {
- IType testType = this.createTestIdClassWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- IdClassAnnotation idClass = (IdClassAnnotation) typeResource.getAnnotation(JPA.ID_CLASS);
- assertNotNull(idClass.getValue());
- assertEquals("MyClass", idClass.getFullyQualifiedClass()); //bug 196200 changed this
-
-
- idClass.setValue(TYPE_NAME);
-
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, idClass.getFullyQualifiedClass());
- assertSourceContains("@IdClass(" + TYPE_NAME + ".class)");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdTests.java
deleted file mode 100644
index 2125b5bb75..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdTests.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class IdTests extends JavaResourceModelTestCase {
-
- public IdTests(String name) {
- super(name);
- }
-
- private IType createTestId() throws Exception {
- this.createAnnotationAndMembers("Id", "");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ID);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- public void testId() throws Exception {
- IType testType = this.createTestId();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JavaResourceNode mappingAnnotation = attributeResource.getMappingAnnotation();
- assertTrue(mappingAnnotation instanceof IdAnnotation);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/InheritanceTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/InheritanceTests.java
deleted file mode 100644
index 419d765749..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/InheritanceTests.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.InheritanceAnnotation;
-import org.eclipse.jpt.core.resource.java.InheritanceType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class InheritanceTests extends JavaResourceModelTestCase {
-
- public InheritanceTests(String name) {
- super(name);
- }
-
- private IType createTestInheritance() throws Exception {
- this.createAnnotationAndMembers("Inheritance", "InheritanceType strategy() default SINGLE_TABLE;");
- this.createEnumAndMembers("InheritanceType", "SINGLE_TABLE, JOINED, TABLE_PER_CLASS");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.INHERITANCE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Inheritance");
- }
- });
- }
-
- private IType createTestInheritanceWithStrategy() throws Exception {
- this.createAnnotationAndMembers("Inheritance", "InheritanceType strategy() default SINGLE_TABLE;");
- this.createEnumAndMembers("InheritanceType", "SINGLE_TABLE, JOINED, TABLE_PER_CLASS");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.INHERITANCE, JPA.INHERITANCE_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Inheritance(strategy=InheritanceType.JOINED)");
- }
- });
- }
-
- public void testInheritance() throws Exception {
- IType testType = this.createTestInheritance();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- InheritanceAnnotation inheritance = (InheritanceAnnotation) typeResource.getAnnotation(JPA.INHERITANCE);
- assertNotNull(inheritance);
- }
-
- public void testGetStrategy() throws Exception {
- IType testType = this.createTestInheritanceWithStrategy();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- InheritanceAnnotation inheritance = (InheritanceAnnotation) typeResource.getAnnotation(JPA.INHERITANCE);
- assertEquals(InheritanceType.JOINED, inheritance.getStrategy());
- }
-
- public void testSetStrategy() throws Exception {
- IType testType = this.createTestInheritance();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- InheritanceAnnotation inheritance = (InheritanceAnnotation) typeResource.getAnnotation(JPA.INHERITANCE);
- inheritance.setStrategy(InheritanceType.TABLE_PER_CLASS);
-
- assertSourceContains("@Inheritance(strategy=TABLE_PER_CLASS)");
-
- inheritance.setStrategy(null);
-
- assertSourceDoesNotContain("@Inheritance");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JPTToolsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JPTToolsTests.java
deleted file mode 100644
index d6cde50613..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JPTToolsTests.java
+++ /dev/null
@@ -1,527 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTTools;
-import org.eclipse.jpt.core.internal.utility.jdt.JPTTools;
-import org.eclipse.jpt.core.utility.jdt.FieldAttribute;
-import org.eclipse.jpt.core.utility.jdt.MethodAttribute;
-import org.eclipse.jpt.core.utility.jdt.Type;
-
-public class JPTToolsTests extends JavaResourceModelTestCase {
-
- public JPTToolsTests(String name) {
- super(name);
- }
-
- private IType createTestTypeFieldWithModifier(final String modifier) throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" " + modifier + " String foo;").append(CR);
- sb.append(CR);
- }
- });
- }
-
- protected FieldAttribute fooField() throws JavaModelException {
- return this.fieldNamed("foo");
- }
-
-
- private IType createTestTypeGetMethodWithModifier(final String modifier) throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" " + modifier + " int getFoo() {").append(CR);
- sb.append(" return this.id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" public void setFoo(int id) {").append(CR);
- sb.append(" this.id = id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private IType createTestTypeInvalidMethodName() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" public int foo() {").append(CR);
- sb.append(" return this.id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" public void setFoo(int id) {").append(CR);
- sb.append(" this.id = id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private IType createTestTypeConstructor() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" public " + TYPE_NAME + "() {").append(CR);
- sb.append(" super();").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private IType createTestTypeVoidMethodReturnType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" public void getFoo() {").append(CR);
- sb.append(" return this.id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" public void setFoo(int id) {").append(CR);
- sb.append(" this.id = id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- }
- });
- }
-
-// private IType createTestTypeInvalidMethodReturnType() throws Exception {
-// return this.createTestType(new DefaultAnnotationWriter() {
-//
-// @Override
-// public Iterator<String> imports() {
-// return new ArrayIterator<String>("com.foo.Foo");
-// }
-// @Override
-// public void appendGetIdMethodAnnotationTo(StringBuffer sb) {
-// sb.append(CR);
-// sb.append(" public Foo getFoo() {").append(CR);
-// sb.append(" return null;").append(CR);
-// sb.append(" }").append(CR);
-// sb.append(CR);
-// sb.append(" public void setFoo(Foo id) {").append(CR);
-// sb.append(" this.id = id;").append(CR);
-// sb.append(" }").append(CR);
-// sb.append(CR);
-// }
-// });
-// }
-
- private IType createTestTypeIsMethod() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" public boolean isFoo() {").append(CR);
- sb.append(" return this.id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" public void setFoo(boolean id) {").append(CR);
- sb.append(" this.id = id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private IType createTestTypeIsMethodReturnInt() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" public int isFoo() {").append(CR);
- sb.append(" return this.id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" public void setFoo(int id) {").append(CR);
- sb.append(" this.id = id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private IType createTestTypeIsAndGetMethodWithModifier(final String modifier) throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" " + modifier + " boolean isFoo() {").append(CR);
- sb.append(" return this.id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" " + modifier + " boolean getFoo() {").append(CR);
- sb.append(" return this.id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" public void setFoo(boolean id) {").append(CR);
- sb.append(" this.id = id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private IType createTestTypeSetMethodWithModifier(final String modifier) throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" public int getFoo() {").append(CR);
- sb.append(" return this.id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" " + modifier + " void setFoo(int id) {").append(CR);
- sb.append(" this.id = id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private IType createTestTypeWithMemberTypes() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public void appendMemberTypeTo(StringBuilder sb) {
- sb.append(" public static class FooStatic {}").append(CR);
- sb.append(CR);
- sb.append(" public class FooNotStatic {}").append(CR);
- sb.append(CR);
- sb.append(" public @interface MyAnnotation {}").append(CR);
- sb.append(CR);
- sb.append(" public enum MyEnum {}").append(CR);
- }
- });
- }
-
- protected MethodAttribute fooMethod() throws JavaModelException {
- return this.methodNamed("getFoo");
- }
-
- //private String foo; - persistable
- public void testFieldIsPersistable1() throws Exception {
- IType testType = createTestTypeFieldWithModifier("private");
- FieldAttribute fieldAttribute = fooField();
- IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertTrue(JPTTools.fieldIsPersistable(variableBinding));
- }
-
- //private static String foo; - not persistable
- public void testFieldIsPersistable2() throws Exception {
- IType testType = createTestTypeFieldWithModifier("private static");
- FieldAttribute fieldAttribute = fooField();
- IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertFalse(JPTTools.fieldIsPersistable(variableBinding));
- }
-
- //private transient String foo; - not persistable
- public void testFieldIsPersistable3() throws Exception {
- IType testType = createTestTypeFieldWithModifier("private transient");
- FieldAttribute fieldAttribute = fooField();
- IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertFalse(JPTTools.fieldIsPersistable(variableBinding));
- }
-
- //private final String foo; - persistable
- public void testFieldIsPersistable4() throws Exception {
- IType testType = createTestTypeFieldWithModifier("private final");
- FieldAttribute fieldAttribute = fooField();
- IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertTrue(JPTTools.fieldIsPersistable(variableBinding));
- }
-
- //public String foo; - persistable
- public void testFieldIsPersistable5() throws Exception {
- IType testType = createTestTypeFieldWithModifier("public");
- FieldAttribute fieldAttribute = fooField();
- IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertTrue(JPTTools.fieldIsPersistable(variableBinding));
- }
-
-
- //public int getFoo() {} - persistable
- public void testMethodIsPersistablePropertyGetter1() throws Exception {
- IType testType = createTestTypeGetMethodWithModifier("public");
- MethodAttribute methodAttribute = fooMethod();
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertTrue(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
-
- }
-
- //protected int getFoo() {} - persistable
- public void testMethodIsPersistablePropertyGetter2() throws Exception {
- IType testType = createTestTypeGetMethodWithModifier("protected");
- MethodAttribute methodAttribute = fooMethod();
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertTrue(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
- }
-
- //int getFoo() {} - not persistable
- public void testMethodIsPersistablePropertyGetter3() throws Exception {
- IType testType = createTestTypeGetMethodWithModifier("");
- MethodAttribute methodAttribute = fooMethod();
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
- }
-
- //private int getFoo() {} - not persistable
- public void testMethodIsPersistablePropertyGetter4() throws Exception {
- IType testType = createTestTypeGetMethodWithModifier("private");
- MethodAttribute methodAttribute = fooMethod();
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
- }
-
- //public static int getFoo() {} - not persistable
- public void testMethodIsPersistablePropertyGetter5() throws Exception {
- IType testType = createTestTypeGetMethodWithModifier("public static");
- MethodAttribute methodAttribute = fooMethod();
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
- }
-
- //public final int getFoo() {} - not persistable
- public void testMethodIsPersistablePropertyGetter6() throws Exception {
- IType testType = createTestTypeGetMethodWithModifier("public final");
- MethodAttribute methodAttribute = fooMethod();
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
- }
-
- //public void setFoo(int foo) {} - persistable
- public void testMethodIsPersistablePropertyGetter7() throws Exception {
- IType testType = createTestTypeSetMethodWithModifier("public");
- MethodAttribute methodAttribute = fooMethod();
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertTrue(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
-
- }
-
- //protected void setFoo(int foo) {} - persistable
- public void testMethodIsPersistablePropertyGetter8() throws Exception {
- IType testType = createTestTypeSetMethodWithModifier("protected");
- MethodAttribute methodAttribute = fooMethod();
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertTrue(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
- }
-
- //void setFoo(int foo) {} - not persistable
- public void testMethodIsPersistablePropertyGetter9() throws Exception {
- IType testType = createTestTypeSetMethodWithModifier("");
- MethodAttribute methodAttribute = fooMethod();
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
- }
-
- //private void setFoo(int foo) {} - not persistable
- public void testMethodIsPersistablePropertyGetter10() throws Exception {
- IType testType = createTestTypeSetMethodWithModifier("private");
- MethodAttribute methodAttribute = fooMethod();
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
- }
-
- //public static void setFoo(int foo) {} - not persistable
- public void testMethodIsPersistablePropertyGetter11() throws Exception {
- IType testType = createTestTypeSetMethodWithModifier("public static");
- MethodAttribute methodAttribute = fooMethod();
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
- }
-
- //public final void setFoo(int foo) {} - not persistable
- public void testMethodIsPersistablePropertyGetter12() throws Exception {
- IType testType = createTestTypeSetMethodWithModifier("public final");
- MethodAttribute methodAttribute = fooMethod();
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
- }
-
- //public boolean isFoo() {} - persistable
- public void testMethodIsPersistablePropertyGetter13() throws Exception {
- IType testType = createTestTypeIsMethod();
- MethodAttribute methodAttribute = this.methodNamed("isFoo");
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertTrue(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
-
- }
-
- //public int isFoo() {} - not persistable
- public void testMethodIsPersistablePropertyGetter14() throws Exception {
- IType testType = createTestTypeIsMethodReturnInt();
- MethodAttribute methodAttribute = this.methodNamed("isFoo");
- IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType));
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding));
-
- }
-
- //public int isFoo() {} - persistable
- //public int getFoo() {} - not persistable
- public void testMethodIsPersistablePropertyGetter15() throws Exception {
- IType testType = createTestTypeIsAndGetMethodWithModifier("public");
- MethodAttribute isFooMethod = this.methodNamed("isFoo");
- MethodAttribute getFooMethod = this.methodNamed("getFoo");
-
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertTrue(JPTTools.methodIsPersistablePropertyGetter(isFooMethod.getBinding(astRoot)));
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(getFooMethod.getBinding(astRoot)));
- }
-
- //public int foo() {} - not persistable
- public void testMethodIsPersistablePropertyGetter16() throws Exception {
- IType testType = createTestTypeInvalidMethodName();
- MethodAttribute fooMethod = this.methodNamed("foo");
-
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(fooMethod.getBinding(astRoot)));
- }
-
- //public void getFoo() {} - not persistable - void return type
- public void testMethodIsPersistablePropertyGetter17() throws Exception {
- IType testType = createTestTypeVoidMethodReturnType();
- MethodAttribute fooMethod = this.methodNamed("getFoo");
-
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(fooMethod.getBinding(astRoot)));
- }
-
- //TODO
- //**getFooMethod.binding(CompliationUnit) is returning null, not sure why and don't know how to test
- //**this if it is returning null there instead of returning null for IMethodBinding.getReturnType()
-// //public Foo getFoo() {} - not persistable - Foo does not resolve
-// public void testMethodIsPersistablePropertyGetter18() throws Exception {
-// IType testType = createTestTypeInvalidMethodReturnType();
-// MethodAttribute getFooMethod = this.methodNamed("getFoo");
-//
-// CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
-// assertFalse(JPTTools.methodIsPersistablePropertyGetter(fooMethod.binding(astRoot)));
-// }
-
- //method with parameters - not persistable
- public void testMethodIsPersistablePropertyGetter19() throws Exception {
- IType testType = createTestType();
- MethodAttribute setIdMethod = idSetMethod();
-
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(setIdMethod.getBinding(astRoot)));
- }
-
- //constructor - not persistable
- public void testMethodIsPersistablePropertyGetter20() throws Exception {
- IType testType = createTestTypeConstructor();
- MethodAttribute constructor = methodNamed(TYPE_NAME);
-
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(constructor.getBinding(astRoot)));
- }
-
- //no corresponding set method - not persistable
- public void testMethodIsPersistablePropertyGetter21() throws Exception {
- IType testType = createTestType();
- MethodAttribute getNameMethod = nameGetMethod();
-
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertFalse(JPTTools.methodIsPersistablePropertyGetter(getNameMethod.getBinding(astRoot)));
- }
-
- //public class AnnotationTestType
- public void testTypeIsPersistable() throws Exception {
- IType testType = createTestType();
- Type type = buildType(testType);
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertTrue(JPTTools.typeIsPersistable(type.getBinding(astRoot)));
- }
-
- //public final class MyFinal
- public void testTypeIsPersistable2() throws Exception {
- IType testType = this.javaProject.createType("finals", "MyFinal.java", "public final class MyFinal { }");
- Type type = buildType(testType);
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertFalse(JPTTools.typeIsPersistable(type.getBinding(astRoot)));
- }
-
- //public interface AnnotationTestType
- public void testTypeIsPersistable3() throws Exception {
- IType testType = this.javaProject.createType("interfaces", "MyInterface.java", "public interface MyInterface { }");
- Type type = buildType(testType);
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertFalse(JPTTools.typeIsPersistable(type.getBinding(astRoot)));
- }
-
- //enum not persistable
- public void testTypeIsPersistable4() throws Exception {
- IType testType = this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ");
- Type type = buildType(testType);
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertFalse(JPTTools.typeIsPersistable(type.getBinding(astRoot)));
- }
-
- //annotation not persistable
- public void testTypeIsPersistable5() throws Exception {
- IType testType = this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();");
- Type type = buildType(testType);
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertFalse(JPTTools.typeIsPersistable(type.getBinding(astRoot)));
- }
-
- //public static member type is persistable
- public void testTypeIsPersistable6() throws Exception {
- IType testType = this.createTestTypeWithMemberTypes();
- IType staticType = testType.getType("FooStatic");
- Type type = buildType(staticType);
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertTrue(JPTTools.typeIsPersistable(type.getBinding(astRoot)));
- }
-
- //non-static member type is not persistable
- public void testTypeIsPersistable7() throws Exception {
- IType testType = this.createTestTypeWithMemberTypes();
- IType staticType = testType.getType("FooNotStatic");
- Type type = buildType(staticType);
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
- assertFalse(JPTTools.typeIsPersistable(type.getBinding(astRoot)));
- }
- //TODO still need to test typeIsPersistable() returns false for local and anonymous classes
-
-
-
- public void testIsAbstract() throws Exception {
- IType testType = createTestType();
- Type type = buildType(testType);
- CompilationUnit astRoot = JDTTools.buildASTRoot(testType);
-
- assertFalse(JPTTools.typeIsAbstract(type.getBinding(astRoot)));
- }
-
-}
-
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java
deleted file mode 100644
index 2f67eb27f8..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.ElementChangedEvent;
-import org.eclipse.jdt.core.IElementChangedListener;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.JpaRootContextNode;
-import org.eclipse.jpt.core.internal.GenericJpaProject;
-import org.eclipse.jpt.core.internal.SimpleJpaProjectConfig;
-import org.eclipse.jpt.core.internal.resource.java.JavaResourceModelImpl;
-import org.eclipse.jpt.core.internal.utility.jdt.NullAnnotationEditFormatter;
-import org.eclipse.jpt.core.resource.java.JavaResourceModel;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.tests.internal.utility.jdt.AnnotationTestCase;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-public class JavaResourceModelTestCase extends AnnotationTestCase
-{
- private JavaElementChangeListener javaElementChangeListener;
- protected JavaResourceModel javaResourceModel;
-
-
- public JavaResourceModelTestCase(String name) {
- super(name);
- }
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.javaElementChangeListener = new JavaElementChangeListener();
- JavaCore.addElementChangedListener(this.javaElementChangeListener);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- JavaCore.removeElementChangedListener(this.javaElementChangeListener);
- this.javaElementChangeListener = null;
- }
-
- /**
- * Forward the Java element change event back to the JPA model manager.
- */
- private class JavaElementChangeListener implements IElementChangedListener {
- JavaElementChangeListener() {
- super();
- }
- public void elementChanged(ElementChangedEvent event) {
- if (JavaResourceModelTestCase.this.javaResourceModel != null) {
- JavaResourceModelTestCase.this.javaResourceModel.javaElementChanged(event);
- }
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
- }
-
- protected IType createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- return this.javaProject.createType("javax.persistence", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- protected IType createEnumAndMembers(String enumName, String enumBody) throws Exception {
- return this.javaProject.createType("javax.persistence", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }");
- }
-
- //build up a dummy JpaProject that does not have JpaFiles in it and does not update from java changes
- protected JpaProject buildJpaProject() throws CoreException {
- return new TestJpaProject(this.buildJpaProjectConfig(this.javaProject.getProject()));
- }
-
- protected class TestJpaProject extends GenericJpaProject {
- protected TestJpaProject(JpaProject.Config config) throws CoreException {
- super(config);
- this.setUpdater(Updater.Null.instance());// ignore all updates, since there is no context model
- }
-
- @Override
- protected IResourceProxyVisitor buildInitialResourceProxyVisitor() {
- return new IResourceProxyVisitor() {
- public boolean visit(IResourceProxy proxy) throws CoreException {
- return false; // ignore all the files in the Eclipse project
- }
- };
- }
-
- @Override
- protected JpaRootContextNode buildRootContextNode() {
- return null; // no root context
- }
- }
-
- private JpaProject.Config buildJpaProjectConfig(IProject project) {
- SimpleJpaProjectConfig config = new SimpleJpaProjectConfig();
- config.setProject(project);
- config.setJpaPlatform(JptCorePlugin.getJpaPlatform(project));
- config.setConnectionProfileName(JptCorePlugin.getConnectionProfileName(project));
- config.setDiscoverAnnotatedClasses(JptCorePlugin.discoverAnnotatedClasses(project));
- return config;
- }
-
- protected JavaResourcePersistentType buildJavaTypeResource(IType testType)
- throws CoreException {
- this.javaResourceModel = buildJavaResourceModel(testType);
- this.javaResourceModel.resolveTypes();
- return this.javaResourceModel.getResource().getPersistentType();
- }
-
- protected JavaResourceModel buildJavaResourceModel(IType testType) throws CoreException {
- if (this.javaResourceModel != null) {
- throw new IllegalStateException();
- }
- IFile file = (IFile) testType.getResource();
- JpaProject jpaProject = buildJpaProject();
- return new JavaResourceModelImpl(
- file,
- jpaProject.getJpaPlatform().getAnnotationProvider(),
- MODIFY_SHARED_DOCUMENT_COMMAND_EXECUTOR_PROVIDER,
- NullAnnotationEditFormatter.instance());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentAttributeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentAttributeTests.java
deleted file mode 100644
index 5553df00e2..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentAttributeTests.java
+++ /dev/null
@@ -1,900 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Collection;
-import java.util.Iterator;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.internal.resource.java.IdImpl;
-import org.eclipse.jpt.core.internal.resource.java.OneToOneImpl;
-import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.core.utility.jdt.Member.Editor;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-
-public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestCase {
-
- public JavaResourcePersistentAttributeTests(String name) {
- super(name);
- }
-
- private IType createTestEntity() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name();");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private IType createTestEntityWithNonResolvingField() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name();");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("private Foo foo;").append(CR);
- sb.append(CR);
- }
- });
- }
- private IType createTestEntityWithNonResolvingMethod() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name();");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("private Foo foo;").append(CR);
- sb.append(CR);
- sb.append(" @Id");
- sb.append(CR);
- sb.append(" public Foo getFoo() {").append(CR);
- sb.append(" return this.foo;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" ");
- sb.append(CR);
- sb.append(" public void setFoo(Foo foo) {").append(CR);
- sb.append(" this.foo = foo;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- private IType createTestEntityMultipleVariableDeclarationsPerLine() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name();");
- this.createAnnotationAndMembers("Column", "String name();");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" ");
- sb.append("@Id");
- sb.append(CR);
- sb.append(" ");
- sb.append("@Column(name=\"baz\")");
- sb.append(" private String foo, bar;").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private IType createTestEntityWithIdAndBasic() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name();");
- this.createAnnotationAndMembers("Id", "");
- this.createAnnotationAndMembers("Basic", "");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.BASIC);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- sb.append(CR);
- sb.append("@Basic");
- }
- });
- }
-
- private IType createTestEntityAnnotatedField() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name();");
- this.createAnnotationAndMembers("Column", "String name();");
- this.createAnnotationAndMembers("Id", "String name();");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- sb.append(CR);
- sb.append(" ");
- sb.append("@Column");
- }
- });
- }
-
- private IType createTestEntityWithColumn() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name();");
- this.createAnnotationAndMembers("Column", "String name(); String table();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Column(name=\"FOO\", table=\"MY_TABLE\")");
- }
- });
- }
-
- private IType createTestEntityWithIdColumnGeneratedValue() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name();");
- this.createAnnotationAndMembers("Column", "String name(); String table();");
- this.createAnnotationAndMembers("GeneratedValue", "");
- this.createAnnotationAndMembers("Id", "");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.COLUMN, JPA.ID, JPA.GENERATED_VALUE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- sb.append(CR);
- sb.append("@Column");
- sb.append(CR);
- sb.append("@GeneratedValue");
- }
- });
- }
-
-
- private IType createTestEntityMultipleColumns() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name();");
- this.createAnnotationAndMembers("Column", "String name();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Column(name=\"FOO\")");
- sb.append(CR);
- sb.append("@Column(name=\"BAR\")");
- }
- });
- }
-
- private IType createTestEmbeddedWithAttributeOverride() throws Exception {
- this.createAnnotationAndMembers("Embedded", "String name();");
- this.createAnnotationAndMembers("AttributeOverride", "String name();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDED, JPA.ATTRIBUTE_OVERRIDE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Embedded");
- sb.append(CR);
- sb.append("@AttributeOverride(name=\"FOO\")");
- }
- });
- }
- private IType createTestEmbeddedWithAttributeOverrides() throws Exception {
- this.createAnnotationAndMembers("Embedded", "String name();");
- this.createAnnotationAndMembers("AttributeOverride", "String name();");
- this.createAnnotationAndMembers("AttributeOverrides", "AttributeOverride[] value();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDED, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Embedded");
- sb.append(CR);
- sb.append("@AttributeOverrides(@AttributeOverride(name=\"FOO\"))");
- }
- });
- }
- private IType createTestEmbeddedWithAttributeOverridesEmpty() throws Exception {
- this.createAnnotationAndMembers("Embedded", "String name();");
- this.createAnnotationAndMembers("AttributeOverrides", "AttributeOverride[] value();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDED, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Embedded");
- sb.append(CR);
- sb.append("@AttributeOverrides()");
- }
- });
- }
-
- private IType createTestEmbeddedWith2AttributeOverrides() throws Exception {
- this.createAnnotationAndMembers("Embedded", "String name();");
- this.createAnnotationAndMembers("AttributeOverride", "String name();");
- this.createAnnotationAndMembers("AttributeOverrides", "AttributeOverride[] value();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDED, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Embedded");
- sb.append(CR);
- sb.append("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAR\")})");
- }
- });
- }
-
- private IType createTestEmbeddedWithAttributeOverrideAndAttributeOverrides() throws Exception {
- this.createAnnotationAndMembers("Embedded", "String name();");
- this.createAnnotationAndMembers("AttributeOverride", "String name();");
- this.createAnnotationAndMembers("AttributeOverrides", "AttributeOverride[] value();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDED, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Embedded");
- sb.append(CR);
- sb.append("@AttributeOverride(name=\"FOO\")");
- sb.append(CR);
- sb.append("@AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"BAZ\")})");
- }
- });
- }
-
- private IType createTestTypePublicAttribute() throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" public String foo;");
- sb.append(CR);
- }
- });
- }
-
- private IType createTestTypePackageAttribute() throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" String foo;");
- sb.append(CR);
- }
- });
- }
-
- private IType createTestTypeFinalAttribute() throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" public final String foo;");
- sb.append(CR);
- }
- });
- }
-
- public void testJavaAttributeAnnotations() throws Exception {
- IType testType = this.createTestEntityWithColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- assertEquals(1, attributeResource.annotationsSize());
- }
-
- public void testJavaAttributeAnnotation() throws Exception {
- IType testType = this.createTestEntityWithColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- assertNotNull(attributeResource.getAnnotation(JPA.COLUMN));
- }
-
- public void testJavaAttributeAnnotationNull() throws Exception {
- IType testType = this.createTestEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- assertNull(attributeResource.getAnnotation(JPA.TABLE));
- }
-
- //This will result in a compilation error, but we assume the first column found
- public void testDuplicateAnnotations() throws Exception {
- IType testType = this.createTestEntityMultipleColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- ColumnAnnotation columnResource = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
- assertEquals("FOO", columnResource.getName());
- }
-
- public void testRemoveColumn() throws Exception {
- IType testType = this.createTestEntityWithColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- attributeResource.removeAnnotation(JPA.COLUMN);
-
- assertSourceDoesNotContain("@Column");
- }
-
- public void testRemoveColumnName() throws Exception {
- IType testType = this.createTestEntityWithColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ColumnAnnotation columnResource = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
- columnResource.setTable(null);
- assertSourceContains("@Column(name=\"FOO\")");
-
- columnResource.setName(null);
- assertSourceDoesNotContain("@Column");
-
- assertNull(typeResource.getAnnotation(JPA.TABLE));
- }
-
- public void testMultipleAttributeMappings() throws Exception {
- IType testType = this.createTestEntityWithIdAndBasic();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertEquals(2, attributeResource.mappingAnnotationsSize());
- assertEquals(0, attributeResource.annotationsSize());
- assertNotNull(attributeResource.getMappingAnnotation(JPA.BASIC));
- assertNotNull(attributeResource.getMappingAnnotation(JPA.ID));
-
- JavaResourceNode javaAttributeMappingAnnotation = attributeResource.getMappingAnnotation();
- assertTrue(javaAttributeMappingAnnotation instanceof BasicAnnotation);
- assertSourceContains("@Basic");
- assertSourceContains("@Id");
-
- this.createAnnotationAndMembers("OneToMany", "");
- attributeResource.setMappingAnnotation(JPA.ONE_TO_MANY);
- assertEquals(1, attributeResource.mappingAnnotationsSize());
- javaAttributeMappingAnnotation = attributeResource.getMappingAnnotation();
- assertTrue(javaAttributeMappingAnnotation instanceof OneToManyAnnotation);
- assertSourceDoesNotContain("@Id");
- assertSourceContains("@OneToMany");
- assertSourceDoesNotContain("@Basic");
- }
-
- public void testSetJavaAttributeMappingAnnotation() throws Exception {
- IType testType = createTestType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- assertEquals(0, attributeResource.mappingAnnotationsSize());
-
- this.createAnnotationAndMembers("Id", "");
- attributeResource.setMappingAnnotation(JPA.ID);
- assertTrue(attributeResource.getMappingAnnotation() instanceof IdAnnotation);
- assertSourceContains("@Id");
- }
-
- public void testSetJavaAttributeMappingAnnotation2() throws Exception {
- IType testType = createTestEntityWithColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- assertNull(attributeResource.getMappingAnnotation());
-
- this.createAnnotationAndMembers("Id", "");
- attributeResource.setMappingAnnotation(JPA.ID);
- assertTrue(attributeResource.getMappingAnnotation() instanceof IdAnnotation);
-
- assertSourceContains("@Id");
- assertSourceContains("@Column");
- }
-
- public void testSetJavaAttributeMappingAnnotation3() throws Exception {
- IType testType = createTestEntityWithIdColumnGeneratedValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- assertTrue(attributeResource.getMappingAnnotation() instanceof IdAnnotation);
-
- this.createAnnotationAndMembers("Basic", "");
- attributeResource.setMappingAnnotation(JPA.BASIC);
- assertTrue(attributeResource.getMappingAnnotation() instanceof BasicAnnotation);
-
- assertSourceDoesNotContain("@Id");
- assertSourceContains("@GeneratedValue"); //not supported by Basic
- assertSourceContains("@Column"); //common between Id and Basic
- }
-
- public void testSetJavaAttributeMappingAnnotationNull() throws Exception {
- IType testType = createTestEntityWithIdColumnGeneratedValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- assertTrue(attributeResource.getMappingAnnotation() instanceof IdAnnotation);
-
- attributeResource.setMappingAnnotation(null);
- assertNull(attributeResource.getMappingAnnotation());
-
- assertSourceDoesNotContain("@Id");
- assertSourceContains("@GeneratedValue"); //not supported by Basic
- assertSourceContains("@Column"); //common between Id and Basic
- }
-
- public void testAddJavaAttributeAnnotation() throws Exception {
- IType testType = createTestEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertSourceDoesNotContain("@Column");
- attributeResource.addAnnotation(JPA.COLUMN);
- assertSourceContains("@Column");
- }
-
- public void testRemoveJavaAttributeAnnotation() throws Exception {
- IType testType = createTestEntityAnnotatedField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- assertSourceContains("@Column");
- attributeResource.removeAnnotation(JPA.COLUMN);
- assertSourceDoesNotContain("@Column");
- }
-
- //update source code to change from @Id to @OneToOne and make sure @Column is not removed
- public void testChangeAttributeMappingInSource() throws Exception {
- IType jdtType = createTestEntityAnnotatedField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- final JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- idField().edit(new Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ((IdImpl) attributeResource.getMappingAnnotation()).getDeclarationAnnotationAdapter().removeAnnotation(declaration);
- }
- });
-
- this.createAnnotationAndMembers("OneToOne", "");
- jdtType.getCompilationUnit().createImport("javax.persistence.OneToOne", null, new NullProgressMonitor());
-
- idField().edit(new Editor() {
- public void edit(ModifiedDeclaration declaration) {
- OneToOneImpl.DECLARATION_ANNOTATION_ADAPTER.newMarkerAnnotation(declaration);
- }
- });
-
- assertNotNull(attributeResource.getAnnotation(JPA.COLUMN));
- assertNull(attributeResource.getMappingAnnotation(JPA.ID));
- assertNotNull(attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE));
- assertSourceContains("@Column");
- }
-
- public void testJavaAttributeAnnotationsNestable() throws Exception {
- IType jdtType = createTestEmbeddedWithAttributeOverride();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertEquals(1, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES)));
-
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES).next();
-
- assertEquals("FOO", attributeOverride.getName());
- }
-
- public void testJavaAttributeAnnotationsNoNestable() throws Exception {
- IType jdtType = createTestEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertEquals(0, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES)));
- }
-
- public void testJavaAttributeAnnotationsContainerNoNestable() throws Exception {
- IType jdtType = createTestEmbeddedWithAttributeOverridesEmpty();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertEquals(0, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES)));
- }
-
- public void testJavaAttributeAnnotationsNestableAndContainer() throws Exception {
- IType jdtType = createTestEmbeddedWithAttributeOverrideAndAttributeOverrides();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE));
- assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES));
- assertEquals(2, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES)));
-
- AttributeOverrideAnnotation attributeOverrideResource = (AttributeOverrideAnnotation) attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES).next();
- assertEquals("BAR", attributeOverrideResource.getName());
- }
-
- // -->> @AttributeOverride(name="FOO")
- public void testAddJavaAttributeAnnotationNestableContainer() throws Exception {
- IType jdtType = createTestEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- assertSourceContains("@AttributeOverride(name=\"FOO\")");
- }
-
- // @Embedded -->> @Embedded
- // @AttributeOverride(name="FOO") @AttributeOverrides({@AttributeOverride(name="FOO"), @AttributeOverride(name="BAR")})
- public void testAddJavaAttributeAnnotationNestableContainer2() throws Exception {
- IType jdtType = createTestEmbeddedWithAttributeOverride();
- this.createAnnotationAndMembers("AttributeOverrides", "String name();");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"),@AttributeOverride(name=\"BAR\")})");
-
- assertNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE));
- assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES));
- assertEquals(2, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES)));
- }
-
- // @Embedded
- // @AttributeOverrides(@AttributeOverride(name="FOO"))
- // ||
- // \/
- // @Embedded
- // @AttributeOverrides({@AttributeOverride(name="FOO"), @AttributeOverride(name="BAR")})
- public void testAddJavaAttributeAnnotationNestableContainer3() throws Exception {
- IType jdtType = createTestEmbeddedWithAttributeOverrides();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"),@AttributeOverride(name=\"BAR\")})");
-
- assertNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE));
- assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES));
- assertEquals(2, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES)));
- }
-
- public void testAddJavaAttributeAnnotationNestableContainer5() throws Exception {
- IType jdtType = createTestEmbeddedWithAttributeOverrides();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAR\"),@AttributeOverride(name=\"FOO\")})");
-
- assertNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE));
- assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES));
- assertEquals(2, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES)));
- }
-
- // @Embedded
- // @SecondaryTable(name=\"FOO\")
- // @AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"BAZ\")})
- // ||
- // \/
- // @Embedded
- // @AttributeOverride(name=\"FOO\")
- // @AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"BAZ\"), @AttributeOverride(name=\"BOO\")})
- public void testAddJavaAttributeAnnotationNestableContainer4() throws Exception {
- IType jdtType = createTestEmbeddedWithAttributeOverrideAndAttributeOverrides();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE));
- assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES));
- assertEquals(2, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES)));
-
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(2, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"BAZ\"),");
- assertSourceContains("@AttributeOverride})");
- attributeOverride.setName("BOO");
-
- assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE));
- assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES));
- assertEquals(3, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES)));
-
- Iterator<JavaResourceNode> attributeOverrideAnnotations = attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride = (AttributeOverrideAnnotation) attributeOverrideAnnotations.next();
- assertEquals("BAR", attributeOverride.getName());
- attributeOverride = (AttributeOverrideAnnotation) attributeOverrideAnnotations.next();
- assertEquals("BAZ", attributeOverride.getName());
- attributeOverride = (AttributeOverrideAnnotation) attributeOverrideAnnotations.next();
- assertEquals("BOO", attributeOverride.getName());
-
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"BAZ\"),");
- assertSourceContains("@AttributeOverride(name=\"BOO\")})");
- }
-
- //@Entity
- //@AttributeOverride(name="FOO")
- public void testRemoveJavaAttributeAnnotationNestableContainer() throws Exception {
- IType jdtType = createTestEmbeddedWithAttributeOverride();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
-
- assertSourceDoesNotContain("@AttributeOverride");
- }
-
-
- //@Entity
- //@SecondaryTables(@SecondaryTable(name="FOO"))
- public void testRemoveJavaAttributeAnnotationNestableContainer2() throws Exception {
- IType jdtType = createTestEmbeddedWithAttributeOverrides();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
-
- assertSourceDoesNotContain("@AttributeOverride");
- assertSourceDoesNotContain("@AttributeOverrides");
- }
-
- public void testRemoveJavaAttributeAnnotationIndex() throws Exception {
- IType jdtType = createTestEmbeddedWith2AttributeOverrides();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE , JPA.ATTRIBUTE_OVERRIDES);
-
- assertSourceDoesNotContain("@AttributeOverride(name=\"FOO\"");
- assertSourceContains("@AttributeOverride(name=\"BAR\"");
- assertSourceDoesNotContain("@AttributeOverrides");
- }
-
- public void testRemoveJavaAttributeAnnotationIndex2() throws Exception {
- IType jdtType = createTestEmbeddedWith2AttributeOverrides();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AttributeOverrideAnnotation newAnnotation = (AttributeOverrideAnnotation)attributeResource.addAnnotation(2, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- newAnnotation.setName("BAZ");
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAR\"),");
- assertSourceContains("@AttributeOverride(name=\"BAZ\")})");
-
- attributeResource.removeAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAZ\")})");
- }
-
- public void testMoveJavaTypeAnnotation() throws Exception {
- IType jdtType = createTestEmbeddedWith2AttributeOverrides();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AttributeOverrideAnnotation newAnnotation = (AttributeOverrideAnnotation)attributeResource.addAnnotation(2, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- newAnnotation.setName("BAZ");
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAR\"),");
- assertSourceContains("@AttributeOverride(name=\"BAZ\")})");
-
-
- attributeResource.move(0, 2, JPA.ATTRIBUTE_OVERRIDES);
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAZ\"), @AttributeOverride(name=\"FOO\"),");
- assertSourceContains("@AttributeOverride(name=\"BAR\")})");
- }
-
- public void testMoveJavaTypeAnnotation2() throws Exception {
- IType jdtType = createTestEmbeddedWith2AttributeOverrides();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- AttributeOverrideAnnotation newAnnotation = (AttributeOverrideAnnotation) attributeResource.addAnnotation(2, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- newAnnotation.setName("BAZ");
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAR\"),");
- assertSourceContains("@AttributeOverride(name=\"BAZ\")})");
-
- attributeResource.move(1, 0, JPA.ATTRIBUTE_OVERRIDES);
- assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"FOO\"),");
- assertSourceContains("@AttributeOverride(name=\"BAZ\")})");
- }
-
- //more detailed tests in JPTToolsTests
- public void testIsPersistableField() throws Exception {
- IType jdtType = createTestEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertTrue(attributeResource.isPersistable());
- }
-
- public void testIsPersistableField2() throws Exception {
- IType jdtType = createTestEntityWithNonResolvingField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- Collection<JavaResourcePersistentAttribute> attributes = (Collection<JavaResourcePersistentAttribute>) ClassTools.fieldValue(typeResource, "attributes");
- JavaResourcePersistentAttribute attributeResource = attributes.iterator().next();
-
- assertEquals("foo", attributeResource.getName());
- assertTrue(attributeResource.isForField());
- assertTrue(attributeResource.isPersistable()); //bug 196200 changed this
-
- this.javaProject.createType("test", "Foo.java", "public class Foo {}");
- this.javaResourceModel.resolveTypes();
-
- assertTrue(attributeResource.isPersistable());
- }
-
- public void testGetQualifiedTypeName() throws Exception {
- IType jdtType = createTestEntityWithNonResolvingField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- Collection<JavaResourcePersistentAttribute> attributes = (Collection<JavaResourcePersistentAttribute>) ClassTools.fieldValue(typeResource, "attributes");
- JavaResourcePersistentAttribute attributeResource = attributes.iterator().next();
-
- assertEquals("foo", attributeResource.getName());
- assertEquals("test.Foo", attributeResource.getQualifiedTypeName()); //bug 196200 changed this
-
- this.javaProject.createType("test", "Foo.java", "public class Foo {}");
- this.javaResourceModel.resolveTypes();
-
- assertEquals("test.Foo", attributeResource.getQualifiedTypeName());
- }
-
-
- //more detailed tests in JPTToolsTests
- public void testIsPersistableMethod() throws Exception {
- IType jdtType = createTestEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.properties().next();
-
- assertTrue(attributeResource.isPersistable());
- }
-
- public void testIsPersistableMethod2() throws Exception {
- IType jdtType = createTestEntityWithNonResolvingMethod();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- Collection<JavaResourcePersistentAttribute> attributes = (Collection<JavaResourcePersistentAttribute>) ClassTools.fieldValue(typeResource, "attributes");
- JavaResourcePersistentAttribute attributeResource = (JavaResourcePersistentAttribute) attributes.toArray()[3];
-
- assertEquals("foo", attributeResource.getName());
- assertTrue(attributeResource.isForProperty());
- assertTrue(attributeResource.isPersistable());//bug 196200 changed this
-
- this.javaProject.createType("test", "Foo.java", "public class Foo {}");
- this.javaResourceModel.resolveTypes();
-
- assertTrue(attributeResource.isPersistable());
- }
-
- //this tests that we handle mutliple variable declarations in one line.
- //The annotations should apply to all fields defined. This is not really a useful
- //thing to do with JPA beyond the most basic things that use default column names
- public void testMultipleVariableDeclarationsPerLine() throws Exception {
- IType jdtType = createTestEntityMultipleVariableDeclarationsPerLine();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- assertEquals(4, CollectionTools.size(typeResource.fields()));
- Iterator<JavaResourcePersistentAttribute> fields = typeResource.fields();
- JavaResourcePersistentAttribute attributeResource = fields.next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
- assertEquals("baz", column.getName());
-
- attributeResource = fields.next();
- column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN);
- assertEquals("baz", column.getName());
- }
-
- public void testIsPublic() throws Exception {
- IType jdtType = createTestTypePublicAttribute();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attribute = typeResource.attributes().next();
-
- assertTrue(attribute.isPublic());
- }
-
- public void testIsPublicFalse() throws Exception {
- IType jdtType = createTestTypePackageAttribute();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attribute = typeResource.attributes().next();
-
- assertFalse(attribute.isPublic());
- }
-
- public void testIsFinal() throws Exception {
- IType jdtType = createTestTypeFinalAttribute();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attribute = typeResource.attributes().next();
-
- assertTrue(attribute.isFinal());
- }
-
- public void testIsFinalFalse() throws Exception {
- IType jdtType = createTestTypePackageAttribute();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attribute = typeResource.attributes().next();
-
- assertFalse(attribute.isFinal());
- }
-
- //TODO add tests for JPTTools static methods
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentTypeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentTypeTests.java
deleted file mode 100644
index d45678d60c..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentTypeTests.java
+++ /dev/null
@@ -1,998 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.internal.resource.java.EmbeddableImpl;
-import org.eclipse.jpt.core.internal.resource.java.EntityImpl;
-import org.eclipse.jpt.core.resource.java.AccessType;
-import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation;
-import org.eclipse.jpt.core.resource.java.EntityAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation;
-import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation;
-import org.eclipse.jpt.core.resource.java.TableAnnotation;
-import org.eclipse.jpt.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.core.utility.jdt.Member.Editor;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase {
-
- public JavaResourcePersistentTypeTests(String name) {
- super(name);
- }
-
- private void createEntityAnnotation() throws Exception{
- this.createAnnotationAndMembers("Entity", "String name() default \"\";");
- }
-
- private void createEmbeddableAnnotation() throws Exception{
- this.createAnnotationAndMembers("Embeddable", "");
- }
-
- private void createMappedSuperclassAnnotation() throws Exception{
- this.createAnnotationAndMembers("MappedSuperclass", "");
- }
-
- private void createSecondaryTableAnnotation() throws Exception{
- this.createAnnotationAndMembers("SecondaryTable", "String name();");
- }
-
- private void createSecondaryTablesAnnotation() throws Exception{
- this.createAnnotationAndMembers("SecondaryTables", "");
- }
-
-
- private IType createTestEntity() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private IType createTestInvalidAnnotations() throws Exception {
- this.createAnnotationAndMembers("Foo", "String name();");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>("javax.persistence.Foo");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Foo");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Foo");
- }
- });
- }
-
- private IType createTestEntityWithMemberEmbeddable() throws Exception {
- createEntityAnnotation();
- createEmbeddableAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.EMBEDDABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendMemberTypeTo(StringBuilder sb) {
- sb.append(" @Embeddable");
- sb.append(CR);
- sb.append(" public static class Foo { }").append(CR);
-
- }
- });
- }
-
- private IType createTestEntityDuplicates() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity(name=\"FirstEntity\")").append(CR);
- sb.append("@Entity(name=\"SecondEntity\")");
- }
- });
- }
-
- private IType createTestEntityWithEmbeddable() throws Exception {
- createEntityAnnotation();
- createEmbeddableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.EMBEDDABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append(CR);
- sb.append("@Embeddable");
- }
- });
- }
-
- private IType createTestEntityAnnotatedField() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Id", "");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestEntityAnnotatedMethod() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Id", "");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
- private IType createTestEntityAnnotatedFieldAndMethod() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Id", "");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestEntityAnnotatedNonPersistableMethod() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Id", "");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendGetNameMethodAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- }
- });
- }
-
- private IType createTestEntityAnnotatedPersistableMethodNonPersistableField() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Id", "");
- this.createAnnotationAndMembers("Column", "");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Column");
- sb.append(" private transient int notPersistable;").append(CR);
- sb.append(CR);
-
- }
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("@Column");
- }
- });
- }
- private IType createTestEntityNoPersistableFields() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendMemberTypeTo(StringBuilder sb) {
- sb.delete(sb.indexOf("private int id;"), sb.indexOf("private int id;") + "private int id;".length());
- sb.delete(sb.indexOf("private String name;"), sb.indexOf("private String name;") + "private String name;".length());
- }
- });
- }
-
-// private IType createTestEntityLarge(final int i) throws Exception {
-// return this.createTestType(new DefaultAnnotationWriter() {
-// @Override
-// public Iterator<String> imports() {
-// return new ArrayIterator<String>(JPA.ENTITY + i);
-// }
-// @Override
-// public void appendTypeAnnotationTo(StringBuilder sb) {
-// sb.append("@Entity" + i);
-// sb.append(CR);
-// }
-// @Override
-// public String typeName() {
-// return TYPE_NAME + i;
-// }
-// });
-// }
-//
-// public void testLarge() throws Exception {
-// for (int i = START; i <= END; i++) {
-// this.createAnnotationAndMembers("Entity" +i, "String name();");
-// }
-//
-// List<IType> testTypes = new ArrayList<IType>();
-// for (int i = START; i <= END; i++) {
-// testTypes.add(createTestEntityLarge(i));
-// }
-// long start = System.currentTimeMillis();
-// List<JavaPersistentTypeResource> typeResources = new ArrayList<JavaPersistentTypeResource>();
-// for (int i = 0; i < END; i++) {
-// typeResources.add(buildJavaTypeResource(testTypes.get(i)));
-// }
-// long end = System.currentTimeMillis();
-//
-// System.out.println(end-start + "ms");
-// for (int i = 0; i < END; i++) {
-// assertEquals(1, CollectionTools.size(typeResources.get(i).javaTypeMappingAnnotations()));
-// assertNotNull(typeResources.get(i).javaTypeMappingAnnotation(JPA.ENTITY + (i+1)));
-// }
-//
-//
-//// assertEquals(0, CollectionTools.size(typeResource.javaTypeAnnotations()));
-// }
-
-
-
- private IType createTestEntityWithTable() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Table", "String name(); String schema();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append(CR);
- sb.append("@Table(name=\"FOO\", schema=\"BAR\")");
- }
- });
- }
-
- private IType createTestEntityWithTableAndIdClass() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Table", "String name(); String schema();");
- this.createAnnotationAndMembers("IdClass", "Class value();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.TABLE, JPA.ID_CLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append(CR);
- sb.append("@Table");
- sb.append(CR);
- sb.append("@IdClass");
- }
- });
- }
-
-
- private IType createTestEntityMultipleTables() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("Table", "String name(); String schema();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append(CR);
- sb.append("@Table(name=\"FOO\")");
- sb.append(CR);
- sb.append("@Table(name=\"BAR\")");
- }
- });
- }
-
- private IType createTestEntityWithSecondaryTable() throws Exception {
- createEntityAnnotation();
- createSecondaryTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.SECONDARY_TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append(CR);
- sb.append("@SecondaryTable(name=\"FOO\")");
- }
- });
- }
- private IType createTestEntityWithEmptySecondaryTables() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("SecondaryTable", "String name();");
- this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append(CR);
- sb.append("@SecondaryTables()");
- }
- });
- }
-
- private IType createTestEntityWithSecondaryTables() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("SecondaryTable", "String name();");
- this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append(CR);
- sb.append("@SecondaryTables(@SecondaryTable(name=\"FOO\"))");
- }
- });
- }
-
- private IType createTestEntityWith2SecondaryTables() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("SecondaryTable", "String name();");
- this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append(CR);
- sb.append("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\")})");
- }
- });
- }
-
- private IType createTestEntityWithSecondaryTableAndSecondaryTables() throws Exception {
- createEntityAnnotation();
- this.createAnnotationAndMembers("SecondaryTable", "String name();");
- this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append(CR);
- sb.append("@SecondaryTable(name=\"FOO\")");
- sb.append(CR);
- sb.append("@SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\")})");
- }
- });
- }
-
- private IType createTestEntityWithMemberTypes() throws Exception {
- createEntityAnnotation();
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendMemberTypeTo(StringBuilder sb) {
- sb.append(" static class FooStatic {}").append(CR);
- sb.append(CR);
- sb.append(" class FooNotStatic {}").append(CR);
- sb.append(CR);
- sb.append(" @interface MyAnnotation {}").append(CR);
- sb.append(CR);
- sb.append(" enum MyEnum {}").append(CR);
- }
- });
- }
-
- public void testJavaTypeAnnotations() throws Exception {
- IType testType = this.createTestEntityWithTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- assertEquals(1, typeResource.annotationsSize());
- }
-
- public void testJavaTypeAnnotation() throws Exception {
- IType testType = this.createTestEntityWithTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- assertNotNull(typeResource.getAnnotation(JPA.TABLE));
- }
-
- public void testJavaTypeAnnotationNull() throws Exception {
- IType testType = this.createTestEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- assertNull(typeResource.getAnnotation(JPA.TABLE));
- }
-
- //This will result in a compilation error, but we assume the first table found
- public void testDuplicateAnnotations() throws Exception {
- IType testType = this.createTestEntityMultipleTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- TableAnnotation tableResource = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- assertEquals("FOO", tableResource.getName());
- }
-
- public void testRemoveTable() throws Exception {
- IType testType = this.createTestEntityWithTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- typeResource.removeAnnotation(JPA.TABLE);
-
- assertSourceDoesNotContain("@Table");
- }
-
- public void testRemoveTableName() throws Exception {
- IType testType = this.createTestEntityWithTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- TableAnnotation tableResource = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- tableResource.setSchema(null);
- assertSourceContains("@Table(name=\"FOO\")");
-
- tableResource.setName(null);
- assertSourceDoesNotContain("@Table");
-
- assertNull(typeResource.getAnnotation(JPA.TABLE));
- }
-
- public void testMultipleTypeMappings() throws Exception {
- IType testType = this.createTestEntityWithEmbeddable();
- createMappedSuperclassAnnotation();
-
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- assertEquals(2, typeResource.mappingAnnotationsSize());
- assertEquals(0, typeResource.annotationsSize());
- assertNotNull(typeResource.getMappingAnnotation(JPA.EMBEDDABLE));
- assertNotNull(typeResource.getMappingAnnotation(JPA.ENTITY));
-
- JavaResourceNode javaTypeMappingAnnotation = typeResource.getMappingAnnotation();
- assertTrue(javaTypeMappingAnnotation instanceof EmbeddableAnnotation);
- assertSourceContains("@Entity");
- assertSourceContains("@Embeddable");
-
- typeResource.setMappingAnnotation(JPA.MAPPED_SUPERCLASS);
- assertEquals(1, typeResource.mappingAnnotationsSize());
- javaTypeMappingAnnotation = typeResource.getMappingAnnotation();
- assertTrue(javaTypeMappingAnnotation instanceof MappedSuperclassAnnotation);
- assertSourceDoesNotContain("@Entity");
- assertSourceContains("@MappedSuperclass");
- assertSourceDoesNotContain("@Embeddable");
- }
-
- public void testSetJavaTypeMappingAnnotation() throws Exception {
- createEntityAnnotation();
- IType testType = createTestType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- assertEquals(0, typeResource.mappingAnnotationsSize());
-
- typeResource.setMappingAnnotation(JPA.ENTITY);
- assertTrue(typeResource.getMappingAnnotation() instanceof EntityAnnotation);
- assertSourceContains("@Entity");
- }
-
- public void testSetJavaTypeMappingAnnotation2() throws Exception {
- IType testType = createTestEntityWithTable();
- createEmbeddableAnnotation();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- assertTrue(typeResource.getMappingAnnotation() instanceof EntityAnnotation);
-
- typeResource.setMappingAnnotation(JPA.EMBEDDABLE);
- assertTrue(typeResource.getMappingAnnotation() instanceof EmbeddableAnnotation);
-
- assertSourceDoesNotContain("@Entity");
- assertSourceContains("@Table");
- }
-
- public void testAddJavaTypeAnnotation() throws Exception {
- IType testType = createTestEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- assertSourceDoesNotContain("@Table");
- typeResource.addAnnotation(JPA.TABLE);
-
- assertSourceContains("@Table");
- }
-
- public void testRemoveJavaTypeAnnotation() throws Exception {
- IType testType = createTestEntityWithTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- assertSourceContains("@Table");
- typeResource.removeAnnotation(JPA.TABLE);
- assertSourceDoesNotContain("@Table");
- }
-
- //update source code to change from @Entity to @Embeddable and make sure @Table is not removed
- public void testChangeTypeMappingInSource() throws Exception {
- IType jdtType = createTestEntityWithTable();
- final JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- testType().edit(new Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ((EntityImpl) typeResource.getMappingAnnotation()).getDeclarationAnnotationAdapter().removeAnnotation(declaration);
- }
- });
-
- this.createAnnotationAndMembers("Embeddable", "String name();");
- jdtType.getCompilationUnit().createImport("javax.persistence.Embeddable", null, new NullProgressMonitor());
-
- testType().edit(new Editor() {
- public void edit(ModifiedDeclaration declaration) {
- EmbeddableImpl.DECLARATION_ANNOTATION_ADAPTER.newMarkerAnnotation(declaration);
- }
- });
-
- assertNotNull(typeResource.getAnnotation(JPA.TABLE));
- assertNull(typeResource.getMappingAnnotation(JPA.ENTITY));
- assertNotNull(typeResource.getMappingAnnotation(JPA.EMBEDDABLE));
- assertSourceContains("@Table");
- }
-
- public void testJavaTypeAnnotationsNestable() throws Exception {
- IType jdtType = createTestEntityWithSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- assertEquals(1, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
-
- SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next();
-
- assertEquals("FOO", secondaryTableResource.getName());
- }
-
- public void testJavaTypeAnnotationsNoNestable() throws Exception {
- IType jdtType = createTestEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- assertEquals(0, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
- }
-
- public void testJavaTypeAnnotationsContainerNoNestable() throws Exception {
- IType jdtType = createTestEntityWithEmptySecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- assertEquals(0, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
- }
-
- public void testJavaTypeAnnotationsNestableAndContainer() throws Exception {
- IType jdtType = createTestEntityWithSecondaryTableAndSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE));
- assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES));
- assertEquals(2, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
-
- SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next();
- assertEquals("BAR", secondaryTableResource.getName());
- }
-
- // @Entity -->> @Entity
- // @SecondaryTable(name="FOO")
- public void testAddJavaTypeAnnotationNestableContainer() throws Exception {
- IType jdtType = createTestEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTableResource.setName("FOO");
- assertSourceContains("@SecondaryTable(name=\"FOO\")");
- }
-
- // @Entity -->> @Entity
- // @SecondaryTable(name="FOO") @SecondaryTables({@SecondaryTable(name="FOO"), @SecondaryTable(name="BAR")})
- public void testAddJavaTypeAnnotationNestableContainer2() throws Exception {
- IType jdtType = createTestEntityWithSecondaryTable();
- createSecondaryTablesAnnotation();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTableResource.setName("BAR");
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"),@SecondaryTable(name=\"BAR\")})");
-
- assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE));
- assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES));
- assertEquals(2, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
- }
-
- // @Entity
- // @SecondaryTables(@SecondaryTable(name="FOO"))
- // ||
- // \/
- // @Entity
- // @SecondaryTables({@SecondaryTable(name="FOO"), @SecondaryTable(name="BAR")})
- public void testAddJavaTypeAnnotationNestableContainer3() throws Exception {
- IType jdtType = createTestEntityWithSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTableResource.setName("BAR");
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"),@SecondaryTable(name=\"BAR\")})");
-
- assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE));
- assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES));
- assertEquals(2, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
- }
-
- public void testAddJavaTypeAnnotationNestableContainer5() throws Exception {
- IType jdtType = createTestEntityWithSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTableResource.setName("BAR");
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"),@SecondaryTable(name=\"FOO\")})");
-
- assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE));
- assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES));
- assertEquals(2, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
- }
-
- public void testAddJavaTypeAnnotationNestableContainer6() throws Exception {
- IType jdtType = createTestEntityWithSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTableResource.setName("BAR");
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"),@SecondaryTable(name=\"FOO\")})");
-
- assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE));
- assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES));
- assertEquals(2, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
-
- secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTableResource.setName("BAZ");
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAZ\"),@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"FOO\")})");
-
- assertEquals(3, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
- }
-
- // @Entity
- // @SecondaryTable(name=\"FOO\")
- // @SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\")})
- // ||
- // \/
- // @Entity
- // @SecondaryTable(name=\"FOO\")
- // @SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\"), @SecondaryTable(name=\"BOO\")})
- public void testAddJavaTypeAnnotationNestableContainer4() throws Exception {
- IType jdtType = createTestEntityWithSecondaryTableAndSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE));
- assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES));
- assertEquals(2, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
-
- SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(2, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\"), @SecondaryTable})");
- secondaryTableResource.setName("BOO");
-
- assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE));
- assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES));
- assertEquals(3, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
-
- Iterator<JavaResourceNode> secondaryTableAnnotations = typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTableResource = (SecondaryTableAnnotation) secondaryTableAnnotations.next();
- assertEquals("BAR", secondaryTableResource.getName());
- secondaryTableResource = (SecondaryTableAnnotation) secondaryTableAnnotations.next();
- assertEquals("BAZ", secondaryTableResource.getName());
- secondaryTableResource = (SecondaryTableAnnotation) secondaryTableAnnotations.next();
- assertEquals("BOO", secondaryTableResource.getName());
-
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\"), @SecondaryTable(name=\"BOO\")})");
- }
-
- //@Entity
- //@SecondaryTable(name="FOO")
- public void testRemoveJavaTypeAnnotationNestableContainer() throws Exception {
- IType jdtType = createTestEntityWithSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- typeResource.removeAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
-
- assertSourceDoesNotContain("@SecondaryTable");
- }
-
-
- //@Entity
- //@SecondaryTables(@SecondaryTable(name="FOO"))
- public void testRemoveJavaTypeAnnotationNestableContainer2() throws Exception {
- IType jdtType = createTestEntityWithSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- typeResource.removeAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
-
- assertSourceDoesNotContain("@SecondaryTable");
- assertSourceDoesNotContain("@SecondaryTables");
- }
-
- public void testRemoveJavaTypeAnnotationIndex() throws Exception {
- IType jdtType = createTestEntityWith2SecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- typeResource.removeAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
-
- assertSourceDoesNotContain("@SecondaryTable(name=\"FOO\"");
- assertSourceContains("@SecondaryTable(name=\"BAR\"");
- assertSourceDoesNotContain("@SecondaryTables");
- }
-
- public void testRemoveJavaTypeAnnotationIndex2() throws Exception {
- IType jdtType = createTestEntityWith2SecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- SecondaryTableAnnotation newAnnotation = (SecondaryTableAnnotation)typeResource.addAnnotation(2, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- newAnnotation.setName("BAZ");
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\")})");
-
- typeResource.removeAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAZ\")})");
- }
-
- public void testMoveJavaTypeAnnotation() throws Exception {
- IType jdtType = createTestEntityWith2SecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- SecondaryTableAnnotation newAnnotation = (SecondaryTableAnnotation)typeResource.addAnnotation(2, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- newAnnotation.setName("BAZ");
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\")})");
-
- typeResource.move(0, 2, JPA.SECONDARY_TABLES);
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAZ\"), @SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\")})");
- }
-
- public void testMoveJavaTypeAnnotation2() throws Exception {
- IType jdtType = createTestEntityWith2SecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- SecondaryTableAnnotation newAnnotation = (SecondaryTableAnnotation)typeResource.addAnnotation(2, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- newAnnotation.setName("BAZ");
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\")})");
-
- typeResource.move(2, 0, JPA.SECONDARY_TABLES);
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\"), @SecondaryTable(name=\"FOO\")})");
- }
-
- public void testNestedTypes() throws Exception {
- IType jdtType = createTestEntityWithMemberTypes();
- JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType);
-
- assertEquals("only persistable types should be returned by nestedTypes()", 1, CollectionTools.size(persistentType.nestedTypes()));
-
- List<JavaResourcePersistentType> nestedTypes = (List<JavaResourcePersistentType>) ClassTools.fieldValue(persistentType, "nestedTypes");
-
- assertEquals(4, CollectionTools.size(nestedTypes));
-
- }
-
- public void testDuplicateEntityAnnotations() throws Exception {
- IType jdtType = createTestEntityDuplicates();
- JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType);
-
- EntityAnnotation javaTypeMappingAnnotation = (EntityAnnotation) persistentType.getMappingAnnotation(JPA.ENTITY);
- assertEquals("FirstEntity", javaTypeMappingAnnotation.getName());
-
- assertEquals(1, persistentType.mappingAnnotationsSize());
-
- javaTypeMappingAnnotation = (EntityAnnotation) persistentType.getMappingAnnotation();
- assertEquals("FirstEntity", javaTypeMappingAnnotation.getName());
-
- }
-
-
- public void testAttributes() throws Exception {
-
- }
-
- public void testFields() throws Exception {
-
- }
-
- public void testProperties() throws Exception {
-
- }
-
- public void testGetAccessNoAttributesAnnotated() throws Exception {
- IType jdtType = createTestEntity();
- JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType);
-
- assertNull(persistentType.getAccess());
- }
-
- public void testGetAccessFieldsAnnotated() throws Exception {
- IType jdtType = createTestEntityAnnotatedField();
- JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType);
-
- assertEquals(AccessType.FIELD, persistentType.getAccess());
- }
-
- public void testGetAccessMethodsAnnotated() throws Exception {
- IType jdtType = createTestEntityAnnotatedMethod();
- JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType);
-
- assertEquals(AccessType.PROPERTY, persistentType.getAccess());
- }
-
- public void testGetAccessFieldsAndMethodsAnnotated() throws Exception {
- IType jdtType = createTestEntityAnnotatedFieldAndMethod();
- JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType);
-
- assertEquals(AccessType.FIELD, persistentType.getAccess());
- }
-
- public void testGetAccessNonPersistableMethodAnnotated() throws Exception {
- IType jdtType = createTestEntityAnnotatedNonPersistableMethod();
- JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType);
-
- assertNull(persistentType.getAccess());
- }
-
- public void testGetAccessPersistableMethodAndNonPersistableFieldAnnotated() throws Exception {
- IType jdtType = createTestEntityAnnotatedPersistableMethodNonPersistableField();
- JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType);
-
- assertEquals(AccessType.PROPERTY, persistentType.getAccess());
- }
-
- public void testGetAccessNoPersistableFieldsAnnotated() throws Exception {
- IType jdtType = createTestEntityNoPersistableFields();
- JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType);
-
- assertEquals(AccessType.PROPERTY, persistentType.getAccess());
- }
-
- //TODO more tests here with superclasses other than Object.
- //1. Test where the superclass does not resolve
- //2. Test a superclass that does resolve
- //3. What about a superclass that is a class file in a jar??
- //4.
- public void testGetSuperclassQualifiedName() throws Exception {
- IType jdtType = createTestEntity();
- JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType);
-
- assertEquals("java.lang.Object", persistentType.getSuperClassQualifiedName());
-
- }
-
- //more detailed tests in JPTToolsTests
- public void testIsPersistable() throws Exception {
- IType jdtType = createTestEntity();
- JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType);
-
- assertTrue(persistentType.isPersistable());
- }
-
- public void testAnnotatedMemberType() throws Exception {
- IType testType = this.createTestEntityWithMemberEmbeddable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- assertNotNull(typeResource.getMappingAnnotation(JPA.ENTITY));
- assertNull(typeResource.getMappingAnnotation(JPA.EMBEDDABLE));
-
- JavaResourcePersistentType nestedType = typeResource.nestedTypes().next();
- assertNull(nestedType.getMappingAnnotation(JPA.ENTITY));
- assertNotNull(nestedType.getMappingAnnotation(JPA.EMBEDDABLE));
- }
-
- public void testInvalidAnnotations() throws Exception {
- IType testType = this.createTestInvalidAnnotations();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- assertEquals(0, typeResource.mappingAnnotationsSize());
- assertEquals(0, typeResource.annotationsSize());
-
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- assertEquals(0, attributeResource.mappingAnnotationsSize());
- assertEquals(0, attributeResource.annotationsSize());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnTests.java
deleted file mode 100644
index 6f809b64c2..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnTests.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JoinColumnTests extends JavaResourceModelTestCase {
-
- private static final String COLUMN_NAME = "MY_COLUMN";
- private static final String COLUMN_TABLE = "MY_TABLE";
- private static final String COLUMN_COLUMN_DEFINITION = "COLUMN_DEFINITION";
- private static final String COLUMN_REFERENCED_COLUMN_NAME = "MY_REF_COLUMN_NAME";
-
- public JoinColumnTests(String name) {
- super(name);
- }
-
- private void createJoinColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("JoinColumn",
- "String name() default \"\"; " +
- "String referencedColumnName() default \"\"; " +
- "boolean unique() default false; " +
- "boolean nullable() default true; " +
- "boolean insertable() default true; " +
- "boolean updatable() default true; " +
- "String columnDefinition() default \"\"; " +
- "String table() default \"\"; ");
- }
-
- private IType createTestJoinColumn() throws Exception {
- createJoinColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumn");
- }
- });
- }
-
- private IType createTestJoinColumnWithName() throws Exception {
- createJoinColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumn(name=\"" + COLUMN_NAME + "\")");
- }
- });
- }
-
- private IType createTestJoinColumnWithTable() throws Exception {
- createJoinColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumn(table=\"" + COLUMN_TABLE + "\")");
- }
- });
- }
-
- private IType createTestJoinColumnWithReferencedColumnName() throws Exception {
- createJoinColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumn(referencedColumnName=\"" + COLUMN_REFERENCED_COLUMN_NAME + "\")");
- }
- });
- }
-
- private IType createTestJoinColumnWithColumnDefinition() throws Exception {
- createJoinColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumn(columnDefinition=\"" + COLUMN_COLUMN_DEFINITION + "\")");
- }
- });
- }
-
- private IType createTestJoinColumnWithBooleanElement(final String booleanElement) throws Exception {
- createJoinColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumn(" + booleanElement + "=true)");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestJoinColumnWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
- assertNotNull(column);
- assertEquals(COLUMN_NAME, column.getName());
- }
-
- public void testGetNull() throws Exception {
- IType testType = this.createTestJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
- assertNotNull(column);
- assertNull(column.getName());
- assertNull(column.getNullable());
- assertNull(column.getInsertable());
- assertNull(column.getUnique());
- assertNull(column.getUpdatable());
- assertNull(column.getTable());
- assertNull(column.getReferencedColumnName());
- assertNull(column.getColumnDefinition());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getName());
-
- column.setName("Foo");
- assertEquals("Foo", column.getName());
-
- assertSourceContains("@JoinColumn(name=\"Foo\")");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestJoinColumnWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertEquals(COLUMN_NAME, column.getName());
-
- column.setName(null);
- assertNull(column.getName());
-
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetTable() throws Exception {
- IType testType = this.createTestJoinColumnWithTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
- assertEquals(COLUMN_TABLE, column.getTable());
- }
-
- public void testSetTable() throws Exception {
- IType testType = this.createTestJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getTable());
-
- column.setTable("Foo");
- assertEquals("Foo", column.getTable());
-
- assertSourceContains("@JoinColumn(table=\"Foo\")");
-
-
- column.setTable(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetReferencedColumnName() throws Exception {
- IType testType = this.createTestJoinColumnWithReferencedColumnName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
- assertEquals(COLUMN_REFERENCED_COLUMN_NAME, column.getReferencedColumnName());
- }
-
- public void testSetReferencedColumnName() throws Exception {
- IType testType = this.createTestJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getReferencedColumnName());
-
- column.setReferencedColumnName("Foo");
- assertEquals("Foo", column.getReferencedColumnName());
-
- assertSourceContains("@JoinColumn(referencedColumnName=\"Foo\")");
-
-
- column.setReferencedColumnName(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetColumnDefinition() throws Exception {
- IType testType = this.createTestJoinColumnWithColumnDefinition();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
- assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition());
- }
-
- public void testSetColumnDefinition() throws Exception {
- IType testType = this.createTestJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getColumnDefinition());
-
- column.setColumnDefinition("Foo");
- assertEquals("Foo", column.getColumnDefinition());
-
- assertSourceContains("@JoinColumn(columnDefinition=\"Foo\")");
-
-
- column.setColumnDefinition(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetUnique() throws Exception {
- IType testType = this.createTestJoinColumnWithBooleanElement("unique");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertTrue(column.getUnique());
- }
-
- public void testSetUnique() throws Exception {
- IType testType = this.createTestJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getUnique());
-
- column.setUnique(false);
- assertFalse(column.getUnique());
-
- assertSourceContains("@JoinColumn(unique=false)");
-
- column.setUnique(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetNullable() throws Exception {
- IType testType = this.createTestJoinColumnWithBooleanElement("nullable");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertTrue(column.getNullable());
- }
-
- public void testSetNullable() throws Exception {
- IType testType = this.createTestJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getNullable());
-
- column.setNullable(false);
- assertFalse(column.getNullable());
-
- assertSourceContains("@JoinColumn(nullable=false)");
-
- column.setNullable(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetInsertable() throws Exception {
- IType testType = this.createTestJoinColumnWithBooleanElement("insertable");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertTrue(column.getInsertable());
- }
-
- public void testSetInsertable() throws Exception {
- IType testType = this.createTestJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getInsertable());
-
- column.setInsertable(false);
- assertFalse(column.getInsertable());
-
- assertSourceContains("@JoinColumn(insertable=false)");
-
- column.setInsertable(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetUpdatable() throws Exception {
- IType testType = this.createTestJoinColumnWithBooleanElement("updatable");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertTrue(column.getUpdatable());
- }
-
- public void testSetUpdatable() throws Exception {
- IType testType = this.createTestJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getUpdatable());
-
- column.setUpdatable(false);
- assertFalse(column.getUpdatable());
-
- assertSourceContains("@JoinColumn(updatable=false)");
-
- column.setUpdatable(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnsTests.java
deleted file mode 100644
index b5016a6344..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnsTests.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JoinColumnsTests extends JavaResourceModelTestCase {
-
- private static final String COLUMN_NAME = "MY_COLUMN";
- private static final String COLUMN_TABLE = "MY_TABLE";
- private static final String COLUMN_COLUMN_DEFINITION = "COLUMN_DEFINITION";
- private static final String COLUMN_REFERENCED_COLUMN_NAME = "MY_REF_COLUMN_NAME";
-
- public JoinColumnsTests(String name) {
- super(name);
- }
-
- private void createJoinColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("JoinColumn",
- "String name() default \"\"; " +
- "String referencedColumnName() default \"\"; " +
- "boolean unique() default false; " +
- "boolean nullable() default true; " +
- "boolean insertable() default true; " +
- "boolean updatable() default true; " +
- "String columnDefinition() default \"\"; " +
- "String table() default \"\"; ");
- }
-
- private void createJoinColumnsAnnotation() throws Exception {
- createJoinColumnAnnotation();
- this.createAnnotationAndMembers("JoinColumns",
- "JoinColumn[] value();");
- }
-
- private IType createTestJoinColumns() throws Exception {
- createJoinColumnsAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumns(@JoinColumn)");
- }
- });
- }
-
- private IType createTestJoinColumnWithName() throws Exception {
- createJoinColumnsAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumns(@JoinColumn(name=\"" + COLUMN_NAME + "\"))");
- }
- });
- }
-
- private IType createTestJoinColumnWithTable() throws Exception {
- createJoinColumnsAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumns(@JoinColumn(table=\"" + COLUMN_TABLE + "\"))");
- }
- });
- }
-
- private IType createTestJoinColumnWithReferencedColumnName() throws Exception {
- createJoinColumnsAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumns(@JoinColumn(referencedColumnName=\"" + COLUMN_REFERENCED_COLUMN_NAME + "\"))");
- }
- });
- }
-
- private IType createTestJoinColumnWithColumnDefinition() throws Exception {
- createJoinColumnsAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumns(@JoinColumn(columnDefinition=\"" + COLUMN_COLUMN_DEFINITION + "\"))");
- }
- });
- }
-
- private IType createTestJoinColumnWithBooleanElement(final String booleanElement) throws Exception {
- createJoinColumnsAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumns(@JoinColumn(" + booleanElement + "=true))");
- }
- });
- }
-
- private IType createTestJoinColumn() throws Exception {
- createJoinColumnsAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\")");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestJoinColumnWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
- assertNotNull(column);
- assertEquals(COLUMN_NAME, column.getName());
- }
-
- public void testGetNull() throws Exception {
- IType testType = this.createTestJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
- assertNotNull(column);
- assertNull(column.getName());
- assertNull(column.getNullable());
- assertNull(column.getInsertable());
- assertNull(column.getUnique());
- assertNull(column.getUpdatable());
- assertNull(column.getTable());
- assertNull(column.getColumnDefinition());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertNotNull(column);
- assertNull(column.getName());
-
- column.setName("Foo");
- assertEquals("Foo", column.getName());
-
- assertSourceContains("@JoinColumns(@JoinColumn(name=\"Foo\"))");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestJoinColumnWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertEquals(COLUMN_NAME, column.getName());
-
- column.setName(null);
- assertNull(column.getName());
-
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetTable() throws Exception {
- IType testType = this.createTestJoinColumnWithTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
- assertEquals(COLUMN_TABLE, column.getTable());
- }
-
- public void testSetTable() throws Exception {
- IType testType = this.createTestJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertNotNull(column);
- assertNull(column.getTable());
-
- column.setTable("Foo");
- assertEquals("Foo", column.getTable());
-
- assertSourceContains("@JoinColumns(@JoinColumn(table=\"Foo\"))");
-
-
- column.setTable(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetReferencedColumnName() throws Exception {
- IType testType = this.createTestJoinColumnWithReferencedColumnName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
- assertEquals(COLUMN_REFERENCED_COLUMN_NAME, column.getReferencedColumnName());
- }
-
- public void testSetReferencedColumnName() throws Exception {
- IType testType = this.createTestJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertNotNull(column);
- assertNull(column.getReferencedColumnName());
-
- column.setReferencedColumnName("Foo");
- assertEquals("Foo", column.getReferencedColumnName());
-
- assertSourceContains("@JoinColumns(@JoinColumn(referencedColumnName=\"Foo\"))");
-
-
- column.setReferencedColumnName(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetColumnDefinition() throws Exception {
- IType testType = this.createTestJoinColumnWithColumnDefinition();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
- assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition());
- }
-
- public void testSetColumnDefinition() throws Exception {
- IType testType = this.createTestJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertNotNull(column);
- assertNull(column.getColumnDefinition());
-
- column.setColumnDefinition("Foo");
- assertEquals("Foo", column.getColumnDefinition());
-
- assertSourceContains("@JoinColumns(@JoinColumn(columnDefinition=\"Foo\"))");
-
-
- column.setColumnDefinition(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetUnique() throws Exception {
- IType testType = this.createTestJoinColumnWithBooleanElement("unique");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertTrue(column.getUnique());
- }
-
- public void testSetUnique() throws Exception {
- IType testType = this.createTestJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertNotNull(column);
- assertNull(column.getUnique());
-
- column.setUnique(false);
- assertFalse(column.getUnique());
-
- assertSourceContains("@JoinColumns(@JoinColumn(unique=false))");
-
- column.setUnique(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetNullable() throws Exception {
- IType testType = this.createTestJoinColumnWithBooleanElement("nullable");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertTrue(column.getNullable());
- }
-
- public void testSetNullable() throws Exception {
- IType testType = this.createTestJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertNotNull(column);
- assertNull(column.getNullable());
-
- column.setNullable(false);
- assertFalse(column.getNullable());
-
- assertSourceContains("@JoinColumns(@JoinColumn(nullable=false))");
-
- column.setNullable(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetInsertable() throws Exception {
- IType testType = this.createTestJoinColumnWithBooleanElement("insertable");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertTrue(column.getInsertable());
- }
-
- public void testSetInsertable() throws Exception {
- IType testType = this.createTestJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertNotNull(column);
- assertNull(column.getInsertable());
-
- column.setInsertable(false);
- assertFalse(column.getInsertable());
-
- assertSourceContains("@JoinColumns(@JoinColumn(insertable=false))");
-
- column.setInsertable(null);
- assertSourceDoesNotContain("@JoinColumn");
- }
-
- public void testGetUpdatable() throws Exception {
- IType testType = this.createTestJoinColumnWithBooleanElement("updatable");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertTrue(column.getUpdatable());
- }
-
- public void testSetUpdatable() throws Exception {
- IType testType = this.createTestJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next();
-
- assertNotNull(column);
- assertNull(column.getUpdatable());
-
- column.setUpdatable(false);
- assertFalse(column.getUpdatable());
-
- assertSourceContains("@JoinColumns(@JoinColumn(updatable=false))");
-
- column.setUpdatable(null);
- assertSourceDoesNotContain("@JoinColumn");
- assertSourceDoesNotContain("@JoinColumns");
- }
-
-
- public void testAddJoinColumnCopyExisting() throws Exception {
- IType jdtType = createTestJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinColumnAnnotation joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(1, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- joinColumn.setName("FOO");
- assertSourceContains("@JoinColumns({@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\"),@JoinColumn(name=\"FOO\")})");
-
- assertNull(attributeResource.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(attributeResource.getAnnotation(JPA.JOIN_COLUMNS));
- assertEquals(2, CollectionTools.size(attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS)));
- }
-
- public void testAddJoinColumnToBeginningOfList() throws Exception {
- IType jdtType = createTestJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinColumnAnnotation joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(1, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- joinColumn.setName("FOO");
- assertSourceContains("@JoinColumns({@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\"),@JoinColumn(name=\"FOO\")})");
-
- joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- joinColumn.setName("BAZ");
- assertSourceContains("@JoinColumns({@JoinColumn(name=\"BAZ\"),@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\"), @JoinColumn(name=\"FOO\")})");
-
- Iterator<JavaResourceNode> joinColumns = attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- assertEquals("BAZ", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("BAR", ((JoinColumnAnnotation) joinColumns.next()).getName());
- assertEquals("FOO", ((JoinColumnAnnotation) joinColumns.next()).getName());
-
- assertNull(attributeResource.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(attributeResource.getAnnotation(JPA.JOIN_COLUMNS));
- assertEquals(3, CollectionTools.size(attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS)));
- }
-
-
- public void testRemoveJoinColumnCopyExisting() throws Exception {
- IType jdtType = createTestJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinColumnAnnotation joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(1, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- joinColumn.setName("FOO");
- assertSourceContains("@JoinColumns({@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\"),@JoinColumn(name=\"FOO\")})");
-
- attributeResource.removeAnnotation(1, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS);
- assertSourceContains("@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\")");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinTableTests.java
deleted file mode 100644
index 167e5eb386..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinTableTests.java
+++ /dev/null
@@ -1,686 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JoinTableTests extends JavaResourceModelTestCase {
-
- private static final String TABLE_NAME = "MY_TABLE";
- private static final String SCHEMA_NAME = "MY_SCHEMA";
- private static final String CATALOG_NAME = "MY_CATALOG";
-
- public JoinTableTests(String name) {
- super(name);
- }
-
- private void createJoinColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name() default \"\";" +
- "String referencedColumnName() default \"\";" +
- "boolean unique() default false;" +
- "boolean nullable() default true;" +
- "boolean insertable() default true;" +
- "boolean updatable() default true;" +
- "String columnDefinition() default \"\";" +
- "String table() default \"\";");
-
- }
-
- private void createUniqueConstraintAnnotation() throws Exception {
- this.createAnnotationAndMembers("UniqueConstraint", "String[] columnNames();");
- }
-
- private void createJoinTableAnnotation() throws Exception {
- createJoinColumnAnnotation();
- createUniqueConstraintAnnotation();
- this.createAnnotationAndMembers("JoinTable", "String name() default \"\"; String catalog() default \"\"; String schema() default \"\";JoinColumn[] joinColumns() default {}; JoinColumn[] inverseJoinColumns() default {}; UniqueConstraint[] uniqueConstraints() default {};");
- }
-
- private IType createTestJoinTable() throws Exception {
- createJoinTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_TABLE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinTable");
- }
- });
- }
-
- private IType createTestJoinTableWithName() throws Exception {
- createJoinTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_TABLE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinTable(name=\"" + TABLE_NAME + "\")");
- }
- });
- }
-
- private IType createTestJoinTableWithSchema() throws Exception {
- createJoinTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_TABLE);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinTable(schema=\"" + SCHEMA_NAME + "\")");
- }
- });
- }
-
- private IType createTestJoinTableWithCatalog() throws Exception {
- createJoinTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_TABLE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinTable(catalog=\"" + CATALOG_NAME + "\")");
- }
- });
- }
-
- private IType createTestJoinTableWithUniqueConstraints() throws Exception {
- createJoinTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_TABLE, JPA.UNIQUE_CONSTRAINT);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"})})");
- }
- });
- }
-
- private IType createTestJoinTableWithJoinColumns() throws Exception {
- createJoinTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_TABLE, JPA.JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinTable(joinColumns={@JoinColumn(name=\"BAR\"), @JoinColumn})");
- }
- });
- }
-
- private IType createTestJoinTableWithInverseJoinColumns() throws Exception {
- createJoinTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.JOIN_TABLE, JPA.JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"BAR\"), @JoinColumn})");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestJoinTableWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertNotNull(table);
- assertEquals(TABLE_NAME, table.getName());
- }
-
- public void testGetNull() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertNotNull(table);
- assertNull(table.getName());
- assertNull(table.getCatalog());
- assertNull(table.getSchema());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertNotNull(table);
- assertNull(table.getName());
-
- table.setName("Foo");
- assertEquals("Foo", table.getName());
-
- assertSourceContains("@JoinTable(name=\"Foo\")");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestJoinTableWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertEquals(TABLE_NAME, table.getName());
-
- table.setName(null);
- assertNull(table.getName());
-
- assertSourceDoesNotContain("@JoinTable");
- }
-
- public void testGetCatalog() throws Exception {
- IType testType = this.createTestJoinTableWithCatalog();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertNotNull(table);
- assertEquals(CATALOG_NAME, table.getCatalog());
- }
-
- public void testSetCatalog() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertNotNull(table);
- assertNull(table.getCatalog());
-
- table.setCatalog("Foo");
- assertEquals("Foo", table.getCatalog());
-
- assertSourceContains("@JoinTable(catalog=\"Foo\")");
- }
-
- public void testSetCatalogNull() throws Exception {
- IType testType = this.createTestJoinTableWithCatalog();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertEquals(CATALOG_NAME, table.getCatalog());
-
- table.setCatalog(null);
- assertNull(table.getCatalog());
-
- assertSourceDoesNotContain("@JoinTable");
- }
-
- public void testGetSchema() throws Exception {
- IType testType = this.createTestJoinTableWithSchema();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertNotNull(table);
- assertEquals(SCHEMA_NAME, table.getSchema());
- }
-
- public void testSetSchema() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertNotNull(table);
- assertNull(table.getSchema());
-
- table.setSchema("Foo");
- assertEquals("Foo", table.getSchema());
-
- assertSourceContains("@JoinTable(schema=\"Foo\")");
- }
-
- public void testSetSchemaNull() throws Exception {
- IType testType = this.createTestJoinTableWithSchema();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertEquals(SCHEMA_NAME, table.getSchema());
-
- table.setSchema(null);
- assertNull(table.getSchema());
-
- assertSourceDoesNotContain("@JoinTable");
- }
-
- public void testUniqueConstraints() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
- assertEquals(0, table.uniqueConstraintsSize());
- }
-
- public void testUniqueConstraints2() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
-
- table.addUniqueConstraint(0);
- table.addUniqueConstraint(1);
-
- assertEquals(2, table.uniqueConstraintsSize());
- }
-
- public void testUniqueConstraints3() throws Exception {
- IType testType = this.createTestJoinTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
- assertEquals(3, table.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
- table.addUniqueConstraint(0).addColumnName("FOO");
- table.addUniqueConstraint(1);
- table.addUniqueConstraint(0).addColumnName("BAR");
-
- assertEquals("BAR", table.uniqueConstraintAt(0).columnNames().next());
- assertEquals("FOO", table.uniqueConstraintAt(1).columnNames().next());
- assertEquals(0, table.uniqueConstraintAt(2).columnNamesSize());
-
- assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint})");
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- IType testType = this.createTestJoinTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertEquals("BAR", table.uniqueConstraintAt(0).columnNames().next());
- assertEquals("FOO", table.uniqueConstraintAt(1).columnNames().next());
- assertEquals("BAZ", table.uniqueConstraintAt(2).columnNames().next());
- assertEquals(3, table.uniqueConstraintsSize());
-
- table.removeUniqueConstraint(1);
- assertEquals("BAR", table.uniqueConstraintAt(0).columnNames().next());
- assertEquals("BAZ", table.uniqueConstraintAt(1).columnNames().next());
- assertEquals(2, table.uniqueConstraintsSize());
- assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"BAZ\"})})");
-
- table.removeUniqueConstraint(0);
- assertEquals("BAZ", table.uniqueConstraintAt(0).columnNames().next());
- assertEquals(1, table.uniqueConstraintsSize());
- assertSourceContains("@JoinTable(uniqueConstraints=@UniqueConstraint(columnNames={\"BAZ\"}))");
-
- table.removeUniqueConstraint(0);
- assertEquals(0, table.uniqueConstraintsSize());
- assertSourceDoesNotContain("@JoinTable");
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- IType testType = this.createTestJoinTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"})})");
-
- table.moveUniqueConstraint(2, 0);
- assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"})})");
- }
-
- public void testMoveUniqueConstraint2() throws Exception {
- IType testType = this.createTestJoinTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"})})");
-
- table.moveUniqueConstraint(0, 2);
- assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"})})");
- }
-
- public void testJoinColumns() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
- assertEquals(0, table.joinColumnsSize());
- }
-
- public void testJoinColumns2() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
-
- table.addJoinColumn(0);
- table.addJoinColumn(1);
-
- assertEquals(2, table.joinColumnsSize());
- }
-
- public void testJoinColumns3() throws Exception {
- IType testType = this.createTestJoinTableWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
- assertEquals(2, table.joinColumnsSize());
- }
-
- public void testAddJoinColumn() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
- table.addJoinColumn(0).setName("FOO");
- table.addJoinColumn(1);
- table.addJoinColumn(0).setName("BAR");
-
- assertEquals("BAR", table.joinColumnAt(0).getName());
- assertEquals("FOO", table.joinColumnAt(1).getName());
- assertNull(table.joinColumnAt(2).getName());
- assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"BAR\"),@JoinColumn(name=\"FOO\"), @JoinColumn})");
- }
-
- public void testRemoveJoinColumn() throws Exception {
- IType testType = this.createTestJoinTableWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- table.addJoinColumn(0).setName("FOO");
-
- assertEquals("FOO", table.joinColumnAt(0).getName());
- assertEquals("BAR", table.joinColumnAt(1).getName());
- assertNull(table.joinColumnAt(2).getName());
- assertEquals(3, table.joinColumnsSize());
-
- table.removeJoinColumn(1);
- assertEquals("FOO", table.joinColumnAt(0).getName());
- assertNull(table.joinColumnAt(1).getName());
- assertEquals(2, table.joinColumnsSize());
- assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn})");
-
- table.removeJoinColumn(0);
- assertNull(table.joinColumnAt(0).getName());
- assertEquals(1, table.joinColumnsSize());
- assertSourceContains("@JoinTable(joinColumns=@JoinColumn)");
-
-
- table.removeJoinColumn(0);
- assertEquals(0, table.joinColumnsSize());
- assertSourceDoesNotContain("@JoinTable");
- }
-
- public void testMoveJoinColumn() throws Exception {
- IType testType = this.createTestJoinTableWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- JoinColumnAnnotation joinColumn = table.joinColumnAt(0);
- joinColumn.setReferencedColumnName("REF_NAME");
- joinColumn.setUnique(Boolean.FALSE);
- joinColumn.setNullable(Boolean.FALSE);
- joinColumn.setInsertable(Boolean.FALSE);
- joinColumn.setUpdatable(Boolean.FALSE);
- joinColumn.setColumnDefinition("COLUMN_DEF");
- joinColumn.setTable("TABLE");
- table.addJoinColumn(0).setName("FOO");
-
- assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn})");
-
- table.moveJoinColumn(2, 0);
- assertEquals("BAR", table.joinColumnAt(0).getName());
- assertNull(table.joinColumnAt(1).getName());
- assertEquals("FOO", table.joinColumnAt(2).getName());
- assertEquals(3, table.joinColumnsSize());
- assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn, @JoinColumn(name=\"FOO\")})");
- }
-
- public void testMoveJoinColumn2() throws Exception {
- IType testType = this.createTestJoinTableWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
- JoinColumnAnnotation joinColumn = table.joinColumnAt(0);
- joinColumn.setReferencedColumnName("REF_NAME");
- joinColumn.setUnique(Boolean.FALSE);
- joinColumn.setNullable(Boolean.FALSE);
- joinColumn.setInsertable(Boolean.FALSE);
- joinColumn.setUpdatable(Boolean.FALSE);
- joinColumn.setColumnDefinition("COLUMN_DEF");
- joinColumn.setTable("TABLE");
-
- table.addJoinColumn(0).setName("FOO");
-
- assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn})");
-
-
- table.moveJoinColumn(0, 2);
- assertNull(table.joinColumnAt(0).getName());
- assertEquals("FOO", table.joinColumnAt(1).getName());
- assertEquals("BAR", table.joinColumnAt(2).getName());
- assertEquals(3, table.joinColumnsSize());
- assertSourceContains("@JoinTable(joinColumns={@JoinColumn, @JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\")})");
- }
-
- public void testSetJoinColumnName() throws Exception {
- IType testType = this.createTestJoinTableWithJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
- ListIterator<JoinColumnAnnotation> iterator = table.joinColumns();
- assertEquals(2, table.joinColumnsSize());
-
- JoinColumnAnnotation joinColumn = table.joinColumns().next();
-
- assertEquals("BAR", joinColumn.getName());
-
- joinColumn.setName("foo");
- assertEquals("foo", joinColumn.getName());
-
- assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"foo\"), @JoinColumn})");
- }
-
- public void testInverseJoinColumns() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
- assertEquals(0, table.inverseJoinColumnsSize());
- }
-
- public void testInverseJoinColumns2() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
-
- table.addInverseJoinColumn(0);
- table.addInverseJoinColumn(1);
-
- assertEquals(2, table.inverseJoinColumnsSize());
- }
-
- public void testInverseJoinColumns3() throws Exception {
- IType testType = this.createTestJoinTableWithInverseJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
- assertEquals(2, table.inverseJoinColumnsSize());
- }
-
- public void testAddInverseJoinColumn() throws Exception {
- IType testType = this.createTestJoinTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
- table.addInverseJoinColumn(0).setName("FOO");
- table.addInverseJoinColumn(1);
- table.addInverseJoinColumn(0).setName("BAR");
-
- assertEquals("BAR", table.inverseJoinColumnAt(0).getName());
- assertEquals("FOO", table.inverseJoinColumnAt(1).getName());
- assertNull(table.inverseJoinColumnAt(2).getName());
- assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"BAR\"),@JoinColumn(name=\"FOO\"), @JoinColumn})");
- }
-
- public void testRemoveInverseJoinColumn() throws Exception {
- IType testType = this.createTestJoinTableWithInverseJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- table.addInverseJoinColumn(2).setName("FOO");
-
- Iterator<JoinColumnAnnotation> inverseJoinColumns = table.inverseJoinColumns();
- assertEquals("BAR", inverseJoinColumns.next().getName());
- assertNull(inverseJoinColumns.next().getName());
- assertEquals("FOO", inverseJoinColumns.next().getName());
- assertFalse(inverseJoinColumns.hasNext());
-
- table.removeInverseJoinColumn(1);
- assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"BAR\"), @JoinColumn(name=\"FOO\")})");
- inverseJoinColumns = table.inverseJoinColumns();
- assertEquals("BAR", inverseJoinColumns.next().getName());
- assertEquals("FOO", inverseJoinColumns.next().getName());
- assertFalse(inverseJoinColumns.hasNext());
-
- table.removeInverseJoinColumn(0);
- assertSourceContains("@JoinTable(inverseJoinColumns=@JoinColumn(name=\"FOO\"))");
- inverseJoinColumns = table.inverseJoinColumns();
- assertEquals("FOO", inverseJoinColumns.next().getName());
- assertFalse(inverseJoinColumns.hasNext());
-
- table.removeInverseJoinColumn(0);
- assertSourceDoesNotContain("@JoinTable");
- }
-
- public void testMoveInverseJoinColumn() throws Exception {
- IType testType = this.createTestJoinTableWithInverseJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- table.addInverseJoinColumn(0).setName("FOO");
-
- Iterator<JoinColumnAnnotation> inverseJoinColumns = table.inverseJoinColumns();
- assertEquals("FOO", inverseJoinColumns.next().getName());
- assertEquals("BAR", inverseJoinColumns.next().getName());
- assertNull(inverseJoinColumns.next().getName());
-
- table.moveInverseJoinColumn(2, 0);
- inverseJoinColumns = table.inverseJoinColumns();
- assertEquals("BAR", inverseJoinColumns.next().getName());
- assertNull(inverseJoinColumns.next().getName());
- assertEquals("FOO", inverseJoinColumns.next().getName());
-
- assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"BAR\"), @JoinColumn, @JoinColumn(name=\"FOO\")})");
- }
-
- public void testMoveInverseJoinColumn2() throws Exception {
- IType testType = this.createTestJoinTableWithInverseJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
- table.addInverseJoinColumn(1).setName("FOO");
-
- Iterator<JoinColumnAnnotation> inverseJoinColumns = table.inverseJoinColumns();
- assertEquals("BAR", inverseJoinColumns.next().getName());
- assertEquals("FOO", inverseJoinColumns.next().getName());
- assertNull(inverseJoinColumns.next().getName());
-
- table.moveInverseJoinColumn(0, 2);
- inverseJoinColumns = table.inverseJoinColumns();
- assertNull(inverseJoinColumns.next().getName());
- assertEquals("BAR", inverseJoinColumns.next().getName());
- assertEquals("FOO", inverseJoinColumns.next().getName());
-
- assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn, @JoinColumn(name=\"BAR\"), @JoinColumn(name=\"FOO\")})");
- }
-
- public void testSetInverseJoinColumnName() throws Exception {
- IType testType = this.createTestJoinTableWithInverseJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE);
-
- assertEquals(2, table.inverseJoinColumnsSize());
-
- JoinColumnAnnotation joinColumn = table.inverseJoinColumns().next();
-
- assertEquals("BAR", joinColumn.getName());
-
- joinColumn.setName("foo");
- assertEquals("foo", joinColumn.getName());
-
- assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"foo\"), @JoinColumn})");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JpaCompilationUnitTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JpaCompilationUnitTests.java
deleted file mode 100644
index 47a2633dd6..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JpaCompilationUnitTests.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JpaFile;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.resource.java.EntityAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceModel;
-import org.eclipse.jpt.core.resource.java.JpaCompilationUnit;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject;
-import org.eclipse.jpt.core.tests.internal.projects.TestJpaProject;
-import org.eclipse.jpt.core.tests.internal.utility.jdt.AnnotationTestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class JpaCompilationUnitTests extends AnnotationTestCase {
-
- public JpaCompilationUnitTests(String name) {
- super(name);
- }
-
- @Override
- protected TestJavaProject buildJavaProject(String projectName, boolean autoBuild) throws Exception {
- return new TestJpaProject(projectName, autoBuild); // false = no auto-build
- }
-
- private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- this.javaProject.createType("javax.persistence", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- private ICompilationUnit createTestCompilationUnit() throws Exception {
- IType type = createTestEntity();
- return type.getCompilationUnit();
- }
-
- private IType createTestEntity() throws Exception {
- this.createAnnotationAndMembers("Entity", "String name();");
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- protected JpaCompilationUnit getJpaCompilationUnitResource(ICompilationUnit testCompilationUnit) throws CoreException {
- JpaProject jpaProject = ((TestJpaProject) this.javaProject).getJpaProject();
- JpaFile jpaFile = jpaProject.getJpaFile((IFile) testCompilationUnit.getResource());
- JavaResourceModel javaResourceModel = (JavaResourceModel) jpaFile.getResourceModel();
- return javaResourceModel.getResource();
- }
-
- public void testGetPersistentType() throws Exception {
- ICompilationUnit compilationUnit = this.createTestCompilationUnit();
- JpaCompilationUnit jpaCompilationUnit = getJpaCompilationUnitResource(compilationUnit);
-
- assertTrue(jpaCompilationUnit.getPersistentType().getMappingAnnotation() instanceof EntityAnnotation);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JptJavaResourceTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JptJavaResourceTests.java
deleted file mode 100644
index 781a0606dd..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JptJavaResourceTests.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptJavaResourceTests {
-
- public static Test suite() {
- return suite(true);
- }
-
- public static Test suite(boolean all) {
- TestSuite suite = new TestSuite(JptJavaResourceTests.class.getName());
- if (all) {
- suite.addTestSuite(JpaCompilationUnitTests.class);
- }
- suite.addTestSuite(JavaResourcePersistentTypeTests.class);
- suite.addTestSuite(JavaResourcePersistentAttributeTests.class);
- suite.addTestSuite(JPTToolsTests.class);
-
- suite.addTestSuite(AssociationOverrideTests.class);
- suite.addTestSuite(AssociationOverridesTests.class);
- suite.addTestSuite(AttributeOverrideTests.class);
- suite.addTestSuite(AttributeOverridesTests.class);
- suite.addTestSuite(BasicTests.class);
- suite.addTestSuite(ColumnTests.class);
- suite.addTestSuite(DiscriminatorValueTests.class);
- suite.addTestSuite(DiscriminatorColumnTests.class);
- suite.addTestSuite(EmbeddableTests.class);
- suite.addTestSuite(EmbeddedTests.class);
- suite.addTestSuite(EmbeddedIdTests.class);
- suite.addTestSuite(EntityTests.class);
- suite.addTestSuite(EnumeratedTests.class);
- suite.addTestSuite(GeneratedValueTests.class);
- suite.addTestSuite(IdClassTests.class);
- suite.addTestSuite(IdTests.class);
- suite.addTestSuite(InheritanceTests.class);
- suite.addTestSuite(JoinColumnTests.class);
- suite.addTestSuite(JoinColumnsTests.class);
- suite.addTestSuite(JoinTableTests.class);
- suite.addTestSuite(LobTests.class);
- suite.addTestSuite(ManyToManyTests.class);
- suite.addTestSuite(ManyToOneTests.class);
- suite.addTestSuite(MapKeyTests.class);
- suite.addTestSuite(MappedSuperclassTests.class);
- suite.addTestSuite(NamedNativeQueryTests.class);
- suite.addTestSuite(NamedNativeQueriesTests.class);
- suite.addTestSuite(NamedQueryTests.class);
- suite.addTestSuite(NamedQueriesTests.class);
- suite.addTestSuite(OneToManyTests.class);
- suite.addTestSuite(OneToOneTests.class);
- suite.addTestSuite(OrderByTests.class);
- suite.addTestSuite(PrimaryKeyJoinColumnTests.class);
- suite.addTestSuite(PrimaryKeyJoinColumnsTests.class);
- suite.addTestSuite(QueryHintTests.class);
- suite.addTestSuite(SecondaryTableTests.class);
- suite.addTestSuite(SecondaryTablesTests.class);
- suite.addTestSuite(SequenceGeneratorTests.class);
- suite.addTestSuite(TableGeneratorTests.class);
- suite.addTestSuite(TableTests.class);
- suite.addTestSuite(TemporalTests.class);
- suite.addTestSuite(TransientTests.class);
- suite.addTestSuite(VersionTests.class);
-
- return suite;
- }
-
- private JptJavaResourceTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/LobTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/LobTests.java
deleted file mode 100644
index 571be2d017..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/LobTests.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.LobAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class LobTests extends JavaResourceModelTestCase {
-
- public LobTests(String name) {
- super(name);
- }
-
- private IType createTestLob() throws Exception {
- this.createAnnotationAndMembers("Lob", "");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.LOB);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Lob");
- }
- });
- }
-
- public void testLob() throws Exception {
- IType testType = this.createTestLob();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- LobAnnotation lob = (LobAnnotation) attributeResource.getAnnotation(JPA.LOB);
- assertNotNull(lob);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToManyTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToManyTests.java
deleted file mode 100644
index d332d90d8c..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToManyTests.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.FetchType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class ManyToManyTests extends JavaResourceModelTestCase {
-
- public ManyToManyTests(String name) {
- super(name);
- }
-
- private IType createTestManyToMany() throws Exception {
- this.createAnnotationAndMembers("ManyToMany", "FetchType fetch() default FetchType.LAZY; CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_MANY);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany");
- }
- });
- }
-
- private IType createTestManyToManyWithFetch() throws Exception {
- this.createAnnotationAndMembers("ManyToMany", "FetchType fetch() default FetchType.LAZY;");
- this.createEnumAndMembers("FetchType", "EAGER, LAZY");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_MANY, JPA.FETCH_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany(fetch=FetchType.EAGER)");
- }
- });
- }
-
- private IType createTestManyToManyWithTargetEntity() throws Exception {
- this.createAnnotationAndMembers("ManyToMany", "Class targetEntity() default void.class; ");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_MANY);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany(targetEntity=AnnotationTestType.class)");
- }
- });
- }
-
- private IType createTestManyToManyWithMappedBy() throws Exception {
- this.createAnnotationAndMembers("ManyToMany", "String mappedBy() default\"\";");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_MANY);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany(mappedBy=\"foo\")");
- }
- });
- }
-
- private IType createTestManyToManyWithCascade() throws Exception {
- this.createAnnotationAndMembers("ManyToMany", "CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_MANY, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany(cascade=CascadeType.ALL)");
- }
- });
- }
-
- private IType createTestManyToManyWithMultipleCascade() throws Exception {
- this.createAnnotationAndMembers("ManyToMany", "CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_MANY, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany(cascade={CascadeType.MERGE, CascadeType.REMOVE})");
- }
- });
- }
-
- private IType createTestManyToManyWithDuplicateCascade() throws Exception {
- this.createAnnotationAndMembers("ManyToMany", "CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_MANY, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany(cascade={CascadeType.MERGE, CascadeType.MERGE})");
- }
- });
- }
-
- public void testManyToMany() throws Exception {
- IType testType = this.createTestManyToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertNotNull(manyToMany);
- }
-
- public void testGetFetch() throws Exception {
- IType testType = this.createTestManyToManyWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertEquals(FetchType.EAGER, manyToMany.getFetch());
- }
-
- public void testSetFetch() throws Exception {
- IType testType = this.createTestManyToManyWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertEquals(FetchType.EAGER, manyToMany.getFetch());
-
- manyToMany.setFetch(FetchType.LAZY);
- assertEquals(FetchType.LAZY, manyToMany.getFetch());
-
- assertSourceContains("@ManyToMany(fetch=LAZY)");
- }
-
- public void testSetFetchNull() throws Exception {
- IType testType = this.createTestManyToManyWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertEquals(FetchType.EAGER, manyToMany.getFetch());
-
- manyToMany.setFetch(null);
- assertNull(manyToMany.getFetch());
-
- assertSourceContains("@ManyToMany");
- assertSourceDoesNotContain("fetch");
- }
-
- public void testGetTargetEntity() throws Exception {
- IType testType = this.createTestManyToManyWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertEquals(TYPE_NAME, manyToMany.getTargetEntity());
- }
-
- public void testSetTargetEntity() throws Exception {
- IType testType = this.createTestManyToManyWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertEquals(TYPE_NAME, manyToMany.getTargetEntity());
-
- manyToMany.setTargetEntity("Foo");
-
- assertSourceContains("@ManyToMany(targetEntity=Foo.class)");
- }
-
- public void testSetTargetEntityNull() throws Exception {
- IType testType = this.createTestManyToManyWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertEquals(TYPE_NAME, manyToMany.getTargetEntity());
-
- manyToMany.setTargetEntity(null);
-
- assertSourceContains("@ManyToMany");
- assertSourceDoesNotContain("targetEntity");
- }
-
-
- public void testGetFullyQualifiedTargetEntity() throws Exception {
- IType testType = this.createTestManyToManyWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, manyToMany.getFullyQualifiedTargetEntity());
-
- manyToMany.setTargetEntity("Foo");
-
- assertSourceContains("@ManyToMany(targetEntity=Foo.class)");
-
- assertEquals("Foo", manyToMany.getTargetEntity());
-
- assertEquals("Foo", manyToMany.getFullyQualifiedTargetEntity()); //bug 196200 changed this
- }
-
- public void testGetMappedBy() throws Exception {
- IType testType = this.createTestManyToManyWithMappedBy();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertEquals("foo", manyToMany.getMappedBy());
- }
-
- public void testGetMappedByNull() throws Exception {
- IType testType = this.createTestManyToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertEquals(null, manyToMany.getMappedBy());
- }
-
- public void testSetMappedBy() throws Exception {
- IType testType = this.createTestManyToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertNull(manyToMany.getMappedBy());
- manyToMany.setMappedBy("bar");
- assertEquals("bar", manyToMany.getMappedBy());
-
- assertSourceContains("@ManyToMany(mappedBy=\"bar\")");
- }
-
- public void testSetMappedByNull() throws Exception {
- IType testType = this.createTestManyToManyWithMappedBy();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertEquals("foo", manyToMany.getMappedBy());
-
- manyToMany.setMappedBy(null);
- assertNull(manyToMany.getMappedBy());
-
- assertSourceContains("@ManyToMany");
- assertSourceDoesNotContain("mappedBy");
- }
-
- public void testSetCascadeAll() throws Exception {
- IType testType = this.createTestManyToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertFalse(manyToMany.isCascadeAll());
-
- manyToMany.setCascadeAll(true);
- assertSourceContains("@ManyToMany(cascade=ALL)");
-
- assertTrue(manyToMany.isCascadeAll());
- }
-
- public void testSetCascadeMerge() throws Exception {
- IType testType = this.createTestManyToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertFalse(manyToMany.isCascadeMerge());
-
- manyToMany.setCascadeMerge(true);
- assertSourceContains("@ManyToMany(cascade=MERGE)");
-
- assertTrue(manyToMany.isCascadeMerge());
- }
-
- public void testSetCascadePersist() throws Exception {
- IType testType = this.createTestManyToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertFalse(manyToMany.isCascadePersist());
-
- manyToMany.setCascadePersist(true);
- assertSourceContains("@ManyToMany(cascade=PERSIST)");
-
- assertTrue(manyToMany.isCascadePersist());
- }
-
- public void testSetCascadeRemove() throws Exception {
- IType testType = this.createTestManyToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertFalse(manyToMany.isCascadeRemove());
-
- manyToMany.setCascadeRemove(true);
- assertSourceContains("@ManyToMany(cascade=REMOVE)");
-
- assertTrue(manyToMany.isCascadeRemove());
- }
-
- public void testSetCascadeRefresh() throws Exception {
- IType testType = this.createTestManyToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertFalse(manyToMany.isCascadeRefresh());
-
- manyToMany.setCascadeRefresh(true);
- assertSourceContains("@ManyToMany(cascade=REFRESH)");
-
- assertTrue(manyToMany.isCascadeRefresh());
- }
-
- public void testCascadeMoreThanOnce() throws Exception {
- IType testType = this.createTestManyToManyWithCascade();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertTrue(manyToMany.isCascadeAll());
-
- manyToMany.setCascadeAll(true);
- assertTrue(manyToMany.isCascadeAll());
- //a second CascadeType.All should not have been added
- assertSourceContains("@ManyToMany(cascade=CascadeType.ALL)");
-
- manyToMany.setCascadeAll(false);
- assertFalse(manyToMany.isCascadeAll());
-
- assertSourceDoesNotContain("cascade");
-
- //test setting cascadeAll to false again, should just do nothing
- manyToMany.setCascadeAll(false);
- assertFalse(manyToMany.isCascadeAll());
-
- assertSourceDoesNotContain("cascade");
- }
-
- public void testDuplicateCascade() throws Exception {
- IType testType = this.createTestManyToManyWithDuplicateCascade();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertTrue(manyToMany.isCascadeMerge());
-
- manyToMany.setCascadeMerge(false); //TODO should the resource model handle this and remove both MERGE
- //settings instead of having to set it false twice?
- assertTrue(manyToMany.isCascadeMerge());
-
- manyToMany.setCascadeMerge(false);
- assertFalse(manyToMany.isCascadeMerge());
-
- assertSourceDoesNotContain("cascade");
- }
-
- public void testMultipleCascade() throws Exception {
- IType testType = this.createTestManyToManyWithMultipleCascade();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY);
- assertTrue(manyToMany.isCascadeMerge());
- assertTrue(manyToMany.isCascadeRemove());
-
- manyToMany.setCascadeMerge(false);
- assertSourceContains("@ManyToMany(cascade=REMOVE)");
-
- manyToMany.setCascadeRemove(false);
- assertSourceDoesNotContain("cascade");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToOneTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToOneTests.java
deleted file mode 100644
index 75cbc6af6d..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToOneTests.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.FetchType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class ManyToOneTests extends JavaResourceModelTestCase {
-
- public ManyToOneTests(String name) {
- super(name);
- }
-
- private IType createTestManyToOne() throws Exception {
- this.createAnnotationAndMembers("ManyToOne", "FetchType fetch() default FetchType.LAZY; CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_ONE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToOne");
- }
- });
- }
-
- private IType createTestManyToOneWithFetch() throws Exception {
- this.createAnnotationAndMembers("ManyToOne", "FetchType fetch() default FetchType.LAZY;");
- this.createEnumAndMembers("FetchType", "EAGER, LAZY");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_ONE, JPA.FETCH_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToOne(fetch=FetchType.EAGER)");
- }
- });
- }
-
- private IType createTestManyToOneWithTargetEntity() throws Exception {
- this.createAnnotationAndMembers("ManyToOne", "Class targetEntity() default void.class;");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_ONE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToOne(targetEntity=AnnotationTestType.class)");
- }
- });
- }
-
- private IType createTestManyToOneWithOptional() throws Exception {
- this.createAnnotationAndMembers("ManyToOne", "boolean optional() default true;");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_ONE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToOne(optional=true)");
- }
- });
- }
-
- private IType createTestManyToOneWithCascade() throws Exception {
- this.createAnnotationAndMembers("ManyToOne", "CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_ONE, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToOne(cascade=CascadeType.ALL)");
- }
- });
- }
-
- private IType createTestManyToOneWithMultipleCascade() throws Exception {
- this.createAnnotationAndMembers("ManyToOne", "CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_ONE, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToOne(cascade={CascadeType.MERGE, CascadeType.REMOVE})");
- }
- });
- }
-
- private IType createTestManyToOneWithDuplicateCascade() throws Exception {
- this.createAnnotationAndMembers("ManyToOne", "CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MANY_TO_ONE, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToOne(cascade={CascadeType.MERGE, CascadeType.MERGE})");
- }
- });
- }
-
- public void testManyToOne() throws Exception {
- IType testType = this.createTestManyToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertNotNull(manyToOne);
- }
-
- public void testGetFetch() throws Exception {
- IType testType = this.createTestManyToOneWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertEquals(FetchType.EAGER, manyToOne.getFetch());
- }
-
- public void testSetFetch() throws Exception {
- IType testType = this.createTestManyToOneWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertEquals(FetchType.EAGER, manyToOne.getFetch());
-
- manyToOne.setFetch(FetchType.LAZY);
- assertEquals(FetchType.LAZY, manyToOne.getFetch());
-
- assertSourceContains("@ManyToOne(fetch=LAZY)");
- }
-
- public void testSetFetchNull() throws Exception {
- IType testType = this.createTestManyToOneWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertEquals(FetchType.EAGER, manyToOne.getFetch());
-
- manyToOne.setFetch(null);
- assertNull(manyToOne.getFetch());
-
- assertSourceContains("@ManyToOne");
- assertSourceDoesNotContain("fetch");
- }
-
-
- public void testGetTargetEntity() throws Exception {
- IType testType = this.createTestManyToOneWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertEquals(TYPE_NAME, manyToOne.getTargetEntity());
- }
-
- public void testSetTargetEntity() throws Exception {
- IType testType = this.createTestManyToOneWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertEquals(TYPE_NAME, manyToOne.getTargetEntity());
-
- manyToOne.setTargetEntity("Foo");
-
- assertSourceContains("@ManyToOne(targetEntity=Foo.class)");
- }
-
- public void testSetTargetEntityNull() throws Exception {
- IType testType = this.createTestManyToOneWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertEquals(TYPE_NAME, manyToOne.getTargetEntity());
-
- manyToOne.setTargetEntity(null);
-
- assertSourceContains("@ManyToOne");
- assertSourceDoesNotContain("targetEntity");
- }
-
-
- public void testGetFullyQualifiedTargetEntity() throws Exception {
- IType testType = this.createTestManyToOneWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, manyToOne.getFullyQualifiedTargetEntity());
-
- manyToOne.setTargetEntity("Foo");
-
- assertSourceContains("@ManyToOne(targetEntity=Foo.class)");
-
- assertEquals("Foo", manyToOne.getTargetEntity());
-
- assertEquals("Foo", manyToOne.getFullyQualifiedTargetEntity());//bug 196200 changed this
- }
-
- public void testGetOptional() throws Exception {
- IType testType = this.createTestManyToOneWithOptional();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertEquals(Boolean.TRUE, manyToOne.getOptional());
- }
-
- public void testSetOptional() throws Exception {
- IType testType = this.createTestManyToOneWithOptional();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertEquals(Boolean.TRUE, manyToOne.getOptional());
-
- manyToOne.setOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, manyToOne.getOptional());
-
- assertSourceContains("@ManyToOne(optional=false)");
- }
-
- public void testSetOptionalNull() throws Exception {
- IType testType = this.createTestManyToOneWithOptional();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertEquals(Boolean.TRUE, manyToOne.getOptional());
-
- manyToOne.setOptional(null);
- assertNull(manyToOne.getOptional());
-
- assertSourceContains("@ManyToOne");
- assertSourceDoesNotContain("optional");
- }
-
- public void testSetCascadeAll() throws Exception {
- IType testType = this.createTestManyToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertFalse(manyToOne.isCascadeAll());
-
- manyToOne.setCascadeAll(true);
- assertSourceContains("@ManyToOne(cascade=ALL)");
-
- assertTrue(manyToOne.isCascadeAll());
- }
-
- public void testSetCascadeMerge() throws Exception {
- IType testType = this.createTestManyToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertFalse(manyToOne.isCascadeMerge());
-
- manyToOne.setCascadeMerge(true);
- assertSourceContains("@ManyToOne(cascade=MERGE)");
-
- assertTrue(manyToOne.isCascadeMerge());
- }
-
- public void testSetCascadePersist() throws Exception {
- IType testType = this.createTestManyToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertFalse(manyToOne.isCascadePersist());
-
- manyToOne.setCascadePersist(true);
- assertSourceContains("@ManyToOne(cascade=PERSIST)");
-
- assertTrue(manyToOne.isCascadePersist());
- }
-
- public void testSetCascadeRemove() throws Exception {
- IType testType = this.createTestManyToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertFalse(manyToOne.isCascadeRemove());
-
- manyToOne.setCascadeRemove(true);
- assertSourceContains("@ManyToOne(cascade=REMOVE)");
-
- assertTrue(manyToOne.isCascadeRemove());
- }
-
- public void testSetCascadeRefresh() throws Exception {
- IType testType = this.createTestManyToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertFalse(manyToOne.isCascadeRefresh());
-
- manyToOne.setCascadeRefresh(true);
- assertSourceContains("@ManyToOne(cascade=REFRESH)");
-
- assertTrue(manyToOne.isCascadeRefresh());
- }
-
- public void testCascadeMoreThanOnce() throws Exception {
- IType testType = this.createTestManyToOneWithCascade();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertTrue(manyToOne.isCascadeAll());
-
- manyToOne.setCascadeAll(true);
- assertTrue(manyToOne.isCascadeAll());
- //a second CascadeType.All should not have been added
- assertSourceContains("@ManyToOne(cascade=CascadeType.ALL)");
-
- manyToOne.setCascadeAll(false);
- assertFalse(manyToOne.isCascadeAll());
-
- assertSourceDoesNotContain("cascade");
-
- //test setting cascadeAll to false again, should just do nothing
- manyToOne.setCascadeAll(false);
- assertFalse(manyToOne.isCascadeAll());
-
- assertSourceDoesNotContain("cascade");
- }
-
- public void testDuplicateCascade() throws Exception {
- IType testType = this.createTestManyToOneWithDuplicateCascade();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertTrue(manyToOne.isCascadeMerge());
-
- manyToOne.setCascadeMerge(false);//TODO should the resource model handle this and remove both MERGE
- //settings instead of having to set it false twice?
- assertTrue(manyToOne.isCascadeMerge());
-
- manyToOne.setCascadeMerge(false);
- assertFalse(manyToOne.isCascadeMerge());
-
- assertSourceDoesNotContain("cascade");
- }
-
- public void testMultipleCascade() throws Exception {
- IType testType = this.createTestManyToOneWithMultipleCascade();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE);
- assertTrue(manyToOne.isCascadeMerge());
- assertTrue(manyToOne.isCascadeRemove());
-
- manyToOne.setCascadeMerge(false);
- assertSourceContains("@ManyToOne(cascade=REMOVE)");
-
- manyToOne.setCascadeRemove(false);
- assertSourceDoesNotContain("cascade");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MapKeyTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MapKeyTests.java
deleted file mode 100644
index 1692e03434..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MapKeyTests.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class MapKeyTests extends JavaResourceModelTestCase {
-
- public MapKeyTests(String name) {
- super(name);
- }
-
- private IType createTestMapKey() throws Exception {
- this.createAnnotationAndMembers("MapKey", "String name() default \"\";");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAP_KEY);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@MapKey");
- }
- });
- }
-
- private IType createTestMapKeyWithName() throws Exception {
- this.createAnnotationAndMembers("MapKey", "String name() default \"\";");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAP_KEY);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@MapKey(name=\"key\")");
- }
- });
- }
-
- public void testMapKey() throws Exception {
- IType testType = this.createTestMapKey();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(JPA.MAP_KEY);
- assertNotNull(mapKey);
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestMapKeyWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(JPA.MAP_KEY);
- assertEquals("key", mapKey.getName());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestMapKey();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(JPA.MAP_KEY);
-
- mapKey.setName("foo");
-
- assertSourceContains("@MapKey(name=\"foo\")");
-
- mapKey.setName(null);
-
- assertSourceContains("@MapKey");
- assertSourceDoesNotContain("@MapKey(name=\"foo\")");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MappedSuperclassTests.java
deleted file mode 100644
index b018c849bb..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MappedSuperclassTests.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.EntityAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class MappedSuperclassTests extends JavaResourceModelTestCase {
-
- public MappedSuperclassTests(String name) {
- super(name);
- }
-
- private IType createTestMappedSuperclass() throws Exception {
- this.createAnnotationAndMembers("MappedSuperclass", "");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass");
- }
- });
- }
-
- private IType createTestMappedSuperclassAndEntity() throws Exception {
- this.createAnnotationAndMembers("MappedSuperclass", "");
- this.createAnnotationAndMembers("Entity", "");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass");
- sb.append("@Entity");
- }
- });
- }
-
- public void testMappedSuperclass() throws Exception {
- IType testType = this.createTestMappedSuperclass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- JavaResourceNode mappingAnnotation = typeResource.getMappingAnnotation();
- assertTrue(mappingAnnotation instanceof MappedSuperclassAnnotation);
- }
-
- public void testMappedSuperclassAndEntity() throws Exception {
- IType testType = this.createTestMappedSuperclassAndEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- JavaResourceNode mappingAnnotation = typeResource.getMappingAnnotation();
- assertTrue(mappingAnnotation instanceof EntityAnnotation);
-
- MappedSuperclassAnnotation mappedSuperclass = (MappedSuperclassAnnotation) typeResource.getMappingAnnotation(JPA.MAPPED_SUPERCLASS);
- assertNotNull(mappedSuperclass);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueriesTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueriesTests.java
deleted file mode 100644
index eb75a06116..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueriesTests.java
+++ /dev/null
@@ -1,441 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.NamedNativeQueriesAnnotation;
-import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class NamedNativeQueriesTests extends JavaResourceModelTestCase {
-
- private static final String QUERY_NAME = "myQuery";
- private static final String QUERY_QUERY = "SELECT name FROM Employee";
- private static final String QUERY_RESULT_CLASS = "Result";
- private static final String QUERY_RESULT_SET_MAPPING = "resultSetMapping";
-
- public NamedNativeQueriesTests(String name) {
- super(name);
- }
-
- private void createNamedNativeQueryAnnotation() throws Exception {
- createQueryHintAnnotation();
- this.createAnnotationAndMembers("NamedNativeQuery", "String name(); " +
- "String query();" +
- "QueryHint[] hints() default{};");
- }
-
- private void createNamedNativeQueriesAnnotation() throws Exception {
- createNamedNativeQueryAnnotation();
- this.createAnnotationAndMembers("NamedNativeQueries",
- "NamedNativeQuery[] value();");
- }
-
- private void createQueryHintAnnotation() throws Exception {
- this.createAnnotationAndMembers("QueryHint", "String name(); " +
- "String value();");
- }
-
- private IType createTestNamedNativeQueries() throws Exception {
- createNamedNativeQueriesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_NATIVE_QUERIES, JPA.NAMED_NATIVE_QUERY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedNativeQueries(@NamedNativeQuery)");
- }
- });
- }
-
- private IType createTestNamedNativeQueryWithName() throws Exception {
- return createTestNamedNativeQueryWithStringElement("name", QUERY_NAME);
- }
-
- private IType createTestNamedNativeQueryWithQuery() throws Exception {
- return createTestNamedNativeQueryWithStringElement("query", QUERY_QUERY);
- }
-
- private IType createTestNamedNativeQueryWithResultSetMapping() throws Exception {
- return createTestNamedNativeQueryWithStringElement("resultSetMapping", QUERY_RESULT_SET_MAPPING);
- }
-
-
- private IType createTestNamedNativeQueryWithStringElement(final String elementName, final String value) throws Exception {
- createNamedNativeQueriesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_NATIVE_QUERIES, JPA.NAMED_NATIVE_QUERY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedNativeQueries(@NamedNativeQuery(" + elementName + "=\"" + value + "\"))");
- }
- });
- }
-
- private IType createTestNamedNativeQueryWithResultClass() throws Exception {
- createNamedNativeQueriesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_NATIVE_QUERIES, JPA.NAMED_NATIVE_QUERY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedNativeQueries(@NamedNativeQuery(resultClass=" + QUERY_RESULT_CLASS + ".class))");
- }
- });
- }
- private IType createTestNamedNativeQueryWithQueryHints() throws Exception {
- createNamedNativeQueriesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_NATIVE_QUERIES, JPA.NAMED_NATIVE_QUERY, JPA.QUERY_HINT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedNativeQueries(@NamedNativeQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint}))");
- }
- });
- }
-
- private IType createTestNamedNativeQuery() throws Exception {
- createNamedNativeQueriesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_NATIVE_QUERY, JPA.QUERY_HINT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedNativeQuery(name=\"foo\", query=\"bar\", hints=@QueryHint(name=\"BAR\", value=\"FOO\"), resultClass=Foo.class, resultSetMapping=\"mapping\")");
- }
- });
- }
-
- public void testNamedNativeQuery() throws Exception {
- IType testType = this.createTestNamedNativeQueries();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertNotNull(namedQuery);
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertEquals(QUERY_NAME, namedQuery.getName());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertEquals(QUERY_NAME, namedQuery.getName());
-
- namedQuery.setName("foo");
- assertEquals("foo", namedQuery.getName());
-
- assertSourceContains("@NamedNativeQuery(name=\"foo\")");
-
- namedQuery.setName(null);
- assertNull(namedQuery.getName());
-
- assertSourceDoesNotContain("@NamedNativeQuery");
- }
-
- public void testGetQuery() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertEquals(QUERY_QUERY, namedQuery.getQuery());
- }
-
- public void testSetQuery() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertEquals(QUERY_QUERY, namedQuery.getQuery());
-
- namedQuery.setQuery("foo");
- assertEquals("foo", namedQuery.getQuery());
-
- assertSourceContains("@NamedNativeQuery(query=\"foo\")");
-
- namedQuery.setQuery(null);
- assertNull(namedQuery.getQuery());
-
- assertSourceDoesNotContain("@NamedNativeQuery");
- }
-
- public void testGetResultClass() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithResultClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertEquals(QUERY_RESULT_CLASS, namedQuery.getResultClass());
- }
-
- public void testSetResultClass() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithResultClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertEquals(QUERY_RESULT_CLASS, namedQuery.getResultClass());
-
- namedQuery.setResultClass("foo");
- assertEquals("foo", namedQuery.getResultClass());
-
- assertSourceContains("@NamedNativeQuery(resultClass=foo.class)");
-
- namedQuery.setResultClass(null);
- assertNull(namedQuery.getResultClass());
-
- assertSourceDoesNotContain("@NamedNativeQuery");
- }
-
- public void testGetFullyQualifiedClass() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithResultClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertNotNull(namedQuery.getResultClass());
- assertEquals("Result", namedQuery.getFullyQualifiedResultClass());//bug 196200 changed this
-
- namedQuery.setResultClass(TYPE_NAME);
-
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, namedQuery.getFullyQualifiedResultClass());
- assertSourceContains("@NamedNativeQuery(resultClass=" + TYPE_NAME + ".class)");
- }
-
- public void testGetResultSetMapping() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithResultSetMapping();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertEquals(QUERY_RESULT_SET_MAPPING, namedQuery.getResultSetMapping());
- }
-
- public void testSetResultSetMapping() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithResultSetMapping();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertEquals(QUERY_RESULT_SET_MAPPING, namedQuery.getResultSetMapping());
-
- namedQuery.setResultSetMapping("foo");
- assertEquals("foo", namedQuery.getResultSetMapping());
-
- assertSourceContains("@NamedNativeQuery(resultSetMapping=\"foo\")");
-
- namedQuery.setResultSetMapping(null);
- assertNull(namedQuery.getResultSetMapping());
-
- assertSourceDoesNotContain("@NamedNativeQuery");
- }
-
- public void testHints() throws Exception {
- IType testType = this.createTestNamedNativeQueries();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
-
- assertEquals(0, namedQuery.hintsSize());
- }
-
- public void testHints2() throws Exception {
- IType testType = this.createTestNamedNativeQueries();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
-
- namedQuery.addHint(0);
- namedQuery.addHint(1);
-
- assertEquals(2, namedQuery.hintsSize());
- }
-
- public void testHints3() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
-
- assertEquals(2, namedQuery.hintsSize());
- }
-
- public void testAddHint() throws Exception {
- IType testType = this.createTestNamedNativeQueries();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
-
- namedQuery.addHint(0).setName("FOO");
- namedQuery.addHint(1);
- namedQuery.addHint(0).setName("BAR");
-
- assertEquals("BAR", namedQuery.hintAt(0).getName());
- assertEquals("FOO", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertSourceContains("@NamedNativeQuery(hints={@QueryHint(name=\"BAR\"),@QueryHint(name=\"FOO\"), @QueryHint})");
- }
-
- public void testRemoveHint() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- namedQuery.addHint(0).setName("BAZ");
-
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
-
- namedQuery.removeHint(2);
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertEquals(2, namedQuery.hintsSize());
- assertSourceContains("@NamedNativeQueries(@NamedNativeQuery(hints={@QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")}))");
-
- namedQuery.removeHint(0);
- assertEquals("BAR", namedQuery.hintAt(0).getName());
- assertEquals(1, namedQuery.hintsSize());
- assertSourceContains("@NamedNativeQueries(@NamedNativeQuery(hints=@QueryHint(name=\"BAR\", value=\"FOO\")))");
-
-
- namedQuery.removeHint(0);
- assertEquals(0, namedQuery.hintsSize());
- assertSourceDoesNotContain("@NamedNativeQuery");
- }
-
- public void testMoveHint() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
-
- namedQuery.addHint(0).setName("BAZ");
-
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
-
- namedQuery.moveHint(2, 0);
-
- assertEquals("BAR", namedQuery.hintAt(0).getName());
- assertNull(namedQuery.hintAt(1).getName());
- assertEquals("BAZ", namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
- assertSourceContains("@NamedNativeQueries(@NamedNativeQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint, @QueryHint(name=\"BAZ\")}))");
- }
-
- public void testMoveHint2() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES);
- NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
-
- namedQuery.addHint(0).setName("BAZ");
-
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
-
- namedQuery.moveHint(0, 2);
-
- assertNull(namedQuery.hintAt(0).getName());
- assertEquals("BAZ", namedQuery.hintAt(1).getName());
- assertEquals("BAR", namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
- assertSourceContains("@NamedNativeQueries(@NamedNativeQuery(hints={@QueryHint, @QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")}))");
- }
-
- public void testAddNamedNativeQueryCopyExisting() throws Exception {
- IType jdtType = createTestNamedNativeQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.addAnnotation(1, JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES);
- namedQuery.setName("BAR");
- assertSourceContains("@NamedNativeQueries({@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\"),@NamedNativeQuery(name=\"BAR\")})");
-
- assertNull(typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY));
- assertNotNull(typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES));
- assertEquals(2, CollectionTools.size(typeResource.annotations(JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES)));
- }
-
- public void testAddNamedNativeQueryToBeginningOfList() throws Exception {
- IType jdtType = createTestNamedNativeQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.addAnnotation(1, JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES);
- namedQuery.setName("BAR");
- assertSourceContains("@NamedNativeQueries({@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\"),@NamedNativeQuery(name=\"BAR\")})");
-
- namedQuery = (NamedNativeQueryAnnotation) typeResource.addAnnotation(0, JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES);
- namedQuery.setName("BAZ");
- assertSourceContains("@NamedNativeQueries({@NamedNativeQuery(name=\"BAZ\"),@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\"), @NamedNativeQuery(name=\"BAR\")})");
-
- Iterator<JavaResourceNode> namedQueries = typeResource.annotations(JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES);
- assertEquals("BAZ", ((NamedNativeQueryAnnotation) namedQueries.next()).getName());
- assertEquals("foo", ((NamedNativeQueryAnnotation) namedQueries.next()).getName());
- assertEquals("BAR", ((NamedNativeQueryAnnotation) namedQueries.next()).getName());
-
- assertNull(typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY));
- assertNotNull(typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES));
- assertEquals(3, CollectionTools.size(typeResource.annotations(JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES)));
- }
-
- public void testRemoveNamedNativeQueryCopyExisting() throws Exception {
- IType jdtType = createTestNamedNativeQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.addAnnotation(1, JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES);
- namedQuery.setName("BAR");
- assertSourceContains("@NamedNativeQueries({@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\"),@NamedNativeQuery(name=\"BAR\")})");
-
- typeResource.removeAnnotation(1, JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES);
- assertSourceContains("@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\")");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueryTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueryTests.java
deleted file mode 100644
index 1ab577d9cc..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueryTests.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class NamedNativeQueryTests extends JavaResourceModelTestCase {
-
- private static final String QUERY_NAME = "myQuery";
- private static final String QUERY_QUERY = "SELECT name FROM Employee";
- private static final String QUERY_RESULT_CLASS = "Result";
- private static final String QUERY_RESULT_SET_MAPPING = "resultSetMapping";
-
- public NamedNativeQueryTests(String name) {
- super(name);
- }
-
- private void createNamedNativeQueryAnnotation() throws Exception {
- createQueryHintAnnotation();
- this.createAnnotationAndMembers("NamedNativeQuery", "String name(); " +
- "String query();" +
- "QueryHint[] hints() default{};");
- }
-
- private void createQueryHintAnnotation() throws Exception {
- this.createAnnotationAndMembers("QueryHint", "String name(); " +
- "String value();");
- }
-
- private IType createTestNamedNativeQuery() throws Exception {
- createNamedNativeQueryAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_NATIVE_QUERY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedNativeQuery");
- }
- });
- }
-
- private IType createTestNamedNativeQueryWithName() throws Exception {
- return createTestNamedNativeQueryWithStringElement("name", QUERY_NAME);
- }
-
- private IType createTestNamedNativeQueryWithQuery() throws Exception {
- return createTestNamedNativeQueryWithStringElement("query", QUERY_QUERY);
- }
-
- private IType createTestNamedNativeQueryWithResultSetMapping() throws Exception {
- return createTestNamedNativeQueryWithStringElement("resultSetMapping", QUERY_RESULT_SET_MAPPING);
- }
-
-
- private IType createTestNamedNativeQueryWithStringElement(final String elementName, final String value) throws Exception {
- createNamedNativeQueryAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_NATIVE_QUERY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedNativeQuery(" + elementName + "=\"" + value + "\")");
- }
- });
- }
-
- private IType createTestNamedNativeQueryWithResultClass() throws Exception {
- createNamedNativeQueryAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_NATIVE_QUERY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedNativeQuery(resultClass=" + QUERY_RESULT_CLASS + ".class)");
- }
- });
- }
- private IType createTestNamedNativeQueryWithQueryHints() throws Exception {
- createNamedNativeQueryAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_NATIVE_QUERY, JPA.QUERY_HINT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedNativeQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint})");
- }
- });
- }
-
- public void testNamedNativeQuery() throws Exception {
- IType testType = this.createTestNamedNativeQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
- assertNotNull(namedQuery);
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
- assertEquals(QUERY_NAME, namedQuery.getName());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
- assertEquals(QUERY_NAME, namedQuery.getName());
-
- namedQuery.setName("foo");
- assertEquals("foo", namedQuery.getName());
-
- assertSourceContains("@NamedNativeQuery(name=\"foo\")");
-
- namedQuery.setName(null);
- assertNull(namedQuery.getName());
-
- assertSourceDoesNotContain("@NamedNativeQuery");
- }
-
- public void testGetQuery() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
- assertEquals(QUERY_QUERY, namedQuery.getQuery());
- }
-
- public void testSetQuery() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
- assertEquals(QUERY_QUERY, namedQuery.getQuery());
-
- namedQuery.setQuery("foo");
- assertEquals("foo", namedQuery.getQuery());
-
- assertSourceContains("@NamedNativeQuery(query=\"foo\")");
-
- namedQuery.setQuery(null);
- assertNull(namedQuery.getQuery());
-
- assertSourceDoesNotContain("@NamedNativeQuery");
- }
-
- public void testGetResultClass() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithResultClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
- assertEquals(QUERY_RESULT_CLASS, namedQuery.getResultClass());
- }
-
- public void testSetResultClass() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithResultClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
- assertEquals(QUERY_RESULT_CLASS, namedQuery.getResultClass());
-
- namedQuery.setResultClass("foo");
- assertEquals("foo", namedQuery.getResultClass());
-
- assertSourceContains("@NamedNativeQuery(resultClass=foo.class)");
-
- namedQuery.setResultClass(null);
- assertNull(namedQuery.getResultClass());
-
- assertSourceDoesNotContain("@NamedNativeQuery");
- }
-
- public void testGetFullyQualifiedClass() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithResultClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
- assertNotNull(namedQuery.getResultClass());
- assertEquals("Result", namedQuery.getFullyQualifiedResultClass());//bug 196200 changed this
-
- namedQuery.setResultClass(TYPE_NAME);
-
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, namedQuery.getFullyQualifiedResultClass());
- assertSourceContains("@NamedNativeQuery(resultClass=" + TYPE_NAME + ".class)");
- }
-
- public void testGetResultSetMapping() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithResultSetMapping();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
- assertEquals(QUERY_RESULT_SET_MAPPING, namedQuery.getResultSetMapping());
- }
-
- public void testSetResultSetMapping() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithResultSetMapping();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
- assertEquals(QUERY_RESULT_SET_MAPPING, namedQuery.getResultSetMapping());
-
- namedQuery.setResultSetMapping("foo");
- assertEquals("foo", namedQuery.getResultSetMapping());
-
- assertSourceContains("@NamedNativeQuery(resultSetMapping=\"foo\")");
-
- namedQuery.setResultSetMapping(null);
- assertNull(namedQuery.getResultSetMapping());
-
- assertSourceDoesNotContain("@NamedNativeQuery");
- }
-
- public void testHints() throws Exception {
- IType testType = this.createTestNamedNativeQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
-
- assertEquals(0, namedQuery.hintsSize());
- }
-
- public void testHints2() throws Exception {
- IType testType = this.createTestNamedNativeQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
-
- namedQuery.addHint(0);
- namedQuery.addHint(1);
-
- assertEquals(2, namedQuery.hintsSize());
- }
-
- public void testHints3() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
-
- assertEquals(2, namedQuery.hintsSize());
- }
-
-
- public void testAddHint() throws Exception {
- IType testType = this.createTestNamedNativeQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
-
- namedQuery.addHint(0).setName("FOO");
- namedQuery.addHint(1);
- namedQuery.addHint(0).setName("BAR");
-
- assertEquals("BAR", namedQuery.hintAt(0).getName());
- assertEquals("FOO", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertSourceContains("@NamedNativeQuery(hints={@QueryHint(name=\"BAR\"),@QueryHint(name=\"FOO\"), @QueryHint})");
- }
-
- public void testRemoveHint() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
- namedQuery.addHint(0).setName("BAZ");
-
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
-
- namedQuery.removeHint(2);
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertEquals(2, namedQuery.hintsSize());
- assertSourceContains("@NamedNativeQuery(hints={@QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")})");
-
- namedQuery.removeHint(0);
- assertEquals("BAR", namedQuery.hintAt(0).getName());
- assertEquals(1, namedQuery.hintsSize());
- assertSourceContains("@NamedNativeQuery(hints=@QueryHint(name=\"BAR\", value=\"FOO\"))");
-
-
- namedQuery.removeHint(0);
- assertEquals(0, namedQuery.hintsSize());
- assertSourceDoesNotContain("@NamedNativeQuery");
- }
-
- public void testMoveHint() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
-
- namedQuery.addHint(0).setName("BAZ");
-
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
-
- namedQuery.moveHint(2, 0);
-
- assertEquals("BAR", namedQuery.hintAt(0).getName());
- assertNull(namedQuery.hintAt(1).getName());
- assertEquals("BAZ", namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
- assertSourceContains("@NamedNativeQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint, @QueryHint(name=\"BAZ\")})");
- }
-
- public void testMoveHint2() throws Exception {
- IType testType = this.createTestNamedNativeQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY);
- namedQuery.addHint(0).setName("BAZ");
-
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
-
- namedQuery.moveHint(0, 2);
-
- assertNull(namedQuery.hintAt(0).getName());
- assertEquals("BAZ", namedQuery.hintAt(1).getName());
- assertEquals("BAR", namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
- assertSourceContains("@NamedNativeQuery(hints={@QueryHint, @QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")})");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java
deleted file mode 100644
index fa37ac561d..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation;
-import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class NamedQueriesTests extends JavaResourceModelTestCase {
-
- private static final String QUERY_NAME = "myQuery";
- private static final String QUERY_QUERY = "SELECT name FROM Employee";
-
- public NamedQueriesTests(String name) {
- super(name);
- }
-
- private void createNamedQueryAnnotation() throws Exception {
- createQueryHintAnnotation();
- this.createAnnotationAndMembers("NamedQuery", "String name(); " +
- "String query();" +
- "QueryHint[] hints() default{};");
- }
-
- private void createNamedQueriesAnnotation() throws Exception {
- createNamedQueryAnnotation();
- this.createAnnotationAndMembers("NamedQueries",
- "NamedQuery[] value();");
- }
-
- private void createQueryHintAnnotation() throws Exception {
- this.createAnnotationAndMembers("QueryHint", "String name(); " +
- "String value();");
- }
-
- private IType createTestNamedQueries() throws Exception {
- createNamedQueriesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_QUERIES, JPA.NAMED_QUERY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedQueries(@NamedQuery)");
- }
- });
- }
-
- private IType createTestNamedQueryWithName() throws Exception {
- return createTestNamedQueryWithStringElement("name", QUERY_NAME);
- }
-
- private IType createTestNamedQueryWithQuery() throws Exception {
- return createTestNamedQueryWithStringElement("query", QUERY_QUERY);
- }
-
- private IType createTestNamedQueryWithStringElement(final String elementName, final String value) throws Exception {
- createNamedQueriesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_QUERIES, JPA.NAMED_QUERY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedQueries(@NamedQuery(" + elementName + "=\"" + value + "\"))");
- }
- });
- }
-
- private IType createTestNamedQueryWithQueryHints() throws Exception {
- createNamedQueriesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_QUERIES, JPA.NAMED_QUERY, JPA.QUERY_HINT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedQueries(@NamedQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint}))");
- }
- });
- }
-
-
- private IType createTestNamedQuery() throws Exception {
- createNamedQueriesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_QUERY, JPA.QUERY_HINT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedQuery(name=\"foo\", query=\"bar\", hints=@QueryHint(name=\"BAR\", value=\"FOO\"))");
- }
- });
- }
-
- public void testNamedQuery() throws Exception {
- IType testType = this.createTestNamedQueries();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertNotNull(namedQuery);
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestNamedQueryWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertEquals(QUERY_NAME, namedQuery.getName());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestNamedQueryWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertEquals(QUERY_NAME, namedQuery.getName());
-
- namedQuery.setName("foo");
- assertEquals("foo", namedQuery.getName());
-
- assertSourceContains("@NamedQuery(name=\"foo\")");
-
- namedQuery.setName(null);
- assertNull(namedQuery.getName());
-
- assertSourceDoesNotContain("@NamedQuery");
- }
-
- public void testGetQuery() throws Exception {
- IType testType = this.createTestNamedQueryWithQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertEquals(QUERY_QUERY, namedQuery.getQuery());
- }
-
- public void testSetQuery() throws Exception {
- IType testType = this.createTestNamedQueryWithQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- assertEquals(QUERY_QUERY, namedQuery.getQuery());
-
- namedQuery.setQuery("foo");
- assertEquals("foo", namedQuery.getQuery());
-
- assertSourceContains("@NamedQuery(query=\"foo\")");
-
- namedQuery.setQuery(null);
- assertNull(namedQuery.getQuery());
-
- assertSourceDoesNotContain("@NamedQuery");
- }
-
- public void testHints() throws Exception {
- IType testType = this.createTestNamedQueries();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
-
- assertEquals(0, namedQuery.hintsSize());
- }
-
- public void testHints2() throws Exception {
- IType testType = this.createTestNamedQueries();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
-
- namedQuery.addHint(0);
- namedQuery.addHint(1);
-
- assertEquals(2, namedQuery.hintsSize());
- }
-
- public void testHints3() throws Exception {
- IType testType = this.createTestNamedQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
-
- assertEquals(2, namedQuery.hintsSize());
- }
-
- public void testAddHint() throws Exception {
- IType testType = this.createTestNamedQueries();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
-
- namedQuery.addHint(0).setName("FOO");
- namedQuery.addHint(1);
- namedQuery.addHint(0).setName("BAR");
-
- assertEquals("BAR", namedQuery.hintAt(0).getName());
- assertEquals("FOO", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
-
- assertSourceContains("@NamedQuery(hints={@QueryHint(name=\"BAR\"),@QueryHint(name=\"FOO\"), @QueryHint})");
- }
-
- public void testRemoveHint() throws Exception {
- IType testType = this.createTestNamedQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- namedQuery.addHint(0).setName("BAZ");
-
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
-
- namedQuery.removeHint(2);
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertEquals(2, namedQuery.hintsSize());
- assertSourceContains("@NamedQueries(@NamedQuery(hints={@QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")}))");
-
- namedQuery.removeHint(0);
- assertEquals("BAR", namedQuery.hintAt(0).getName());
- assertEquals(1, namedQuery.hintsSize());
- assertSourceContains("@NamedQueries(@NamedQuery(hints=@QueryHint(name=\"BAR\", value=\"FOO\")))");
-
- namedQuery.removeHint(0);
- assertEquals(0, namedQuery.hintsSize());
- assertSourceDoesNotContain("@NamedQueries");
- }
-
- public void testMoveHint() throws Exception {
- IType testType = this.createTestNamedQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- namedQuery.addHint(0).setName("BAZ");
-
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
-
- namedQuery.moveHint(2, 0);
-
- assertEquals("BAR", namedQuery.hintAt(0).getName());
- assertNull(namedQuery.hintAt(1).getName());
- assertEquals("BAZ", namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
- assertSourceContains("@NamedQueries(@NamedQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint, @QueryHint(name=\"BAZ\")}))");
- }
-
- public void testMoveHint2() throws Exception {
- IType testType = this.createTestNamedQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
- namedQuery.addHint(0).setName("BAZ");
-
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
-
- namedQuery.moveHint(0, 2);
-
- assertNull(namedQuery.hintAt(0).getName());
- assertEquals("BAZ", namedQuery.hintAt(1).getName());
- assertEquals("BAR", namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
- assertSourceContains("@NamedQueries(@NamedQuery(hints={@QueryHint, @QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")}))");
- }
-
- public void testAddNamedQueryCopyExisting() throws Exception {
- IType jdtType = createTestNamedQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.addAnnotation(1, JPA.NAMED_QUERY, JPA.NAMED_QUERIES);
- namedQuery.setName("BAR");
- assertSourceContains("@NamedQueries({@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\")),@NamedQuery(name=\"BAR\")})");
-
- assertNull(typeResource.getAnnotation(JPA.NAMED_QUERY));
- assertNotNull(typeResource.getAnnotation(JPA.NAMED_QUERIES));
- assertEquals(2, CollectionTools.size(typeResource.annotations(JPA.NAMED_QUERY, JPA.NAMED_QUERIES)));
- }
-
- public void testAddNamedQueryToBeginningOfList() throws Exception {
- IType jdtType = createTestNamedQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.addAnnotation(1, JPA.NAMED_QUERY, JPA.NAMED_QUERIES);
- namedQuery.setName("BAR");
- assertSourceContains("@NamedQueries({@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\")),@NamedQuery(name=\"BAR\")})");
-
-
- namedQuery = (NamedQueryAnnotation) typeResource.addAnnotation(0, JPA.NAMED_QUERY, JPA.NAMED_QUERIES);
- namedQuery.setName("BAZ");
- assertSourceContains("@NamedQueries({@NamedQuery(name=\"BAZ\"),@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\")), @NamedQuery(name=\"BAR\")})");
-
- Iterator<JavaResourceNode> namedQueries = typeResource.annotations(JPA.NAMED_QUERY, JPA.NAMED_QUERIES);
- assertEquals("BAZ", ((NamedQueryAnnotation) namedQueries.next()).getName());
- assertEquals("foo", ((NamedQueryAnnotation) namedQueries.next()).getName());
- assertEquals("BAR", ((NamedQueryAnnotation) namedQueries.next()).getName());
-
- assertNull(typeResource.getAnnotation(JPA.NAMED_QUERY));
- assertNotNull(typeResource.getAnnotation(JPA.NAMED_QUERIES));
- assertEquals(3, CollectionTools.size(typeResource.annotations(JPA.NAMED_QUERY, JPA.NAMED_QUERIES)));
- }
-
- public void testRemoveNamedQueryCopyExisting() throws Exception {
- IType jdtType = createTestNamedQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.addAnnotation(1, JPA.NAMED_QUERY, JPA.NAMED_QUERIES);
- namedQuery.setName("BAR");
- assertSourceContains("@NamedQueries({@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\")),@NamedQuery(name=\"BAR\")})");
-
- typeResource.removeAnnotation(1, JPA.NAMED_QUERY, JPA.NAMED_QUERIES);
- assertSourceContains("@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"))");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueryTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueryTests.java
deleted file mode 100644
index e6762ae852..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueryTests.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
-import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class NamedQueryTests extends JavaResourceModelTestCase {
-
- private static final String QUERY_NAME = "myQuery";
- private static final String QUERY_QUERY = "SELECT name FROM Employee";
-
- public NamedQueryTests(String name) {
- super(name);
- }
-
- private void createNamedQueryAnnotation() throws Exception {
- createQueryHintAnnotation();
- this.createAnnotationAndMembers("NamedQuery", "String name(); " +
- "String query();" +
- "QueryHint[] hints() default{};");
- }
-
- private void createQueryHintAnnotation() throws Exception {
- this.createAnnotationAndMembers("QueryHint", "String name(); " +
- "String value();");
- }
-
- private IType createTestNamedQuery() throws Exception {
- createNamedQueryAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_QUERY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedQuery");
- }
- });
- }
-
- private IType createTestNamedQueryWithName() throws Exception {
- return createTestNamedQueryWithStringElement("name", QUERY_NAME);
- }
-
- private IType createTestNamedQueryWithQuery() throws Exception {
- return createTestNamedQueryWithStringElement("query", QUERY_QUERY);
- }
-
- private IType createTestNamedQueryWithStringElement(final String elementName, final String value) throws Exception {
- createNamedQueryAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_QUERY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedQuery(" + elementName + "=\"" + value + "\")");
- }
- });
- }
-
- private IType createTestNamedQueryWithQueryHints() throws Exception {
- createNamedQueryAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_QUERY, JPA.QUERY_HINT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint})");
- }
- });
- }
-
- public void testNamedQuery() throws Exception {
- IType testType = this.createTestNamedQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
- assertNotNull(namedQuery);
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestNamedQueryWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
- assertEquals(QUERY_NAME, namedQuery.getName());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestNamedQueryWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
- assertEquals(QUERY_NAME, namedQuery.getName());
-
- namedQuery.setName("foo");
- assertEquals("foo", namedQuery.getName());
-
- assertSourceContains("@NamedQuery(name=\"foo\")");
-
- namedQuery.setName(null);
- assertNull(namedQuery.getName());
-
- assertSourceDoesNotContain("@NamedQuery");
- }
-
- public void testGetQuery() throws Exception {
- IType testType = this.createTestNamedQueryWithQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
- assertEquals(QUERY_QUERY, namedQuery.getQuery());
- }
-
- public void testSetQuery() throws Exception {
- IType testType = this.createTestNamedQueryWithQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
- assertEquals(QUERY_QUERY, namedQuery.getQuery());
-
- namedQuery.setQuery("foo");
- assertEquals("foo", namedQuery.getQuery());
-
- assertSourceContains("@NamedQuery(query=\"foo\")");
-
- namedQuery.setQuery(null);
- assertNull(namedQuery.getQuery());
-
- assertSourceDoesNotContain("@NamedQuery");
- }
-
- public void testHints() throws Exception {
- IType testType = this.createTestNamedQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
-
- assertEquals(0, namedQuery.hintsSize());
- }
-
- public void testHints2() throws Exception {
- IType testType = this.createTestNamedQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
-
- namedQuery.addHint(0);
- namedQuery.addHint(1);
-
- assertEquals(2, namedQuery.hintsSize());
- }
-
- public void testHints3() throws Exception {
- IType testType = this.createTestNamedQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
-
- assertEquals(2, namedQuery.hintsSize());
-
- ListIterator<QueryHintAnnotation> iterator = namedQuery.hints();
- assertEquals("BAR", iterator.next().getName());
- assertNull(iterator.next().getName());
- }
-
- public void testAddHint() throws Exception {
- IType testType = this.createTestNamedQuery();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
-
- namedQuery.addHint(0).setName("FOO");
- namedQuery.addHint(1);
- QueryHintAnnotation queryHint = namedQuery.addHint(0);
- queryHint.setName("BAR");
-
- assertEquals("BAR", namedQuery.hintAt(0).getName());
- assertEquals("FOO", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertSourceContains("@NamedQuery(hints={@QueryHint(name=\"BAR\"),@QueryHint(name=\"FOO\"), @QueryHint})");
- }
-
- public void testRemoveHint() throws Exception {
- IType testType = this.createTestNamedQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
- namedQuery.addHint(0).setName("BAZ");
-
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
-
- namedQuery.removeHint(2);
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertEquals(2, namedQuery.hintsSize());
- assertSourceContains("@NamedQuery(hints={@QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")})");
-
- namedQuery.removeHint(0);
- assertEquals("BAR", namedQuery.hintAt(0).getName());
- assertEquals(1, namedQuery.hintsSize());
- assertSourceContains("@NamedQuery(hints=@QueryHint(name=\"BAR\", value=\"FOO\"))");
-
- namedQuery.removeHint(0);
- assertEquals(0, namedQuery.hintsSize());
- assertSourceDoesNotContain("@NamedQuery");
- }
-
- public void testMoveHint() throws Exception {
- IType testType = this.createTestNamedQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
- namedQuery.addHint(0).setName("BAZ");
-
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
-
- namedQuery.moveHint(2, 0);
-
- assertEquals("BAR", namedQuery.hintAt(0).getName());
- assertNull(namedQuery.hintAt(1).getName());
- assertEquals("BAZ", namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
- assertSourceContains("@NamedQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint, @QueryHint(name=\"BAZ\")})");
- }
-
- public void testMoveHint2() throws Exception {
- IType testType = this.createTestNamedQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
- namedQuery.addHint(0).setName("BAZ");
-
- assertEquals("BAZ", namedQuery.hintAt(0).getName());
- assertEquals("BAR", namedQuery.hintAt(1).getName());
- assertNull(namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
-
- namedQuery.moveHint(0, 2);
-
- assertNull(namedQuery.hintAt(0).getName());
- assertEquals("BAZ", namedQuery.hintAt(1).getName());
- assertEquals("BAR", namedQuery.hintAt(2).getName());
- assertEquals(3, namedQuery.hintsSize());
- assertSourceContains("@NamedQuery(hints={@QueryHint, @QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")})");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToManyTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToManyTests.java
deleted file mode 100644
index b4e5c6ebe8..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToManyTests.java
+++ /dev/null
@@ -1,408 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.FetchType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OneToManyTests extends JavaResourceModelTestCase {
-
- public OneToManyTests(String name) {
- super(name);
- }
-
- private IType createTestOneToMany() throws Exception {
- this.createAnnotationAndMembers("OneToMany", "FetchType fetch() default FetchType.LAZY; CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_MANY);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany");
- }
- });
- }
-
- private IType createTestOneToManyWithFetch() throws Exception {
- this.createAnnotationAndMembers("OneToMany", "FetchType fetch() default FetchType.LAZY;");
- this.createEnumAndMembers("FetchType", "EAGER, LAZY");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_MANY, JPA.FETCH_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany(fetch=FetchType.EAGER)");
- }
- });
- }
-
- private IType createTestOneToManyWithTargetEntity() throws Exception {
- this.createAnnotationAndMembers("OneToMany", "Class targetEntity() default void.class;");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_MANY);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany(targetEntity=AnnotationTestType.class)");
- }
- });
- }
-
- private IType createTestOneToManyWithMappedBy() throws Exception {
- this.createAnnotationAndMembers("OneToMany", "String mappedBy() default\"\";");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_MANY);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany(mappedBy=\"foo\")");
- }
- });
- }
-
- private IType createTestOneToManyWithCascade() throws Exception {
- this.createAnnotationAndMembers("OneToMany", "CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_MANY, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany(cascade=CascadeType.ALL)");
- }
- });
- }
-
- private IType createTestOneToManyWithMultipleCascade() throws Exception {
- this.createAnnotationAndMembers("OneToMany", "CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_MANY, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany(cascade={CascadeType.MERGE, CascadeType.REMOVE})");
- }
- });
- }
-
- private IType createTestOneToManyWithDuplicateCascade() throws Exception {
- this.createAnnotationAndMembers("OneToMany", "CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_MANY, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany(cascade={CascadeType.MERGE, CascadeType.MERGE})");
- }
- });
- }
-
- public void testOneToMany() throws Exception {
- IType testType = this.createTestOneToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertNotNull(oneToMany);
- }
-
- public void testGetFetch() throws Exception {
- IType testType = this.createTestOneToManyWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertEquals(FetchType.EAGER, oneToMany.getFetch());
- }
-
- public void testSetFetch() throws Exception {
- IType testType = this.createTestOneToManyWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertEquals(FetchType.EAGER, oneToMany.getFetch());
-
- oneToMany.setFetch(FetchType.LAZY);
- assertEquals(FetchType.LAZY, oneToMany.getFetch());
-
- assertSourceContains("@OneToMany(fetch=LAZY)");
- }
-
- public void testSetFetchNull() throws Exception {
- IType testType = this.createTestOneToManyWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertEquals(FetchType.EAGER, oneToMany.getFetch());
-
- oneToMany.setFetch(null);
- assertNull(oneToMany.getFetch());
-
- assertSourceContains("@OneToMany");
- assertSourceDoesNotContain("fetch");
- }
-
-
- public void testGetTargetEntity() throws Exception {
- IType testType = this.createTestOneToManyWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertEquals(TYPE_NAME, oneToMany.getTargetEntity());
- }
-
- public void testSetTargetEntity() throws Exception {
- IType testType = this.createTestOneToManyWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertEquals(TYPE_NAME, oneToMany.getTargetEntity());
-
- oneToMany.setTargetEntity("Foo");
-
- assertSourceContains("@OneToMany(targetEntity=Foo.class)");
- }
-
- public void testSetTargetEntityNull() throws Exception {
- IType testType = this.createTestOneToManyWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertEquals(TYPE_NAME, oneToMany.getTargetEntity());
-
- oneToMany.setTargetEntity(null);
-
- assertSourceContains("@OneToMany");
- assertSourceDoesNotContain("targetEntity");
- }
-
-
- public void testGetFullyQualifiedTargetEntity() throws Exception {
- IType testType = this.createTestOneToManyWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, oneToMany.getFullyQualifiedTargetEntity());
-
- oneToMany.setTargetEntity("Foo");
-
- assertSourceContains("@OneToMany(targetEntity=Foo.class)");
-
- assertEquals("Foo", oneToMany.getTargetEntity());
-
- assertEquals("Foo", oneToMany.getFullyQualifiedTargetEntity()); //bug 196200 changed this
- }
-
- public void testGetMappedBy() throws Exception {
- IType testType = this.createTestOneToManyWithMappedBy();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertEquals("foo", oneToMany.getMappedBy());
- }
-
-
- public void testGetMappedByNull() throws Exception {
- IType testType = this.createTestOneToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertEquals(null, oneToMany.getMappedBy());
- }
-
- public void testSetMappedBy() throws Exception {
- IType testType = this.createTestOneToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertNull(oneToMany.getMappedBy());
- oneToMany.setMappedBy("bar");
- assertEquals("bar", oneToMany.getMappedBy());
-
- assertSourceContains("@OneToMany(mappedBy=\"bar\")");
- }
-
- public void testSetMappedByNull() throws Exception {
- IType testType = this.createTestOneToManyWithMappedBy();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertEquals("foo", oneToMany.getMappedBy());
-
- oneToMany.setMappedBy(null);
- assertNull(oneToMany.getMappedBy());
-
- assertSourceContains("@OneToMany");
- assertSourceDoesNotContain("mappedBy");
- }
-
- public void testSetCascadeAll() throws Exception {
- IType testType = this.createTestOneToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertFalse(oneToMany.isCascadeAll());
-
- oneToMany.setCascadeAll(true);
- assertSourceContains("@OneToMany(cascade=ALL)");
-
- assertTrue(oneToMany.isCascadeAll());
- }
-
- public void testSetCascadeMerge() throws Exception {
- IType testType = this.createTestOneToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertFalse(oneToMany.isCascadeMerge());
-
- oneToMany.setCascadeMerge(true);
- assertSourceContains("@OneToMany(cascade=MERGE)");
-
- assertTrue(oneToMany.isCascadeMerge());
- }
-
- public void testSetCascadePersist() throws Exception {
- IType testType = this.createTestOneToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertFalse(oneToMany.isCascadePersist());
-
- oneToMany.setCascadePersist(true);
- assertSourceContains("@OneToMany(cascade=PERSIST)");
-
- assertTrue(oneToMany.isCascadePersist());
- }
-
- public void testSetCascadeRemove() throws Exception {
- IType testType = this.createTestOneToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertFalse(oneToMany.isCascadeRemove());
-
- oneToMany.setCascadeRemove(true);
- assertSourceContains("@OneToMany(cascade=REMOVE)");
-
- assertTrue(oneToMany.isCascadeRemove());
- }
-
- public void testSetCascadeRefresh() throws Exception {
- IType testType = this.createTestOneToMany();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertFalse(oneToMany.isCascadeRefresh());
-
- oneToMany.setCascadeRefresh(true);
- assertSourceContains("@OneToMany(cascade=REFRESH)");
-
- assertTrue(oneToMany.isCascadeRefresh());
- }
-
- public void testCascadeMoreThanOnce() throws Exception {
- IType testType = this.createTestOneToManyWithCascade();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertTrue(oneToMany.isCascadeAll());
-
- oneToMany.setCascadeAll(true);
- assertTrue(oneToMany.isCascadeAll());
- //a second CascadeType.All should not have been added
- assertSourceContains("@OneToMany(cascade=CascadeType.ALL)");
-
- oneToMany.setCascadeAll(false);
- assertFalse(oneToMany.isCascadeAll());
-
- assertSourceDoesNotContain("cascade");
-
- //test setting cascadeAll to false again, should just do nothing
- oneToMany.setCascadeAll(false);
- assertFalse(oneToMany.isCascadeAll());
-
- assertSourceDoesNotContain("cascade");
- }
-
- public void testDuplicateCascade() throws Exception {
- IType testType = this.createTestOneToManyWithDuplicateCascade();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertTrue(oneToMany.isCascadeMerge());
-
- oneToMany.setCascadeMerge(false);//TODO should the resource model handle this and remove both MERGE
- //settings instead of having to set it false twice?
- assertTrue(oneToMany.isCascadeMerge());
-
- oneToMany.setCascadeMerge(false);
- assertFalse(oneToMany.isCascadeMerge());
-
- assertSourceDoesNotContain("cascade");
- }
-
- public void testMultipleCascade() throws Exception {
- IType testType = this.createTestOneToManyWithMultipleCascade();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY);
- assertTrue(oneToMany.isCascadeMerge());
- assertTrue(oneToMany.isCascadeRemove());
-
- oneToMany.setCascadeMerge(false);
- assertSourceContains("@OneToMany(cascade=REMOVE)");
-
- oneToMany.setCascadeRemove(false);
- assertSourceDoesNotContain("cascade");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToOneTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToOneTests.java
deleted file mode 100644
index 141797cfe2..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToOneTests.java
+++ /dev/null
@@ -1,459 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.FetchType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OneToOneTests extends JavaResourceModelTestCase {
-
- public OneToOneTests(String name) {
- super(name);
- }
-
- private IType createTestOneToOne() throws Exception {
- this.createAnnotationAndMembers("OneToOne", "FetchType fetch() default FetchType.LAZY; CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_ONE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne");
- }
- });
- }
-
- private IType createTestOneToOneWithFetch() throws Exception {
- this.createAnnotationAndMembers("OneToOne", "FetchType fetch() default FetchType.LAZY;");
- this.createEnumAndMembers("FetchType", "EAGER, LAZY");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_ONE, JPA.FETCH_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne(fetch=FetchType.EAGER)");
- }
- });
- }
-
- private IType createTestOneToOneWithTargetEntity() throws Exception {
- this.createAnnotationAndMembers("OneToOne", "Class targetEntity() default void.class;");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_ONE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne(targetEntity=AnnotationTestType.class)");
- }
- });
- }
-
- private IType createTestOneToOneWithOptional() throws Exception {
- this.createAnnotationAndMembers("OneToOne", "boolean optional() default true;");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_ONE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne(optional=true)");
- }
- });
- }
-
- private IType createTestOneToOneWithMappedBy() throws Exception {
- this.createAnnotationAndMembers("OneToOne", "String mappedBy() default\"\";");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_ONE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne(mappedBy=\"foo\")");
- }
- });
- }
-
- private IType createTestOneToOneWithCascade() throws Exception {
- this.createAnnotationAndMembers("OneToOne", "CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_ONE, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne(cascade=CascadeType.ALL)");
- }
- });
- }
-
- private IType createTestOneToOneWithMultipleCascade() throws Exception {
- this.createAnnotationAndMembers("OneToOne", "CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_ONE, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne(cascade={CascadeType.MERGE, CascadeType.REMOVE})");
- }
- });
- }
-
- private IType createTestOneToOneWithDuplicateCascade() throws Exception {
- this.createAnnotationAndMembers("OneToOne", "CascadeType[] cascade() default = {};");
- this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ONE_TO_ONE, JPA.CASCADE_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne(cascade={CascadeType.MERGE, CascadeType.MERGE})");
- }
- });
- }
-
- public void testOneToOne() throws Exception {
- IType testType = this.createTestOneToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertNotNull(oneToOne);
- }
-
- public void testGetFetch() throws Exception {
- IType testType = this.createTestOneToOneWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals(FetchType.EAGER, oneToOne.getFetch());
- }
-
- public void testSetFetch() throws Exception {
- IType testType = this.createTestOneToOneWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals(FetchType.EAGER, oneToOne.getFetch());
-
- oneToOne.setFetch(FetchType.LAZY);
- assertEquals(FetchType.LAZY, oneToOne.getFetch());
-
- assertSourceContains("@OneToOne(fetch=LAZY)");
- }
-
- public void testSetFetchNull() throws Exception {
- IType testType = this.createTestOneToOneWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals(FetchType.EAGER, oneToOne.getFetch());
-
- oneToOne.setFetch(null);
- assertNull(oneToOne.getFetch());
-
- assertSourceContains("@OneToOne");
- assertSourceDoesNotContain("fetch");
- }
-
-
- public void testGetTargetEntity() throws Exception {
- IType testType = this.createTestOneToOneWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals(TYPE_NAME, oneToOne.getTargetEntity());
- }
-
- public void testSetTargetEntity() throws Exception {
- IType testType = this.createTestOneToOneWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals(TYPE_NAME, oneToOne.getTargetEntity());
-
- oneToOne.setTargetEntity("Foo");
-
- assertSourceContains("@OneToOne(targetEntity=Foo.class)");
- }
-
- public void testSetTargetEntityNull() throws Exception {
- IType testType = this.createTestOneToOneWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals(TYPE_NAME, oneToOne.getTargetEntity());
-
- oneToOne.setTargetEntity(null);
-
- assertSourceContains("@OneToOne");
- assertSourceDoesNotContain("targetEntity");
- }
-
-
- public void testGetFullyQualifiedTargetEntity() throws Exception {
- IType testType = this.createTestOneToOneWithTargetEntity();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, oneToOne.getFullyQualifiedTargetEntity());
-
- oneToOne.setTargetEntity("Foo");
-
- assertSourceContains("@OneToOne(targetEntity=Foo.class)");
-
- assertEquals("Foo", oneToOne.getTargetEntity());
-
- assertEquals("Foo", oneToOne.getFullyQualifiedTargetEntity()); //bug 196200 changed this
- }
-
- public void testGetOptional() throws Exception {
- IType testType = this.createTestOneToOneWithOptional();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals(Boolean.TRUE, oneToOne.getOptional());
- }
-
- public void testSetOptional() throws Exception {
- IType testType = this.createTestOneToOneWithOptional();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals(Boolean.TRUE, oneToOne.getOptional());
-
- oneToOne.setOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, oneToOne.getOptional());
-
- assertSourceContains("@OneToOne(optional=false)");
- }
-
- public void testSetOptionalNull() throws Exception {
- IType testType = this.createTestOneToOneWithOptional();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals(Boolean.TRUE, oneToOne.getOptional());
-
- oneToOne.setOptional(null);
- assertNull(oneToOne.getOptional());
-
- assertSourceContains("@OneToOne");
- assertSourceDoesNotContain("optional");
- }
-
- public void testGetMappedBy() throws Exception {
- IType testType = this.createTestOneToOneWithMappedBy();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals("foo", oneToOne.getMappedBy());
- }
-
- public void testGetMappedByNull() throws Exception {
- IType testType = this.createTestOneToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals(null, oneToOne.getMappedBy());
- }
-
- public void testSetMappedBy() throws Exception {
- IType testType = this.createTestOneToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertNull(oneToOne.getMappedBy());
- oneToOne.setMappedBy("bar");
- assertEquals("bar", oneToOne.getMappedBy());
-
- assertSourceContains("@OneToOne(mappedBy=\"bar\")");
- }
-
- public void testSetMappedByNull() throws Exception {
- IType testType = this.createTestOneToOneWithMappedBy();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertEquals("foo", oneToOne.getMappedBy());
-
- oneToOne.setMappedBy(null);
- assertNull(oneToOne.getMappedBy());
-
- assertSourceContains("@OneToOne");
- assertSourceDoesNotContain("mappedBy");
- }
-
- public void testSetCascadeAll() throws Exception {
- IType testType = this.createTestOneToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertFalse(oneToOne.isCascadeAll());
-
- oneToOne.setCascadeAll(true);
- assertSourceContains("@OneToOne(cascade=ALL)");
-
- assertTrue(oneToOne.isCascadeAll());
- }
-
- public void testSetCascadeMerge() throws Exception {
- IType testType = this.createTestOneToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertFalse(oneToOne.isCascadeMerge());
-
- oneToOne.setCascadeMerge(true);
- assertSourceContains("@OneToOne(cascade=MERGE)");
-
- assertTrue(oneToOne.isCascadeMerge());
- }
-
- public void testSetCascadePersist() throws Exception {
- IType testType = this.createTestOneToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertFalse(oneToOne.isCascadePersist());
-
- oneToOne.setCascadePersist(true);
- assertSourceContains("@OneToOne(cascade=PERSIST)");
-
- assertTrue(oneToOne.isCascadePersist());
- }
-
- public void testSetCascadeRemove() throws Exception {
- IType testType = this.createTestOneToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertFalse(oneToOne.isCascadeRemove());
-
- oneToOne.setCascadeRemove(true);
- assertSourceContains("@OneToOne(cascade=REMOVE)");
-
- assertTrue(oneToOne.isCascadeRemove());
- }
-
- public void testSetCascadeRefresh() throws Exception {
- IType testType = this.createTestOneToOne();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertFalse(oneToOne.isCascadeRefresh());
-
- oneToOne.setCascadeRefresh(true);
- assertSourceContains("@OneToOne(cascade=REFRESH)");
-
- assertTrue(oneToOne.isCascadeRefresh());
- }
-
- public void testCascadeMoreThanOnce() throws Exception {
- IType testType = this.createTestOneToOneWithCascade();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertTrue(oneToOne.isCascadeAll());
-
- oneToOne.setCascadeAll(true);
- assertTrue(oneToOne.isCascadeAll());
- //a second CascadeType.All should not have been added
- assertSourceContains("@OneToOne(cascade=CascadeType.ALL)");
-
- oneToOne.setCascadeAll(false);
- assertFalse(oneToOne.isCascadeAll());
-
- assertSourceDoesNotContain("cascade");
-
- //test setting cascadeAll to false again, should just do nothing
- oneToOne.setCascadeAll(false);
- assertFalse(oneToOne.isCascadeAll());
-
- assertSourceDoesNotContain("cascade");
- }
-
- public void testDuplicateCascade() throws Exception {
- IType testType = this.createTestOneToOneWithDuplicateCascade();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertTrue(oneToOne.isCascadeMerge());
-
- oneToOne.setCascadeMerge(false);//TODO should the resource model handle this and remove both MERGE
- //settings instead of having to set it false twice?
- assertTrue(oneToOne.isCascadeMerge());
-
- oneToOne.setCascadeMerge(false);
- assertFalse(oneToOne.isCascadeMerge());
-
- assertSourceDoesNotContain("cascade");
- }
-
- public void testMultipleCascade() throws Exception {
- IType testType = this.createTestOneToOneWithMultipleCascade();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE);
- assertTrue(oneToOne.isCascadeMerge());
- assertTrue(oneToOne.isCascadeRemove());
-
- oneToOne.setCascadeMerge(false);
- assertSourceContains("@OneToOne(cascade=REMOVE)");
-
- oneToOne.setCascadeRemove(false);
- assertSourceDoesNotContain("cascade");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OrderByTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OrderByTests.java
deleted file mode 100644
index e8ad7984b6..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OrderByTests.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.OrderByAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class OrderByTests extends JavaResourceModelTestCase {
-
- public OrderByTests(String name) {
- super(name);
- }
-
- private IType createTestOrderBy() throws Exception {
- this.createAnnotationAndMembers("OrderBy", "String value() default \"\";");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ORDER_BY);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OrderBy");
- }
- });
- }
-
- private IType createTestOrderByWithValue() throws Exception {
- this.createAnnotationAndMembers("OrderBy", "String value() default \"\";");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ORDER_BY);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OrderBy(value=\"key\")");
- }
- });
- }
-
- public void testOrderBy() throws Exception {
- IType testType = this.createTestOrderBy();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(JPA.ORDER_BY);
- assertNotNull(orderBy);
- }
-
- public void testGetValue() throws Exception {
- IType testType = this.createTestOrderByWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(JPA.ORDER_BY);
- assertEquals("key", orderBy.getValue());
- }
-
- public void testSetValue() throws Exception {
- IType testType = this.createTestOrderBy();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(JPA.ORDER_BY);
-
- orderBy.setValue("foo");
-
- assertSourceContains("@OrderBy(\"foo\")");
-
- orderBy.setValue(null);
-
- assertSourceContains("@OrderBy");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnTests.java
deleted file mode 100644
index 39575f9b82..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnTests.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class PrimaryKeyJoinColumnTests extends JavaResourceModelTestCase {
-
- private static final String COLUMN_NAME = "MY_COLUMN";
- private static final String COLUMN_COLUMN_DEFINITION = "COLUMN_DEFINITION";
- private static final String COLUMN_REFERENCED_COLUMN_NAME = "MY_REF_COLUMN_NAME";
-
- public PrimaryKeyJoinColumnTests(String name) {
- super(name);
- }
-
- private void createPrimaryKeyJoinColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("PrimaryKeyJoinColumn",
- "String name() default \"\"; " +
- "String referencedColumnName() default \"\"; " +
- "String columnDefinition() default \"\"; ");
- }
-
- private IType createTestPrimaryKeyJoinColumn() throws Exception {
- createPrimaryKeyJoinColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.PRIMARY_KEY_JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@PrimaryKeyJoinColumn");
- }
- });
- }
-
- private IType createTestPrimaryKeyJoinColumnWithName() throws Exception {
- createPrimaryKeyJoinColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.PRIMARY_KEY_JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@PrimaryKeyJoinColumn(name=\"" + COLUMN_NAME + "\")");
- }
- });
- }
-
- private IType createTestPrimaryKeyJoinColumnWithReferencedColumnName() throws Exception {
- createPrimaryKeyJoinColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.PRIMARY_KEY_JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@PrimaryKeyJoinColumn(referencedColumnName=\"" + COLUMN_REFERENCED_COLUMN_NAME + "\")");
- }
- });
- }
-
- private IType createTestPrimaryKeyJoinColumnWithColumnDefinition() throws Exception {
- createPrimaryKeyJoinColumnAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.PRIMARY_KEY_JOIN_COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@PrimaryKeyJoinColumn(columnDefinition=\"" + COLUMN_COLUMN_DEFINITION + "\")");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumnWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
- assertNotNull(column);
- assertEquals(COLUMN_NAME, column.getName());
- }
-
- public void testGetNull() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
- assertNotNull(column);
- assertNull(column.getReferencedColumnName());
- assertNull(column.getColumnDefinition());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getName());
-
- column.setName("Foo");
- assertEquals("Foo", column.getName());
-
- assertSourceContains("@PrimaryKeyJoinColumn(name=\"Foo\")");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumnWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
-
- assertEquals(COLUMN_NAME, column.getName());
-
- column.setName(null);
- assertNull(column.getName());
-
- assertSourceDoesNotContain("@PrimaryKeyJoinColumn");
- }
-
-
-
- public void testGetReferencedColumnName() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumnWithReferencedColumnName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
- assertEquals(COLUMN_REFERENCED_COLUMN_NAME, column.getReferencedColumnName());
- }
-
- public void testSetReferencedColumnName() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getReferencedColumnName());
-
- column.setReferencedColumnName("Foo");
- assertEquals("Foo", column.getReferencedColumnName());
-
- assertSourceContains("@PrimaryKeyJoinColumn(referencedColumnName=\"Foo\")");
-
-
- column.setReferencedColumnName(null);
- assertSourceDoesNotContain("@PrimaryKeyJoinColumn");
- }
-
- public void testGetColumnDefinition() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumnWithColumnDefinition();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
- assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition());
- }
-
- public void testSetColumnDefinition() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
-
- assertNotNull(column);
- assertNull(column.getColumnDefinition());
-
- column.setColumnDefinition("Foo");
- assertEquals("Foo", column.getColumnDefinition());
-
- assertSourceContains("@PrimaryKeyJoinColumn(columnDefinition=\"Foo\")");
-
-
- column.setColumnDefinition(null);
- assertSourceDoesNotContain("@PrimaryKeyJoinColumn");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnsTests.java
deleted file mode 100644
index 62af247415..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnsTests.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase {
-
- private static final String COLUMN_NAME = "MY_COLUMN";
- private static final String COLUMN_COLUMN_DEFINITION = "COLUMN_DEFINITION";
- private static final String COLUMN_REFERENCED_COLUMN_NAME = "MY_REF_COLUMN_NAME";
-
- public PrimaryKeyJoinColumnsTests(String name) {
- super(name);
- }
-
- private void createPrimaryKeyJoinColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("PrimaryKeyJoinColumn",
- "String name() default \"\"; " +
- "String referencedColumnName() default \"\"; " +
- "String columnDefinition() default \"\";");
- }
-
- private void createPrimaryKeyJoinColumnsAnnotation() throws Exception {
- createPrimaryKeyJoinColumnAnnotation();
- this.createAnnotationAndMembers("PrimaryKeyJoinColumns",
- "PrimaryKeyJoinColumn[] value();");
- }
-
- private IType createTestPrimaryKeyJoinColumns() throws Exception {
- createPrimaryKeyJoinColumnsAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn)");
- }
- });
- }
-
- private IType createTestPrimaryKeyJoinColumnWithName() throws Exception {
- createPrimaryKeyJoinColumnsAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(name=\"" + COLUMN_NAME + "\"))");
- }
- });
- }
-
- private IType createTestPrimaryKeyJoinColumnWithReferencedColumnName() throws Exception {
- createPrimaryKeyJoinColumnsAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(referencedColumnName=\"" + COLUMN_REFERENCED_COLUMN_NAME + "\"))");
- }
- });
- }
-
- private IType createTestPrimaryKeyJoinColumnWithColumnDefinition() throws Exception {
- createPrimaryKeyJoinColumnsAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(columnDefinition=\"" + COLUMN_COLUMN_DEFINITION + "\"))");
- }
- });
- }
-
- private IType createTestPrimaryKeyJoinColumn() throws Exception {
- createPrimaryKeyJoinColumnsAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\")");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumnWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next();
- assertNotNull(column);
- assertEquals(COLUMN_NAME, column.getName());
- }
-
- public void testGetNull() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next();
- assertNotNull(column);
- assertNull(column.getName());
- assertNull(column.getReferencedColumnName());
- assertNull(column.getColumnDefinition());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next();
-
- assertNotNull(column);
- assertNull(column.getName());
-
- column.setName("Foo");
- assertEquals("Foo", column.getName());
-
- assertSourceContains("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(name=\"Foo\"))");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumnWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next();
-
- assertEquals(COLUMN_NAME, column.getName());
-
- column.setName(null);
- assertNull(column.getName());
-
- assertSourceDoesNotContain("@PrimaryKeyJoinColumn");
- }
-
- public void testGetReferencedColumnName() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumnWithReferencedColumnName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next();
- assertEquals(COLUMN_REFERENCED_COLUMN_NAME, column.getReferencedColumnName());
- }
-
- public void testSetReferencedColumnName() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next();
-
- assertNotNull(column);
- assertNull(column.getReferencedColumnName());
-
- column.setReferencedColumnName("Foo");
- assertEquals("Foo", column.getReferencedColumnName());
-
- assertSourceContains("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(referencedColumnName=\"Foo\"))");
-
-
- column.setReferencedColumnName(null);
- assertSourceDoesNotContain("@PrimaryKeyJoinColumn");
- }
-
- public void testGetColumnDefinition() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumnWithColumnDefinition();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next();
- assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition());
- }
-
- public void testSetColumnDefinition() throws Exception {
- IType testType = this.createTestPrimaryKeyJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
- PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next();
-
- assertNotNull(column);
- assertNull(column.getColumnDefinition());
-
- column.setColumnDefinition("Foo");
- assertEquals("Foo", column.getColumnDefinition());
-
- assertSourceContains("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(columnDefinition=\"Foo\"))");
-
-
- column.setColumnDefinition(null);
- assertSourceDoesNotContain("@PrimaryKeyJoinColumn");
- }
-
-
- public void testAddPrimaryKeyJoinColumnCopyExisting() throws Exception {
- IType jdtType = createTestPrimaryKeyJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- PrimaryKeyJoinColumnAnnotation joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(1, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- joinColumn.setName("FOO");
- assertSourceContains("@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\"),@PrimaryKeyJoinColumn(name=\"FOO\")})");
-
- assertNull(attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
- assertNotNull(attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMNS));
- assertEquals(2, CollectionTools.size(attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS)));
- }
- public void testAddPrimaryKeyJoinColumnToBeginningOfList() throws Exception {
- IType jdtType = createTestPrimaryKeyJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- PrimaryKeyJoinColumnAnnotation joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(1, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- joinColumn.setName("FOO");
- assertSourceContains("@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\"),@PrimaryKeyJoinColumn(name=\"FOO\")})");
-
- joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- joinColumn.setName("BAZ");
- assertSourceContains("@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn(name=\"BAZ\"),@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\"), @PrimaryKeyJoinColumn(name=\"FOO\")})");
-
- Iterator<JavaResourceNode> pkJoinColumns = attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- assertEquals("BAZ", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumns.next()).getName());
- assertEquals("BAR", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumns.next()).getName());
- assertEquals("FOO", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumns.next()).getName());
-
- assertNull(attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
- assertNotNull(attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMNS));
- assertEquals(3, CollectionTools.size(attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS)));
- }
-
- public void testRemovePrimaryKeyJoinColumnCopyExisting() throws Exception {
- IType jdtType = createTestPrimaryKeyJoinColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- PrimaryKeyJoinColumnAnnotation joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(1, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- joinColumn.setName("FOO");
- assertSourceContains("@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\"),@PrimaryKeyJoinColumn(name=\"FOO\")})");
-
- attributeResource.removeAnnotation(1, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS);
- assertSourceContains("@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\")");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/QueryHintTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/QueryHintTests.java
deleted file mode 100644
index 02c06ba2d8..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/QueryHintTests.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
-import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class QueryHintTests extends JavaResourceModelTestCase {
-
- private static final String QUERY_HINT_NAME = "myHint";
- private static final String QUERY_HINT_VALUE = "myValue";
-
- public QueryHintTests(String name) {
- super(name);
- }
-
- private void createNamedQueryAnnotation() throws Exception {
- createQueryHintAnnotation();
- this.createAnnotationAndMembers("NamedQuery", "String name(); " +
- "String query();" +
- "QueryHint[] hints() default{};");
- }
-
- private void createQueryHintAnnotation() throws Exception {
- this.createAnnotationAndMembers("QueryHint", "String name(); " +
- "String value();");
- }
-
- private IType createTestNamedQueryWithQueryHints() throws Exception {
- createNamedQueryAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.NAMED_QUERY, JPA.QUERY_HINT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@NamedQuery(hints={@QueryHint(name=\"" + QUERY_HINT_NAME + "\", value=\"" + QUERY_HINT_VALUE + "\"), @QueryHint})");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestNamedQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
- QueryHintAnnotation queryHint = namedQuery.hints().next();
- assertEquals(QUERY_HINT_NAME, queryHint.getName());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestNamedQueryWithQueryHints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY);
- QueryHintAnnotation queryHint = namedQuery.hints().next();
- assertEquals(QUERY_HINT_NAME, queryHint.getName());
-
- queryHint.setName("foo");
- assertEquals("foo", queryHint.getName());
-
- assertSourceContains("@QueryHint(name=\"foo\", value=\"" + QUERY_HINT_VALUE + "\")");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTableTests.java
deleted file mode 100644
index 3aeac765d7..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTableTests.java
+++ /dev/null
@@ -1,459 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation;
-import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class SecondaryTableTests extends JavaResourceModelTestCase {
-
- private static final String TABLE_NAME = "MY_TABLE";
- private static final String SCHEMA_NAME = "MY_SCHEMA";
- private static final String CATALOG_NAME = "MY_CATALOG";
-
- public SecondaryTableTests(String name) {
- super(name);
- }
-
- private void createUniqueConstraintAnnotation() throws Exception {
- this.createAnnotationAndMembers("UniqueConstraint", "String[] columnNames();");
- }
-
- private void createPrimaryKeyJoinColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("PrimaryKeyJoinColumn", "String name() default \"\"; String referencedColumnName() default \"\";String columnDefinition() default \"\";");
- }
-
- private void createSecondaryTableAnnotation() throws Exception {
- createPrimaryKeyJoinColumnAnnotation();
- createUniqueConstraintAnnotation();
- this.createAnnotationAndMembers("SecondaryTable", "String name() default \"\"; " +
- "String catalog() default \"\";" +
- "String schema() default \"\";" +
- "PrimaryKeyJoinColumn[] pkJoinColumns() default {};" +
- "UniqueConstraint[] uniqueConstraints() default {};");
- }
-
- private IType createTestSecondaryTable() throws Exception {
- createSecondaryTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SECONDARY_TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SecondaryTable");
- }
- });
- }
-
- private IType createTestSecondaryTableWithName() throws Exception {
- createSecondaryTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SECONDARY_TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SecondaryTable(name=\"" + TABLE_NAME + "\")");
- }
- });
- }
-
- private IType createTestSecondaryTableWithSchema() throws Exception {
- createSecondaryTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SECONDARY_TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SecondaryTable(schema=\"" + SCHEMA_NAME + "\")");
- }
- });
- }
- private IType createTestSecondaryTableWithCatalog() throws Exception {
- createSecondaryTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SECONDARY_TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SecondaryTable(catalog=\"" + CATALOG_NAME + "\")");
- }
- });
- }
-
-
- private IType createTestSecondaryTableWithUniqueConstraints() throws Exception {
- createSecondaryTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SECONDARY_TABLE, JPA.UNIQUE_CONSTRAINT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"})})");
- }
- });
- }
-
- private IType createTestSecondaryTableWithPkJoinColumns() throws Exception {
- createSecondaryTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SECONDARY_TABLE, JPA.PRIMARY_KEY_JOIN_COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"), @PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\")})");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestSecondaryTableWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- assertNotNull(table);
- assertEquals(TABLE_NAME, table.getName());
- }
-
- public void testGetNull() throws Exception {
- IType testType = this.createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- assertNotNull(table);
- assertNull(table.getName());
- assertNull(table.getCatalog());
- assertNull(table.getSchema());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- assertNotNull(table);
- assertNull(table.getName());
-
- table.setName("Foo");
- assertEquals("Foo", table.getName());
-
- assertSourceContains("@SecondaryTable(name=\"Foo\")");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestSecondaryTableWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- assertEquals(TABLE_NAME, table.getName());
-
- table.setName(null);
- assertNull(table.getName());
-
- assertSourceDoesNotContain("@SecondaryTable");
- }
-
- public void testGetCatalog() throws Exception {
- IType testType = this.createTestSecondaryTableWithCatalog();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- assertNotNull(table);
- assertEquals(CATALOG_NAME, table.getCatalog());
- }
-
- public void testSetCatalog() throws Exception {
- IType testType = this.createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- assertNotNull(table);
- assertNull(table.getCatalog());
-
- table.setCatalog("Foo");
- assertEquals("Foo", table.getCatalog());
-
- assertSourceContains("@SecondaryTable(catalog=\"Foo\")");
- }
-
- public void testSetCatalogNull() throws Exception {
- IType testType = this.createTestSecondaryTableWithCatalog();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- assertEquals(CATALOG_NAME, table.getCatalog());
-
- table.setCatalog(null);
- assertNull(table.getCatalog());
-
- assertSourceDoesNotContain("@SecondaryTable");
- }
-
- public void testGetSchema() throws Exception {
- IType testType = this.createTestSecondaryTableWithSchema();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- assertNotNull(table);
- assertEquals(SCHEMA_NAME, table.getSchema());
- }
-
- public void testSetSchema() throws Exception {
- IType testType = this.createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- assertNotNull(table);
- assertNull(table.getSchema());
-
- table.setSchema("Foo");
- assertEquals("Foo", table.getSchema());
-
- assertSourceContains("@SecondaryTable(schema=\"Foo\")");
- }
-
- public void testSetSchemaNull() throws Exception {
- IType testType = this.createTestSecondaryTableWithSchema();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- assertEquals(SCHEMA_NAME, table.getSchema());
-
- table.setSchema(null);
- assertNull(table.getSchema());
-
- assertSourceDoesNotContain("@SecondaryTable");
- }
-
-
- public void testUniqueConstraints() throws Exception {
- IType testType = this.createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals(0, table.uniqueConstraintsSize());
- }
-
- public void testUniqueConstraints2() throws Exception {
- IType testType = this.createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- table.addUniqueConstraint(0);
- table.addUniqueConstraint(1);
-
- assertEquals(2, table.uniqueConstraintsSize());
- }
-
- public void testUniqueConstraints3() throws Exception {
- IType testType = this.createTestSecondaryTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals(3, table.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- IType testType = this.createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- table.addUniqueConstraint(0).addColumnName("FOO");
- table.addUniqueConstraint(1);
- table.addUniqueConstraint(0).addColumnName("BAR");
-
- assertEquals("BAR", table.uniqueConstraintAt(0).columnNames().next());
- assertEquals("FOO", table.uniqueConstraintAt(1).columnNames().next());
- assertEquals(0, table.uniqueConstraintAt(2).columnNamesSize());
-
- assertSourceContains("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint})");
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- IType testType = this.createTestSecondaryTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- table.removeUniqueConstraint(1);
- Iterator<UniqueConstraintAnnotation> uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- assertSourceContains("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"BAZ\"})})");
-
- table.removeUniqueConstraint(0);
- uniqueConstraints = table.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- assertSourceContains("@SecondaryTable(uniqueConstraints=@UniqueConstraint(columnNames={\"BAZ\"}))");
-
- table.removeUniqueConstraint(0);
- uniqueConstraints = table.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- assertSourceDoesNotContain("@SecondaryTable");
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- IType testType = this.createTestSecondaryTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals("BAR", secondaryTable.uniqueConstraintAt(0).columnNames().next());
- assertEquals("FOO", secondaryTable.uniqueConstraintAt(1).columnNames().next());
- assertEquals("BAZ", secondaryTable.uniqueConstraintAt(2).columnNames().next());
- assertEquals(3, secondaryTable.uniqueConstraintsSize());
-
- secondaryTable.moveUniqueConstraint(2, 0);
- assertEquals("FOO", secondaryTable.uniqueConstraintAt(0).columnNames().next());
- assertEquals("BAZ", secondaryTable.uniqueConstraintAt(1).columnNames().next());
- assertEquals("BAR", secondaryTable.uniqueConstraintAt(2).columnNames().next());
- assertEquals(3, secondaryTable.uniqueConstraintsSize());
- assertSourceContains("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"})})");
- }
-
- public void testMoveUniqueConstraint2() throws Exception {
- IType testType = this.createTestSecondaryTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals("BAR", secondaryTable.uniqueConstraintAt(0).columnNames().next());
- assertEquals("FOO", secondaryTable.uniqueConstraintAt(1).columnNames().next());
- assertEquals("BAZ", secondaryTable.uniqueConstraintAt(2).columnNames().next());
- assertEquals(3, secondaryTable.uniqueConstraintsSize());
-
- secondaryTable.moveUniqueConstraint(0, 2);
- assertEquals("BAZ", secondaryTable.uniqueConstraintAt(0).columnNames().next());
- assertEquals("BAR", secondaryTable.uniqueConstraintAt(1).columnNames().next());
- assertEquals("FOO", secondaryTable.uniqueConstraintAt(2).columnNames().next());
- assertEquals(3, secondaryTable.uniqueConstraintsSize());
- assertSourceContains("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"})})");
- }
-
-
- public void testPkJoinColumns() throws Exception {
- IType testType = this.createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals(0, table.pkJoinColumnsSize());
- }
-
- public void testPkJoinColumns2() throws Exception {
- IType testType = this.createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- table.addPkJoinColumn(0);
- table.addPkJoinColumn(1);
-
- assertEquals(2, table.pkJoinColumnsSize());
- }
-
- public void testPkJoinColumns3() throws Exception {
- IType testType = this.createTestSecondaryTableWithPkJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals(3, table.pkJoinColumnsSize());
- }
-
- public void testAddPkJoinColumn() throws Exception {
- IType testType = this.createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
-
- table.addPkJoinColumn(0).setName("FOO");
- table.addPkJoinColumn(0);
- table.addPkJoinColumn(0).setName("BAR");//test adding a pkJoinColumn in front of 2 other joinColumns
-
- assertEquals("BAR", table.pkJoinColumnAt(0).getName());
- assertNull(table.pkJoinColumnAt(1).getName());
- assertEquals("FOO", table.pkJoinColumnAt(2).getName());
-
- assertEquals(3, table.pkJoinColumnsSize());
- assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"),@PrimaryKeyJoinColumn, @PrimaryKeyJoinColumn(name=\"FOO\")})");
- }
-
- public void testRemovePkJoinColumn() throws Exception {
- IType testType = this.createTestSecondaryTableWithPkJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- table.removePkJoinColumn(1);
- assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"), @PrimaryKeyJoinColumn(name=\"BAZ\")})");
-
- table.removePkJoinColumn(0);
- assertSourceContains("@SecondaryTable(pkJoinColumns=@PrimaryKeyJoinColumn(name=\"BAZ\"))");
-
-
- table.removePkJoinColumn(0);
- assertSourceDoesNotContain("@SecondaryTable");
- }
-
- public void testMovePkJoinColumn() throws Exception {
- IType testType = this.createTestSecondaryTableWithPkJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- PrimaryKeyJoinColumnAnnotation joinColumn = table.pkJoinColumnAt(0);
- joinColumn.setReferencedColumnName("REF_NAME");
- joinColumn.setColumnDefinition("COLUMN_DEF");
- table.movePkJoinColumn(2, 0);
- assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\"), @PrimaryKeyJoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", columnDefinition = \"COLUMN_DEF\")})");
- }
-
- public void testMovePkJoinColumn2() throws Exception {
- IType testType = this.createTestSecondaryTableWithPkJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
-
- PrimaryKeyJoinColumnAnnotation joinColumn = table.pkJoinColumnAt(0);
- joinColumn.setReferencedColumnName("REF_NAME");
- joinColumn.setColumnDefinition("COLUMN_DEF");
- table.movePkJoinColumn(0, 2);
- assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAZ\"), @PrimaryKeyJoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", columnDefinition = \"COLUMN_DEF\"), @PrimaryKeyJoinColumn(name=\"FOO\")})");
- }
-
- public void testSetPkJoinColumnName() throws Exception {
- IType testType = this.createTestSecondaryTableWithPkJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
-
- assertEquals(3, table.pkJoinColumnsSize());
-
- PrimaryKeyJoinColumnAnnotation joinColumn = table.pkJoinColumns().next();
-
- assertEquals("BAR", joinColumn.getName());
-
- joinColumn.setName("foo");
- assertEquals("foo", joinColumn.getName());
-
- assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"foo\"), @PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\")})");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTablesTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTablesTests.java
deleted file mode 100644
index 190d7801c0..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTablesTests.java
+++ /dev/null
@@ -1,532 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation;
-import org.eclipse.jpt.core.resource.java.SecondaryTablesAnnotation;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class SecondaryTablesTests extends JavaResourceModelTestCase {
-
- private static final String TABLE_NAME = "MY_TABLE";
- private static final String SCHEMA_NAME = "MY_SCHEMA";
- private static final String CATALOG_NAME = "MY_CATALOG";
-
- public SecondaryTablesTests(String name) {
- super(name);
- }
-
-
- private void createUniqueConstraintAnnotation() throws Exception {
- this.createAnnotationAndMembers("UniqueConstraint", "String[] columnNames();");
- }
-
- private void createPrimaryKeyJoinColumnAnnotation() throws Exception {
- this.createAnnotationAndMembers("PrimaryKeyJoinColumn", "String name() default \"\"; String referencedColumnName() default \"\";String columnDefinition() default \"\";");
- }
-
- private void createSecondaryTableAnnotation() throws Exception {
- createPrimaryKeyJoinColumnAnnotation();
- createUniqueConstraintAnnotation();
- this.createAnnotationAndMembers("SecondaryTable", "String name() default \"\"; " +
- "String catalog() default \"\"; " +
- "String schema() default \"\";" +
- "PrimaryKeyJoinColumn[] pkJoinColumns() default {};" +
- "UniqueConstraint[] uniqueConstraints() default {};");
-
- }
- private void createSecondaryTablesAnnotation() throws Exception {
- createSecondaryTableAnnotation();
- this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value()");
- }
-
- private IType createTestSecondaryTables() throws Exception {
- createSecondaryTablesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SecondaryTables(@SecondaryTable)");
- }
- });
- }
-
- private IType createTestSecondaryTableWithName() throws Exception {
- createSecondaryTablesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SecondaryTables(@SecondaryTable(name=\"" + TABLE_NAME + "\"))");
- }
- });
- }
-
- private IType createTestSecondaryTableWithSchema() throws Exception {
- createSecondaryTablesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SecondaryTables(@SecondaryTable(schema=\"" + SCHEMA_NAME + "\"))");
- }
- });
- }
- private IType createTestSecondaryTableWithCatalog() throws Exception {
- createSecondaryTablesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SecondaryTables(@SecondaryTable(catalog=\"" + CATALOG_NAME + "\"))");
- }
- });
- }
-
-
- private IType createTestSecondaryTableWithUniqueConstraints() throws Exception {
- createSecondaryTablesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES, JPA.UNIQUE_CONSTRAINT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint}))");
- }
- });
- }
-
- private IType createTestSecondaryTable() throws Exception {
- createSecondaryTablesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.SECONDARY_TABLE, JPA.UNIQUE_CONSTRAINT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- sb.append(CR);
- sb.append("@SecondaryTable(name=\"FOO\", catalog=\"BAR\", schema=\"BAZ\", uniqueConstraints=@UniqueConstraint(columnNames={\"BAR\"}))");
- }
- });
- }
-
- private IType createTestSecondaryTablesWithPkJoinColumns() throws Exception {
- createSecondaryTablesAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SECONDARY_TABLES, JPA.SECONDARY_TABLE, JPA.PRIMARY_KEY_JOIN_COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"), @PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\")}))");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestSecondaryTableWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE);
- assertNull(table);
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- assertNotNull(secondaryTables);
-
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
- assertEquals(TABLE_NAME, secondaryTable.getName());
- }
-
- public void testGetNull() throws Exception {
- IType testType = this.createTestSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
- assertNull(secondaryTable.getName());
- assertNull(secondaryTable.getCatalog());
- assertNull(secondaryTable.getSchema());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
-
- assertNull(secondaryTable.getName());
-
- secondaryTable.setName("Foo");
- assertEquals("Foo", secondaryTable.getName());
-
- assertSourceContains("@SecondaryTables(@SecondaryTable(name=\"Foo\"))");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestSecondaryTableWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
- assertEquals(TABLE_NAME, secondaryTable.getName());
-
- secondaryTable.setName(null);
- assertNull(secondaryTable.getName());
-
- assertSourceDoesNotContain("@SecondaryTable");
- }
-
- public void testGetCatalog() throws Exception {
- IType testType = this.createTestSecondaryTableWithCatalog();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
- assertEquals(CATALOG_NAME, secondaryTable.getCatalog());
- }
-
- public void testSetCatalog() throws Exception {
- IType testType = this.createTestSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
- assertNull(secondaryTable.getCatalog());
-
- secondaryTable.setCatalog("Foo");
- assertEquals("Foo", secondaryTable.getCatalog());
-
- assertSourceContains("@SecondaryTables(@SecondaryTable(catalog=\"Foo\"))");
- }
-
- public void testSetCatalogNull() throws Exception {
- IType testType = this.createTestSecondaryTableWithCatalog();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
- assertEquals(CATALOG_NAME, secondaryTable.getCatalog());
-
- secondaryTable.setCatalog(null);
- assertNull(secondaryTable.getCatalog());
-
- assertSourceDoesNotContain("@SecondaryTable");
- }
-
- public void testGetSchema() throws Exception {
- IType testType = this.createTestSecondaryTableWithSchema();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
- assertNotNull(secondaryTable);
- assertEquals(SCHEMA_NAME, secondaryTable.getSchema());
- }
-
- public void testSetSchema() throws Exception {
- IType testType = this.createTestSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
- assertNull(secondaryTable.getSchema());
-
- secondaryTable.setSchema("Foo");
- assertEquals("Foo", secondaryTable.getSchema());
-
- assertSourceContains("@SecondaryTables(@SecondaryTable(schema=\"Foo\"))");
- }
-
- public void testSetSchemaNull() throws Exception {
- IType testType = this.createTestSecondaryTableWithSchema();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
- assertEquals(SCHEMA_NAME, secondaryTable.getSchema());
-
- secondaryTable.setSchema(null);
- assertNull(secondaryTable.getSchema());
-
- assertSourceDoesNotContain("@SecondaryTable");
- }
-
-
- public void testUniqueConstraints() throws Exception {
- IType testType = this.createTestSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
-
- assertEquals(0, secondaryTable.uniqueConstraintsSize());
- }
-
- public void testUniqueConstraints2() throws Exception {
- IType testType = this.createTestSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
-
- secondaryTable.addUniqueConstraint(0);
- secondaryTable.addUniqueConstraint(1);
-
- assertEquals(2, secondaryTable.uniqueConstraintsSize());
- }
-
- public void testUniqueConstraints3() throws Exception {
- IType testType = this.createTestSecondaryTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
-
- assertEquals(2, secondaryTable.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- IType testType = this.createTestSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
-
- secondaryTable.addUniqueConstraint(0).addColumnName("FOO");
- secondaryTable.addUniqueConstraint(1);
- secondaryTable.addUniqueConstraint(0).addColumnName("BAR");
-
- assertEquals("BAR", secondaryTable.uniqueConstraintAt(0).columnNames().next());
- assertEquals("FOO", secondaryTable.uniqueConstraintAt(1).columnNames().next());
- assertEquals(0, secondaryTable.uniqueConstraintAt(2).columnNamesSize());
-
- assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint}))");
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- IType testType = this.createTestSecondaryTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
- secondaryTable.addUniqueConstraint(0).addColumnName("FOO");
-
- secondaryTable.removeUniqueConstraint(2);
- assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint(columnNames={\"BAR\"})})");
-
- secondaryTable.removeUniqueConstraint(0);
- assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints=@UniqueConstraint(columnNames={\"BAR\"}))");
-
- secondaryTable.removeUniqueConstraint(0);
- assertSourceDoesNotContain("@SecondaryTable");
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- IType testType = this.createTestSecondaryTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
- secondaryTable.addUniqueConstraint(0).addColumnName("FOO");
-
- assertEquals("FOO", secondaryTable.uniqueConstraintAt(0).columnNames().next());
- assertEquals("BAR", secondaryTable.uniqueConstraintAt(1).columnNames().next());
- assertFalse(secondaryTable.uniqueConstraintAt(2).columnNames().hasNext());
-
- secondaryTable.moveUniqueConstraint(2, 0);
- assertEquals("BAR", secondaryTable.uniqueConstraintAt(0).columnNames().next());
- assertFalse(secondaryTable.uniqueConstraintAt(1).columnNames().hasNext());
- assertEquals("FOO", secondaryTable.uniqueConstraintAt(2).columnNames().next());
- assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint, @UniqueConstraint(columnNames=\"FOO\")}))");
- }
-
- public void testMoveUniqueConstraint2() throws Exception {
- IType testType = this.createTestSecondaryTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES);
- SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0);
- secondaryTable.addUniqueConstraint(0).addColumnName("FOO");
-
- assertEquals("FOO", secondaryTable.uniqueConstraintAt(0).columnNames().next());
- assertEquals("BAR", secondaryTable.uniqueConstraintAt(1).columnNames().next());
- assertFalse(secondaryTable.uniqueConstraintAt(2).columnNames().hasNext());
-
- secondaryTable.moveUniqueConstraint(0, 2);
- assertFalse(secondaryTable.uniqueConstraintAt(0).columnNames().hasNext());
- assertEquals("FOO", secondaryTable.uniqueConstraintAt(1).columnNames().next());
- assertEquals("BAR", secondaryTable.uniqueConstraintAt(2).columnNames().next());
- assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint, @UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint(columnNames={\"BAR\"})}))");
- }
-
-
- // @Entity -->> @Entity
- // @SecondaryTable(name="FOO") @SecondaryTables({@SecondaryTable(name="FOO"), @SecondaryTable(name="BAR")})
- public void testAddSecondaryTableCopyExisting() throws Exception {
- IType jdtType = createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.addAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTable.setName("BAR");
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\")),@SecondaryTable(name=\"BAR\")})");
-
- assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE));
- assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES));
- assertEquals(2, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
- }
-
- public void testAddSecondaryTable() throws Exception {
- IType jdtType = createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.addAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTable.setName("BAR");
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\")),@SecondaryTable(name=\"BAR\")})");
-
- secondaryTable = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTable.setName("BAZ");
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAZ\"),@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\")), @SecondaryTable(name=\"BAR\")})");
-
- Iterator<JavaResourceNode> secondaryTables = typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- assertEquals("BAZ", ((SecondaryTableAnnotation) secondaryTables.next()).getName());
- assertEquals("FOO", ((SecondaryTableAnnotation) secondaryTables.next()).getName());
- assertEquals("BAR", ((SecondaryTableAnnotation) secondaryTables.next()).getName());
-
- assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE));
- assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES));
- assertEquals(3, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES)));
- }
-
- public void testRemoveSecondaryTableCopyExisting() throws Exception {
- IType jdtType = createTestSecondaryTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType);
-
- SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.addAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- secondaryTable.setName("BAR");
- assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\")),@SecondaryTable(name=\"BAR\")})");
-
- typeResource.removeAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
- assertSourceContains("@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\"))");
- }
-
-
- public void testPkJoinColumns() throws Exception {
- IType testType = this.createTestSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next();
-
- assertEquals(0, table.pkJoinColumnsSize());
- }
-
- public void testPkJoinColumns2() throws Exception {
- IType testType = this.createTestSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next();
-
- table.addPkJoinColumn(0);
- table.addPkJoinColumn(1);
-
- assertEquals(2, table.pkJoinColumnsSize());
- }
-
- public void testPkJoinColumns3() throws Exception {
- IType testType = this.createTestSecondaryTablesWithPkJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next();
-
- assertEquals(3, table.pkJoinColumnsSize());
- }
-
- public void testAddPkJoinColumn() throws Exception {
- IType testType = this.createTestSecondaryTables();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next();
-
- table.addPkJoinColumn(0).setName("FOO");
- table.addPkJoinColumn(1);
- table.addPkJoinColumn(0).setName("BAR");
-
- assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"),@PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn}))");
- }
-
- public void testRemovePkJoinColumn() throws Exception {
- IType testType = this.createTestSecondaryTablesWithPkJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next();
-
- table.removePkJoinColumn(1);
- assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"), @PrimaryKeyJoinColumn(name=\"BAZ\")}))");
-
- table.removePkJoinColumn(0);
- assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns=@PrimaryKeyJoinColumn(name=\"BAZ\")))");
-
- table.removePkJoinColumn(0);
- assertSourceDoesNotContain("@SecondaryTable");
- }
-
- public void testMovePkJoinColumn() throws Exception {
- IType testType = this.createTestSecondaryTablesWithPkJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next();
- PrimaryKeyJoinColumnAnnotation joinColumn = table.pkJoinColumnAt(0);
- joinColumn.setReferencedColumnName("REF_NAME");
- joinColumn.setColumnDefinition("COLUMN_DEF");
- table.movePkJoinColumn(2, 0);
- assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\"), @PrimaryKeyJoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", columnDefinition = \"COLUMN_DEF\")}))");
- }
-
- public void testMovePkJoinColumn2() throws Exception {
- IType testType = this.createTestSecondaryTablesWithPkJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next();
-
-
- PrimaryKeyJoinColumnAnnotation joinColumn = table.pkJoinColumnAt(0);
- joinColumn.setReferencedColumnName("REF_NAME");
- joinColumn.setColumnDefinition("COLUMN_DEF");
- table.movePkJoinColumn(0, 2);
- assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAZ\"), @PrimaryKeyJoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", columnDefinition = \"COLUMN_DEF\"), @PrimaryKeyJoinColumn(name=\"FOO\")}))");
- }
-
- public void testSetPkJoinColumnName() throws Exception {
- IType testType = this.createTestSecondaryTablesWithPkJoinColumns();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next();
-
- assertEquals(3, table.pkJoinColumnsSize());
-
- PrimaryKeyJoinColumnAnnotation joinColumn = table.pkJoinColumns().next();
-
- assertEquals("BAR", joinColumn.getName());
-
- joinColumn.setName("foo");
- assertEquals("foo", joinColumn.getName());
-
- assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"foo\"), @PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\")}))");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SequenceGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SequenceGeneratorTests.java
deleted file mode 100644
index 7199c991d4..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SequenceGeneratorTests.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class SequenceGeneratorTests extends JavaResourceModelTestCase {
-
- private static final String GENERATOR_NAME = "MY_GENERATOR";
- private static final String GENERATOR_SEQUENCE_NAME = "MY_SEQUENCE";
- private static final Integer GENERATOR_ALLOCATION_SIZE = Integer.valueOf(5);
- private static final Integer GENERATOR_INITIAL_VALUE = Integer.valueOf(5);
-
- public SequenceGeneratorTests(String name) {
- super(name);
- }
-
- private void createSequenceGeneratorAnnotation() throws Exception {
- this.createAnnotationAndMembers("SequenceGenerator", "String name(); " +
- "String sequenceName() default \"\"" +
- "int initialValue() default 1" +
- "int allocationSize() default 50");
- }
-
- private IType createTestSequenceGeneratorOnField() throws Exception {
- createSequenceGeneratorAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SEQUENCE_GENERATOR);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@SequenceGenerator");
- }
- });
- }
-
- private IType createTestSequenceGeneratorOnType() throws Exception {
- createSequenceGeneratorAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SEQUENCE_GENERATOR);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@SequenceGenerator");
- }
- });
- }
-
- private IType createTestSequenceGeneratorWithName() throws Exception {
- return createTestSequenceGeneratorWithStringElement("name", GENERATOR_NAME);
- }
-
- private IType createTestSequenceGeneratorWithSequenceName() throws Exception {
- return createTestSequenceGeneratorWithStringElement("sequenceName", GENERATOR_SEQUENCE_NAME);
- }
-
- private IType createTestSequenceGeneratorWithStringElement(final String elementName, final String value) throws Exception {
- createSequenceGeneratorAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SEQUENCE_GENERATOR);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@SequenceGenerator(" + elementName + "=\"" + value + "\")");
- }
- });
- }
-
- private IType createTestSequenceGeneratorWithAllocationSize() throws Exception {
- return createTestSequenceGeneratorWithIntElement("allocationSize", GENERATOR_ALLOCATION_SIZE);
- }
-
- private IType createTestSequenceGeneratorWithInitialValue() throws Exception {
- return createTestSequenceGeneratorWithIntElement("initialValue", GENERATOR_INITIAL_VALUE);
- }
-
- private IType createTestSequenceGeneratorWithIntElement(final String elementName, final int value) throws Exception {
- createSequenceGeneratorAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.SEQUENCE_GENERATOR);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@SequenceGenerator(" + elementName + "=" + value + ")");
- }
- });
- }
-
- public void testSequenceGeneratorOnField() throws Exception {
- IType testType = this.createTestSequenceGeneratorOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
- assertNotNull(sequenceGenerator);
- }
-
- public void testSequenceGeneratorOnType() throws Exception {
- IType testType = this.createTestSequenceGeneratorOnType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) typeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
- assertNotNull(sequenceGenerator);
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestSequenceGeneratorWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
- assertEquals(GENERATOR_NAME, sequenceGenerator.getName());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestSequenceGeneratorWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
- assertEquals(GENERATOR_NAME, sequenceGenerator.getName());
-
- sequenceGenerator.setName("foo");
- assertEquals("foo", sequenceGenerator.getName());
-
- assertSourceContains("@SequenceGenerator(name=\"foo\")");
-
- sequenceGenerator.setName(null);
- assertNull(sequenceGenerator.getName());
-
- assertSourceDoesNotContain("@SequenceGenerator");
- }
-
- public void testGetSequenceName() throws Exception {
- IType testType = this.createTestSequenceGeneratorWithSequenceName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
- assertEquals(GENERATOR_SEQUENCE_NAME, sequenceGenerator.getSequenceName());
- }
-
- public void testSetSequenceName() throws Exception {
- IType testType = this.createTestSequenceGeneratorWithSequenceName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
- assertEquals(GENERATOR_SEQUENCE_NAME, sequenceGenerator.getSequenceName());
-
- sequenceGenerator.setSequenceName("foo");
- assertEquals("foo", sequenceGenerator.getSequenceName());
-
- assertSourceContains("@SequenceGenerator(sequenceName=\"foo\")");
-
- sequenceGenerator.setSequenceName(null);
- assertNull(sequenceGenerator.getSequenceName());
-
- assertSourceDoesNotContain("@SequenceGenerator");
- }
-
- public void testGetAllocationSize() throws Exception {
- IType testType = this.createTestSequenceGeneratorWithAllocationSize();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
- assertEquals(GENERATOR_ALLOCATION_SIZE, sequenceGenerator.getAllocationSize());
- }
-
- public void testSetAllocationSize() throws Exception {
- IType testType = this.createTestSequenceGeneratorWithAllocationSize();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
- assertEquals(GENERATOR_ALLOCATION_SIZE, sequenceGenerator.getAllocationSize());
-
- sequenceGenerator.setAllocationSize(Integer.valueOf(500));
- assertEquals(Integer.valueOf(500), sequenceGenerator.getAllocationSize());
-
- assertSourceContains("@SequenceGenerator(allocationSize=500)");
-
- sequenceGenerator.setAllocationSize(null);
-
- assertSourceDoesNotContain("@SequenceGenerator");
-
- sequenceGenerator.setAllocationSize(Integer.valueOf(0));
- assertSourceContains("@SequenceGenerator(allocationSize=0)");
- }
-
- public void testGetInitialValue() throws Exception {
- IType testType = this.createTestSequenceGeneratorWithInitialValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
- assertEquals(GENERATOR_INITIAL_VALUE, sequenceGenerator.getInitialValue());
- }
-
- public void testSetInitialValue() throws Exception {
- IType testType = this.createTestSequenceGeneratorWithInitialValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR);
- assertEquals(GENERATOR_INITIAL_VALUE, sequenceGenerator.getInitialValue());
-
- sequenceGenerator.setInitialValue(Integer.valueOf(500));
- assertEquals(Integer.valueOf(500), sequenceGenerator.getInitialValue());
-
- assertSourceContains("@SequenceGenerator(initialValue=500)");
-
- sequenceGenerator.setInitialValue(null);
-
- assertSourceDoesNotContain("@SequenceGenerator");
-
- sequenceGenerator.setInitialValue(Integer.valueOf(0));
- assertSourceContains("@SequenceGenerator(initialValue=0)");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableGeneratorTests.java
deleted file mode 100644
index 79dd41ccce..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableGeneratorTests.java
+++ /dev/null
@@ -1,521 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class TableGeneratorTests extends JavaResourceModelTestCase {
-
- private static final String GENERATOR_NAME = "MY_GENERATOR";
- private static final String GENERATOR_TABLE = "MY_TABLE";
- private static final String GENERATOR_CATALOG = "MY_CATALOG";
- private static final String GENERATOR_SCHEMA = "MY_SCHEMA";
- private static final String GENERATOR_PK_COLUMN_NAME = "MY_PK_COLUMN_NAME";
- private static final String GENERATOR_VALUE_COLUMN_NAME = "MY_VALUE_COLUMN_NAME";
- private static final String GENERATOR_PK_COLUMN_VALUE = "MY_PK_COLUMN_VALUE";
- private static final Integer GENERATOR_ALLOCATION_SIZE = Integer.valueOf(5);
- private static final Integer GENERATOR_INITIAL_VALUE = Integer.valueOf(5);
-
- public TableGeneratorTests(String name) {
- super(name);
- }
-
- private void createTableGeneratorAnnotation() throws Exception {
- this.createAnnotationAndMembers("TableGenerator", "String name(); " +
- "String table() default \"\"" +
- "String catalog() default \"\"" +
- "String schema() default \"\"" +
- "String pkColumnName() default \"\"" +
- "String valueColumnName() default \"\"" +
- "String pkColumnValue() default \"\"" +
- "int initialValue() default 0" +
- "int allocationSize() default 50" +
- "UniqueConstraint[] uniqueConstraints() default{}");
- }
-
- private IType createTestTableGeneratorOnField() throws Exception {
- createTableGeneratorAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TABLE_GENERATOR);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@TableGenerator");
- }
- });
- }
-
- private IType createTestTableGeneratorOnType() throws Exception {
- createTableGeneratorAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TABLE_GENERATOR);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@TableGenerator");
- }
- });
- }
-
- private IType createTestTableGeneratorWithName() throws Exception {
- return createTestTableGeneratorWithStringElement("name", GENERATOR_NAME);
- }
-
- private IType createTestTableGeneratorWithTable() throws Exception {
- return createTestTableGeneratorWithStringElement("table", GENERATOR_TABLE);
- }
-
- private IType createTestTableGeneratorWithCatalog() throws Exception {
- return createTestTableGeneratorWithStringElement("catalog", GENERATOR_CATALOG);
- }
-
- private IType createTestTableGeneratorWithSchema() throws Exception {
- return createTestTableGeneratorWithStringElement("schema", GENERATOR_SCHEMA);
- }
- private IType createTestTableGeneratorWithPkColumnName() throws Exception {
- return createTestTableGeneratorWithStringElement("pkColumnName", GENERATOR_PK_COLUMN_NAME);
- }
-
- private IType createTestTableGeneratorWithValueColumnName() throws Exception {
- return createTestTableGeneratorWithStringElement("valueColumnName", GENERATOR_VALUE_COLUMN_NAME);
- }
-
- private IType createTestTableGeneratorWithPkColumnValue() throws Exception {
- return createTestTableGeneratorWithStringElement("pkColumnValue", GENERATOR_PK_COLUMN_VALUE);
- }
-
- private IType createTestTableGeneratorWithStringElement(final String elementName, final String value) throws Exception {
- createTableGeneratorAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TABLE_GENERATOR);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@TableGenerator(" + elementName + "=\"" + value + "\")");
- }
- });
- }
-
- private IType createTestTableGeneratorWithAllocationSize() throws Exception {
- return createTestTableGeneratorWithIntElement("allocationSize", GENERATOR_ALLOCATION_SIZE);
- }
-
- private IType createTestTableGeneratorWithInitialValue() throws Exception {
- return createTestTableGeneratorWithIntElement("initialValue", GENERATOR_INITIAL_VALUE);
- }
-
- private IType createTestTableGeneratorWithIntElement(final String elementName, final int value) throws Exception {
- createTableGeneratorAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TABLE_GENERATOR);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@TableGenerator(" + elementName + "=" + value + ")");
- }
- });
- }
-
- private IType createTestTableGeneratorWithUniqueConstraints() throws Exception {
- createTableGeneratorAnnotation();
- this.createAnnotationAndMembers("UniqueConstraint", "String[] columnNames();");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TABLE_GENERATOR, JPA.UNIQUE_CONSTRAINT);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"})})");
- }
- });
- }
-
- public void testTableGeneratorOnField() throws Exception {
- IType testType = this.createTestTableGeneratorOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertNotNull(tableGenerator);
- }
-
- public void testTableGeneratorOnType() throws Exception {
- IType testType = this.createTestTableGeneratorOnType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) typeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertNotNull(tableGenerator);
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestTableGeneratorWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_NAME, tableGenerator.getName());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestTableGeneratorWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_NAME, tableGenerator.getName());
-
- tableGenerator.setName("foo");
- assertEquals("foo", tableGenerator.getName());
-
- assertSourceContains("@TableGenerator(name=\"foo\")");
-
- tableGenerator.setName(null);
- assertNull(tableGenerator.getName());
-
- assertSourceDoesNotContain("@TableGenerator");
- }
-
- public void testGetTable() throws Exception {
- IType testType = this.createTestTableGeneratorWithTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_TABLE, tableGenerator.getTable());
- }
-
- public void testSetTable() throws Exception {
- IType testType = this.createTestTableGeneratorWithTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_TABLE, tableGenerator.getTable());
-
- tableGenerator.setTable("foo");
- assertEquals("foo", tableGenerator.getTable());
-
- assertSourceContains("@TableGenerator(table=\"foo\")");
-
- tableGenerator.setTable(null);
- assertNull(tableGenerator.getTable());
-
- assertSourceDoesNotContain("@TableGenerator");
- }
-
- public void testGetCatalog() throws Exception {
- IType testType = this.createTestTableGeneratorWithCatalog();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_CATALOG, tableGenerator.getCatalog());
- }
-
- public void testSetCatalog() throws Exception {
- IType testType = this.createTestTableGeneratorWithCatalog();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_CATALOG, tableGenerator.getCatalog());
-
- tableGenerator.setCatalog("foo");
- assertEquals("foo", tableGenerator.getCatalog());
-
- assertSourceContains("@TableGenerator(catalog=\"foo\")");
-
- tableGenerator.setCatalog(null);
- assertNull(tableGenerator.getCatalog());
-
- assertSourceDoesNotContain("@TableGenerator");
- }
-
- public void testGetSchema() throws Exception {
- IType testType = this.createTestTableGeneratorWithSchema();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_SCHEMA, tableGenerator.getSchema());
- }
-
- public void testSetSchema() throws Exception {
- IType testType = this.createTestTableGeneratorWithSchema();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_SCHEMA, tableGenerator.getSchema());
-
- tableGenerator.setSchema("foo");
- assertEquals("foo", tableGenerator.getSchema());
-
- assertSourceContains("@TableGenerator(schema=\"foo\")");
-
- tableGenerator.setSchema(null);
- assertNull(tableGenerator.getSchema());
-
- assertSourceDoesNotContain("@TableGenerator");
- }
-
- public void testGetPkColumnName() throws Exception {
- IType testType = this.createTestTableGeneratorWithPkColumnName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_PK_COLUMN_NAME, tableGenerator.getPkColumnName());
- }
-
- public void testSetPkColumnName() throws Exception {
- IType testType = this.createTestTableGeneratorWithPkColumnName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_PK_COLUMN_NAME, tableGenerator.getPkColumnName());
-
- tableGenerator.setPkColumnName("foo");
- assertEquals("foo", tableGenerator.getPkColumnName());
-
- assertSourceContains("@TableGenerator(pkColumnName=\"foo\")");
-
- tableGenerator.setPkColumnName(null);
- assertNull(tableGenerator.getPkColumnName());
-
- assertSourceDoesNotContain("@TableGenerator");
- }
-
- public void testGetValueColumnName() throws Exception {
- IType testType = this.createTestTableGeneratorWithValueColumnName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_VALUE_COLUMN_NAME, tableGenerator.getValueColumnName());
- }
-
- public void testSetValueColumnName() throws Exception {
- IType testType = this.createTestTableGeneratorWithValueColumnName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_VALUE_COLUMN_NAME, tableGenerator.getValueColumnName());
-
- tableGenerator.setValueColumnName("foo");
- assertEquals("foo", tableGenerator.getValueColumnName());
-
- assertSourceContains("@TableGenerator(valueColumnName=\"foo\")");
-
- tableGenerator.setValueColumnName(null);
- assertNull(tableGenerator.getValueColumnName());
-
- assertSourceDoesNotContain("@TableGenerator");
- }
-
- public void testGetPkColumnValue() throws Exception {
- IType testType = this.createTestTableGeneratorWithPkColumnValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_PK_COLUMN_VALUE, tableGenerator.getPkColumnValue());
- }
-
- public void testSetPkColumnValue() throws Exception {
- IType testType = this.createTestTableGeneratorWithPkColumnValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_PK_COLUMN_VALUE, tableGenerator.getPkColumnValue());
-
- tableGenerator.setPkColumnValue("foo");
- assertEquals("foo", tableGenerator.getPkColumnValue());
-
- assertSourceContains("@TableGenerator(pkColumnValue=\"foo\")");
-
- tableGenerator.setPkColumnValue(null);
- assertNull(tableGenerator.getPkColumnValue());
-
- assertSourceDoesNotContain("@TableGenerator");
- }
-
- public void testGetAllocationSize() throws Exception {
- IType testType = this.createTestTableGeneratorWithAllocationSize();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_ALLOCATION_SIZE, tableGenerator.getAllocationSize());
- }
-
- public void testSetAllocationSize() throws Exception {
- IType testType = this.createTestTableGeneratorWithAllocationSize();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_ALLOCATION_SIZE, tableGenerator.getAllocationSize());
-
- tableGenerator.setAllocationSize(Integer.valueOf(500));
- assertEquals(Integer.valueOf(500), tableGenerator.getAllocationSize());
-
- assertSourceContains("@TableGenerator(allocationSize=500)");
-
- tableGenerator.setAllocationSize(null);
-
- assertSourceDoesNotContain("@TableGenerator");
-
- tableGenerator.setAllocationSize(Integer.valueOf(0));
- assertSourceContains("@TableGenerator(allocationSize=0)");
- }
-
- public void testGetInitialValue() throws Exception {
- IType testType = this.createTestTableGeneratorWithInitialValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_INITIAL_VALUE, tableGenerator.getInitialValue());
- }
-
- public void testSetInitialValue() throws Exception {
- IType testType = this.createTestTableGeneratorWithInitialValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
- assertEquals(GENERATOR_INITIAL_VALUE, tableGenerator.getInitialValue());
-
- tableGenerator.setInitialValue(Integer.valueOf(500));
- assertEquals(Integer.valueOf(500), tableGenerator.getInitialValue());
-
- assertSourceContains("@TableGenerator(initialValue=500)");
-
- tableGenerator.setInitialValue(null);
-
- assertSourceDoesNotContain("@TableGenerator");
-
- tableGenerator.setInitialValue(Integer.valueOf(0));
- assertSourceContains("@TableGenerator(initialValue=0)");
- }
-
- public void testUniqueConstraints() throws Exception {
- IType testType = this.createTestTableGeneratorOnField();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertEquals(0, tableGenerator.uniqueConstraintsSize());
- }
-
- public void testUniqueConstraints2() throws Exception {
- IType testType = this.createTestTableGeneratorOnField();
- this.createAnnotationAndMembers("UniqueConstraint", "String[] columnNames();");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.addUniqueConstraint(0);
- tableGenerator.addUniqueConstraint(1);
-
- assertEquals(2, tableGenerator.uniqueConstraintsSize());
- }
-
- public void testUniqueConstraints3() throws Exception {
- IType testType = this.createTestTableGeneratorWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- assertEquals(3, tableGenerator.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- IType testType = this.createTestTableGeneratorOnField();
- this.createAnnotationAndMembers("UniqueConstraint", "String[] columnNames();");
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.addUniqueConstraint(0).addColumnName("FOO");
- tableGenerator.addUniqueConstraint(1);
- tableGenerator.addUniqueConstraint(0).addColumnName("BAR");
-
- assertEquals("BAR", tableGenerator.uniqueConstraintAt(0).columnNames().next());
- assertEquals("FOO", tableGenerator.uniqueConstraintAt(1).columnNames().next());
- assertEquals(0, tableGenerator.uniqueConstraintAt(2).columnNamesSize());
-
- assertEquals(3, tableGenerator.uniqueConstraintsSize());
- assertSourceContains("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint})");
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- IType testType = this.createTestTableGeneratorWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.removeUniqueConstraint(1);
- assertSourceContains("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"BAZ\"})})");
-
- tableGenerator.removeUniqueConstraint(0);
- assertSourceContains("@TableGenerator(uniqueConstraints=@UniqueConstraint(columnNames={\"BAZ\"}))");
-
- tableGenerator.removeUniqueConstraint(0);
- assertSourceDoesNotContain("@TableGenerator");
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- IType testType = this.createTestTableGeneratorWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.moveUniqueConstraint(2, 0);
- assertSourceContains("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"})})");
- }
-
- public void testMoveUniqueConstraint2() throws Exception {
- IType testType = this.createTestTableGeneratorWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR);
-
- tableGenerator.moveUniqueConstraint(0, 2);
- assertSourceContains("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"})})");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableTests.java
deleted file mode 100644
index 562733a2e8..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableTests.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.TableAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class TableTests extends JavaResourceModelTestCase {
-
- private static final String TABLE_NAME = "MY_TABLE";
- private static final String SCHEMA_NAME = "MY_SCHEMA";
- private static final String CATALOG_NAME = "MY_CATALOG";
-
- public TableTests(String name) {
- super(name);
- }
-
- private void createTableAnnotation() throws Exception {
- createUniqueConstraintAnnotation();
- this.createAnnotationAndMembers("Table", "String name() default \"\"; String catalog() default \"\"; String schema() default \"\"; UniqueConstraint[] uniqueConstraints() default {};");
- }
-
- private void createUniqueConstraintAnnotation() throws Exception {
- createAnnotationAndMembers("UniqueConstraint", "String[] columnNames();");
- }
-
- private IType createTestTable() throws Exception {
- createTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Table");
- }
- });
- }
-
- private IType createTestTableWithName() throws Exception {
- createTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Table(name=\"" + TABLE_NAME + "\")");
- }
- });
- }
-
- private IType createTestTableWithSchema() throws Exception {
- createTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Table(schema=\"" + SCHEMA_NAME + "\")");
- }
- });
- }
-
- private IType createTestTableWithCatalog() throws Exception {
- createTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Table(catalog=\"" + CATALOG_NAME + "\")");
- }
- });
- }
-
- private IType createTestTableWithUniqueConstraints() throws Exception {
- createTableAnnotation();
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TABLE, JPA.UNIQUE_CONSTRAINT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Table(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"})})");
- }
- });
- }
-
- public void testGetName() throws Exception {
- IType testType = this.createTestTableWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- assertNotNull(table);
- assertEquals(TABLE_NAME, table.getName());
- }
-
- public void testGetNull() throws Exception {
- IType testType = this.createTestTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- assertNotNull(table);
- assertNull(table.getName());
- assertNull(table.getCatalog());
- assertNull(table.getSchema());
- }
-
- public void testSetName() throws Exception {
- IType testType = this.createTestTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- assertNotNull(table);
- assertNull(table.getName());
-
- table.setName("Foo");
- assertEquals("Foo", table.getName());
-
- assertSourceContains("@Table(name=\"Foo\")");
- }
-
- public void testSetNameNull() throws Exception {
- IType testType = this.createTestTableWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- assertEquals(TABLE_NAME, table.getName());
-
- table.setName(null);
- assertNull(table.getName());
-
- assertSourceDoesNotContain("@Table");
- }
-
- public void testGetCatalog() throws Exception {
- IType testType = this.createTestTableWithCatalog();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- assertNotNull(table);
- assertEquals(CATALOG_NAME, table.getCatalog());
- }
-
- public void testSetCatalog() throws Exception {
- IType testType = this.createTestTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- assertNotNull(table);
- assertNull(table.getCatalog());
-
- table.setCatalog("Foo");
- assertEquals("Foo", table.getCatalog());
-
- assertSourceContains("@Table(catalog=\"Foo\")");
- }
-
- public void testSetCatalogNull() throws Exception {
- IType testType = this.createTestTableWithCatalog();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- assertEquals(CATALOG_NAME, table.getCatalog());
-
- table.setCatalog(null);
- assertNull(table.getCatalog());
-
- assertSourceDoesNotContain("@Table");
- }
-
- public void testGetSchema() throws Exception {
- IType testType = this.createTestTableWithSchema();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- assertNotNull(table);
- assertEquals(SCHEMA_NAME, table.getSchema());
- }
-
- public void testSetSchema() throws Exception {
- IType testType = this.createTestTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- assertNotNull(table);
- assertNull(table.getSchema());
-
- table.setSchema("Foo");
- assertEquals("Foo", table.getSchema());
-
- assertSourceContains("@Table(schema=\"Foo\")");
- }
-
- public void testSetSchemaNull() throws Exception {
- IType testType = this.createTestTableWithSchema();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
-
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- assertEquals(SCHEMA_NAME, table.getSchema());
-
- table.setSchema(null);
- assertNull(table.getSchema());
-
- assertSourceDoesNotContain("@Table");
- }
-
- public void testUniqueConstraints() throws Exception {
- IType testType = this.createTestTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- assertEquals(0, table.uniqueConstraintsSize());
- }
-
- public void testUniqueConstraints2() throws Exception {
- IType testType = this.createTestTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- table.addUniqueConstraint(0);
- table.addUniqueConstraint(1);
-
- assertEquals(2, table.uniqueConstraintsSize());
- }
-
- public void testUniqueConstraints3() throws Exception {
- IType testType = this.createTestTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- assertEquals(3, table.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- IType testType = this.createTestTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- table.addUniqueConstraint(0).addColumnName("FOO");
- table.addUniqueConstraint(1);
- table.addUniqueConstraint(0).addColumnName("BAR");
-
- assertEquals("BAR", table.uniqueConstraintAt(0).columnNames().next());
- assertEquals("FOO", table.uniqueConstraintAt(1).columnNames().next());
- assertEquals(0, table.uniqueConstraintAt(2).columnNamesSize());
-
- assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint})");
- }
-
- public void testAddUniqueConstraint2() throws Exception {
- IType testType = this.createTestTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- table.addUniqueConstraint(0).addColumnName("FOO");
- table.addUniqueConstraint(0);
- table.addUniqueConstraint(1).addColumnName("BAR");
- table.uniqueConstraintAt(1).addColumnName("BAZ");
-
- assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint,@UniqueConstraint(columnNames={ \"BAR\", \"BAZ\" }), @UniqueConstraint(columnNames=\"FOO\")})");
-
- assertEquals("FOO", table.uniqueConstraintAt(2).columnNames().next());
- ListIterator<String> columnNames = table.uniqueConstraintAt(1).columnNames();
- assertEquals("BAR", columnNames.next());
- assertEquals("BAZ", columnNames.next());
- }
- public void testRemoveUniqueConstraint() throws Exception {
- IType testType = this.createTestTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- table.removeUniqueConstraint(1);
- assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"BAZ\"})})");
-
- table.removeUniqueConstraint(0);
- assertSourceContains("@Table(uniqueConstraints=@UniqueConstraint(columnNames={\"BAZ\"}))");
-
- table.removeUniqueConstraint(0);
- assertSourceDoesNotContain("@Table");
- }
-
- public void testRemoveUniqueConstraint2() throws Exception {
- IType testType = this.createTestTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- table.addUniqueConstraint(0).addColumnName("FOO");
- table.addUniqueConstraint(1).addColumnName("BAR");
- table.addUniqueConstraint(2).addColumnName("BAZ");
- assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"FOO\"),@UniqueConstraint(columnNames=\"BAR\"), @UniqueConstraint(columnNames=\"BAZ\")})");
-
- table.removeUniqueConstraint(0);
- assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"BAZ\")})");
-
- table.removeUniqueConstraint(0);
- assertSourceContains("@Table(uniqueConstraints=@UniqueConstraint(columnNames=\"BAZ\"))");
-
- table.removeUniqueConstraint(0);
- assertSourceDoesNotContain("@Table");
- }
-
- public void testRemoveUniqueConstraint3() throws Exception {
- IType testType = this.createTestTable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
- table.addUniqueConstraint(0).addColumnName("FOO");
- table.addUniqueConstraint(1).addColumnName("BAR");
- table.addUniqueConstraint(2).addColumnName("BAZ");
- assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"FOO\"),@UniqueConstraint(columnNames=\"BAR\"), @UniqueConstraint(columnNames=\"BAZ\")})");
-
- table.removeUniqueConstraint(2);
- assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"FOO\"),@UniqueConstraint(columnNames=\"BAR\")})");
-
- table.removeUniqueConstraint(1);
- assertSourceContains("@Table(uniqueConstraints=@UniqueConstraint(columnNames=\"FOO\"))");
-
- table.removeUniqueConstraint(0);
- assertSourceDoesNotContain("@Table");
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- IType testType = this.createTestTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- table.moveUniqueConstraint(2, 0);
- assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"})})");
- }
-
- public void testMoveUniqueConstraint2() throws Exception {
- IType testType = this.createTestTableWithUniqueConstraints();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE);
-
- table.moveUniqueConstraint(0, 2);
- assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"})})");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TemporalTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TemporalTests.java
deleted file mode 100644
index 7fcad1f3e5..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TemporalTests.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.TemporalAnnotation;
-import org.eclipse.jpt.core.resource.java.TemporalType;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class TemporalTests extends JavaResourceModelTestCase {
-
- public TemporalTests(String name) {
- super(name);
- }
-
- private IType createTestTemporal() throws Exception {
- this.createAnnotationAndMembers("Temporal", "TemporalType value();");
- this.createEnumAndMembers("TemporalType", "DATE, TIME, TIMESTAMP");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TEMPORAL);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Temporal");
- }
- });
- }
-
- private IType createTestTemporalWithValue() throws Exception {
- this.createAnnotationAndMembers("Temporal", "TemporalType value();");
- this.createEnumAndMembers("TemporalType", "DATE, TIME, TIMESTAMP");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TEMPORAL, JPA.TEMPORAL_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Temporal(TemporalType.DATE)");
- }
- });
- }
-
- public void testTemporal() throws Exception {
- IType testType = this.createTestTemporal();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.getAnnotation(JPA.TEMPORAL);
- assertNotNull(temporal);
- }
-
- public void testGetValue() throws Exception {
- IType testType = this.createTestTemporalWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.getAnnotation(JPA.TEMPORAL);
- assertEquals(TemporalType.DATE, temporal.getValue());
- }
-
- public void testSetValue() throws Exception {
- IType testType = this.createTestTemporal();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.getAnnotation(JPA.TEMPORAL);
-
- temporal.setValue(TemporalType.TIME);
-
- assertSourceContains("@Temporal(TIME)");
-
- temporal.setValue(null);
-
- assertSourceDoesNotContain("@Temporal");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TransientTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TransientTests.java
deleted file mode 100644
index 141ed87d81..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TransientTests.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class TransientTests extends JavaResourceModelTestCase {
-
- public TransientTests(String name) {
- super(name);
- }
-
- private IType createTestTransient() throws Exception {
- this.createAnnotationAndMembers("Transient", "");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.TRANSIENT);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Transient");
- }
- });
- }
-
- public void testTransient() throws Exception {
- IType testType = this.createTestTransient();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JavaResourceNode mappingAnnotation = attributeResource.getMappingAnnotation();
- assertTrue(mappingAnnotation instanceof TransientAnnotation);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/VersionTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/VersionTests.java
deleted file mode 100644
index 46a5579a71..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/VersionTests.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class VersionTests extends JavaResourceModelTestCase {
-
- public VersionTests(String name) {
- super(name);
- }
-
- private IType createTestVersion() throws Exception {
- this.createAnnotationAndMembers("Version", "");
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.VERSION);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Version");
- }
- });
- }
-
- public void testVersion() throws Exception {
- IType testType = this.createTestVersion();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(testType);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- JavaResourceNode mappingAnnotation = attributeResource.getMappingAnnotation();
- assertTrue(mappingAnnotation instanceof VersionAnnotation);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/AnnotationTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/AnnotationTestCase.java
deleted file mode 100644
index f22c6b3aa6..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/AnnotationTestCase.java
+++ /dev/null
@@ -1,506 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.utility.jdt;
-
-import java.io.File;
-import java.util.Iterator;
-import java.util.List;
-import junit.framework.TestCase;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.NumberLiteral;
-import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jdt.core.dom.StringLiteral;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTFieldAttribute;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTMethodAttribute;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTType;
-import org.eclipse.jpt.core.tests.internal.ProjectUtility;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject;
-import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.utility.CommandExecutor;
-import org.eclipse.jpt.utility.CommandExecutorProvider;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-/**
- * Provide an easy(?) way to build an annotated source file.
- * The type must be created by calling one of the #createType() methods
- * before calling any of the various helper methods (i.e. the type is *not*
- * created during #setUp()).
- */
-public abstract class AnnotationTestCase extends TestCase {
- protected TestJavaProject javaProject;
-
- protected static final String CR = System.getProperty("line.separator");
- protected static final String SEP = File.separator;
- protected static final String PROJECT_NAME = "AnnotationTestProject";
- protected static final String PACKAGE_NAME = "test";
- protected static final String TYPE_NAME = "AnnotationTestType";
- protected static final String FULLY_QUALIFIED_TYPE_NAME = PACKAGE_NAME + "." + TYPE_NAME;
- protected static final String FILE_NAME = TYPE_NAME + ".java";
- protected static final IPath FILE_PATH = new Path("src" + SEP + PACKAGE_NAME + SEP + FILE_NAME);
-
- protected static final String[] EMPTY_STRING_ARRAY = new String[0];
-
-
- // ********** TestCase behavior **********
-
- protected AnnotationTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.deleteAllProjects();
- this.javaProject = this.buildJavaProject(false); // false = no auto-build
- }
-
- protected void deleteAllProjects() throws Exception {
- ProjectUtility.deleteAllProjects();
- }
-
- protected TestJavaProject buildJavaProject(boolean autoBuild) throws Exception {
- return this.buildJavaProject(PROJECT_NAME, autoBuild);
- }
-
- protected TestJavaProject buildJavaProject(String projectName, boolean autoBuild) throws Exception {
- return new TestJavaProject(projectName, autoBuild);
- }
-
- @Override
- protected void tearDown() throws Exception {
-// this.dumpSource();
-// this.javaProject.dispose();
- TestTools.clear(this);
- super.tearDown();
- }
-
- protected void dumpSource() throws Exception {
- System.out.println("*** " + this.getName() + " ****");
- System.out.println(this.source());
- System.out.println();
- }
-
-
- // ********** type creation **********
-
- /**
- * create an un-annotated type
- */
- protected IType createTestType() throws CoreException {
- return this.createTestType(new DefaultAnnotationWriter());
- }
-
- /**
- * shortcut for simply adding an annotation to the 'id' field
- */
- protected IType createTestType(final String annotationImport, final String idFieldAnnotation) throws CoreException {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return (annotationImport == null) ?
- EmptyIterator.<String>instance()
- :
- new SingleElementIterator<String>(annotationImport);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(idFieldAnnotation);
- }
- });
- }
-
- /**
- * shortcut for simply adding a fully-qualified annotation to the 'id' field
- */
- protected IType createTestType(final String idFieldAnnotation) throws CoreException {
- return this.createTestType(null, idFieldAnnotation);
- }
-
-
- protected IType createTestType(AnnotationWriter annotationWriter) throws CoreException {
- return this.javaProject.createType(PACKAGE_NAME, FILE_NAME, this.createSourceWriter(annotationWriter));
- }
-
- protected IType createTestType(String packageName, String fileName, String typeName, AnnotationWriter annotationWriter) throws CoreException {
- return this.javaProject.createType(packageName, fileName, this.createSourceWriter(annotationWriter, typeName));
- }
-
- protected SourceWriter createSourceWriter(AnnotationWriter annotationWriter) {
- return new AnnotatedSourceWriter(annotationWriter);
- }
-
- protected SourceWriter createSourceWriter(AnnotationWriter annotationWriter, String typeName) {
- return new AnnotatedSourceWriter(annotationWriter, typeName);
- }
-
- protected void appendSourceTo(StringBuilder sb, AnnotationWriter annotationWriter, String typeName) {
- sb.append(CR);
- for (Iterator<String> stream = annotationWriter.imports(); stream.hasNext(); ) {
- sb.append("import ");
- sb.append(stream.next());
- sb.append(";");
- sb.append(CR);
- }
- sb.append(CR);
- annotationWriter.appendTypeAnnotationTo(sb);
- sb.append(CR);
- sb.append("public class ").append(typeName).append(" ");
- annotationWriter.appendExtendsImplementsTo(sb);
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendIdFieldAnnotationTo(sb);
- sb.append(CR);
- sb.append(" private int id;").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendNameFieldAnnotationTo(sb);
- sb.append(CR);
- sb.append(" private String name;").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendGetIdMethodAnnotationTo(sb);
- sb.append(CR);
- sb.append(" public int getId() {").append(CR);
- sb.append(" return this.id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendSetIdMethodAnnotationTo(sb);
- sb.append(CR);
- sb.append(" public void setId(int id) {").append(CR);
- sb.append(" this.id = id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendGetNameMethodAnnotationTo(sb);
- sb.append(CR);
- sb.append(" public String getName() {").append(CR);
- sb.append(" return this.name;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendSetNameMethodAnnotationTo(sb);
- sb.append(CR);
- sb.append(" public void setTestField(String testField) {").append(CR);
- sb.append(" this.testField = testField;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- annotationWriter.appendMemberTypeTo(sb);
- sb.append(CR);
- sb.append("}").append(CR);
- annotationWriter.appendTopLevelTypesTo(sb);
- sb.append(CR);
- }
-
-
- // ********** queries **********
-
- protected TestJavaProject getJavaProject() {
- return this.javaProject;
- }
-
- protected IType jdtType() throws JavaModelException {
- return this.javaProject.findType(FULLY_QUALIFIED_TYPE_NAME);
- }
-
- protected JDTType testType() throws JavaModelException {
- return this.buildType(this.jdtType());
- }
-
- protected JDTType buildType(IType jdtType) {
- return new JDTType(jdtType, this.modifySharedDocumentCommandExecutorProvider());
- }
-
- protected JDTFieldAttribute idField() throws JavaModelException {
- return this.fieldNamed("id");
- }
-
- protected JDTFieldAttribute nameField() throws JavaModelException {
- return this.fieldNamed("name");
- }
-
- protected JDTFieldAttribute fieldNamed(String fieldName) throws JavaModelException {
- return new JDTFieldAttribute(this.jdtType().getField(fieldName), this.modifySharedDocumentCommandExecutorProvider());
- }
-
- protected JDTMethodAttribute idGetMethod() throws JavaModelException {
- return this.methodNamed("getId");
- }
-
- protected JDTMethodAttribute idSetMethod() throws JavaModelException {
- return this.method("setId", new String[] {"I"});
- }
-
- protected JDTMethodAttribute nameGetMethod() throws JavaModelException {
- return this.methodNamed("getName");
- }
-
- protected JDTMethodAttribute methodNamed(String methodName) throws JavaModelException {
- return this.method(methodName, EMPTY_STRING_ARRAY);
- }
-
- protected JDTMethodAttribute method(String methodName, String[] parameterTypeSignatures) throws JavaModelException {
- return new JDTMethodAttribute(this.jdtType().getMethod(methodName, parameterTypeSignatures), this.modifySharedDocumentCommandExecutorProvider());
- }
-
- protected String source() throws JavaModelException {
- return this.jdtType().getOpenable().getBuffer().getContents();
- }
-
- /**
- * the tests will be run "headless" so use the default "shared document modifier"
- */
- protected CommandExecutorProvider modifySharedDocumentCommandExecutorProvider() {
- return MODIFY_SHARED_DOCUMENT_COMMAND_EXECUTOR_PROVIDER;
- }
-
- protected static final CommandExecutorProvider MODIFY_SHARED_DOCUMENT_COMMAND_EXECUTOR_PROVIDER =
- new CommandExecutorProvider() {
- public CommandExecutor getCommandExecutor() {
- return CommandExecutor.Default.instance();
- }
- };
-
-
- // ********** test validation **********
-
- protected void assertSourceContains(String s) throws JavaModelException {
- String source = this.source();
- boolean found = source.indexOf(s) > -1;
- if ( ! found) {
- String msg = "source does not contain the expected string: " + s + " (see System console)";
- System.out.println("*** " + this.getName() + " ****");
- System.out.println(msg);
- System.out.println(source);
- System.out.println();
- fail(msg);
- }
- }
-
- protected void assertSourceDoesNotContain(String s) throws JavaModelException {
- String source = this.source();
- int pos = source.indexOf(s);
- if (pos != -1) {
- String msg = "unexpected string in source (position: " + pos + "): " + s + " (see System console)";
- System.out.println("*** " + this.getName() + " ****");
- System.out.println(msg);
- System.out.println(source);
- System.out.println();
- fail(msg);
- }
- }
-
-
- // ********** manipulate annotations **********
-
- /**
- * Return the *first* member value pair for the specified annotation element
- * with the specified name.
- * Return null if the annotation has no such element.
- */
- protected MemberValuePair memberValuePair(NormalAnnotation annotation, String elementName) {
- for (MemberValuePair pair : this.values(annotation)) {
- if (pair.getName().getFullyQualifiedName().equals(elementName)) {
- return pair;
- }
- }
- return null;
- }
-
- /**
- * minimize the scope of the suppressed warnings
- */
- @SuppressWarnings("unchecked")
- protected List<MemberValuePair> values(NormalAnnotation na) {
- return na.values();
- }
-
- /**
- * check for null member value pair
- */
- protected Expression valueInternal(MemberValuePair pair) {
- return (pair == null) ? null : pair.getValue();
- }
-
- /**
- * Return the value of the *first* annotation element
- * with the specified name.
- * Return null if the annotation has no such element.
- */
- protected Expression annotationElementValue(NormalAnnotation annotation, String elementName) {
- return this.valueInternal(this.memberValuePair(annotation, elementName));
- }
-
- /**
- * Return the value of the *first* annotation element
- * with the specified name.
- * Return null if the annotation has no such element.
- */
- protected Expression annotationElementValue(SingleMemberAnnotation annotation, String elementName) {
- return elementName.equals("value") ? annotation.getValue() : null;
- }
-
- /**
- * Return the value of the *first* annotation element
- * with the specified name.
- * Return null if the annotation has no such element.
- * (An element name of "value" will return the value of a single
- * member annotation.)
- */
- protected Expression annotationElementValue(Annotation annotation, String elementName) {
- if (annotation.isNormalAnnotation()) {
- return this.annotationElementValue((NormalAnnotation) annotation, elementName);
- }
- if (annotation.isSingleMemberAnnotation()) {
- return this.annotationElementValue((SingleMemberAnnotation) annotation, elementName);
- }
- return null;
- }
-
- /**
- * Build a number literal and set its initial value to the specified literal.
- */
- protected NumberLiteral newNumberLiteral(AST ast, int value) {
- return ast.newNumberLiteral(Integer.toString(value));
- }
-
- /**
- * Build a string literal and set its initial value.
- */
- protected StringLiteral newStringLiteral(AST ast, String value) {
- StringLiteral stringLiteral = ast.newStringLiteral();
- stringLiteral.setLiteralValue(value);
- return stringLiteral;
- }
-
- protected MemberValuePair newMemberValuePair(AST ast, SimpleName name, Expression value) {
- MemberValuePair pair = ast.newMemberValuePair();
- pair.setName(name);
- pair.setValue(value);
- return pair;
- }
-
- protected MemberValuePair newMemberValuePair(AST ast, String name, Expression value) {
- return this.newMemberValuePair(ast, ast.newSimpleName(name), value);
- }
-
- protected MemberValuePair newMemberValuePair(AST ast, String name, String value) {
- return this.newMemberValuePair(ast, name, this.newStringLiteral(ast, value));
- }
-
- protected MemberValuePair newMemberValuePair(AST ast, String name, int value) {
- return this.newMemberValuePair(ast, name, this.newNumberLiteral(ast, value));
- }
-
- /**
- * Add the specified member value pair to the specified annotation.
- * Return the resulting annotation.
- */
- protected NormalAnnotation addMemberValuePair(NormalAnnotation annotation, MemberValuePair pair) {
- this.values(annotation).add(pair);
- return annotation;
- }
-
- /**
- * Add the specified member value pair to the specified annotation.
- * Return the resulting annotation.
- */
- protected NormalAnnotation addMemberValuePair(NormalAnnotation annotation, String name, int value) {
- return this.addMemberValuePair(annotation, this.newMemberValuePair(annotation.getAST(), name, value));
- }
-
- /**
- * Add the specified member value pair to the specified annotation.
- * Return the resulting annotation.
- */
- protected NormalAnnotation addMemberValuePair(NormalAnnotation annotation, String name, String value) {
- return this.addMemberValuePair(annotation, this.newMemberValuePair(annotation.getAST(), name, value));
- }
-
-
- // ********** member classes **********
-
- public interface AnnotationWriter {
- Iterator<String> imports();
- void appendTypeAnnotationTo(StringBuilder sb);
- void appendExtendsImplementsTo(StringBuilder sb);
- void appendIdFieldAnnotationTo(StringBuilder sb);
- void appendNameFieldAnnotationTo(StringBuilder sb);
- void appendGetIdMethodAnnotationTo(StringBuilder sb);
- void appendSetIdMethodAnnotationTo(StringBuilder sb);
- void appendGetNameMethodAnnotationTo(StringBuilder sb);
- void appendSetNameMethodAnnotationTo(StringBuilder sb);
- void appendMemberTypeTo(StringBuilder sb);
- void appendTopLevelTypesTo(StringBuilder sb);
- }
-
- public static class DefaultAnnotationWriter implements AnnotationWriter {
- public Iterator<String> imports() {return EmptyIterator.instance();}
- public void appendTypeAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendExtendsImplementsTo(StringBuilder sb) {/* do nothing */}
- public void appendIdFieldAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendNameFieldAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendSetIdMethodAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendGetNameMethodAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendSetNameMethodAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendMemberTypeTo(StringBuilder sb) {/* do nothing */}
- public void appendTopLevelTypesTo(StringBuilder sb) {/* do nothing */}
- }
-
- public static class AnnotationWriterWrapper implements AnnotationWriter {
- private final AnnotationWriter aw;
- public AnnotationWriterWrapper(AnnotationWriter aw) {
- super();
- this.aw = aw;
- }
- public Iterator<String> imports() {return aw.imports();}
- public void appendTypeAnnotationTo(StringBuilder sb) {aw.appendTypeAnnotationTo(sb);}
- public void appendExtendsImplementsTo(StringBuilder sb) {aw.appendExtendsImplementsTo(sb);}
- public void appendIdFieldAnnotationTo(StringBuilder sb) {aw.appendIdFieldAnnotationTo(sb);}
- public void appendNameFieldAnnotationTo(StringBuilder sb) {aw.appendNameFieldAnnotationTo(sb);}
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {aw.appendGetIdMethodAnnotationTo(sb);}
- public void appendSetIdMethodAnnotationTo(StringBuilder sb) {aw.appendSetIdMethodAnnotationTo(sb);}
- public void appendGetNameMethodAnnotationTo(StringBuilder sb) {aw.appendGetNameMethodAnnotationTo(sb);}
- public void appendSetNameMethodAnnotationTo(StringBuilder sb) {aw.appendSetNameMethodAnnotationTo(sb);}
- public void appendMemberTypeTo(StringBuilder sb) {aw.appendMemberTypeTo(sb);}
- public void appendTopLevelTypesTo(StringBuilder sb) {aw.appendTopLevelTypesTo(sb);}
- }
-
- public class AnnotatedSourceWriter implements SourceWriter {
- private AnnotationWriter annotationWriter;
- private String typeName;
- public AnnotatedSourceWriter(AnnotationWriter annotationWriter) {
- this(annotationWriter, TYPE_NAME);
- }
- public AnnotatedSourceWriter(AnnotationWriter annotationWriter, String typeName) {
- super();
- this.annotationWriter = annotationWriter;
- this.typeName = typeName;
- }
- public void appendSourceTo(StringBuilder sb) {
- AnnotationTestCase.this.appendSourceTo(sb, this.annotationWriter, typeName);
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapterTests.java
deleted file mode 100644
index 6ec7a4037e..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapterTests.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.StringLiteral;
-import org.eclipse.jpt.core.internal.utility.jdt.CombinationIndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-
-public class CombinationIndexedDeclarationAnnotationAdapterTests extends AnnotationTestCase {
-
- public CombinationIndexedDeclarationAnnotationAdapterTests(String name) {
- super(name);
- }
-
- private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- public void testAnnotation1() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 0);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
- assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isNormalAnnotation());
- }
-
- public void testAnnotation2() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testAnnotation3() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 0);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
- assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isNormalAnnotation());
- }
-
- public void testAnnotation4() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testAnnotation5() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
- assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isNormalAnnotation());
- String value = ((StringLiteral) ((MemberValuePair) ((NormalAnnotation) annotation).values().get(0)).getValue()).getLiteralValue();
- assertEquals("ADDRESS_ID2", value);
- }
-
- public void testAnnotation6() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testAnnotation7() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
- assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isNormalAnnotation());
- String value = ((StringLiteral) ((MemberValuePair) ((NormalAnnotation) annotation).values().get(0)).getValue()).getLiteralValue();
- assertEquals("ADDRESS_ID2", value);
- }
-
- public void testAnnotation8() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testRemoveAnnotation1() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 0);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("JoinColumn");
- }
-
- public void testRemoveAnnotation2() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 0);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("JoinColumns");
- this.assertSourceDoesNotContain("JoinColumn");
- }
-
- public void testRemoveAnnotation3() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("JoinColumns");
- this.assertSourceDoesNotContain("ADDRESS_ID2");
- this.assertSourceContains("@JoinColumn(name=\"ADDRESS_ID1\")");
- }
-
- public void testRemoveAnnotation4() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("JoinColumns");
- this.assertSourceDoesNotContain("ADDRESS_ID2");
- this.assertSourceContains("@JoinColumn(name=\"ADDRESS_ID1\")");
- }
-
- public void testRemoveAnnotation5() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "String comment(); JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(comment=\"test\",columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.removeAnnotation();
- this.assertSourceContains("@annot.JoinColumns(comment=\"test\",columns=@annot.JoinColumn(name=\"ADDRESS_ID1\"))");
- }
-
- public void testRemoveAnnotation6() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns(null)");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 0);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.removeAnnotation();
- this.assertSourceContains("@annot.JoinColumns(null)");
- }
-
- public void testRemoveAnnotation12() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID0\")";
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 2);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(expected);
- this.assertSourceDoesNotContain("JoinColumns");
- }
-
- public void testRemoveAnnotation13() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns({null, @annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- this.assertSourceContains("@annot.JoinColumn");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("JoinColumn");
- }
-
- public void testRemoveAnnotation14() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\"), null})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID0\")";
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 2);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation15() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\")})");
- String expected = "@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, null, @annot.JoinColumn(name=\"ADDRESS_ID3\")})";
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 2);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation16() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\")})");
- String expected = "@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})";
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 3);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation17() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns({null, null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- this.assertSourceContains("@annot.JoinColumn");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 2);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("JoinColumn");
- }
-
- public void testNewMarkerAnnotation1() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType();
- this.assertSourceDoesNotContain("JoinColumn");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 0);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("JoinColumn");
- this.assertSourceDoesNotContain("JoinColumns");
- }
-
- public void testNewMarkerAnnotation2() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumn");
- this.assertSourceDoesNotContain("JoinColumns");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@JoinColumns(columns={@JoinColumn,@JoinColumn})");
- }
-
- public void testNewMarkerAnnotation3() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn, @annot.JoinColumn})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 2);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn, @annot.JoinColumn," + CR + " @JoinColumn})");
- }
-
- public void testNewMarkerAnnotation4() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumn(77)");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 0);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("JoinColumn");
- this.assertSourceDoesNotContain("JoinColumns");
- this.assertSourceDoesNotContain("77");
- }
-
- public void testNewMarkerAnnotation5() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns=@annot.JoinColumn(77))");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 0);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@annot.JoinColumns(columns=@JoinColumn)");
- this.assertSourceDoesNotContain("77");
- }
-
- public void testNewMarkerAnnotation6() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns=@annot.JoinColumn(77))");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn(77),@JoinColumn})");
- }
-
- public void testNewMarkerAnnotation7() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumn(77)");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@JoinColumns(columns={@JoinColumn(77),@JoinColumn})");
- }
-
- public void testNewMarkerAnnotation8() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(77),@annot.JoinColumn(88)})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn(77),@JoinColumn})");
- }
-
- public void testNewMarkerAnnotation9() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name(); String text(); int num();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@JoinColumns(columns={@JoinColumn(text=\"blah\", num=42),@JoinColumn})");
- }
-
- public void testNewMarkerAnnotation23() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name(); String text(); int num();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)");
- String expected = "@JoinColumns(columns={@JoinColumn(text=\"blah\", num=42),null,@JoinColumn})";
- this.assertSourceDoesNotContain(expected);
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 2);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation24() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name(); String text(); int num();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)");
- String expected1 = "@JoinColumns({";
- String expected2 = "@JoinColumn(text=\"blah\", num=42),null,";
- String expected3 = "@JoinColumn" + CR + " })";
- this.assertSourceDoesNotContain(expected1);
- this.assertSourceDoesNotContain(expected2);
- this.assertSourceDoesNotContain(expected3);
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 2);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected1);
- this.assertSourceContains(expected2);
- this.assertSourceContains(expected3);
- }
-
- public void testNewMarkerAnnotation25() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- String expected1 = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, null,"; // the line gets split
- String expected2 = "@JoinColumn})";
- this.assertSourceDoesNotContain(expected1);
- this.assertSourceDoesNotContain(expected2);
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 4);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected1);
- this.assertSourceContains(expected2);
- }
-
- public void testNewMarkerAnnotation26() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- String expected1 = "@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, null,"; // the line gets split
- String expected2 = "@JoinColumn})";
- this.assertSourceDoesNotContain(expected1);
- this.assertSourceDoesNotContain(expected2);
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 4);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected1);
- this.assertSourceContains(expected2);
- }
-
- public void testMoveAnnotation1() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID0\")");
- String expected = "@JoinColumns(columns={null,@JoinColumn(name=\"ADDRESS_ID0\")})";
- this.assertSourceDoesNotContain(expected);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 0);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(1);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation2() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={null,@annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID1\")";
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- this.assertSourceDoesNotContain("JoinColumns");
- }
-
- public void testMoveAnnotation2a() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns({null,@annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID1\")";
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 1);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- this.assertSourceDoesNotContain("JoinColumns");
- }
-
- public void testMoveAnnotation3() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\")})");
- String expected = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})";
- this.assertSourceDoesNotContain(expected);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 3);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation4() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID4\")})");
- String expected = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), null, @annot.JoinColumn(name=\"ADDRESS_ID4\")})";
- this.assertSourceDoesNotContain(expected);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 3);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation5() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- String expected = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})";
- this.assertSourceDoesNotContain(expected);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 2);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(3);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation6() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- String expected = "@annot.JoinColumns(columns={null, @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID0\")})";
- this.assertSourceDoesNotContain(expected);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 0);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(3);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation7() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- String expected = "@annot.JoinColumns(columns={null, @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})";
- this.assertSourceDoesNotContain(expected);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 3);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation8() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), null, @annot.JoinColumn(name=\"ADDRESS_ID4\")})");
- String expected = "@annot.JoinColumns(columns={null, @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), null, @annot.JoinColumn(name=\"ADDRESS_ID4\")})";
- this.assertSourceDoesNotContain(expected);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 3);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation9() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- String expected = "@annot.JoinColumns(columns={null, @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})";
- this.createTestType(expected); // the source should be unchanged
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 0);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- iaa.moveAnnotation(3);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation10() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID0\")";
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 2);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- iaa.moveAnnotation(1);
- this.assertSourceContains(expected);
- this.assertSourceDoesNotContain("@annot.JoinColumns");
- }
-
- public void testMoveAnnotation10a() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID0\")";
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 2);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- iaa.moveAnnotation(1);
- this.assertSourceContains(expected);
- this.assertSourceDoesNotContain("@annot.JoinColumns");
- }
-
- public void testMoveAnnotation11() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID0\")");
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceDoesNotContain("JoinColumn");
- }
-
- public void testMoveAnnotation12() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID2\")";
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 2);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- this.assertSourceDoesNotContain("@annot.JoinColumns");
- }
-
- public void testMoveAnnotation13() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, @annot.JoinColumn(name=\"ADDRESS_ID3\")})");
- String expected = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})";
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 3);
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/DefaultAnnotationEditFormatterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/DefaultAnnotationEditFormatterTests.java
deleted file mode 100644
index e3e909794a..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/DefaultAnnotationEditFormatterTests.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.utility.jdt;
-
-import org.eclipse.jpt.core.internal.utility.jdt.DefaultAnnotationEditFormatter;
-import org.eclipse.jpt.utility.internal.ClassTools;
-
-public class DefaultAnnotationEditFormatterTests extends AnnotationTestCase {
-
-
- // ********** TestCase behavior **********
-
- public DefaultAnnotationEditFormatterTests(String name) {
- super(name);
- }
-
-
- // ********** tests **********
-
- public void testCommaLength() throws Exception {
- assertEquals(1, this.commaLength(","));
- assertEquals(1, this.commaLength(", "));
- assertEquals(1, this.commaLength(", "));
-
- assertEquals(2, this.commaLength(" ,"));
- assertEquals(2, this.commaLength(" , "));
- assertEquals(2, this.commaLength(" , "));
-
- assertEquals(3, this.commaLength(" ,"));
- assertEquals(3, this.commaLength(" , "));
- assertEquals(3, this.commaLength(" , "));
-
- assertEquals(0, this.commaLength(" ,,,"));
- assertEquals(0, this.commaLength(" ,,, "));
- assertEquals(0, this.commaLength(" , ,"));
-
- assertEquals(0, this.commaLength(" ,x"));
- assertEquals(0, this.commaLength(" ,x "));
- assertEquals(0, this.commaLength(" , x"));
-
- assertEquals(0, this.commaLength("x ,"));
- assertEquals(0, this.commaLength("x , "));
- assertEquals(0, this.commaLength("x , "));
- }
-
- private int commaLength(String s) {
- Integer len = (Integer) ClassTools.executeMethod(DefaultAnnotationEditFormatter.instance(), "commaLength", String.class, s);
- return len.intValue();
- }
-
- public void testStringIsAnnotation() throws Exception {
- assertTrue(this.stringIsAnnotation("@F"));
- assertTrue(this.stringIsAnnotation("@Foo"));
- assertTrue(this.stringIsAnnotation("@org.bar.Foo"));
-
- assertFalse(this.stringIsAnnotation(""));
- assertFalse(this.stringIsAnnotation("@"));
- assertFalse(this.stringIsAnnotation("Foo"));
- assertFalse(this.stringIsAnnotation("Foo@"));
- }
-
- private boolean stringIsAnnotation(String s) {
- Boolean b = (Boolean) ClassTools.executeMethod(DefaultAnnotationEditFormatter.instance(), "stringIsAnnotation", String.class, s);
- return b.booleanValue();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/JDTToolsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/JDTToolsTests.java
deleted file mode 100644
index 3fa9437aed..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/JDTToolsTests.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTFieldAttribute;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTTools;
-import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
-
-public class JDTToolsTests extends AnnotationTestCase {
-
- public JDTToolsTests(String name) {
- super(name);
- }
-
- private void createEnumAndMembers(String enumName, String enumBody) throws Exception {
- this.javaProject.createType("enums", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }");
- }
-
- private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- public void testResolveEnum1() throws Exception {
- this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ");
- this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();");
-
- this.createTestType("@annot.TestAnnotation(foo=enums.TestEnum.BAZ)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo");
- JDTFieldAttribute field = this.idField();
-
- String actual = JDTTools.resolveEnum((Name) daea.getExpression(field.getModifiedDeclaration(this.idField().getAstRoot())));
- assertEquals("enums.TestEnum.BAZ", actual);
- }
-
- public void testResolveEnum2() throws Exception {
- this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ");
- this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();");
-
- this.createTestType("static enums.TestEnum.BAZ", "@annot.TestAnnotation(foo=BAZ)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo");
- JDTFieldAttribute field = this.idField();
-
- String actual = JDTTools.resolveEnum((Name) daea.getExpression(field.getModifiedDeclaration(this.idField().getAstRoot())));
- assertEquals("enums.TestEnum.BAZ", actual);
- }
-
- public void testResolveEnum3() throws Exception {
- this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ");
- this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();");
-
- this.createTestType("static enums.TestEnum.*", "@annot.TestAnnotation(foo=BAZ)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo");
- JDTFieldAttribute field = this.idField();
-
- String actual = JDTTools.resolveEnum((Name)daea.getExpression(field.getModifiedDeclaration(this.idField().getAstRoot())));
- assertEquals("enums.TestEnum.BAZ", actual);
- }
-
- public void testResolveEnum4() throws Exception {
- this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ");
- this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();");
-
- this.createTestType("enums.TestEnum", "@annot.TestAnnotation(foo=TestEnum.BAZ)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo");
- JDTFieldAttribute field = this.idField();
-
- String actual = JDTTools.resolveEnum((Name) daea.getExpression(field.getModifiedDeclaration(this.idField().getAstRoot())));
- assertEquals("enums.TestEnum.BAZ", actual);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/JptCoreUtilityJdtTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/JptCoreUtilityJdtTests.java
deleted file mode 100644
index e95256f3e5..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/JptCoreUtilityJdtTests.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.utility.jdt;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptCoreUtilityJdtTests {
-
- public static Test suite() {
- return suite(true);
- }
-
- public static Test suite(boolean all) {
- TestSuite suite = new TestSuite(JptCoreUtilityJdtTests.class.getPackage().getName());
- suite.addTestSuite(CombinationIndexedDeclarationAnnotationAdapterTests.class);
- suite.addTestSuite(DefaultAnnotationEditFormatterTests.class);
- suite.addTestSuite(JDTToolsTests.class);
- suite.addTestSuite(MemberAnnotationElementAdapterTests.class);
- suite.addTestSuite(NestedDeclarationAnnotationAdapterTests.class);
- suite.addTestSuite(NestedIndexedDeclarationAnnotationAdapterTests.class);
- suite.addTestSuite(SimpleDeclarationAnnotationAdapterTests.class);
- suite.addTestSuite(TypeTests.class);
- return suite;
- }
-
- private JptCoreUtilityJdtTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/MemberAnnotationElementAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/MemberAnnotationElementAdapterTests.java
deleted file mode 100644
index 86c3da71ec..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/MemberAnnotationElementAdapterTests.java
+++ /dev/null
@@ -1,948 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.utility.jdt;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.core.internal.utility.jdt.ASTNodeTextRange;
-import org.eclipse.jpt.core.internal.utility.jdt.AnnotationStringArrayExpressionConverter;
-import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter;
-import org.eclipse.jpt.core.internal.utility.jdt.CharacterStringExpressionConverter;
-import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.EnumArrayDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.NestedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.NumberIntegerExpressionConverter;
-import org.eclipse.jpt.core.internal.utility.jdt.PrimitiveTypeStringExpressionConverter;
-import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
-import org.eclipse.jpt.core.internal.utility.jdt.StringExpressionConverter;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.utility.jdt.ExpressionConverter;
-
-public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
-
- public MemberAnnotationElementAdapterTests(String name) {
- super(name);
- }
-
- private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- private void createEnum(String enumName, String enumBody) throws Exception {
- this.javaProject.createType("enums", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }");
- }
-
- public void testValue1() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- this.createTestType("@annot.Foo(bar=\"xxx\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("xxx", aea.getValue());
- }
-
- public void testValue2() throws Exception {
- this.createAnnotationAndMembers("Foo", "int bar();");
- this.createTestType("@annot.Foo(bar=48)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Integer> daea = new ConversionDeclarationAnnotationElementAdapter<Integer>(daa, "bar", NumberIntegerExpressionConverter.instance());
- AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(), daea);
- assertEquals(Integer.valueOf(48), aea.getValue());
- }
-
- public void testValue3() throws Exception {
- this.createAnnotationAndMembers("Foo", "char bar();");
- this.createTestType("@annot.Foo(bar='c')");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", CharacterStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("c", aea.getValue());
- }
-
- public void testValue4() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean bar();");
- this.createTestType("@annot.Foo(bar=false)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa, "bar", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- }
-
- public void testValue5() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- this.createTestType("@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))");
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- }
-
- public void testValue6() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean value();");
- this.createTestType("@annot.Foo(false)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa, BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- }
-
- public void testValueNull1() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- this.createTestType("@annot.Foo");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueNull2() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- this.createTestType();
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueNull3() throws Exception {
- this.createAnnotationAndMembers("Baz", "String fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- this.createTestType("@annot.Foo(@annot.Bar(jimmy=@annot.Baz))");
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa3, "fred");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueStringConcatenation() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- this.createTestType("@annot.Foo(bar=\"xxx\" + \"yyy\" + \"zzz\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("xxxyyyzzz", aea.getValue());
- }
-
- public void testValueStringConstant() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- // just a bit hacky:
- this.createTestType("private static final String FOO_BAR = \"xxx\"; @annot.Foo(bar=FOO_BAR + \"yyy\" + \"zzz\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("xxxyyyzzz", aea.getValue());
- }
-
- public void testValueNumberArithmetic() throws Exception {
- this.createAnnotationAndMembers("Foo", "int bar();");
- this.createTestType("@annot.Foo(bar=47 - 7 + 2 * 1 / 1)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Integer> daea = ConversionDeclarationAnnotationElementAdapter.forNumbers(daa, "bar");
- AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(), daea);
- assertEquals(Integer.valueOf(42), aea.getValue());
- }
-
- public void testValueNumberShift() throws Exception {
- this.createAnnotationAndMembers("Foo", "int bar();");
- this.createTestType("@annot.Foo(bar=2 << 2)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Integer> daea = ConversionDeclarationAnnotationElementAdapter.forNumbers(daa, "bar");
- AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(), daea);
- assertEquals(Integer.valueOf(8), aea.getValue());
- }
-
- public void testValueNumberConstant() throws Exception {
- this.createAnnotationAndMembers("Foo", "int bar();");
- // just a bit hacky:
- this.createTestType("private static final int FOO_BAR = 77; @annot.Foo(bar=FOO_BAR)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Integer> daea = ConversionDeclarationAnnotationElementAdapter.forNumbers(daa, "bar");
- AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(), daea);
- assertEquals(Integer.valueOf(77), aea.getValue());
- }
-
- public void testValueCharacterConstant() throws Exception {
- this.createAnnotationAndMembers("Foo", "char bar();");
- // just a bit hacky:
- this.createTestType("private static final char FOO_BAR = 'Q'; @annot.Foo(bar=FOO_BAR)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forCharacters(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("Q", aea.getValue());
- }
-
- public void testValueCharacterCast() throws Exception {
- this.createAnnotationAndMembers("Foo", "char bar();");
- this.createTestType("@annot.Foo(bar=(char) 0x41)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forCharacters(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("A", aea.getValue());
- }
-
- public void testValueBooleanOperator1() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean bar();");
- this.createTestType("@annot.Foo(bar=7 > 2)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar");
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
- assertEquals(Boolean.TRUE, aea.getValue());
- }
-
- public void testValueBooleanOperator2() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean bar();");
- this.createTestType("@annot.Foo(bar=7 == 2)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar");
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- }
-
- public void testValueBooleanOperator3() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean bar();");
- this.createTestType("@annot.Foo(bar=(7 != 2) && false)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar");
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- }
-
- public void testValueBooleanOperator4() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean bar();");
- this.createTestType("@annot.Foo(bar=(7 != 2) ? false : true)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar");
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- }
-
- public void testValueInvalidValue1() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- this.createTestType("@annot.Foo(bar=77)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue2() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- this.createTestType("@annot.Foo(bar=bazzzz)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue3() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean bar();");
- this.createTestType("@annot.Foo(bar=bazzzz)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar");
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue4() throws Exception {
- this.createAnnotationAndMembers("Foo", "char bar();");
- this.createTestType("@annot.Foo(bar=\"bazzzz\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forCharacters(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue5() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- this.createTestType("@annot.Foo(bar=\"java.lang.Object\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue6() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- this.createTestType("@annot.Foo(bar=enums.TestEnum.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue7() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- String value = "\"false\"";
- String element = "fred=" + value;
- String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(" + element + ")))";
- this.createTestType(annotation);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue8() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- this.createTestType("@annot.Foo(bar={true, false})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[] {null, null}, aea.getValue()));
- }
-
- public void testValueInvalidValue9() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- this.createTestType("@annot.Foo(bar=77)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[] {null}, aea.getValue()));
- }
-
- public void testASTNode1() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- String value = "\"xxx\"";
- String element = "bar=" + value;
- String annotation = "@annot.Foo(" + element + ")";
- this.createTestType(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
-
- TextRange textRange = new ASTNodeTextRange(aea.getAstNode(idField().getAstRoot()));
- assertEquals(this.source().indexOf(value), textRange.getOffset());
- assertEquals(value.length(), textRange.getLength());
- assertEquals(8, textRange.getLineNumber());
- }
-
- public void testASTNode2() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- String value = "false";
- String element = "fred=" + value;
- String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(" + element + ")))";
- this.createTestType(annotation);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- TextRange textRange = new ASTNodeTextRange(aea.getAstNode(idField().getAstRoot()));
- assertEquals(value.length(), textRange.getLength());
- }
-
- public void testASTNode3() throws Exception {
- this.createAnnotationAndMembers("Foo", "String value();");
- String element = "\"xxx\"";
- String annotation = "@annot.Foo(" + element + ")";
- this.createTestType(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa);
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
-
- TextRange textRange = new ASTNodeTextRange(aea.getAstNode(idField().getAstRoot()));
- assertEquals(this.source().indexOf(element), textRange.getOffset());
- assertEquals(element.length(), textRange.getLength());
- }
-
- public void testASTNode4() throws Exception {
- this.createAnnotationAndMembers("Foo", "String value();");
- String annotation = "@annot.Foo";
- this.createTestType(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa);
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
-
- TextRange textRange = new ASTNodeTextRange(aea.getAstNode(idField().getAstRoot()));
- assertEquals(this.source().indexOf(annotation), textRange.getOffset());
- assertEquals(annotation.length(), textRange.getLength());
- }
-
- public void testSetValue1() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- String annotation = "@annot.Foo(bar=\"xxx\")";
- this.createTestType(annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
-
- aea.setValue(null);
- this.assertSourceDoesNotContain("Foo");
- }
-
- public void testSetValue2() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- String annotation = "@annot.Foo(bar=\"xxx\")";
- this.createTestType(annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar", false);
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
-
- aea.setValue(null);
- this.assertSourceDoesNotContain(annotation);
- this.assertSourceContains("@Foo");
- }
-
- public void testSetValue3() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))";
- this.createTestType(annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
-
- aea.setValue(null);
- this.assertSourceDoesNotContain(annotation);
- this.assertSourceDoesNotContain("Foo");
- this.assertSourceDoesNotContain("Bar");
- }
-
- public void testSetValue3a() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))";
- this.createTestType(annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar", false);
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz", false);
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
-
- aea.setValue(null);
- this.assertSourceDoesNotContain(annotation);
- this.assertSourceContains("@annot.Foo(@Bar)");
- }
-
- public void testSetValue4() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- this.createTestType();
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
-
- aea.setValue("xxx");
- this.assertSourceContains("@Foo(bar=\"xxx\")");
- }
-
- public void testSetValue5() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))";
- this.createTestType(annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
-
- aea.setValue(Boolean.TRUE);
- this.assertSourceDoesNotContain(annotation);
- this.assertSourceContains("@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=true)))");
- }
-
- public void testSetValue6() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- this.createTestType();
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea);
-
- aea.setValue(Boolean.TRUE);
- this.assertSourceContains("@Foo(@Bar(jimmy=@Baz(fred=true)))");
- }
-
- public void testSetValue7() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- String annotation = "@annot.Foo(bar=\"xxx\")";
- this.createTestType(annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
-
- aea.setValue("yyy");
- this.assertSourceDoesNotContain(annotation);
- this.assertSourceContains("@annot.Foo(bar=\"yyy\")");
- }
-
- public void testSetValue8() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- String annotation = "@annot.Foo";
- this.createTestType(annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
-
- aea.setValue("xxx");
- this.assertSourceContains("@Foo(bar=\"xxx\")");
- }
-
- public void testSetValue9() throws Exception {
- this.createAnnotationAndMembers("Foo", "String value(); String bar();");
- String annotation = "@annot.Foo(\"zzz\")";
- this.createTestType(annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
-
- aea.setValue("xxx");
- this.assertSourceDoesNotContain(annotation);
- this.assertSourceContains("@Foo(value=\"zzz\", bar=\"xxx\")");
- }
-
- public void testSetValue10() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar(); String baz();");
- String annotation = "@annot.Foo(bar=\"xxx\")";
- this.createTestType(annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "baz");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
-
- aea.setValue("yyy");
- this.assertSourceDoesNotContain(annotation);
- this.assertSourceContains("@annot.Foo(bar=\"xxx\", baz = \"yyy\")");
- }
-
- public void testSetValue11() throws Exception {
- this.createAnnotationAndMembers("Baz", "int fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz[] jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- String annotation = "@annot.Foo(@annot.Bar(jimmy={@annot.Baz(fred=0), @annot.Baz(fred=1), @annot.Baz(fred=2), @annot.Baz(fred=3)}))";
- this.createTestType(annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "jimmy", 2, "annot.Baz");
- DeclarationAnnotationElementAdapter<Integer> daea = new ConversionDeclarationAnnotationElementAdapter<Integer>(daa3, "fred", NumberIntegerExpressionConverter.instance());
- AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(), daea);
-
- assertEquals(Integer.valueOf(2), aea.getValue());
- aea.setValue(Integer.valueOf(48));
- this.assertSourceContains("@annot.Foo(@annot.Bar(jimmy={@annot.Baz(fred=0), @annot.Baz(fred=1), @annot.Baz(fred=48), @annot.Baz(fred=3)}))");
- }
-
- public void testSetValue12() throws Exception {
- this.createAnnotationAndMembers("Foo", "String value();");
- String annotation = "@annot.Foo";
- this.createTestType(annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "value");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
-
- aea.setValue("xxx");
- this.assertSourceContains("@Foo(\"xxx\")");
- }
-
- public void testSetValue13() throws Exception {
- this.createAnnotationAndMembers("Foo", "String value();");
- String annotation = "@annot.Foo(\"zzz\")";
- this.createTestType(annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "value");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
-
- aea.setValue("xxx");
- this.assertSourceDoesNotContain(annotation);
- this.assertSourceContains("@annot.Foo(\"xxx\")");
- }
-
- public void testSimpleTypeLiteral1() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- this.createTestType("@annot.Foo(bar=java.lang.Object.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("java.lang.Object", aea.getValue());
- }
-
- public void testSimpleTypeLiteral2() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- this.createTestType();
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- aea.setValue("java.lang.Object");
- this.assertSourceContains("@Foo(bar=java.lang.Object.class)");
- }
-
- public void testSimpleTypeLiteral3() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- this.createTestType("@annot.Foo(bar=int.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testSimpleTypeLiteral4() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- this.createTestType("@annot.Foo(bar=java.util.Map.Entry.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("java.util.Map.Entry", aea.getValue());
- }
-
- public void testPrimitiveTypeLiteral1() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- this.createTestType("@annot.Foo(bar=int.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("int", aea.getValue());
- }
-
- public void testPrimitiveTypeLiteral2() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- this.createTestType();
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- aea.setValue("int");
- this.assertSourceContains("@Foo(bar=int.class)");
- }
-
- public void testPrimitiveTypeLiteral3() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- this.createTestType("@annot.Foo(bar=java.lang.Object.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testPrimitiveTypeLiteral4() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- this.createTestType("@annot.Foo(bar=void.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("void", aea.getValue());
- }
-
- public void testValueEnum1() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- this.createTestType("@annot.Foo(bar=enums.TestEnum.XXX)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("enums.TestEnum.XXX", aea.getValue());
- }
-
- public void testValueEnum2() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- this.createTestType("static enums.TestEnum.XXX", "@annot.Foo(bar=XXX)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("enums.TestEnum.XXX", aea.getValue());
- }
-
- public void testValueEnum3() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- this.createTestType("@annot.Foo");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueEnum4() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- this.createTestType("enums.TestEnum", "@annot.Foo(bar=TestEnum.XXX)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- assertEquals("enums.TestEnum.XXX", aea.getValue());
- }
-
- public void testSetValueEnum1() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- String annotation = "@annot.Foo(bar=XXX)";
- this.createTestType("static enums.TestEnum.XXX", annotation);
- this.assertSourceContains(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- aea.setValue(null);
- this.assertSourceDoesNotContain("Foo");
- }
-
- public void testSetValueEnum2() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- String annotation = "@Foo(bar=XXX)";
- this.createTestType();
- this.assertSourceDoesNotContain(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
- aea.setValue("enums.TestEnum.XXX");
- this.assertSourceContains("import static enums.TestEnum.XXX;");
- this.assertSourceContains(annotation);
- }
-
- public void testValueStringArray() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- this.createTestType("@annot.Foo(bar={\"string0\", \"string1\"})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[] {"string0", "string1"}, aea.getValue()));
- }
-
- public void testValueStringArrayConcatenation() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- this.createTestType("@annot.Foo(bar={\"stri\" + \"ng0\", \"s\" + \"tring1\"})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[] {"string0", "string1"}, aea.getValue()));
- }
-
- public void testValueStringArrayEmpty() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- this.createTestType("@annot.Foo(bar={})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[0], aea.getValue()));
- }
-
- public void testValueStringArraySingleElement() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- this.createTestType("@annot.Foo(bar=\"string0\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[] {"string0"}, aea.getValue()));
- }
-
- public void testValueNullStringArray() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- this.createTestType("@annot.Foo()");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[0], aea.getValue()));
- }
-
- public void testSetValueStringArray() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- String annotation = "@Foo(bar={\"string0\",\"string1\"})";
- this.createTestType();
- this.assertSourceDoesNotContain(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- aea.setValue(new String[] {"string0", "string1"});
- this.assertSourceContains(annotation);
- }
-
- public void testSetValueStringArrayEmptyRemove() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- String annotation = "@Foo";
- this.createTestType();
- this.assertSourceDoesNotContain(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- aea.setValue(new String[0]);
- this.assertSourceDoesNotContain(annotation);
- }
-
- public void testSetValueStringArrayEmpty() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- String annotation = "@Foo(bar={})";
- this.createTestType();
- this.assertSourceDoesNotContain(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- ExpressionConverter<String[]> expressionConverter = new AnnotationStringArrayExpressionConverter(StringExpressionConverter.instance(), false);
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", expressionConverter);
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- aea.setValue(new String[0]);
- this.assertSourceContains(annotation);
- }
-
- public void testSetValueStringArraySingleElement() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- String annotation = "@Foo(bar=\"string0\")";
- this.createTestType();
- this.assertSourceDoesNotContain(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- aea.setValue(new String[] {"string0"});
- this.assertSourceContains(annotation);
- }
-
- public void testValueEnumArray() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- this.createTestType("@annot.Foo(bar={enums.TestEnum.XXX, enums.TestEnum.YYY})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX", "enums.TestEnum.YYY"}, aea.getValue()));
- }
-
- public void testValueEnumArrayInvalidEntry() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- this.createTestType("@annot.Foo(bar={enums.TestEnum.XXX, 88})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX", null}, aea.getValue()));
- }
-
- public void testValueEnumArrayEmpty() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- this.createTestType("@annot.Foo(bar={})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[0], aea.getValue()));
- }
-
- public void testValueEnumArraySingleElement() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- this.createTestType("@annot.Foo(bar=enums.TestEnum.XXX)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX"}, aea.getValue()));
- }
-
- public void testValueEnumArraySingleElementInvalid() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- this.createTestType("@annot.Foo(bar=\"\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[] {null}, aea.getValue()));
- }
-
- public void testValueNullEnumArray() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- this.createTestType("@annot.Foo()");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- assertTrue(Arrays.equals(new String[0], aea.getValue()));
- }
-
- public void testSetValueEnumArray() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- String annotation = "@Foo(bar={XXX,YYY})";
- this.createTestType();
- this.assertSourceDoesNotContain(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- aea.setValue(new String[] {"enums.TestEnum.XXX", "enums.TestEnum.YYY"});
- this.assertSourceContains("import static enums.TestEnum.XXX;");
- this.assertSourceContains("import static enums.TestEnum.YYY;");
- this.assertSourceContains(annotation);
- }
-
- public void testSetValueEnumArrayEmptyRemove() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- String annotation = "@Foo";
- this.createTestType();
- this.assertSourceDoesNotContain(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- aea.setValue(new String[0]);
- this.assertSourceDoesNotContain(annotation);
- }
-
- public void testSetValueEnumArrayEmpty() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- String annotation = "@Foo(bar={})";
- this.createTestType();
- this.assertSourceDoesNotContain(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar", true, false);
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- aea.setValue(new String[0]);
- this.assertSourceContains(annotation);
- }
-
- public void testSetValueEnumArraySingleElement() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- String annotation = "@Foo(bar=XXX)";
- this.createTestType();
- this.assertSourceDoesNotContain(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
- aea.setValue(new String[] {"enums.TestEnum.XXX"});
- this.assertSourceContains("import static enums.TestEnum.XXX;");
- this.assertSourceContains(annotation);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedDeclarationAnnotationAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedDeclarationAnnotationAdapterTests.java
deleted file mode 100644
index 59b50e66e4..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedDeclarationAnnotationAdapterTests.java
+++ /dev/null
@@ -1,763 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jdt.core.dom.StringLiteral;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.NestedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.Member;
-import org.eclipse.jpt.core.utility.jdt.ModifiedDeclaration;
-
-public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase {
-
- public NestedDeclarationAnnotationAdapterTests(String name) {
- super(name);
- }
-
- private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- public void testAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar)");
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
- assertEquals("annot.Bar", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
- }
-
- public void testAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Baz", "String value();");
- this.createAnnotationAndMembers("Bar", "annot.Baz yana();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar(yana=@annot.Baz))");
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "nestedAnnotation", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "yana", "annot.Baz");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa3);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
- assertEquals("annot.Baz", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
- }
-
- public void testAnnotationNull1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- this.createTestType("@annot.Foo()");
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testAnnotationNull2() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- this.createTestType();
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testAnnotationNull3() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "String nestedAnnotation();");
- this.createTestType("@annot.Foo(nestedAnnotation=\"annot.Bar\")");
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testAnnotationNull4() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Bar2", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar2 nestedAnnotation();");
- this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar2)");
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testRemoveAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- String na = "@annot.Foo(nestedAnnotation=@annot.Bar)";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain(na);
- this.assertSourceDoesNotContain("Foo");
- }
-
- public void testRemoveAnnotation1a() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- String na = "@annot.Foo(nestedAnnotation=@annot.Bar)";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar", false);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains("Foo");
- }
-
- public void testRemoveAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- this.createTestType();
- this.assertSourceDoesNotContain("Foo");
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("Foo");
- }
-
- public void testRemoveAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "String nestedAnnotation();");
- String na = "@annot.Foo(nestedAnnotation=\"annot.Bar\")";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(na);
- }
-
- public void testRemoveAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Bar2", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar2 nestedAnnotation();");
- String na = "@annot.Foo(nestedAnnotation=@annot.Bar2)";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(na);
- }
-
- public void testRemoveAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Baz", "String value();");
- this.createAnnotationAndMembers("Bar", "annot.Baz nestedAnnotation2();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation1();");
- String na = "@annot.Foo(nestedAnnotation1=@annot.Bar(nestedAnnotation2=@annot.Baz))";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daaFoo = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daaBar = new NestedDeclarationAnnotationAdapter(daaFoo, "nestedAnnotation1", "annot.Bar");
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(daaBar, "nestedAnnotation2", "annot.Baz");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain(na);
- this.assertSourceDoesNotContain("Foo");
- this.assertSourceDoesNotContain("Bar");
- this.assertSourceDoesNotContain("Baz");
- }
-
- public void testRemoveAnnotation5a() throws Exception {
- this.createAnnotationAndMembers("Baz", "String value();");
- this.createAnnotationAndMembers("Bar", "annot.Baz nestedAnnotation2();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation1();");
- String na = "@annot.Foo(nestedAnnotation1=@annot.Bar(nestedAnnotation2=@annot.Baz))";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daaFoo = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daaBar = new NestedDeclarationAnnotationAdapter(daaFoo, "nestedAnnotation1", "annot.Bar", false);
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(daaBar, "nestedAnnotation2", "annot.Baz", false);
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains("@annot.Foo(nestedAnnotation1=@Bar)");
- }
-
- public void testNewMarkerAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- this.createTestType();
- this.assertSourceDoesNotContain("Foo");
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@Foo(nestedAnnotation=@Bar)");
- }
-
- public void testNewMarkerAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- this.createTestType();
- this.assertSourceDoesNotContain("Foo");
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@Foo(@Bar)");
- }
-
- public void testNewMarkerAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- this.createTestType("@annot.Foo");
- String expected = "@Foo(nestedAnnotation=@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- this.createTestType("@annot.Foo");
- String expected = "@Foo(@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String value();");
- this.createTestType("@annot.Foo(\"something\")");
- String expected = "@Foo(value=\"something\", nestedAnnotation=@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "Object value();");
- this.createTestType("@annot.Foo(\"something\")");
- String expected = "@annot.Foo(@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar nestedAnnotation();");
- this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", nestedAnnotation = @Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar value();");
- this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", value = @Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewSingleMemberAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- this.createTestType();
- this.assertSourceDoesNotContain("Foo");
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation1(declaration);
- }
- });
- this.assertSourceContains("@Foo(nestedAnnotation=@Bar(\"test string literal\"))");
- }
-
- void editNewSingleMemberAnnotation1(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- this.createTestType();
- this.assertSourceDoesNotContain("Foo");
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation2(declaration);
- }
- });
- this.assertSourceContains("@Foo(@Bar(\"test string literal\"))");
- }
-
- void editNewSingleMemberAnnotation2(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- this.createTestType("@annot.Foo");
- String expected = "@Foo(nestedAnnotation=@Bar(\"test string literal\"))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation3(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation3(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- this.createTestType("@annot.Foo");
- String expected = "@Foo(@Bar(\"test string literal\"))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation4(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation4(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String value();");
- this.createTestType("@annot.Foo(\"something\")");
- String expected = "@Foo(value=\"something\", nestedAnnotation=@Bar(\"test string literal\"))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation5(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation5(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "Object value();");
- this.createTestType("@annot.Foo(\"something\")");
- String expected = "@annot.Foo(@Bar(\"test string literal\"))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation6(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation6(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String xxx();");
- this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", nestedAnnotation = @Bar(\"test string literal\"))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation7(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation7(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value(); String xxx();");
- this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", value = @Bar(\"test string literal\"))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation8(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation8(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewNormalAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- this.createTestType();
- this.assertSourceDoesNotContain("Foo");
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation1(declaration);
- }
- });
- this.assertSourceContains("@Foo(nestedAnnotation=@Bar(yyy=\"test string literal\"))");
- }
-
- void editNewNormalAnnotation1(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- this.createTestType();
- this.assertSourceDoesNotContain("Foo");
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation2(declaration);
- }
- });
- this.assertSourceContains("@Foo(@Bar(yyy=\"test string literal\"))");
- }
-
- void editNewNormalAnnotation2(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- this.createTestType("@annot.Foo");
- String expected = "@Foo(nestedAnnotation=@Bar(yyy=\"test string literal\"))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation3(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation3(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- this.createTestType("@annot.Foo");
- String expected = "@Foo(@Bar(yyy=\"test string literal\"))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation4(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation4(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String value();");
- this.createTestType("@annot.Foo(\"something\")");
- String expected = "@Foo(value=\"something\", nestedAnnotation=@Bar(yyy=\"test string literal\"))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation5(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation5(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "Object value();");
- this.createTestType("@annot.Foo(\"something\")");
- String expected = "@annot.Foo(@Bar(yyy=\"test string literal\"))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation6(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation6(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar nestedAnnotation();");
- this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", nestedAnnotation = @Bar(yyy = \"test string literal\"))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation7(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation7(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar value();");
- this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", value = @Bar(yyy = \"test string literal\"))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation8(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation8(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapterTests.java
deleted file mode 100644
index 4470720136..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapterTests.java
+++ /dev/null
@@ -1,2218 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.NumberLiteral;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.Member;
-import org.eclipse.jpt.core.utility.jdt.ModifiedDeclaration;
-
-public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTestCase {
-
- public NestedIndexedDeclarationAnnotationAdapterTests(String name) {
- super(name);
- }
-
- private void createAnnotation(String annotationName) throws Exception {
- this.createAnnotationAndMembers(annotationName, "");
- }
-
- private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- public void testAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations={@annot.Bar, @annot.Bar(\"two\")})");
- // 0
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- CompilationUnit astRoot = this.idField().getAstRoot();
- Annotation annotation = aa.getAnnotation(astRoot);
- assertNotNull(annotation);
- assertEquals("annot.Bar", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
-
- // 1
- daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 1, "annot.Bar");
- aa = new MemberAnnotationAdapter(this.idField(), daa);
- annotation = aa.getAnnotation(astRoot);
- assertNotNull(annotation);
- assertEquals("annot.Bar", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isSingleMemberAnnotation());
- }
-
- public void testAnnotation2() throws Exception {
- this.createAnnotation("Baz");
- this.createAnnotationAndMembers("Bar", "annot.Baz[] yana();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(yana=@annot.Baz))");
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Baz");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa3);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
- assertEquals("annot.Baz", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
- }
-
- public void testAnnotation3() throws Exception {
- this.createAnnotation("Baz");
- this.createAnnotationAndMembers("Bar", "annot.Baz[] yana();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(yana={@annot.Baz}))");
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Baz");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa3);
- CompilationUnit astRoot = this.idField().getAstRoot();
- Annotation annotation = aa.getAnnotation(astRoot);
- assertNotNull(annotation);
- assertEquals("annot.Baz", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
-
- // name mismatch
- daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Xyz");
- aa = new MemberAnnotationAdapter(this.idField(), daa3);
- annotation = aa.getAnnotation(astRoot);
- assertNull(annotation);
- }
-
- public void testAnnotationNull1() throws Exception {
- this.createAnnotation("Bar");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo()");
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testAnnotationNull2() throws Exception {
- this.createAnnotation("Bar");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType();
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testAnnotationNull3() throws Exception {
- this.createAnnotation("Bar");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=\"annot.Bar\")");
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testAnnotationNull4() throws Exception {
- this.createAnnotation("NotBar");
- this.createAnnotation("Bar");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testAnnotationNull5() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations={@annot.Bar, @annot.Bar(\"two\")})");
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 2, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testAnnotationNull6() throws Exception {
- this.createAnnotation("Xyz");
- this.createAnnotation("Baz");
- this.createAnnotationAndMembers("Bar", "annot.Baz[] yana();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(yana={@annot.Baz}))");
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Xyz");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa3);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testRemoveAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), @annot.Bar(1)})";
- String expected = "@annot.Foo(nestedAnnotations={null, @annot.Bar(1)})";
- this.createTestType(na);
- this.assertSourceDoesNotContain(expected);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa2);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType();
- this.assertSourceDoesNotContain("Foo");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("Foo");
- }
-
- public void testRemoveAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={\"annot.Bar1\", \"annot.Bar2\", \"annot.Bar3\"})";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(na);
- }
-
- public void testRemoveAnnotation4() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.NotBar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.NotBar(0), @annot.NotBar(1)})";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(na);
- }
-
- public void testRemoveAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations=@annot.Bar)";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa2);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- assertNull(aa.getAnnotation(this.idField().getAstRoot()));
- this.assertSourceDoesNotContain(na);
- this.assertSourceDoesNotContain("Foo");
- }
-
- public void testRemoveAnnotation5a() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations=@annot.Bar)";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar", false);
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertTrue(aa1.getAnnotation(this.idField().getAstRoot()).isMarkerAnnotation());
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains("import annot.Foo;");
- this.assertSourceContains("@Foo");
- }
-
- public void testRemoveAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations=\"annot.Bar\")";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(na);
- }
-
- public void testRemoveAnnotation7() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.NotBar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations=@annot.NotBar)";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(na);
- }
-
- public void testRemoveAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), @annot.Bar(1), @annot.Bar(2), @annot.Bar(3)})";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- CompilationUnit astRoot = this.idField().getAstRoot();
- Annotation annotation = aa2.getAnnotation(astRoot);
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertTrue(aa1.getAnnotation(astRoot).isNormalAnnotation());
- assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "nestedAnnotations").getNodeType());
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.Bar(0), @annot.Bar(1), null, @annot.Bar(3)})");
- }
-
- public void testRemoveAnnotation9() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), @annot.Bar(1), @annot.Bar(2), @annot.Bar(3)})";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- CompilationUnit astRoot = this.idField().getAstRoot();
- Annotation annotation = aa2.getAnnotation(astRoot);
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertTrue(aa1.getAnnotation(astRoot).isSingleMemberAnnotation());
- assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "value").getNodeType());
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains("@annot.Foo({@annot.Bar(0), @annot.Bar(1), null, @annot.Bar(3)})");
- }
-
- public void testRemoveAnnotation10() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), @annot.Bar(1)})";
- String expected = "@annot.Foo({null, @annot.Bar(1)})";
- this.createTestType(na);
- this.assertSourceDoesNotContain(expected);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 0, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation11() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), @annot.Bar(1)})";
- String expected = "@annot.Foo(@annot.Bar(0))";
- this.createTestType(na);
- this.assertSourceDoesNotContain(expected);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 1, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.idField().getAstRoot()), "value").getNodeType());
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation12() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2)})";
- String expected = "@annot.Foo(@annot.Bar(0))";
- this.createTestType(na);
- this.assertSourceDoesNotContain(expected);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.idField().getAstRoot()), "value").getNodeType());
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation13() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({null, @annot.Bar(1)})";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 1, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- this.assertSourceDoesNotContain("Foo");
- }
-
- public void testRemoveAnnotation14() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2), null})";
- String expected = "@annot.Foo(@annot.Bar(0))";
- this.createTestType(na);
- this.assertSourceDoesNotContain(expected);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.idField().getAstRoot()), "value").getNodeType());
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation15() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2), @annot.Bar(3)})";
- String expected = "@annot.Foo({@annot.Bar(0), null, null, @annot.Bar(3)})";
- this.createTestType(na);
- this.assertSourceDoesNotContain(expected);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- CompilationUnit astRoot = this.idField().getAstRoot();
- Annotation annotation = aa2.getAnnotation(astRoot);
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "value").getNodeType());
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation16() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2), @annot.Bar(3)})";
- String expected = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2)})";
- this.createTestType(na);
- this.assertSourceDoesNotContain(expected);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 3, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- CompilationUnit astRoot = this.idField().getAstRoot();
- Annotation annotation = aa2.getAnnotation(astRoot);
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "value").getNodeType());
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation17() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2)})";
- String expected = "@annot.Foo(nestedAnnotations=@annot.Bar(0))";
- this.createTestType(na);
- this.assertSourceDoesNotContain(expected);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.idField().getAstRoot()), "nestedAnnotations").getNodeType());
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation18() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={null, @annot.Bar(1)})";
- this.createTestType(na);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 1, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- this.assertSourceDoesNotContain("Foo");
- }
-
- public void testRemoveAnnotation19() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2), null})";
- String expected = "@annot.Foo(nestedAnnotations=@annot.Bar(0))";
- this.createTestType(na);
- this.assertSourceDoesNotContain(expected);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.idField().getAstRoot()), "nestedAnnotations").getNodeType());
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation20() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2), @annot.Bar(3)})";
- String expected = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, null, @annot.Bar(3)})";
- this.createTestType(na);
- this.assertSourceDoesNotContain(expected);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- CompilationUnit astRoot = this.idField().getAstRoot();
- Annotation annotation = aa2.getAnnotation(astRoot);
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "nestedAnnotations").getNodeType());
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains(expected);
- }
-
- public void testRemoveAnnotation21() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2), @annot.Bar(3)})";
- String expected = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2)})";
- this.createTestType(na);
- this.assertSourceDoesNotContain(expected);
- this.assertSourceContains(na);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 3, "annot.Bar");
- AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2);
- CompilationUnit astRoot = this.idField().getAstRoot();
- Annotation annotation = aa2.getAnnotation(astRoot);
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "nestedAnnotations").getNodeType());
- this.assertSourceDoesNotContain(na);
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType();
- this.assertSourceDoesNotContain("Foo");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@Foo(nestedAnnotations=@Bar)");
- }
-
- public void testNewMarkerAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType();
- this.assertSourceDoesNotContain("Foo");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@Foo(@Bar)");
- }
-
- public void testNewMarkerAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo");
- String expected = "@Foo(nestedAnnotations=@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo");
- String expected = "@Foo(@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(\"something\")");
- String expected = "@Foo(value=\"something\", nestedAnnotations=@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo(\"something\")");
- String expected = "@annot.Foo(@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", nestedAnnotations = @Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] value();");
- this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", value = @Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation9() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType();
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- assertNull(aa.getAnnotation(this.idField().getAstRoot()));
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@Foo(nestedAnnotations={null,null,null,null,null,@Bar})");
- }
-
- public void testNewMarkerAnnotation10() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(\"something\")");
- this.assertSourceDoesNotContain("Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@Foo(value=\"something\", nestedAnnotations={null,null,null,null,null,@Bar})");
- }
-
- public void testNewMarkerAnnotation11() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo({\"one\", \"two\"})");
- String expected = "@annot.Foo({@Bar, \"two\"})";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation12() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo({\"one\", \"two\"})");
- this.assertSourceDoesNotContain("Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("Bar})"); // split line
- }
-
- public void testNewMarkerAnnotation13() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo(7)");
- String expected = "@annot.Foo(@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation14() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo(7)");
- this.assertSourceDoesNotContain("Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar})");
- }
-
- public void testNewMarkerAnnotation15() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo(@annot.NotBar)");
- String expected = "@annot.Foo(@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation16() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo(@annot.Bar(55))");
- String expected = "@annot.Foo({@annot.Bar(55),@Bar})";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation17() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})");
- String expected = "@annot.Foo(nestedAnnotations={@Bar})";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation18() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})");
- this.assertSourceDoesNotContain("Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("Bar})"); // split line
- }
-
- public void testNewMarkerAnnotation19() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=\"something\")");
- String expected = "@annot.Foo(nestedAnnotations=@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation20() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- String expected = "@annot.Foo(nestedAnnotations=@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation21() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar})");
- }
-
- public void testNewMarkerAnnotation22() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(88))");
- String expected = "@annot.Foo(nestedAnnotations=@Bar)";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation23() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(88))");
- String expected = "@annot.Foo(nestedAnnotations={@annot.Bar(88),null,@Bar})";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 2, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation24() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo(@annot.Bar(88))");
- String expected = "@annot.Foo({@annot.Bar(88),null,@Bar})";
- this.assertSourceDoesNotContain(expected);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected);
- }
-
- public void testNewMarkerAnnotation25() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations={@annot.Bar(88), @annot.Bar(77)})");
- String expected1 = "@annot.Foo(nestedAnnotations={@annot.Bar(88), @annot.Bar(77), null, null,"; // the line gets split
- String expected2 = "@Bar})";
- this.assertSourceDoesNotContain(expected1);
- this.assertSourceDoesNotContain(expected2);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 4, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected1);
- this.assertSourceContains(expected2);
- }
-
- public void testNewMarkerAnnotation26() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo({@annot.Bar(88), @annot.Bar(77)})");
- String expected1 = "@annot.Foo({@annot.Bar(88), @annot.Bar(77), null, null,"; // the line gets split
- String expected2 = "@Bar})";
- this.assertSourceDoesNotContain(expected1);
- this.assertSourceDoesNotContain(expected2);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 4, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected1);
- this.assertSourceContains(expected2);
- }
-
- public void testNewSingleMemberAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType();
- this.assertSourceDoesNotContain("@Foo");
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation1(declaration);
- }
- });
- this.assertSourceContains("@Foo(nestedAnnotations=@Bar(88))");
- }
-
- void editNewSingleMemberAnnotation1(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType();
- this.assertSourceDoesNotContain("@Foo");
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation2(declaration);
- }
- });
- this.assertSourceContains("@Foo(@Bar(88))");
- }
-
- void editNewSingleMemberAnnotation2(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo");
- String expected = "@Foo(nestedAnnotations=@Bar(88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation3(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation3(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo");
- String expected = "@Foo(@Bar(88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation4(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation4(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(\"something\")");
- String expected = "@Foo(value=\"something\", nestedAnnotations=@Bar(88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation5(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation5(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo(\"something\")");
- String expected = "@annot.Foo(@Bar(88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation6(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation6(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", nestedAnnotations = @Bar(88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation7(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation7(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] value();");
- this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", value = @Bar(88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation8(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation8(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation9() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType();
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newSingleMemberAnnotation();
- this.assertSourceContains("@Foo(nestedAnnotations={null,null,null,null,null,@Bar(MISSING)})"); // ???
- }
-
- public void testNewSingleMemberAnnotation10() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(\"something\")");
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newSingleMemberAnnotation();
- this.assertSourceContains("@Foo(value=\"something\", nestedAnnotations={null,null,null,null,null,@Bar(MISSING)})"); // ???
- }
-
- public void testNewSingleMemberAnnotation11() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo({\"one\", \"two\"})");
- String expected = "@annot.Foo({@Bar(88), \"two\"})";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation11(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation11(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation12() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo({\"one\", \"two\"})");
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newSingleMemberAnnotation();
- this.assertSourceContains("@Bar(MISSING)})"); // split line
- }
-
- public void testNewSingleMemberAnnotation13() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo(7)");
- String expected = "@annot.Foo(@Bar(88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation13(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation13(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation14() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo(7)");
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newSingleMemberAnnotation();
- this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar(MISSING)})");
- }
-
- public void testNewSingleMemberAnnotation15() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo(@annot.NotBar)");
- String expected = "@annot.Foo(@Bar(88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation15(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation15(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation16() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo(@annot.Bar(55))");
- String expected = "@annot.Foo({@annot.Bar(55),@Bar(88)})";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation16(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation16(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation17() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})");
- String expected = "@annot.Foo(nestedAnnotations={@Bar(88)})";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation17(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation17(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation18() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})");
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newSingleMemberAnnotation();
- this.assertSourceContains("@Bar(MISSING)})"); // ???
- }
-
- public void testNewSingleMemberAnnotation19() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=\"something\")");
- String expected = "@annot.Foo(nestedAnnotations=@Bar(88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation19(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation19(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation20() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- String expected = "@annot.Foo(nestedAnnotations=@Bar(88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation20(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation20(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation21() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newSingleMemberAnnotation();
- this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar(MISSING)})");
- }
-
- public void testNewSingleMemberAnnotation22() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(77))");
- String expected = "@annot.Foo(nestedAnnotations=@Bar(88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation22(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewSingleMemberAnnotation22(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewNormalAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType();
- this.assertSourceDoesNotContain("@Foo");
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation1(declaration);
- }
- });
- this.assertSourceContains("@Foo(nestedAnnotations=@Bar(xxx=88))");
- }
-
- void editNewNormalAnnotation1(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType();
- this.assertSourceDoesNotContain("@Foo");
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation2(declaration);
- }
- });
- this.assertSourceContains("@Foo(@Bar(xxx=88))");
- }
-
- void editNewNormalAnnotation2(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo");
- String expected = "@Foo(nestedAnnotations=@Bar(xxx=88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation3(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation3(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- this.createTestType("@annot.Foo");
- String expected = "@Foo(@Bar(xxx=88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation4(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation4(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String value();");
- this.createTestType("@annot.Foo(\"something\")");
- String expected = "@Foo(value=\"something\", nestedAnnotations=@Bar(xxx=88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation5(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation5(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo(\"something\")");
- String expected = "@annot.Foo(@Bar(xxx=88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation6(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation6(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String xxx();");
- this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", nestedAnnotations = @Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation7(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation7(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value(); String xxx();");
- this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", value = @Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation8(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation8(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation9() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String xxx();");
- this.createTestType();
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newNormalAnnotation();
- this.assertSourceContains("@Foo(nestedAnnotations={null,null,null,null,null,@Bar()})");
- }
-
- public void testNewNormalAnnotation10() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String value();");
- this.createTestType("@annot.Foo(\"something\")");
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newNormalAnnotation();
- this.assertSourceContains("@Foo(value=\"something\", nestedAnnotations={null,null,null,null,null,@Bar()})");
- }
-
- public void testNewNormalAnnotation11() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo({\"one\", \"two\"})");
- String expected = "@annot.Foo({@Bar(xxx=88), \"two\"})";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation11(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation11(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation12() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo({\"one\", \"two\"})");
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newNormalAnnotation();
- this.assertSourceContains("@Bar()})"); // split line
- }
-
- public void testNewNormalAnnotation13() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo(7)");
- String expected = "@annot.Foo(@Bar(xxx=88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation13(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation13(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation14() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo(7)");
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newNormalAnnotation();
- this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar()})");
- }
-
- public void testNewNormalAnnotation15() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int xxx();");
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- this.createTestType("@annot.Foo(@annot.NotBar)");
- String expected = "@annot.Foo(@Bar(xxx=88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation15(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation15(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation16() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo(@annot.Bar(55))");
- String expected = "@annot.Foo({@annot.Bar(55),@Bar(xxx=88)})";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation16(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation16(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation17() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})");
- String expected = "@annot.Foo(nestedAnnotations={@Bar(xxx=88)})";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation17(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation17(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation18() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})");
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newNormalAnnotation();
- this.assertSourceContains("@Bar()})"); // split line
- }
-
- public void testNewNormalAnnotation19() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=\"something\")");
- String expected = "@annot.Foo(nestedAnnotations=@Bar(xxx=88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation19(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation19(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation20() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int xxx();");
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- String expected = "@annot.Foo(nestedAnnotations=@Bar(xxx=88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation20(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation20(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation21() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int xxx();");
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- this.assertSourceDoesNotContain("@Bar");
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newNormalAnnotation();
- this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar()})");
- }
-
- public void testNewNormalAnnotation22() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(77))");
- String expected = "@annot.Foo(nestedAnnotations=@Bar(xxx=88))";
- this.assertSourceDoesNotContain(expected);
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation22(declaration);
- }
- });
- this.assertSourceContains(expected);
- }
-
- void editNewNormalAnnotation22(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testMoveAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo(@annot.Bar(00))");
- String expected = "@annot.Foo({null,@annot.Bar(00)})";
- this.assertSourceDoesNotContain(expected);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(1);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo({null, @annot.Bar(11)})");
- String expected = "@annot.Foo(@annot.Bar(11))";
- this.assertSourceDoesNotContain(expected);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22), @annot.Bar(33)})");
- String expected = "@annot.Foo({@annot.Bar(33), @annot.Bar(11), @annot.Bar(22)})";
- this.assertSourceDoesNotContain(expected);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22), @annot.Bar(33), @annot.Bar(44)})");
- String expected = "@annot.Foo({@annot.Bar(33), @annot.Bar(11), @annot.Bar(22), null, @annot.Bar(44)})";
- this.assertSourceDoesNotContain(expected);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22)})");
- String expected = "@annot.Foo({@annot.Bar(00), @annot.Bar(11), null, @annot.Bar(22)})";
- this.assertSourceDoesNotContain(expected);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(3);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22)})");
- String expected = "@annot.Foo({null, @annot.Bar(11), @annot.Bar(22), @annot.Bar(00)})";
- this.assertSourceDoesNotContain(expected);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(3);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22)})");
- String expected = "@annot.Foo({null, @annot.Bar(11), @annot.Bar(22)})";
- this.assertSourceDoesNotContain(expected);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22), null, @annot.Bar(44)})");
- String expected = "@annot.Foo({null, @annot.Bar(11), @annot.Bar(22), null, @annot.Bar(44)})";
- this.assertSourceDoesNotContain(expected);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation9() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String expected = "@annot.Foo({null, @annot.Bar(11), @annot.Bar(22)})";
- this.createTestType(expected); // the source should be unchanged
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- iaa.moveAnnotation(3);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation10() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11)})");
- String expected = "@annot.Foo(@annot.Bar(00))";
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- iaa.moveAnnotation(1);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation11() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo(@annot.Bar(00))");
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceDoesNotContain("Foo");
- }
-
- public void testMoveAnnotation12() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo({@annot.Bar(00), null, @annot.Bar(22)})");
- String expected = "@annot.Foo(@annot.Bar(22))";
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- }
-
- public void testMoveAnnotation13() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), null, @annot.Bar(33)})");
- String expected = "@annot.Foo({@annot.Bar(33), @annot.Bar(11)})";
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar");
- IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa);
- Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/SimpleDeclarationAnnotationAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/SimpleDeclarationAnnotationAdapterTests.java
deleted file mode 100644
index 0c7e7eaff6..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/SimpleDeclarationAnnotationAdapterTests.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.NumberLiteral;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jdt.core.dom.StringLiteral;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.Member;
-import org.eclipse.jpt.core.utility.jdt.ModifiedDeclaration;
-
-public class SimpleDeclarationAnnotationAdapterTests extends AnnotationTestCase {
-
- public SimpleDeclarationAnnotationAdapterTests(String name) {
- super(name);
- }
-
- private void createAnnotation(String annotationName) throws Exception {
- this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " {}");
- }
-
- public void testAnnotation1() throws Exception {
- this.createAnnotation("Foo");
- this.createTestType("@annot.Foo");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
- assertEquals("annot.Foo", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
- }
-
- public void testAnnotation2() throws Exception {
- this.createAnnotation("Foo");
- this.createTestType("@annot.Foo(1) @annot.Foo(2)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
- assertEquals("annot.Foo", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isSingleMemberAnnotation());
- Expression value = ((SingleMemberAnnotation) annotation).getValue();
- assertEquals(ASTNode.NUMBER_LITERAL, value.getNodeType());
- assertEquals("1", ((NumberLiteral) value).getToken());
- }
-
- public void testAnnotation3() throws Exception {
- this.createAnnotation("Foo");
- this.createTestType("annot.Foo", "@Foo");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
- assertEquals("Foo", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
- }
-
- public void testAnnotationNull1() throws Exception {
- this.createAnnotation("Foo");
- this.createTestType();
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- }
-
- public void testAnnotationNull2() throws Exception {
- this.createAnnotation("Foo");
- this.createAnnotation("Fop");
- this.createTestType("@annot.Fop");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- this.assertSourceContains("@annot.Fop");
- }
-
- public void testAnnotationNull3() throws Exception {
- this.createAnnotation("Foo");
- this.createTestType("@annot.Foo");
- // un-qualified name
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
- this.assertSourceContains("@annot.Foo");
- }
-
- public void testRemoveAnnotation1() throws Exception {
- this.createAnnotation("Foo");
- this.createTestType("@annot.Foo");
- this.assertSourceContains("@annot.Foo");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("@annot.Foo");
- }
-
- public void testRemoveAnnotation2() throws Exception {
- this.createAnnotation("Foo");
- this.createTestType("@annot.Foo(1) @annot.Foo(2)");
- this.assertSourceContains("@annot.Foo(1) @annot.Foo(2)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("@annot.Foo(1)");
- this.assertSourceContains("@annot.Foo(2)");
- }
-
- public void testNewMarkerAnnotation1() throws Exception {
- this.createAnnotation("Foo");
- this.createTestType();
- this.assertSourceDoesNotContain("@annot.Foo");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("import annot.Foo;");
- this.assertSourceContains("@Foo");
- }
-
- public void testNewMarkerAnnotation2() throws Exception {
- this.createAnnotation("Foo");
- this.createTestType("@annot.Foo(88)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa);
- Annotation annotation = aa.getAnnotation(this.idField().getAstRoot());
- assertNotNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("import annot.Foo;");
- this.assertSourceContains("@Foo");
- this.assertSourceDoesNotContain("@annot.Foo(88)");
- }
-
- public void testNewSingleMemberAnnotation() throws Exception {
- this.createAnnotation("Foo");
- this.createTestType();
- this.assertSourceDoesNotContain("@Foo");
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- SimpleDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation(declaration);
- }
- });
- this.assertSourceContains("import annot.Foo;");
- this.assertSourceContains("@Foo(\"test string literal\")");
- }
-
- void editNewSingleMemberAnnotation(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewNormalAnnotation() throws Exception {
- this.createAnnotation("Foo");
- this.createTestType();
- this.assertSourceDoesNotContain("@Foo");
- this.idField().edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- SimpleDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation(declaration);
- }
- });
- this.assertSourceContains("import annot.Foo;");
- this.assertSourceContains("@Foo(bar=\"test string literal\")");
- }
-
- void editNewNormalAnnotation(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- MemberValuePair mvp = this.newMemberValuePair(annotation.getAST(), "bar", "test string literal");
- this.values(annotation).add(mvp);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/TypeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/TypeTests.java
deleted file mode 100644
index 956727ba8e..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/TypeTests.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.tests.internal.utility.jdt;
-
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTType;
-
-public class TypeTests extends AnnotationTestCase {
-
- private IType jdtType;
- private JDTType testType;
-
-
- public TypeTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.jdtType = this.createTestType();
- this.testType = this.buildType(this.jdtType);
- }
-
- @Override
- protected void tearDown() throws Exception {
- this.testType = null;
- this.jdtType = null;
- super.tearDown();
- }
-
- public void testName() throws Exception {
- assertEquals(TYPE_NAME, this.testType.getName());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/test.xml b/jpa/tests/org.eclipse.jpt.core.tests/test.xml
deleted file mode 100644
index c935ae3aab..0000000000
--- a/jpa/tests/org.eclipse.jpt.core.tests/test.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0"?>
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <echo message="basedir ${basedir}" />
- <echo message="eclipse place ${eclipse-home}" />
- <!-- sets the properties plugin-name -->
- <property name="plugin-name" value="org.eclipse.jpt.core.tests"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname" value="org.eclipse.jpt.core.tests.internal.JptCoreTests" />
- <property name="plugin-path" value="${eclipse-home}/plugins/${plugin-name}"/>
- <property name="extraVMargs" value=""/>
- </ant>
- </target>
-
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init, suite, cleanup">
- </target>
-</project> \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/.classpath b/jpa/tests/org.eclipse.jpt.db.tests/.classpath
deleted file mode 100644
index ef8d91ca94..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/utility/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/.cvsignore b/jpa/tests/org.eclipse.jpt.db.tests/.cvsignore
deleted file mode 100644
index ba077a4031..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/.project b/jpa/tests/org.eclipse.jpt.db.tests/.project
deleted file mode 100644
index f5b0127a1e..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.db.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/.settings/org.eclipse.core.resources.prefs b/jpa/tests/org.eclipse.jpt.db.tests/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index b23d0c7038..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tue Jan 15 11:11:11 EST 2008
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.db.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index 23cadfc899..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,19 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.db.tests
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.jpt.db.tests.internal.JptDbTestsPlugin
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Bundle-ActivationPolicy: lazy
-Eclipse-LazyStart: false
-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
- org.junit;bundle-version="[3.8.2,4.0.0)",
- org.eclipse.datatools.connectivity;bundle-version="[1.1.0,1.2.0)",
- org.eclipse.datatools.connectivity.db.generic;bundle-version="[1.0.0,1.2.0)",
- org.eclipse.jpt.utility;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.jpt.db;bundle-version="[1.1.1,2.0.0)"
-Export-Package: org.eclipse.jpt.db.tests.internal;x-internal:=true,
- org.eclipse.jpt.db.tests.internal.platforms;x-internal:=true
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/build.properties b/jpa/tests/org.eclipse.jpt.db.tests/build.properties
deleted file mode 100644
index cd0d010fd1..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/build.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- plugin.properties
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/config/derby101.properties b/jpa/tests/org.eclipse.jpt.db.tests/config/derby101.properties
deleted file mode 100644
index 1d97add8dd..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/config/derby101.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-# Platform Property names & Default
-#
-# profileName - jpatest
-# profileDescription - JDBC Profile for JPA Testing
-# userName - jpatest
-# userPassword - (empty)
-# databasedriverJarList - (mandatory)
-# databaseName - testdb
-# databaseUrl - (mandatory)
-# Driver class name - org.apache.derby.jdbc.EmbeddedDriver
-#
-profileName = derby101
-profileDescription = Derby Embedded JDBC Profile for Testing
-# set user name
-userName =
-userPassword =
-# set path to Derby driver here (example: databasedriverJarList = c:/derbydb/lib/derby.jar )
-databasedriverJarList =
-databaseName = testdb
-# set database URL here (example: databaseUrl = jdbc:derby:c:/derbydb/testdb;create=true )
-databaseUrl =
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/config/mysql41.properties b/jpa/tests/org.eclipse.jpt.db.tests/config/mysql41.properties
deleted file mode 100644
index 4ac94784bb..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/config/mysql41.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-# Platform Property names & Default
-#
-# profileName - jpatest
-# profileDescription - JDBC Profile for JPA Testing
-# userName - jpatest
-# userPassword - (empty)
-# databasedriverJarList - (mandatory)
-# databaseName - testdb
-# databaseUrl - (mandatory)
-#
-# Driver class (jconn3.jar) - com.mysql.jdbc.Driver
-#
-profileName = mysq41
-profileDescription = MySql 4.1.16 JDBC Profile for Testing
-# set user name
-userName =
-userPassword =
-# set path to Derby driver here (example: databasedriverJarList = C:/jlib/mysql-connector-java-3.1.7-bin.jar )
-databasedriverJarList =
-databaseName = testdb
-# set database URL here (example: databaseUrl = jdbc:sybase:Tds:localhost:5000/testdb )
-databaseUrl =
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/config/oracle10g.properties b/jpa/tests/org.eclipse.jpt.db.tests/config/oracle10g.properties
deleted file mode 100644
index 603e56d7db..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/config/oracle10g.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# Platform Property names & Default
-#
-# profileName - jpatest
-# profileDescription - JDBC Profile for JPA Testing
-# userName - jpatest
-# userPassword - (empty)
-# databasedriverJarList - jar list separate by comma (mandatory)
-# databaseName - testdb
-# databaseUrl - (mandatory)
-# Driver: oracle.jdbc.OracleDriver
-#
-profileName = Oracle10g_10_1_0_4
-profileDescription = Oracle10g (10.1.0.4) Thin JDBC Profile for Testing
-userName =
-userPassword =
-# set path to Oracle driver here (example: databasedriverJarList = c:/oracle/jdbc/lib/ojdbc14.jar )
-databasedriverJarList =
-databaseName =
-# set database URL here (example: databaseUrl = jdbc:oracle:thin:@localhost:1521:testdb )
-databaseUrl =
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/config/oracle10gXE.properties b/jpa/tests/org.eclipse.jpt.db.tests/config/oracle10gXE.properties
deleted file mode 100644
index 8d72946e2a..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/config/oracle10gXE.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# Platform Property names & Default
-#
-# profileName - jpatest
-# profileDescription - JDBC Profile for JPA Testing
-# userName - jpatest
-# userPassword - (empty)
-# databasedriverJarList - jar list separate by comma (mandatory)
-# databaseName - testdb
-# databaseUrl - (mandatory)
-# Driver: oracle.jdbc.OracleDriver
-#
-profileName = oracleXE10g
-profileDescription = Oracle10g XE Release 2 (10.2) Thin JDBC Profile for Testing
-userName = scott
-userPassword = tiger
-# set path to Oracle driver here (example: databasedriverJarList = c:/oracle/jdbc/lib/ojdbc14.jar )
-databasedriverJarList =
-databaseName = XE
-# set database URL here (example: databaseUrl = jdbc:oracle:thin:@localhost:1521:XE )
-databaseUrl =
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/config/oracle9i.properties b/jpa/tests/org.eclipse.jpt.db.tests/config/oracle9i.properties
deleted file mode 100644
index 8357e15c58..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/config/oracle9i.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# Platform Property names & Default
-#
-# profileName - jpatest
-# profileDescription - JDBC Profile for JPA Testing
-# userName - jpatest
-# userPassword - (empty)
-# databasedriverJarList - jar list separate by comma (mandatory)
-# databaseName - testdb
-# databaseUrl - (mandatory)
-# Driver: oracle.jdbc.OracleDriver
-#
-profileName = oracle9i
-profileDescription = Oracle Thin JDBC Profile for Testing
-userName =
-userPassword =
-# set path to Oracle driver here (example: databasedriverJarList = c:/oracle/jdbc/lib/ojdbc14.jar )
-databasedriverJarList =
-databaseName = testdb
-# set database URL here (example: databaseUrl = jdbc:oracle:thin:@server:1521:testdb )
-databaseUrl =
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/config/postgresql824.properties b/jpa/tests/org.eclipse.jpt.db.tests/config/postgresql824.properties
deleted file mode 100644
index f529359523..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/config/postgresql824.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-# Platform Property names & Default
-#
-# profileName - jpatest
-# profileDescription - JDBC Profile for JPA Testing
-# userName - jpatest
-# userPassword - (empty)
-# databasedriverJarList - (mandatory)
-# databaseName - testdb
-# databaseUrl - (mandatory)
-# Driver class (postgresql-8.2-505.jdbc2.jar) - org.postgresql.Driver
-#
-profileName = postgresql
-profileDescription = PostgreSQL 8.2.4 JDBC Profile for Testing
-# set user name
-userName =
-userPassword =
-# set path to Derby driver here (example: databasedriverJarList = c:/jlib/postgresql-8.2-505.jdbc2.jar)
-databasedriverJarList =
-databaseName = postgres
-# set database URL here (example: databaseUrl = jdbc:postgresql:postgres )
-databaseUrl = jdbc:postgresql:postgres
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/config/sqlserver2005.properties b/jpa/tests/org.eclipse.jpt.db.tests/config/sqlserver2005.properties
deleted file mode 100644
index 8451351e83..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/config/sqlserver2005.properties
+++ /dev/null
@@ -1,30 +0,0 @@
-###############################################################################
-# Copyright (c) 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# Platform Property names & Default
-#
-# profileName - jpatest
-# profileDescription - JDBC Profile for JPA Testing
-# userName - jpatest
-# userPassword - (empty)
-# databasedriverJarList - (mandatory)
-# databaseName - testdb
-# databaseUrl - (mandatory)
-#
-profileName = sqlserver2005
-profileDescription = MS SQL Server 2005 JDBC Profile for Testing
-# set user name
-userName =
-userPassword =
-# set path to Derby driver here (example: databasedriverJarList = c:/sqlserver/lib/sqljdbc.jar )
-databasedriverJarList =
-databaseName = testdb
-# set database URL here (example: databaseUrl = jdbc:sqlserver://localhost:1433;databaseName=testdb )
-databaseUrl =
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/config/sybase12.properties b/jpa/tests/org.eclipse.jpt.db.tests/config/sybase12.properties
deleted file mode 100644
index 34aab2556b..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/config/sybase12.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-# Platform Property names & Default
-#
-# profileName - jpatest
-# profileDescription - JDBC Profile for JPA Testing
-# userName - jpatest
-# userPassword - (empty)
-# databasedriverJarList - (mandatory)
-# databaseName - testdb
-# databaseUrl - (mandatory)
-# Driver class (jconn3.jar) - com.sybase.jdbc3.jdbc.SybDriver
-#
-profileName = jconnect6
-profileDescription = Sybase 12.x jConnect JDBC Profile for Testing
-# set user name
-userName =
-userPassword =
-# set path to Derby driver here (example: databasedriverJarList = c:/sybase/lib/jconn3.jar )
-databasedriverJarList =
-databaseName = testdb
-# set database URL here (example: databaseUrl = jdbc:sybase:Tds:localhost:5000/testdb )
-databaseUrl =
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/plugin.properties b/jpa/tests/org.eclipse.jpt.db.tests/plugin.properties
deleted file mode 100644
index b04fe27976..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/plugin.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-###############################################################################
-# Copyright (c) 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName = JPA DB Tests
-providerName = Eclipse.org
-
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTests.java
deleted file mode 100644
index ecb2b84188..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTests.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.tests.internal;
-
-import org.eclipse.jpt.db.tests.internal.platforms.AllPlatformTests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-/**
- * JptDbTests
- */
-public class JptDbTests {
-
- public static void main( String[] args) {
- TestRunner.main( new String[] { "-c", JptDbTests.class.getName()});
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptDbTests.class.getPackage().getName());
-
- suite.addTest( AllPlatformTests.suite());
-
- return suite;
- }
-
- private JptDbTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTestsPlugin.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTestsPlugin.java
deleted file mode 100644
index a5fe382da0..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTestsPlugin.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0, which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.tests.internal;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * JptDbTestsPlugin
- */
-public class JptDbTestsPlugin extends Plugin {
-
- // The shared instance
- private static JptDbTestsPlugin plugin;
-
- public static final String BUNDLE_ID = "org.eclipse.jpt.db.tests"; //$NON-NLS-1$
-
- /**
- * Returns the shared instance
- */
- public static JptDbTestsPlugin getDefault() {
- return plugin;
- }
-
- /**
- * The constructor
- */
- public JptDbTestsPlugin() {
- super();
- plugin = this;
- }
-
- /**
- * This method is called upon plug-in activation
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/AllPlatformTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/AllPlatformTests.java
deleted file mode 100644
index c11b296e3f..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/AllPlatformTests.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.tests.internal.platforms;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * AllPlatformTests
- */
-public class AllPlatformTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(AllPlatformTests.class.getPackage().getName());
-
-// TODO - Uncomment the platform to test.
-// suite.addTestSuite(Derby101Tests.class);
-// suite.addTestSuite(Oracle9iTests.class);
-// suite.addTestSuite(Oracle10gTests.class);
-// suite.addTestSuite(Oracle10gXETests.class);
-// suite.addTestSuite(SQLServer2005Tests.class);
-// suite.addTestSuite(MySQL41Tests.class);
-// suite.addTestSuite(PostgreSQL824Tests.class);
-// suite.addTestSuite(Sybase12Tests.class);
-
- return suite;
- }
-
- private AllPlatformTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DTPPlatformTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DTPPlatformTests.java
deleted file mode 100644
index 8c0424d97d..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DTPPlatformTests.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.tests.internal.platforms;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.NoSuchElementException;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.datatools.connectivity.ConnectionProfileException;
-import org.eclipse.datatools.connectivity.IConnectionProfile;
-import org.eclipse.datatools.connectivity.ProfileManager;
-import org.eclipse.datatools.connectivity.drivers.IDriverMgmtConstants;
-import org.eclipse.datatools.connectivity.drivers.IPropertySet;
-import org.eclipse.datatools.connectivity.drivers.PropertySetImpl;
-import org.eclipse.datatools.connectivity.drivers.XMLFileManager;
-import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
-import org.eclipse.datatools.connectivity.internal.ConnectivityPlugin;
-import org.eclipse.jpt.db.ConnectionProfile;
-import org.eclipse.jpt.db.ConnectionProfileRepository;
-import org.eclipse.jpt.db.Database;
-import org.eclipse.jpt.db.JptDbPlugin;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.db.tests.internal.JptDbTestsPlugin;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-/**
- * Base class for all supported DTP platform.
- */
-public abstract class DTPPlatformTests extends TestCase {
-
- protected ConnectionProfileRepository connectionRepository;
-
- private Properties platformProperties;
- private String currentDbVendor;
- private String currentDbVersion;
-
- private static final String PLATFORM_CONFIG_DIRECTORY = "config"; //$NON-NLS-1$
-
- private static final String PROFILE_NAME_PROPERTY = "profileName"; //$NON-NLS-1$
- private static final String PROFILE_DESCRIPTION_PROPERTY = "profileDescription"; //$NON-NLS-1$
- private static final String USER_NAME_PROPERTY = "userName"; //$NON-NLS-1$
- private static final String USER_PASSWORD_PROPERTY = "userPassword"; //$NON-NLS-1$
- private static final String DB_DRIVER_JAR_PROPERTY = "databasedriverJarList"; //$NON-NLS-1$
- private static final String DB_NAME_PROPERTY = "databaseName"; //$NON-NLS-1$
- private static final String DB_URL_PROPERTY = "databaseUrl"; //$NON-NLS-1$
-
- private static final String PROFILE_NAME_DEFAULT = "jpatest"; //$NON-NLS-1$
- private static final String PROFILE_DESCRIPTION_DEFAULT = "JDBC Profile for JPA Testing"; //$NON-NLS-1$
- private static final String USER_NAME_DEFAULT = "userName"; //$NON-NLS-1$
- private static final String USER_PASSWORD_DEFAULT = ""; //$NON-NLS-1$
- private static final String DB_NAME_DEFAULT = "testdb"; //$NON-NLS-1$
-
- private static final String MISSING_PROPERTY_MESSAGE = "Enter missing property in platform config file (config/database.properties)";
-
- public DTPPlatformTests( String name) {
- super( name);
-
- this.connectionRepository = JptDbPlugin.instance().getConnectionProfileRepository();
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- if( this.platformIsNew()) {
- this.loadPlatformProperties();
-
- this.buildDriverDefinitionFile( IDriverMgmtConstants.DRIVER_FILE);
- this.buildConnectionProfile( this.profileName());
- this.currentDbVendor = this.databaseVendor();
- this.currentDbVersion = this.databaseVersion();
- }
- this.verifyProfileNamed( this.profileName());
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-
- // ********** tests **********
-
- public void testConnection() throws Exception {
-
- this.connect();
-
- this.verifyDatabaseVersionNumber();
- this.verifyDatabaseContent();
-
- this.disconnect();
- }
-
- public void testGetProfiles() {
- // Getting the profile directly from DTP ProfileManager
- IConnectionProfile[] profiles = ProfileManager.getInstance().getProfiles();
- Assert.assertNotNull( profiles);
- Assert.assertTrue( profiles.length > 0);
- }
-
- public void testGetProfilesByProvider() {
- // Get Profiles By ProviderID
- IConnectionProfile[] profiles = ProfileManager.getInstance().getProfileByProviderID( this.getProfile().getProviderID());
- Assert.assertNotNull( profiles);
- Assert.assertTrue( profiles.length > 0);
- }
-
- public void testGetProfileByName() {
- // Get Profile By Name
- IConnectionProfile dtpProfile = this.getDTPProfile();
- Assert.assertNotNull( dtpProfile);
- Assert.assertTrue( dtpProfile.getName().equals( this.profileName()));
- }
-
- public void testGetProfileByInstanceId() {
- // Get Profile By InstanceID
- IConnectionProfile dtpProfile = ProfileManager.getInstance().getProfileByInstanceID( this.getProfile().getInstanceID());
- Assert.assertNotNull( dtpProfile);
- Assert.assertTrue( dtpProfile.getName().equals( this.profileName()));
- }
-
- public void testWorkingOffline() {
-
- if( this.getProfile().supportsWorkOfflineMode()) {
-
- if( ! this.getProfile().canWorkOffline()) {
- this.connect();
- this.saveWorkOfflineData();
- this.disconnect();
-
- Assert.assertTrue( this.getProfile().canWorkOffline());
- }
- this.workOffline();
-
- Assert.assertTrue( this.getProfile().isActive());
- Assert.assertTrue( this.getProfile().isWorkingOffline());
-
- this.disconnect();
- }
- }
-
- // ********** internal tests **********
-
- private void verifyDatabaseVersionNumber() {
- Database database = this.getProfile().getDatabase();
- Assert.assertNotNull( database);
-
- String actualVersionNumber = database.getVersion();
- String expectedVersionNumber = this.databaseVersion();
- String errorMessage = "Expected version number: " + expectedVersionNumber + " but the actual version number was: " + actualVersionNumber;
- assertTrue( errorMessage, actualVersionNumber.indexOf( expectedVersionNumber) != -1);
-
- String actualVendor = database.getVendor();
- String expectedVendor = this.databaseVendor();
- errorMessage = "Expected vendor: " + expectedVendor + " but the actual vendor was: " + actualVendor;
- assertEquals( errorMessage, actualVendor, expectedVendor);
- }
-
- private void verifyDatabaseContent() {
- Database database = this.getProfile().getDatabase();
- Assert.assertTrue( database.schemataSize() > 0);
-
- Schema schema = database.schemaNamed( this.getProfile().getUserName());
- if( schema != null) {
- Assert.assertTrue( schema.sequencesSize() >= 0);
-
- Object[] tableNames = CollectionTools.array( schema.tableNames());
- if( tableNames.length >= 1) {
- Table table = schema.tableNamed(( String)tableNames[ 0]);
- Assert.assertTrue( table.columnsSize() >= 0);
- Assert.assertTrue( table.foreignKeysSize() >= 0);
- Assert.assertTrue( table.primaryKeyColumnsSize() >= 0);
- }
- }
- }
-
- private void verifyProfileNamed( String profileName) {
-
- ConnectionProfile profile = this.getProfileNamed( profileName);
- Assert.assertTrue( "ConnectionProfile not found", profileName.equals( profile.getName()));
- }
-
- // ***** Platform specific behavior *****
-
- protected abstract String databaseVendor();
- protected abstract String databaseVersion();
-
- protected abstract String driverName();
- protected abstract String driverDefinitionType();
- protected abstract String driverDefinitionId();
- protected abstract String driverClass();
-
- protected abstract String getConfigName();
-
- // ***** Behavior *****
-
- protected void connect() {
-
- this.getProfile().connect();
- Assert.assertTrue( "Could not connect.", this.getProfile().isActive());
- Assert.assertFalse( "Connection corrupted.", this.getProfile().isWorkingOffline());
- }
-
- protected void disconnect() {
-
- this.getProfile().disconnect();
- Assert.assertFalse( "Disconnect failed.", this.getProfile().isActive());
- }
-
- private void workOffline() {
- IStatus status = this.getProfile().workOffline();
-
- Assert.assertTrue( "Could not work offline.", status.isOK());
- }
-
- private void saveWorkOfflineData() {
- IStatus status = this.getProfile().saveWorkOfflineData();
-
- Assert.assertTrue( "Could not save offline data.", status.isOK());
- }
-
- // ********** queries **********
-
- protected Schema getSchemaNamed( String schemaName) {
-
- return this.getProfile().getDatabase().schemaNamed( schemaName);
- }
-
- protected Collection<Table> getTables() {
-
- Schema schema = this.getSchemaNamed( this.getProfile().getUserName());
- if( schema == null) {
- return new ArrayList<Table>();
- }
- return CollectionTools.collection( schema.tables());
- }
-
- protected Table getTableNamed( String tableName) {
-
- Schema schema = this.getSchemaNamed( this.getProfile().getUserName());
- Assert.assertNotNull( schema);
-
- return schema.tableNamed( tableName);
- }
-
- protected String providerId() {
- return ConnectionProfile.CONNECTION_PROFILE_TYPE;
- }
-
- protected String passwordIsSaved() {
- return "true";
- }
-
-
- protected IConnectionProfile getDTPProfile() {
- return ProfileManager.getInstance().getProfileByName( this.profileName());
- }
-
- protected String profileName() {
- return this.platformProperties.getProperty( PROFILE_NAME_PROPERTY, PROFILE_NAME_DEFAULT);
- }
-
- protected String profileDescription() {
- return this.platformProperties.getProperty( PROFILE_DESCRIPTION_PROPERTY, PROFILE_DESCRIPTION_DEFAULT);
- }
-
- protected String userName() {
- return this.platformProperties.getProperty( USER_NAME_PROPERTY, USER_NAME_DEFAULT);
- }
-
- protected String userPassword() {
- return this.platformProperties.getProperty( USER_PASSWORD_PROPERTY, USER_PASSWORD_DEFAULT);
- }
-
- protected String databaseName() {
- return this.platformProperties.getProperty( DB_NAME_PROPERTY, DB_NAME_DEFAULT);
- }
-
- protected String databasedriverJarList() {
- String dbDriverJarList = this.platformProperties.getProperty( DB_DRIVER_JAR_PROPERTY);
- if ( StringTools.stringIsEmpty( dbDriverJarList)) {
- throw new NoSuchElementException( MISSING_PROPERTY_MESSAGE);
- }
- return dbDriverJarList;
- }
-
- protected String databaseUrl() {
- String dbUrl = this.platformProperties.getProperty( DB_URL_PROPERTY);
- if ( StringTools.stringIsEmpty( dbUrl)) {
- throw new NoSuchElementException( MISSING_PROPERTY_MESSAGE);
- }
- return dbUrl;
- }
-
- protected ConnectionProfile getProfile() {
-
- return this.getProfileNamed( this.profileName());
- }
-
- protected ConnectionProfile getProfileNamed( String profileName) {
-
- return this.connectionRepository.connectionProfileNamed( profileName);
- }
-
- private String getTestPluginBundleId() {
- return JptDbTestsPlugin.BUNDLE_ID;
- }
-
- private IPath getDriverDefinitionLocation() {
- return ConnectivityPlugin.getDefault().getStateLocation();
- }
-
- private String getConfigPath() {
- return this.getConfigDir() + "/" + this.getConfigName();
- }
-
- private String getConfigDir() {
- return PLATFORM_CONFIG_DIRECTORY;
- }
-
- private boolean platformIsNew() {
- return( !this.databaseVendor().equals( this.currentDbVendor) || this.databaseVersion().equals( this.currentDbVersion));
- }
-
- private void loadPlatformProperties() throws IOException {
-
- if( this.platformProperties == null) {
- URL configUrl = Platform.getBundle( this.getTestPluginBundleId()).getEntry( this.getConfigPath());
-
- this.platformProperties = new Properties();
- this.platformProperties.load( configUrl.openStream());
- }
- }
-
- private Properties buildDriverProperties() {
- Properties driverProperties = new Properties();
- driverProperties.setProperty( ConnectionProfile.DRIVER_DEFINITION_TYPE_PROP_ID, this.driverDefinitionType());
- driverProperties.setProperty( ConnectionProfile.DRIVER_JAR_LIST_PROP_ID, this.databasedriverJarList());
- driverProperties.setProperty( IJDBCDriverDefinitionConstants.USERNAME_PROP_ID, this.userName());
- driverProperties.setProperty( IJDBCDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, this.driverClass());
- driverProperties.setProperty( IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID, this.databaseName());
- driverProperties.setProperty( IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID, this.userPassword());
- driverProperties.setProperty( IJDBCDriverDefinitionConstants.URL_PROP_ID, this.databaseUrl());
- driverProperties.setProperty( IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, this.databaseVendor());
- driverProperties.setProperty( IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, this.databaseVersion());
- return driverProperties;
- }
-
- private Properties buildBasicProperties() {
- Properties basicProperties = new Properties();
- basicProperties.setProperty( IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID, this.databaseName());
- basicProperties.setProperty( IJDBCDriverDefinitionConstants.USERNAME_PROP_ID, this.userName());
- basicProperties.setProperty( IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID, this.userPassword());
- basicProperties.setProperty( ConnectionProfile.DRIVER_DEFINITION_PROP_ID, this.driverDefinitionId());
-
- basicProperties.setProperty( IJDBCDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, this.driverClass());
- basicProperties.setProperty( IJDBCDriverDefinitionConstants.URL_PROP_ID, this.databaseUrl());
- basicProperties.setProperty( IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, this.databaseVendor());
- basicProperties.setProperty( IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, this.databaseVersion());
-
- basicProperties.setProperty( ConnectionProfile.DATABASE_SAVE_PWD_PROP_ID, this.passwordIsSaved());
- return basicProperties;
- }
-
- private void buildConnectionProfile( String profileName) throws ConnectionProfileException {
-
- ProfileManager profileManager = ProfileManager.getInstance();
- Assert.assertNotNull( profileManager);
-
- IConnectionProfile dtpProfile = this.getDTPProfile();
- if( dtpProfile == null) {
- Properties basicProperties = buildBasicProperties();
- ProfileManager.getInstance().createProfile( profileName, this.profileDescription(), this.providerId(), basicProperties);
- }
- }
-
- private void buildDriverDefinitionFile( String driverFileName) throws CoreException {
-
- XMLFileManager.setStorageLocation( this.getDriverDefinitionLocation());
- XMLFileManager.setFileName( driverFileName);
- IPropertySet[] propsets = new IPropertySet[ 1];
- String driverName = this.driverName();
- String driverId = this.driverDefinitionId();
- PropertySetImpl propertySet = new PropertySetImpl( driverName, driverId);
- propertySet.setProperties( driverId, this.buildDriverProperties());
- propsets[ 0] = propertySet;
-
- XMLFileManager.saveNamedPropertySet( propsets);
-
- File driverDefinitioneFile = this.getDriverDefinitionLocation().append( driverFileName).toFile();
- Assert.assertTrue( driverDefinitioneFile.exists());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Derby101Tests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Derby101Tests.java
deleted file mode 100644
index 2244b0e623..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Derby101Tests.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.tests.internal.platforms;
-
-
-/**
- * Derby 10.1 Embedded Driver Test
- */
-public class Derby101Tests extends DTPPlatformTests {
-
- public Derby101Tests( String name) {
- super( name);
- }
-
- @Override
- protected String databaseVendor() {
- return "Derby";
- }
-
- @Override
- protected String databaseVersion() {
- return "10.1";
- }
-
- @Override
- protected String providerId() {
- return "org.eclipse.datatools.connectivity.db.derby.embedded.connectionProfile";
- }
-
- @Override
- protected String driverName() {
- return "Derby Embedded JDBC Driver";
- }
-
- @Override
- protected String driverDefinitionType() {
- return "org.eclipse.datatools.connectivity.db.derby101.genericDriverTemplate";
- }
-
- @Override
- protected String driverDefinitionId() {
- return "DriverDefn.Derby Embedded JDBC Driver";
- }
-
- @Override
- protected String driverClass() {
- return "org.apache.derby.jdbc.EmbeddedDriver";
- }
-
- @Override
- protected String getConfigName() {
- return "derby101.properties";
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/MySQL41Tests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/MySQL41Tests.java
deleted file mode 100644
index 37c190f113..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/MySQL41Tests.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.tests.internal.platforms;
-
-
-/**
- * SQL Server 2005 Driver Test
- */
-public class MySQL41Tests extends DTPPlatformTests {
-
- public MySQL41Tests( String name) {
- super( name);
- }
-
- @Override
- protected String databaseVendor() {
- return "MySql";
- }
-
- @Override
- protected String databaseVersion() {
- return "4.1";
- }
-
- @Override
- protected String driverClass() {
- return "com.mysql.jdbc.Driver";
- }
-
- @Override
- protected String driverDefinitionId() {
- return "DriverDefn.MySQL JDBC Driver";
- }
-
- @Override
- protected String driverDefinitionType() {
- return "org.eclipse.datatools.enablement.mysql.4_1.driverTemplate";
- }
-
- @Override
- protected String driverName() {
- return "MySQL JDBC Driver";
- }
-
- @Override
- protected String getConfigName() {
- return "mysql41.properties";
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gTests.java
deleted file mode 100644
index 4fa85b4db8..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gTests.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.tests.internal.platforms;
-
-
-/**
- * Oracle 10g Thin Driver Test
- */
-public class Oracle10gTests extends DTPPlatformTests {
-
- public Oracle10gTests( String name) {
- super( name);
- }
-
- @Override
- protected String databaseVendor() {
- return "Oracle";
- }
-
- @Override
- protected String databaseVersion() {
- return "10";
- }
-
- @Override
- protected String driverClass() {
- return "oracle.jdbc.OracleDriver";
- }
-
- @Override
- protected String driverDefinitionId() {
- return "DriverDefn.Oracle Thin Driver";
- }
-
- @Override
- protected String driverDefinitionType() {
- return "org.eclipse.datatools.enablement.oracle.10.driverTemplate";
- }
-
- @Override
- protected String driverName() {
- return "Oracle 10g Thin Driver";
- }
-
- @Override
- protected String getConfigName() {
- return "oracle10g.properties";
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gXETests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gXETests.java
deleted file mode 100644
index 78e0548b1b..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gXETests.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.tests.internal.platforms;
-
-
-/**
- * Oracle 10g Thin Driver Test
- */
-public class Oracle10gXETests extends DTPPlatformTests {
-
- public Oracle10gXETests( String name) {
- super( name);
- }
-
- @Override
- protected String databaseVendor() {
- return "Oracle";
- }
-
- @Override
- protected String databaseVersion() {
- return "10";
- }
-
- @Override
- protected String driverClass() {
- return "oracle.jdbc.OracleDriver";
- }
-
- @Override
- protected String driverDefinitionId() {
- return "DriverDefn.Oracle Thin Driver";
- }
-
- @Override
- protected String driverDefinitionType() {
- return "org.eclipse.datatools.enablement.oracle.10.driverTemplate";
- }
-
- @Override
- protected String driverName() {
- return "Oracle 10g Thin Driver";
- }
-
- @Override
- protected String getConfigName() {
- return "oracle10gXE.properties";
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle9iTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle9iTests.java
deleted file mode 100644
index 8e1795dc24..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle9iTests.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.tests.internal.platforms;
-
-
-/**
- * Oracle 9i Thin Driver Test
- */
-public class Oracle9iTests extends DTPPlatformTests {
-
- public Oracle9iTests( String name) {
- super( name);
- }
-
- @Override
- protected String databaseVendor() {
- return "Oracle";
- }
-
- @Override
- protected String databaseVersion() {
- return "9";
- }
-
- @Override
- protected String driverClass() {
- return "oracle.jdbc.OracleDriver";
- }
-
- @Override
- protected String driverDefinitionId() {
- return "DriverDefn.Oracle Thin Driver";
- }
-
- @Override
- protected String driverDefinitionType() {
- return "org.eclipse.datatools.enablement.oracle.9.driverTemplate";
- }
-
- @Override
- protected String driverName() {
- return "Oracle 9i Thin Driver";
- }
-
- @Override
- protected String getConfigName() {
- return "oracle9i.properties";
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/PostgreSQL824Tests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/PostgreSQL824Tests.java
deleted file mode 100644
index 8e011ad987..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/PostgreSQL824Tests.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.tests.internal.platforms;
-
-
-/**
- * Oracle 10g Thin Driver Test
- */
-public class PostgreSQL824Tests extends DTPPlatformTests {
-
- public PostgreSQL824Tests( String name) {
- super( name);
- }
-
- @Override
- protected String databaseVendor() {
- return "postgres";
- }
-
- @Override
- protected String databaseVersion() {
- return "8.x";
- }
-
- @Override
- protected String driverClass() {
- return "org.postgresql.Driver";
- }
-
- @Override
- protected String driverDefinitionId() {
- return "DriverDefn.PostgreSQL JDBC Driver";
- }
-
- @Override
- protected String driverDefinitionType() {
- return "org.eclipse.datatools.enablement.postgresql.postgresqlDriverTemplate";
- }
-
- @Override
- protected String driverName() {
- return "PostgreSQL JDBC Driver";
- }
-
- @Override
- protected String getConfigName() {
- return "postgresql824.properties";
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SQLServer2005Tests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SQLServer2005Tests.java
deleted file mode 100644
index 350d844d56..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SQLServer2005Tests.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.tests.internal.platforms;
-
-
-/**
- * SQL Server 2005 Driver Test
- */
-public class SQLServer2005Tests extends DTPPlatformTests {
-
- public SQLServer2005Tests( String name) {
- super( name);
- }
-
- @Override
- protected String databaseVendor() {
- return "SQLServer";
- }
-
- @Override
- protected String databaseVersion() {
- return "2005";
- }
-
- @Override
- protected String providerId() {
- return "org.eclipse.datatools.connectivity.db.generic.connectionProfile";
- }
-
- @Override
- protected String driverName() {
- return "Microsoft SQL Server 2005 JDBC Driver";
- }
-
- @Override
- protected String driverDefinitionType() {
- return "org.eclipse.datatools.enablement.msft.sqlserver.2005.driverTemplate";
- }
-
- @Override
- protected String driverDefinitionId() {
- return "DriverDefn.Microsoft SQL Server 2005 JDBC Driver";
- }
-
- @Override
- protected String driverClass() {
- return "com.microsoft.sqlserver.jdbc.SQLServerDriver";
- }
-
- @Override
- protected String getConfigName() {
- return "sqlserver2005.properties";
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Sybase12Tests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Sybase12Tests.java
deleted file mode 100644
index c6c7eb3e89..0000000000
--- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Sybase12Tests.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.db.tests.internal.platforms;
-
-
-/**
- * Oracle 10g Thin Driver Test
- */
-public class Sybase12Tests extends DTPPlatformTests {
-
- public Sybase12Tests( String name) {
- super( name);
- }
-
- @Override
- protected String databaseVendor() {
- return "Sybase";
- }
-
- @Override
- protected String databaseVersion() {
- return "12.x";
- }
-
- @Override
- protected String driverClass() {
- return "com.sybase.jdbc3.jdbc.SybDriver";
- }
-
- @Override
- protected String driverDefinitionId() {
- return "DriverDefn.Sybase JDBC Driver";
- }
-
- @Override
- protected String driverDefinitionType() {
- return "org.eclipse.datatools.enablement.sybase.ase.12_x.driverTemplate";
- }
-
- @Override
- protected String driverName() {
- return "Sybase JDBC Driver";
- }
-
- @Override
- protected String getConfigName() {
- return "sybase12.properties";
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.classpath b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.classpath
deleted file mode 100644
index db34e47716..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.classpath
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/wst/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jst/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.cvsignore b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.cvsignore
deleted file mode 100644
index c4ba612bad..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-bin
-@dot
-temp.folder
-build.xml
-javaCompiler...args \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.project b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.project
deleted file mode 100644
index 26141a5bbf..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.eclipselink.core.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.settings/org.eclipse.core.resources.prefs b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 11155f4708..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Mon Apr 07 14:26:54 EDT 2008
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index 0781905987..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,21 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.eclipselink.core.tests
-Bundle-Version: 1.0.0
-Bundle-Localization: plugin
-Require-Bundle: org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jem;bundle-version="[2.0.200,3.0.0)",
- org.eclipse.jpt.core;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jpt.core.tests;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jpt.utility;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.wst.common.frameworks;bundle-version="[1.1.200,1.2.0)",
- org.eclipse.wst.common.modulecore;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.wst.common.project.facet.core;bundle-version="[1.3.0,2.0.0)",
- org.junit;bundle-version="[3.8.2,4.0.0)",
- org.eclipse.jpt.eclipselink.core;bundle-version="[1.0.0,2.0.0)"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Import-Package: org.eclipse.jpt.utility.tests.internal
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/about.html b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/about.html
deleted file mode 100644
index 9e73bdabb6..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>June 06, 2007</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/build.properties b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/build.properties
deleted file mode 100644
index bf0049751c..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-javacSource = 1.5
-javacTarget = 1.5
-bin.includes = .,\
- META-INF/,\
- plugin.properties
-source.. = src/
-output.. = bin/
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/plugin.properties b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/plugin.properties
deleted file mode 100644
index b7c25079b4..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/plugin.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 Oracle. All rights reserved. This
-# program and the accompanying materials are made available under the terms of
-# the Eclipse Public License v1.0 which accompanies this distribution, and is
-# available at http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors: Oracle. - initial API and implementation
-###############################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName=EclipseLink Core Tests
-providerName=Eclipse.org
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/JptEclipseLinkCoreTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/JptEclipseLinkCoreTests.java
deleted file mode 100644
index 84a323020b..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/JptEclipseLinkCoreTests.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.jpt.eclipselink.core.tests.internal.caching.JptEclipseLinkCoreCachingTests;
-import org.eclipse.jpt.eclipselink.core.tests.internal.connection.JptEclipseLinkCoreConnectionTests;
-import org.eclipse.jpt.eclipselink.core.tests.internal.customization.JptEclipseLinkCoreCustomizationTests;
-import org.eclipse.jpt.eclipselink.core.tests.internal.logging.JptEclipseLinkCoreLoggingTests;
-import org.eclipse.jpt.eclipselink.core.tests.internal.options.JptEclipseLinkCoreOptionsTests;
-import org.eclipse.jpt.eclipselink.core.tests.internal.schema.generation.JptEclipseLinkCoreSchemaGenerationTests;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkCoreTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkCoreTests.class.getPackage().getName());
-
- suite.addTest(JptEclipseLinkCoreConnectionTests.suite());
- suite.addTest(JptEclipseLinkCoreOptionsTests.suite());
- suite.addTest(JptEclipseLinkCoreLoggingTests.suite());
- suite.addTest(JptEclipseLinkCoreCustomizationTests.suite());
- suite.addTest(JptEclipseLinkCoreCachingTests.suite());
- suite.addTest(JptEclipseLinkCoreSchemaGenerationTests.suite());
-
- return suite;
- }
-
- private JptEclipseLinkCoreTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/PersistenceUnitTestCase.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/PersistenceUnitTestCase.java
deleted file mode 100644
index d7f89f05e7..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/PersistenceUnitTestCase.java
+++ /dev/null
@@ -1,422 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.Property;
-import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkJpaProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkPersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * PersistenceUnitTestCase
- */
-public abstract class PersistenceUnitTestCase extends ContextModelTestCase
-{
- protected PersistenceUnit subject;
-
- protected PropertyValueModel<PersistenceUnit> subjectHolder;
-
- protected EclipseLinkProperties persistenceUnitProperties;
-
- protected PropertyChangeEvent propertyChangedEvent;
-
- protected int propertyChangedEventCount;
-
- protected int propertiesTotal;
-
- protected int modelPropertiesSizeOriginal;
-
- protected int modelPropertiesSize;
-
- protected PersistenceUnitTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.subject = this.persistenceUnit();
- this.subjectHolder = new SimplePropertyValueModel<PersistenceUnit>(this.subject);
- this.persistenceUnitProperties = new EclipseLinkJpaProperties(this.subject);
- this.populatePu();
- }
-
- // ****** abstract methods *******
- protected abstract PersistenceUnitProperties model();
-
- /**
- * Initializes directly the PU properties before testing. Cannot use
- * Property Holder to initialize because it is not created yet
- */
- protected abstract void populatePu();
-
- /**
- * Gets the model's property identified by the given propertyName.
- *
- * @param propertyName
- * name of property to get
- * @throws Exception
- */
- protected abstract Object getProperty(String propertyName) throws Exception;
-
-
- /**
- * Sets the model's property identified by the given propertyName.
- * Used in verifySetProperty()
- *
- * @param propertyName
- * name of property to be set
- * @param newValue
- * value of property
- * @throws Exception
- */
- protected abstract void setProperty(String propertyName, Object newValue) throws Exception;
-
-
- // ****** convenience test methods *******
-
- protected String getEclipseLinkStringValueOf(Object value) {
- return EclipseLinkPersistenceUnitProperties.getEclipseLinkStringValueOf(value);
- }
-
- /**
- * Put into persistenceUnit properties. Do not allows to put duplicate entry.
- *
- * @param key -
- * EclipseLink Key
- * @param value -
- * property value
- */
- protected void persistenceUnitPut(String key, Object value) {
- if (key == null) {
- throw new IllegalArgumentException("EclipseLink Key cannot be null");
- }
- if (value == null)
- this.putNullProperty(key);
- else
- this.putProperty_(key, value);
- }
-
- private void putProperty_(String elKey, Object value) {
- this.clearEvent();
- this.persistenceUnit().putProperty(elKey, this.getEclipseLinkStringValueOf(value), false);
- }
-
- protected void putNullProperty(String elKey) {
- this.clearEvent();
- this.persistenceUnit().putProperty(elKey, null, false);
- }
-
- protected void clearEvent() {
- this.propertyChangedEvent = null;
- this.propertyChangedEventCount = 0;
- }
-
- protected void throwMissingDefinition(String methodName, String propertyName) throws NoSuchFieldException {
- throw new NoSuchFieldException("Missing Definition for: " + methodName + "( " + propertyName + ")");
- }
-
- protected void throwUnsupportedOperationException(ListChangeEvent e) {
- throw new UnsupportedOperationException(e.getAspectName());
- }
-
- protected PropertyChangeListener buildPropertyChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- PersistenceUnitTestCase.this.propertyChangedEvent = event;
- PersistenceUnitTestCase.this.propertyChangedEventCount++;
- }
-
- @Override
- public String toString() {
- return "Connection listener";
- }
- };
- }
-
- // ****** verify EclipseLink properties *******
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyAAValue(Boolean expectedValue, Boolean subjectValue, PropertyValueModel<Boolean> aa, String persistenceXmlKey) {
- assertEquals(expectedValue, subjectValue);
- assertEquals(expectedValue, aa.getValue());
- if (expectedValue != null) {
- assertEquals(expectedValue.toString(), this.persistenceUnit().getProperty(persistenceXmlKey).getValue());
- }
- }
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected <T extends Enum<T>> void verifyAAValue(T expectedValue, T subjectValue, PropertyValueModel<? extends Enum<T>> aa, String elKey) {
- assertEquals(expectedValue, subjectValue);
- assertEquals(expectedValue, aa.getValue());
- if (expectedValue != null) {
- assertEquals(this.getEclipseLinkStringValueOf(expectedValue), this.persistenceUnit().getProperty(elKey).getValue());
- }
- }
-
- /**
- * Performs the following tests:<br>
- * 1. verify total number of EclipseLink properties<br>
- * 2. verify PU has the given propertyName<br>
- * 3. verify listening to propertyListAdapter<br>
- * 4. verify that the model can identify propertyName<br>
- */
- protected void verifyInitialState(String propertyName, String elKey, ListValueModel<Property> propertyListAdapter) throws Exception {
- assertEquals("Total not updated in populatePu(): ", propertyListAdapter.size(), this.propertiesTotal);
- this.verifyPuHasProperty(elKey, "Property not added to populatePu()");
- this.verifyHasListeners(propertyListAdapter);
- this.verifyHasListeners(this.model(), propertyName);
-
- Property property = this.persistenceUnit().getProperty(elKey);
- assertTrue("model.itemIsProperty() is false: ", model().itemIsProperty(property));
- assertEquals("propertyIdFor() not updated: ", propertyName, model().propertyIdFor(property));
- }
-
- /**
- * Verifies that the persistence unit is populated, and that the model for
- * the tested Property is initialized with the value from the persistence
- * unit.
- * @throws Exception
- */
- protected void verifyModelInitialized(String elKey, Object expectedValue) throws Exception {
- Property property = this.persistenceUnit().getProperty(elKey);
- assertTrue("model.itemIsProperty() is false: ", model().itemIsProperty(property));
-
- assertEquals("PersistenceUnit not populated - populatedPu()", this.getEclipseLinkStringValueOf(expectedValue), property.getValue());
- String propertyName = this.model().propertyIdFor(property);
- Object modelValue = this.getProperty(propertyName);
- assertEquals(
- "Model not initialized - model.initializeProperties() - modelValue = " + modelValue,
- expectedValue,
- modelValue);
- }
-
- /**
- * Performs the following operations with the property:<br>
- * 1. verifies the initial state<br>
- * 2. persistenceUnit putProperty<br>
- * 3. adapter setProperty<br>
- */
- protected void verifySetProperty(String elKey, Object testValue1, Object testValue2) throws Exception {
- ListValueModel<Property> propertyListAdapter = ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertyListAdapter();
- Property property = this.persistenceUnit().getProperty(elKey);
- String propertyName = this.model().propertyIdFor(property);
-
- // Basic
- this.verifyInitialState(propertyName, elKey, propertyListAdapter);
-
- // Replace
- this.persistenceUnitPut(elKey, testValue2);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
- this.verifyPutProperty(propertyName, testValue2);
-
- // Replace by setting model object
- this.clearEvent();
- this.setProperty(propertyName, testValue1);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
- this.verifyPutProperty(propertyName, testValue1);
- }
-
- /**
- * Performs the following operations with the property:<br>
- * 1. performs a remove on the PU<br>
- * 2. performs a add with putProperty<br>
- * 3. performs a replace with putProperty<br>
- */
- protected void verifyAddRemoveProperty(String elKey, Object testValue1, Object testValue2) throws Exception {
- ListValueModel<Property> propertyListAdapter = ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertyListAdapter();
- Property property = this.persistenceUnit().getProperty(elKey);
- String propertyName = this.model().propertyIdFor(property);
-
- // Remove
- this.clearEvent();
- --this.propertiesTotal;
- --this.modelPropertiesSize;
- assertTrue("persistenceUnit.properties doesn't contains: " + elKey, this.persistenceUnit().containsProperty(elKey));
- this.persistenceUnit().removeProperty(elKey);
- assertFalse(this.persistenceUnit().containsProperty(elKey));
- assertEquals(this.modelPropertiesSize, this.modelPropertiesSizeOriginal - 1);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
- this.verifyPutProperty(propertyName, null);
-
- // Add original CacheTypeDefault
- ++this.propertiesTotal;
- ++this.modelPropertiesSize;
- this.persistenceUnitPut(elKey, testValue1);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
- this.verifyPutProperty(propertyName, testValue1);
-
- // Replace
- this.persistenceUnitPut(elKey, testValue2);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
- this.verifyPutProperty(propertyName, testValue2);
- }
-
- /**
- * Verifies the model's property identified by the given propertyName
- * Used in verifySetProperty() and verifyAddRemoveProperty
- *
- * @param propertyName
- * name of property to be verified
- * @param expectedValue
- * @throws Exception
- */
- protected void verifyPutProperty(String propertyName, Object expectedValue) throws Exception {
-
- this.verifyPutEvent(propertyName, this.getProperty(propertyName), expectedValue);
- }
-
- /**
- * Verifies the event of the put() action.
- *
- * @param propertyName
- * name of property to be verified
- * @param propertyValue
- * value of property
- * @param expectedValue
- * @throws Exception
- */
- protected void verifyPutEvent(String propertyName, Object propertyValue, Object expectedValue) {
-
- this.verifyEvent(propertyName);
- this.verifyEventValue(propertyValue, expectedValue);
- }
-
- /**
- * Performs the following tests:<br>
- * 1. verifies the new value of this.propertyChangedEvent<br>
- * 2. verifies the given value<br>
- */
- protected void verifyEventValue(Object value, Object expectedValue) {
- // verify event value
- assertEquals(expectedValue, this.propertyChangedEvent.getNewValue());
- assertEquals(expectedValue, value);
- }
-
- /**
- * Performs the following tests:<br>
- * 1. verifies that an event is fired<br>
- * 2. verifies that it is the correct event<br>
- * 3. verifies that a single event is fired<br>
- */
- protected void verifyEvent(String propertyName) {
- // verify event received
- assertNotNull("No Event Fired.", this.propertyChangedEvent);
- // verify event for the expected property
- assertEquals("Wrong Event.", this.propertyChangedEvent.getAspectName(), propertyName);
- // verify event occurence
- assertTrue("No Event Received.", this.propertyChangedEventCount > 0);
- assertTrue("Multiple Event Received (" + this.propertyChangedEventCount + ")",
- this.propertyChangedEventCount < 2);
- }
-
- protected void verifyHasNoListeners(ListValueModel listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- protected void verifyHasListeners(ListValueModel listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- protected void verifyHasListeners(PersistenceUnitProperties model, String propertyName) throws Exception {
- assertTrue("Listener not added in setUp() - " + propertyName, ((AbstractModel) model).hasAnyPropertyChangeListeners(propertyName));
- }
-
- protected void verifyHasListeners(PropertyValueModel pvm, String propertyName) throws Exception {
- assertTrue(((AbstractModel) pvm).hasAnyPropertyChangeListeners(propertyName));
- }
-
- protected void verifyPuHasProperty(String eclipseLinkPropertyName, String msg) {
- assertNotNull(msg + " - " + eclipseLinkPropertyName, this.persistenceUnit().getProperty(eclipseLinkPropertyName));
- }
-
- protected void verifyPuHasNotProperty(String eclipseLinkPropertyName, String msg) {
- assertNull(msg + " - " + eclipseLinkPropertyName, this.persistenceUnit().getProperty(eclipseLinkPropertyName));
- }
-
- // ****** verify Persistence Unit properties *******
-
- /**
- * Performs the following tests:<br>
- * 1. verify Persistence Unit specified property initialized<br>
- * 2. set the PU property and verify PU its value<br>
- * 3. set the PU property to null and verify PU its value<br>
- * 4. set model value property and verify PU modified<br>
- * 5. set model value property to null and verify PU modified<br>
- */
- protected void verifySetPersistenceUnitProperty(String propertyName, Object testValue1, Object testValue2) throws Exception {
- // Basic
- this.verifyHasListeners(this.model(), propertyName);
- assertEquals("Persistence Unit not initialized.", testValue1, this.getPersistenceUnitProperty(propertyName));
- Object initialModelValue = this.getProperty(propertyName);
- assertEquals(
- "Model not initialized - model.initializeProperties() - modelValue = " + initialModelValue,
- testValue1,
- initialModelValue);
-
- // Modifying value by setting PU
- this.clearEvent();
- this.setPersistenceUnitProperty(propertyName, testValue2);
- this.verifyModelModified(propertyName, testValue2);
-
- // Setting PU to null
- this.clearEvent();
- this.setPersistenceUnitProperty(propertyName, null);
- this.verifyModelModified(propertyName, null);
-
- // Modifying value by setting model object
- this.clearEvent();
- this.setProperty(propertyName, testValue1);
- this.verifyPersistenceUnitModified(propertyName, testValue1);
-
- // Setting model to null
- this.clearEvent();
- this.setProperty(propertyName, null);
- this.verifyPersistenceUnitModified(propertyName, null);
- }
-
- protected void verifyPersistenceUnitModified(String propertyName, Object expectedValue) throws Exception {
- assertEquals("Persistence Unit not modified.", expectedValue, this.getPersistenceUnitProperty(propertyName));
- this.verifyPutProperty(propertyName, expectedValue);
- }
-
- protected void verifyModelModified(String propertyName, Object expectedValue) throws Exception {
- Object modelValue = this.getProperty(propertyName);
- assertEquals("connection value not modified.", expectedValue, modelValue);
- this.verifyPutEvent(propertyName, modelValue, expectedValue);
- }
-
- protected void setPersistenceUnitProperty(String propertyName, Object newValue) throws NoSuchFieldException {
- throw new NoSuchMethodError("Missing implementation for setPersistenceUnitProperty");
- }
-
- protected Object getPersistenceUnitProperty(String propertyName) throws NoSuchFieldException {
- throw new NoSuchMethodError("Missing implementation for getPersistenceUnitProperty");
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/caching/CachingAdapterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/caching/CachingAdapterTests.java
deleted file mode 100644
index 63c1ed7e5b..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/caching/CachingAdapterTests.java
+++ /dev/null
@@ -1,442 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.caching;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.Property;
-import org.eclipse.jpt.core.internal.context.persistence.GenericProperty;
-import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkJpaProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitPropertyListListener;
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.CacheProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.CacheType;
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.EclipseLinkCaching;
-import org.eclipse.jpt.eclipselink.core.tests.internal.PersistenceUnitTestCase;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Tests the update of model objects by the Caching adapter when the
- * PersistenceUnit changes.
- */
-public class CachingAdapterTests extends PersistenceUnitTestCase
-{
- private Caching caching;
- private ListChangeEvent entitiesEvent;
-
- public static final String ENTITY_TEST = "Employee";
- public static final String ENTITY_TEST_2 = "Address";
-
- public static final String CACHE_TYPE_DEFAULT_KEY = Caching.ECLIPSELINK_CACHE_TYPE_DEFAULT;
- public static final CacheType CACHE_TYPE_DEFAULT_TEST_VALUE = CacheType.soft_weak;
- public static final CacheType CACHE_TYPE_DEFAULT_TEST_VALUE_2 = CacheType.full;
-
- public static final String CACHE_SIZE_DEFAULT_KEY = Caching.ECLIPSELINK_CACHE_SIZE_DEFAULT;
- public static final Integer CACHE_SIZE_DEFAULT_TEST_VALUE = 12345;
- public static final Integer CACHE_SIZE_DEFAULT_TEST_VALUE_2 = 67890;
-
- public static final String SHARED_CACHE_DEFAULT_KEY = Caching.ECLIPSELINK_CACHE_SHARED_DEFAULT;
- public static final Boolean SHARED_CACHE_DEFAULT_TEST_VALUE = false;
- public static final Boolean SHARED_CACHE_DEFAULT_TEST_VALUE_2 = true;
-
- public static final String CACHE_TYPE_KEY = Caching.ECLIPSELINK_CACHE_TYPE + ENTITY_TEST;
- public static final CacheType CACHE_TYPE_TEST_VALUE = CacheType.soft_weak;
- public static final CacheType CACHE_TYPE_TEST_VALUE_2 = CacheType.full;
-
- public static final String SHARED_CACHE_KEY = Caching.ECLIPSELINK_SHARED_CACHE + ENTITY_TEST;
- public static final Boolean SHARED_CACHE_TEST_VALUE = false;
- public static final Boolean SHARED_CACHE_TEST_VALUE_2 = true;
-
- public static final String CACHE_SIZE_KEY = Caching.ECLIPSELINK_CACHE_SIZE + ENTITY_TEST;
- public static final Integer CACHE_SIZE_TEST_VALUE = 12345;
- public static final Integer CACHE_SIZE_TEST_VALUE_2 = 67890;
-
- public CachingAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.caching = this.persistenceUnitProperties.getCaching();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.caching.addPropertyChangeListener(Caching.CACHE_TYPE_DEFAULT_PROPERTY, propertyChangeListener);
- this.caching.addPropertyChangeListener(Caching.CACHE_SIZE_DEFAULT_PROPERTY, propertyChangeListener);
- this.caching.addPropertyChangeListener(Caching.SHARED_CACHE_DEFAULT_PROPERTY, propertyChangeListener);
- this.caching.addPropertyChangeListener(Caching.CACHE_TYPE_PROPERTY, propertyChangeListener);
- this.caching.addPropertyChangeListener(Caching.CACHE_SIZE_PROPERTY, propertyChangeListener);
- this.caching.addPropertyChangeListener(Caching.SHARED_CACHE_PROPERTY, propertyChangeListener);
-
- ListChangeListener entitiesChangeListener = this.buildEntitiesChangeListener();
- this.caching.addListChangeListener(Caching.ENTITIES_LIST_PROPERTY, entitiesChangeListener);
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 6;
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 4; // 4 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitPut("misc.property.1", "value.1");
- this.persistenceUnitPut(CACHE_TYPE_DEFAULT_KEY, CACHE_TYPE_DEFAULT_TEST_VALUE);
- this.persistenceUnitPut("misc.property.2", "value.2");
- this.persistenceUnitPut(CACHE_SIZE_DEFAULT_KEY, CACHE_SIZE_DEFAULT_TEST_VALUE);
- this.persistenceUnitPut(SHARED_CACHE_DEFAULT_KEY, SHARED_CACHE_DEFAULT_TEST_VALUE);
- this.persistenceUnitPut("misc.property.3", "value.3");
- this.persistenceUnitPut("misc.property.4", "value.4");
- this.persistenceUnitPut(CACHE_SIZE_KEY, CACHE_SIZE_TEST_VALUE);
- this.persistenceUnitPut(CACHE_TYPE_KEY, CACHE_TYPE_TEST_VALUE);
- this.persistenceUnitPut(SHARED_CACHE_KEY, SHARED_CACHE_TEST_VALUE);
- return;
- }
-
- // ********** Listeners **********
- private ListChangeListener buildEntitiesChangeListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent e) {
- CachingAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void itemsRemoved(ListChangeEvent e) {
- CachingAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void itemsReplaced(ListChangeEvent e) {
- CachingAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void itemsMoved(ListChangeEvent e) {
- CachingAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void listCleared(ListChangeEvent e) {
- CachingAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void listChanged(ListChangeEvent e) {
- CachingAdapterTests.this.entityChanged(e);
- }
- };
- }
-
- @Override
- protected void clearEvent() {
- super.clearEvent();
- this.entitiesEvent = null;
- }
-
- void entityChanged(ListChangeEvent e) {
- this.entitiesEvent = e;
- }
-
- // ********** entities list **********
- public void testEntitiesList() throws Exception {
- // add
- this.clearEvent();
- this.caching.addEntity(ENTITY_TEST_2);
-
- // verify event received
- assertNotNull("No Event Fired.", this.entitiesEvent);
- // verify event for the expected property
- assertEquals("Wrong Event.", this.entitiesEvent.getAspectName(), Caching.ENTITIES_LIST_PROPERTY);
-
- // try to add it again
- this.clearEvent();
- this.caching.addEntity(ENTITY_TEST_2);
- // verify event received
- assertNull("Event was Fired.", this.entitiesEvent);
-
- // remove
- this.clearEvent();
- this.caching.removeEntity(ENTITY_TEST_2);
- // verify event received
- assertNotNull("No Event Fired.", this.entitiesEvent);
- // verify event for the expected property
- assertEquals("Wrong Event.", this.entitiesEvent.getAspectName(), Caching.ENTITIES_LIST_PROPERTY);
- }
-
- // ********** Listeners tests **********
- public void testHasListeners() throws Exception {
- // new
- ListAspectAdapter<PersistenceUnit, Property> propertiesAdapter =
- (ListAspectAdapter<PersistenceUnit, Property>) ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertiesAdapter();
- GenericProperty ctdProperty = (GenericProperty) this.persistenceUnit().getProperty(CACHE_TYPE_DEFAULT_KEY);
- ListValueModel<Property> propertyListAdapter = ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertyListAdapter();
-
- assertTrue(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(ctdProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- this.verifyHasListeners(this.caching, Caching.CACHE_TYPE_DEFAULT_PROPERTY);
- this.verifyHasListeners(propertyListAdapter);
-
- EclipseLinkCaching elCaching = (EclipseLinkCaching) this.caching;
- PersistenceUnitPropertyListListener propertyListListener = elCaching.propertyListListener();
- propertyListAdapter.removeListChangeListener(ListValueModel.LIST_VALUES, propertyListListener);
- assertTrue(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES)); // other properties are still listening
- this.verifyHasListeners(this.caching, Caching.CACHE_TYPE_DEFAULT_PROPERTY);
- }
-
- // ********** CacheTypeDefault **********
- /**
- * Tests the update of CacheTypeDefault property by the Caching adapter when
- * the PU or the model changes.
- */
- public void testSetCacheTypeDefault() throws Exception {
- this.verifyModelInitialized(
- CACHE_TYPE_DEFAULT_KEY,
- CACHE_TYPE_DEFAULT_TEST_VALUE);
- this.verifySetProperty(
- CACHE_TYPE_DEFAULT_KEY,
- CACHE_TYPE_DEFAULT_TEST_VALUE,
- CACHE_TYPE_DEFAULT_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheTypeDefault() throws Exception {
- this.verifyAddRemoveProperty(
- CACHE_TYPE_DEFAULT_KEY,
- CACHE_TYPE_DEFAULT_TEST_VALUE,
- CACHE_TYPE_DEFAULT_TEST_VALUE_2);
- }
-
- // ********** CacheSizeDefault **********
- /**
- * Tests the update of CacheSizeDefault property by the Caching adapter when
- * the PU or the model changes.
- */
- public void testSetCacheSizeDefault() throws Exception {
- this.verifyModelInitialized(
- CACHE_SIZE_DEFAULT_KEY,
- CACHE_SIZE_DEFAULT_TEST_VALUE);
- this.verifySetProperty(
- CACHE_SIZE_DEFAULT_KEY,
- CACHE_SIZE_DEFAULT_TEST_VALUE,
- CACHE_SIZE_DEFAULT_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheSizeDefault() throws Exception {
- this.verifyAddRemoveProperty(
- CACHE_SIZE_DEFAULT_KEY,
- CACHE_SIZE_DEFAULT_TEST_VALUE,
- CACHE_SIZE_DEFAULT_TEST_VALUE_2);
- }
-
- // ********** SharedCacheDefault **********
- public void testSetSharedCacheDefault() throws Exception {
- this.verifyModelInitialized(
- SHARED_CACHE_DEFAULT_KEY,
- SHARED_CACHE_DEFAULT_TEST_VALUE);
- this.verifySetProperty(
- SHARED_CACHE_DEFAULT_KEY,
- SHARED_CACHE_DEFAULT_TEST_VALUE,
- SHARED_CACHE_DEFAULT_TEST_VALUE_2);
- }
-
- public void testAddRemoveSharedCacheDefault() throws Exception {
- this.verifyAddRemoveProperty(
- SHARED_CACHE_DEFAULT_KEY,
- SHARED_CACHE_DEFAULT_TEST_VALUE,
- SHARED_CACHE_DEFAULT_TEST_VALUE_2);
- }
-
- // ********** CacheType **********
- /**
- * Tests the update of CacheType property by the Caching adapter when the PU
- * or the model changes.
- */
- public void testSetCacheType() throws Exception {
- this.verifyModelInitialized(
- CACHE_TYPE_KEY,
- CACHE_TYPE_TEST_VALUE);
- this.verifySetCachingProperty(
- Caching.CACHE_TYPE_PROPERTY,
- CACHE_TYPE_KEY,
- CACHE_TYPE_TEST_VALUE,
- CACHE_TYPE_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheType() throws Exception {
- this.verifyAddRemoveCachingProperty(
- Caching.CACHE_TYPE_PROPERTY,
- CACHE_TYPE_KEY,
- CACHE_TYPE_TEST_VALUE,
- CACHE_TYPE_TEST_VALUE_2);
- }
-
- // ********** CacheSize **********
- /**
- * Tests the update of CacheSize property by the Caching adapter when the PU
- * or the model changes.
- */
- public void testSetCacheSize() throws Exception {
- this.verifyModelInitialized(
- CACHE_SIZE_KEY,
- CACHE_SIZE_TEST_VALUE);
- this.verifySetCachingProperty(
- Caching.CACHE_SIZE_PROPERTY,
- CACHE_SIZE_KEY,
- CACHE_SIZE_TEST_VALUE,
- CACHE_SIZE_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheSize() throws Exception {
- this.verifyAddRemoveCachingProperty(
- Caching.CACHE_SIZE_PROPERTY,
- CACHE_SIZE_KEY,
- CACHE_SIZE_TEST_VALUE,
- CACHE_SIZE_TEST_VALUE_2);
- }
-
- // ********** SharedCache **********
- /**
- * Tests the update of SharedCache property by the Caching adapter when the
- * PU or the model changes.
- */
- public void testSetSharedCache() throws Exception {
- this.verifyModelInitialized(
- SHARED_CACHE_KEY,
- SHARED_CACHE_TEST_VALUE);
- this.verifySetCachingProperty(
- Caching.SHARED_CACHE_PROPERTY,
- SHARED_CACHE_KEY,
- SHARED_CACHE_TEST_VALUE,
- SHARED_CACHE_TEST_VALUE_2);
- }
-
- public void testAddRemoveSharedCache() throws Exception {
- this.verifyAddRemoveCachingProperty(
- Caching.SHARED_CACHE_PROPERTY,
- SHARED_CACHE_KEY,
- SHARED_CACHE_TEST_VALUE,
- SHARED_CACHE_TEST_VALUE_2);
- }
-
- // ****** convenience methods *******
- protected PersistenceUnitProperties model() {
- return this.caching;
- }
-
- protected void verifySetCachingProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- ListValueModel<Property> propertyListAdapter = ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertyListAdapter();
- // Basic
- this.verifyInitialState(propertyName, key, propertyListAdapter);
-
- // Replace
- this.persistenceUnitPut(key, testValue2);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
- this.verifyPutCachingProperty(propertyName, ENTITY_TEST, testValue2);
-
- // Replace by setting model object
- this.clearEvent();
- this.setCachingProperty(propertyName, ENTITY_TEST, testValue1);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
- this.verifyPutCachingProperty(propertyName, ENTITY_TEST, testValue1);
- }
-
- protected void verifyAddRemoveCachingProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- ListValueModel<Property> propertyListAdapter = ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertyListAdapter();
- // Remove
- this.clearEvent();
- --this.propertiesTotal;
- --this.modelPropertiesSize;
- this.persistenceUnit().removeProperty(key);
- assertFalse(this.persistenceUnit().containsProperty(key));
- assertEquals(this.modelPropertiesSize, this.modelPropertiesSizeOriginal - 1);
- this.verifyPutCachingProperty(propertyName, ENTITY_TEST, null);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
-
- // Add original Property
- ++this.propertiesTotal;
- ++this.modelPropertiesSize;
- this.persistenceUnitPut(key, testValue1);
- this.verifyPutCachingProperty(propertyName, ENTITY_TEST, testValue1);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
-
- // Replace
- this.persistenceUnitPut(key, testValue2);
- this.verifyPutCachingProperty(propertyName, ENTITY_TEST, testValue2);
- }
-
- protected void verifyPutCachingProperty(String propertyName, String entityName, Object expectedValue) throws Exception {
- this.verifyEvent(propertyName);
- this.verifyCachingEvent(propertyName, entityName, expectedValue);
- }
-
- protected void verifyCachingEvent(String propertyName, String entityName, Object expectedValue) throws Exception {
- // verify event value
- CacheProperties cache = (CacheProperties) this.propertyChangedEvent.getNewValue();
- if (propertyName.equals(Caching.CACHE_TYPE_PROPERTY)) {
- assertEquals(expectedValue, cache.getType());
- assertEquals(expectedValue, this.caching.getCacheType(entityName));
- }
- else if (propertyName.equals(Caching.CACHE_SIZE_PROPERTY)) {
- assertEquals(expectedValue, cache.getSize());
- assertEquals(expectedValue, this.caching.getCacheSize(entityName));
- }
- else if (propertyName.equals(Caching.SHARED_CACHE_PROPERTY)) {
- assertEquals(expectedValue, cache.isShared());
- assertEquals(expectedValue, this.caching.getSharedCache(entityName));
- }
- else {
- this.throwMissingDefinition("verifyCachingEvent", propertyName);
- }
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(Caching.CACHE_TYPE_DEFAULT_PROPERTY))
- this.caching.setCacheTypeDefault((CacheType) newValue);
- else if (propertyName.equals(Caching.CACHE_SIZE_DEFAULT_PROPERTY))
- this.caching.setCacheSizeDefault((Integer) newValue);
- else if (propertyName.equals(Caching.SHARED_CACHE_DEFAULT_PROPERTY))
- this.caching.setSharedCacheDefault((Boolean) newValue);
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- protected void setCachingProperty(String propertyName, String entityName, Object newValue) throws NoSuchFieldException {
- if (propertyName.equals(Caching.CACHE_TYPE_PROPERTY))
- this.caching.setCacheType((CacheType) newValue, entityName);
- else if (propertyName.equals(Caching.CACHE_SIZE_PROPERTY))
- this.caching.setCacheSize((Integer) newValue, entityName);
- else if (propertyName.equals(Caching.SHARED_CACHE_PROPERTY))
- this.caching.setSharedCache((Boolean) newValue, entityName);
- else
- this.throwMissingDefinition("setCachingProperty", propertyName);
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(Caching.CACHE_TYPE_DEFAULT_PROPERTY))
- modelValue = this.caching.getCacheTypeDefault();
- else if (propertyName.equals(Caching.CACHE_SIZE_DEFAULT_PROPERTY))
- modelValue = this.caching.getCacheSizeDefault();
- else if (propertyName.equals(Caching.SHARED_CACHE_DEFAULT_PROPERTY))
- modelValue = this.caching.getSharedCacheDefault();
- else if (propertyName.equals(Caching.CACHE_SIZE_PROPERTY))
- modelValue = this.caching.getCacheSize(ENTITY_TEST);
- else if (propertyName.equals(Caching.CACHE_TYPE_PROPERTY))
- modelValue = this.caching.getCacheType(ENTITY_TEST);
- else if (propertyName.equals(Caching.SHARED_CACHE_PROPERTY))
- modelValue = this.caching.getSharedCache(ENTITY_TEST);
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/caching/CachingValueModelTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/caching/CachingValueModelTests.java
deleted file mode 100644
index 24f7d7a80e..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/caching/CachingValueModelTests.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.caching;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.CacheType;
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
-import org.eclipse.jpt.eclipselink.core.tests.internal.PersistenceUnitTestCase;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * CachingValueModelTests
- */
-public class CachingValueModelTests extends PersistenceUnitTestCase
-{
- private Caching caching;
- private PropertyValueModel<Caching> cachingHolder;
-
- private WritablePropertyValueModel<CacheType> cacheTypeHolder;
- private PropertyChangeListener cacheTypeListener;
- private PropertyChangeEvent cacheTypeEvent;
-
- private WritablePropertyValueModel<Boolean> sharedCacheHolder;
- private PropertyChangeListener sharedCacheListener;
- private PropertyChangeEvent sharedCacheEvent;
-
- private WritablePropertyValueModel<CacheType> cacheTypeDefaultHolder;
- private PropertyChangeListener cacheTypeDefaultListener;
- private PropertyChangeEvent cacheTypeDefaultEvent;
-
- private WritablePropertyValueModel<Boolean> sharedCacheDefaultHolder;
- private PropertyChangeListener sharedCacheDefaultListener;
- private PropertyChangeEvent sharedCacheDefaultEvent;
-
- public static final String ENTITY_NAME_TEST_VALUE = "Employee";
- public static final CacheType CACHE_TYPE_TEST_VALUE = CacheType.hard_weak;
- public static final Boolean SHARED_CACHE_TEST_VALUE = Boolean.FALSE;
- public static final CacheType CACHE_TYPE_DEFAULT_TEST_VALUE = CacheType.weak;
- public static final Boolean SHARED_CACHE_DEFAULT_TEST_VALUE = Boolean.FALSE;
-
- public CachingValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.caching = this.persistenceUnitProperties.getCaching(); // Subject
- this.cachingHolder = new SimplePropertyValueModel<Caching>(this.caching);
-
- this.cacheTypeHolder = this.buildCacheTypeAA(this.cachingHolder);
- this.cacheTypeListener = this.buildCacheTypeChangeListener();
- this.cacheTypeHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeListener);
- this.cacheTypeEvent = null;
-
- this.sharedCacheHolder = this.buildSharedCacheAA(this.cachingHolder);
- this.sharedCacheListener = this.buildSharedCacheChangeListener();
- this.sharedCacheHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheListener);
- this.sharedCacheEvent = null;
-
- this.cacheTypeDefaultHolder = this.buildCacheTypeDefaultAA(this.cachingHolder);
- this.cacheTypeDefaultListener = this.buildCacheTypeDefaultChangeListener();
- this.cacheTypeDefaultHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeDefaultListener);
- this.cacheTypeDefaultEvent = null;
-
- this.sharedCacheDefaultHolder = this.buildSharedCacheDefaultAA(this.cachingHolder);
- this.sharedCacheDefaultListener = this.buildSharedCacheDefaultChangeListener();
- this.sharedCacheDefaultHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheDefaultListener);
- this.sharedCacheDefaultEvent = null;
- }
-
- public void testHasListeners() {
- AbstractModel subjectCaching = (AbstractModel) this.caching; // Subject
- PropertyAspectAdapter<Caching, CacheType> cacheTypeAA =
- (PropertyAspectAdapter<Caching, CacheType>) this.cacheTypeHolder;
- assertTrue(cacheTypeAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectCaching.hasAnyPropertyChangeListeners(Caching.CACHE_TYPE_PROPERTY));
-
- cacheTypeAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeListener);
- assertFalse(subjectCaching.hasAnyPropertyChangeListeners(Caching.CACHE_TYPE_PROPERTY));
- assertFalse(cacheTypeAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- PropertyAspectAdapter<Caching, Boolean> sharedCacheAA =
- (PropertyAspectAdapter<Caching, Boolean>) this.sharedCacheHolder;
- assertTrue(sharedCacheAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectCaching.hasAnyPropertyChangeListeners(Caching.SHARED_CACHE_PROPERTY));
-
- sharedCacheAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheListener);
- assertFalse(subjectCaching.hasAnyPropertyChangeListeners(Caching.SHARED_CACHE_PROPERTY));
- assertFalse(sharedCacheAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- PropertyAspectAdapter<Caching, CacheType> cacheTypeDefaultAA =
- (PropertyAspectAdapter<Caching, CacheType>) this.cacheTypeDefaultHolder;
- assertTrue(cacheTypeDefaultAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectCaching.hasAnyPropertyChangeListeners(Caching.CACHE_TYPE_DEFAULT_PROPERTY));
-
- cacheTypeDefaultAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeDefaultListener);
- assertFalse(subjectCaching.hasAnyPropertyChangeListeners(Caching.CACHE_TYPE_DEFAULT_PROPERTY));
- assertFalse(cacheTypeDefaultAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- PropertyAspectAdapter<Caching, Boolean> sharedCacheDefaultAA =
- (PropertyAspectAdapter<Caching, Boolean>) this.sharedCacheDefaultHolder;
- assertTrue(sharedCacheDefaultAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectCaching.hasAnyPropertyChangeListeners(Caching.SHARED_CACHE_DEFAULT_PROPERTY));
-
- sharedCacheDefaultAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheDefaultListener);
- assertFalse(subjectCaching.hasAnyPropertyChangeListeners(Caching.SHARED_CACHE_DEFAULT_PROPERTY));
- assertFalse(sharedCacheDefaultAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- protected void populatePu() {
- this.persistenceUnitPut(
- Caching.ECLIPSELINK_CACHE_TYPE + ENTITY_NAME_TEST_VALUE,
- CACHE_TYPE_TEST_VALUE);
- this.persistenceUnitPut(
- Caching.ECLIPSELINK_SHARED_CACHE + ENTITY_NAME_TEST_VALUE,
- SHARED_CACHE_TEST_VALUE);
- this.persistenceUnitPut(
- Caching.ECLIPSELINK_CACHE_TYPE_DEFAULT,
- CACHE_TYPE_DEFAULT_TEST_VALUE);
- this.persistenceUnitPut(
- Caching.ECLIPSELINK_CACHE_SHARED_DEFAULT,
- SHARED_CACHE_DEFAULT_TEST_VALUE);
- return;
- }
-
- protected PersistenceUnitProperties model() {
- return this.caching;
- }
-
- /** ****** CacheType ******* */
- private WritablePropertyValueModel<CacheType> buildCacheTypeAA(PropertyValueModel<Caching> subjectHolder) {
- return new PropertyAspectAdapter<Caching, CacheType>(subjectHolder, Caching.CACHE_TYPE_PROPERTY) {
- @Override
- protected CacheType buildValue_() {
- return this.subject.getCacheType(ENTITY_NAME_TEST_VALUE);
- }
-
- @Override
- protected void setValue_(CacheType enumValue) {
- this.subject.setCacheType(enumValue, ENTITY_NAME_TEST_VALUE);
- }
- };
- }
-
- private PropertyChangeListener buildCacheTypeChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CachingValueModelTests.this.cacheTypeEvent = e;
- }
- };
- }
-
- /** ****** SharedCache ******* */
- private WritablePropertyValueModel<Boolean> buildSharedCacheAA(PropertyValueModel<Caching> subjectHolder) {
- return new PropertyAspectAdapter<Caching, Boolean>(subjectHolder, Caching.SHARED_CACHE_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getSharedCache(ENTITY_NAME_TEST_VALUE);
- }
-
- @Override
- protected void setValue_(Boolean enumValue) {
- this.subject.setSharedCache(enumValue, ENTITY_NAME_TEST_VALUE);
- }
- };
- }
-
- private PropertyChangeListener buildSharedCacheChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CachingValueModelTests.this.sharedCacheEvent = e;
- }
- };
- }
-
- /** ****** CacheTypeDefault ******* */
- private WritablePropertyValueModel<CacheType> buildCacheTypeDefaultAA(PropertyValueModel<Caching> subjectHolder) {
- return new PropertyAspectAdapter<Caching, CacheType>(subjectHolder, Caching.CACHE_TYPE_DEFAULT_PROPERTY) {
- @Override
- protected CacheType buildValue_() {
- return this.subject.getCacheTypeDefault();
- }
-
- @Override
- protected void setValue_(CacheType enumValue) {
- this.subject.setCacheTypeDefault(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildCacheTypeDefaultChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CachingValueModelTests.this.cacheTypeDefaultEvent = e;
- }
- };
- }
-
- /** ****** SharedCacheDefault ******* */
- private WritablePropertyValueModel<Boolean> buildSharedCacheDefaultAA(PropertyValueModel<Caching> subjectHolder) {
- return new PropertyAspectAdapter<Caching, Boolean>(subjectHolder, Caching.SHARED_CACHE_DEFAULT_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getSharedCacheDefault();
- }
-
- @Override
- protected void setValue_(Boolean enumValue) {
- this.subject.setSharedCacheDefault(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildSharedCacheDefaultChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CachingValueModelTests.this.sharedCacheDefaultEvent = e;
- }
- };
- }
-
- /** ****** Tests ******* */
- public void testValue() {
- /** ****** CacheType - defaults for entity level caching are equal to the persistence unit settings ******* */
- this.verifyCacheTypeAAValue(CACHE_TYPE_TEST_VALUE);
- assertEquals(this.caching.getCacheTypeDefault(), this.caching.getDefaultCacheType());
- /** ****** SharedCache - defaults for entity level caching are equal to the persistence unit settings ******* */
- this.verifySharedCacheAAValue(SHARED_CACHE_TEST_VALUE);
- assertEquals(this.caching.getSharedCacheDefault(), this.caching.getDefaultSharedCache());
- /** ****** CacheTypeDefault ******* */
- this.verifyCacheTypeDefaultAAValue(CACHE_TYPE_DEFAULT_TEST_VALUE);
- assertEquals(Caching.DEFAULT_CACHE_TYPE_DEFAULT, this.caching.getDefaultCacheTypeDefault());
- /** ****** SharedCacheDefault ******* */
- this.verifySharedCacheDefaultAAValue(SHARED_CACHE_DEFAULT_TEST_VALUE);
- assertEquals(Caching.DEFAULT_SHARED_CACHE_DEFAULT, this.caching.getDefaultSharedCacheDefault());
- }
-
- public void testSetValue() throws Exception {
- /** ****** CacheType ******* */
- this.cacheTypeEvent = null;
- this.verifyHasListeners(this.cacheTypeHolder, PropertyValueModel.VALUE);
- CacheType newCacheType = CacheType.full;
- // Modify the property holder
- this.cacheTypeHolder.setValue(newCacheType);
- this.verifyCacheTypeAAValue(newCacheType);
- assertNotNull(this.cacheTypeEvent);
- /** ****** SharedCache ******* */
- this.sharedCacheEvent = null;
- this.verifyHasListeners(this.sharedCacheHolder, PropertyValueModel.VALUE);
- Boolean newSharedCache = !SHARED_CACHE_TEST_VALUE;
- // Modify the property holder
- this.sharedCacheHolder.setValue(newSharedCache);
- this.verifySharedCacheAAValue(newSharedCache);
- assertNotNull(this.sharedCacheEvent);
- /** ****** CacheTypeDefault ******* */
- this.cacheTypeDefaultEvent = null;
- this.verifyHasListeners(this.cacheTypeDefaultHolder, PropertyValueModel.VALUE);
- CacheType newCacheTypeDefault = CacheType.none;
- // Modify the property holder
- this.cacheTypeDefaultHolder.setValue(newCacheTypeDefault);
- this.verifyCacheTypeDefaultAAValue(newCacheTypeDefault);
- assertNotNull(this.cacheTypeDefaultEvent);
- /** ****** SharedCacheDefault ******* */
- this.sharedCacheDefaultEvent = null;
- this.verifyHasListeners(this.sharedCacheDefaultHolder, PropertyValueModel.VALUE);
- Boolean newSharedCacheDefault = !SHARED_CACHE_DEFAULT_TEST_VALUE;
- // Modify the property holder
- this.sharedCacheDefaultHolder.setValue(newSharedCacheDefault);
- this.verifySharedCacheDefaultAAValue(newSharedCacheDefault);
- assertNotNull(this.sharedCacheDefaultEvent);
- }
-
- public void testSetNullValue() {
- String notDeleted = "Property not deleted";
- /** ****** CacheType ******* */
- this.cacheTypeEvent = null;
- // Setting the property holder
- this.cacheTypeHolder.setValue(null);
- // testing Holder
- this.verifyCacheTypeAAValue(null);
- assertNotNull(this.cacheTypeEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Caching.ECLIPSELINK_CACHE_TYPE + ENTITY_NAME_TEST_VALUE, notDeleted);
- /** ****** SharedCache ******* */
- this.sharedCacheEvent = null;
- // Setting the property holder
- this.sharedCacheHolder.setValue(null);
- // testing Holder
- this.verifySharedCacheAAValue(null);
- assertNotNull(this.sharedCacheEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Caching.ECLIPSELINK_SHARED_CACHE + ENTITY_NAME_TEST_VALUE, notDeleted);
- /** ****** CacheTypeDefault ******* */
- this.cacheTypeDefaultEvent = null;
- // Setting the property holder
- this.cacheTypeDefaultHolder.setValue(null);
- // testing Holder
- this.verifyCacheTypeDefaultAAValue(null);
- assertNotNull(this.cacheTypeDefaultEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Caching.ECLIPSELINK_CACHE_TYPE_DEFAULT, notDeleted);
- /** ****** SharedCacheDefault ******* */
- this.sharedCacheDefaultEvent = null;
- // Setting the property holder
- this.sharedCacheDefaultHolder.setValue(null);
- // testing Holder
- this.verifySharedCacheDefaultAAValue(null);
- assertNotNull(this.sharedCacheDefaultEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Caching.ECLIPSELINK_CACHE_SHARED_DEFAULT, notDeleted);
- }
-
- /** ****** convenience methods ******* */
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyCacheTypeAAValue(CacheType testValue) {
- this.verifyAAValue(
- testValue,
- this.caching.getCacheType(ENTITY_NAME_TEST_VALUE),
- this.cacheTypeHolder,
- Caching.ECLIPSELINK_CACHE_TYPE + ENTITY_NAME_TEST_VALUE);
- }
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifySharedCacheAAValue(Boolean testValue) {
- this.verifyAAValue(
- testValue,
- this.caching.getSharedCache(ENTITY_NAME_TEST_VALUE),
- this.sharedCacheHolder,
- Caching.ECLIPSELINK_SHARED_CACHE + ENTITY_NAME_TEST_VALUE);
- }
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyCacheTypeDefaultAAValue(CacheType testValue) {
- this.verifyAAValue(
- testValue,
- this.caching.getCacheTypeDefault(),
- this.cacheTypeDefaultHolder,
- Caching.ECLIPSELINK_CACHE_TYPE_DEFAULT);
- }
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifySharedCacheDefaultAAValue(Boolean testValue) {
- this.verifyAAValue(
- testValue,
- this.caching.getSharedCacheDefault(),
- this.sharedCacheDefaultHolder,
- Caching.ECLIPSELINK_CACHE_SHARED_DEFAULT);
- }
-
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/caching/JptEclipseLinkCoreCachingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/caching/JptEclipseLinkCoreCachingTests.java
deleted file mode 100644
index 5f6d62b720..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/caching/JptEclipseLinkCoreCachingTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.caching;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkCoreCachingTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkCoreCachingTests.class.getPackage().getName());
-
- suite.addTestSuite(CachingValueModelTests.class);
- suite.addTestSuite(CachingAdapterTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkCoreCachingTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/connection/ConnectionAdapterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/connection/ConnectionAdapterTests.java
deleted file mode 100644
index 31ea1ea5e1..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/connection/ConnectionAdapterTests.java
+++ /dev/null
@@ -1,586 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.connection;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnitTransactionType;
-import org.eclipse.jpt.core.context.persistence.Property;
-import org.eclipse.jpt.core.internal.context.persistence.GenericProperty;
-import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkJpaProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitPropertyListListener;
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.BatchWriting;
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
-import org.eclipse.jpt.eclipselink.core.internal.context.connection.EclipseLinkConnection;
-import org.eclipse.jpt.eclipselink.core.tests.internal.PersistenceUnitTestCase;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * ConnectionAdapterTests
- */
-public class ConnectionAdapterTests extends PersistenceUnitTestCase
-{
- private Connection connection;
-
- public static final PersistenceUnitTransactionType TRANSACTION_TYPE_TEST_VALUE = PersistenceUnitTransactionType.RESOURCE_LOCAL;
- public static final PersistenceUnitTransactionType TRANSACTION_TYPE_TEST_VALUE_2 = PersistenceUnitTransactionType.JTA;
-
- public static final String JTA_DATA_SOURCE_TEST_VALUE = "Test_JTA";
- public static final String JTA_DATA_SOURCE_TEST_VALUE_2 = "Test_JTA_2";
-
- public static final String NON_JTA_DATA_SOURCE_TEST_VALUE = "Test_Non_JTA";
- public static final String NON_JTA_DATA_SOURCE_TEST_VALUE_2 = "Test_Non_JTA_2";
-
- public static final String NATIVE_SQL_KEY = Connection.ECLIPSELINK_NATIVE_SQL;
- public static final Boolean NATIVE_SQL_TEST_VALUE = false;
- public static final Boolean NATIVE_SQL_TEST_VALUE_2 = ! NATIVE_SQL_TEST_VALUE;
-
- public static final String BATCH_WRITING_KEY = Connection.ECLIPSELINK_BATCH_WRITING;
- public static final BatchWriting BATCH_WRITING_TEST_VALUE = BatchWriting.oracle_jdbc;
- public static final BatchWriting BATCH_WRITING_TEST_VALUE_2 = BatchWriting.buffered;
-
- public static final String CACHE_STATEMENTS_KEY = Connection.ECLIPSELINK_CACHE_STATEMENTS;
- public static final Boolean CACHE_STATEMENTS_TEST_VALUE = false;
- public static final Boolean CACHE_STATEMENTS_TEST_VALUE_2 = ! CACHE_STATEMENTS_TEST_VALUE;
-
- public static final String CACHE_STATEMENTS_SIZE_KEY = Connection.ECLIPSELINK_CACHE_STATEMENTS_SIZE;
- public static final Integer CACHE_STATEMENTS_SIZE_TEST_VALUE = 100;
- public static final Integer CACHE_STATEMENTS_SIZE_TEST_VALUE_2 = 200;
-
- public static final String DRIVER_KEY = Connection.ECLIPSELINK_DRIVER;
- public static final String DRIVER_TEST_VALUE = "test";
- public static final String DRIVER_TEST_VALUE_2 = "test_2";
-
- public static final String URL_KEY = Connection.ECLIPSELINK_URL;
- public static final String URL_TEST_VALUE = "test";
- public static final String URL_TEST_VALUE_2 = "test_2";
-
- public static final String USER_KEY = Connection.ECLIPSELINK_USER;
- public static final String USER_TEST_VALUE = "test";
- public static final String USER_TEST_VALUE_2 = "test_2";
-
- public static final String PASSWORD_KEY = Connection.ECLIPSELINK_PASSWORD;
- public static final String PASSWORD_TEST_VALUE = "test";
- public static final String PASSWORD_TEST_VALUE_2 = "test_2";
-
- public static final String BIND_PARAMETERS_KEY = Connection.ECLIPSELINK_BIND_PARAMETERS;
- public static final Boolean BIND_PARAMETERS_TEST_VALUE = false;
- public static final Boolean BIND_PARAMETERS_TEST_VALUE_2 = ! BIND_PARAMETERS_TEST_VALUE;
-
- public static final String READ_CONNECTIONS_SHARED_KEY = Connection.ECLIPSELINK_READ_CONNECTIONS_SHARED;
- public static final Boolean READ_CONNECTIONS_SHARED_TEST_VALUE = false;
- public static final Boolean READ_CONNECTIONS_SHARED_TEST_VALUE_2 = ! READ_CONNECTIONS_SHARED_TEST_VALUE;
-
- public static final String READ_CONNECTIONS_MIN_KEY = Connection.ECLIPSELINK_READ_CONNECTIONS_MIN;
- public static final Integer READ_CONNECTIONS_MIN_TEST_VALUE = 100;
- public static final Integer READ_CONNECTIONS_MIN_TEST_VALUE_2 = 200;
-
- public static final String READ_CONNECTIONS_MAX_KEY = Connection.ECLIPSELINK_READ_CONNECTIONS_MAX;
- public static final Integer READ_CONNECTIONS_MAX_TEST_VALUE = 100;
- public static final Integer READ_CONNECTIONS_MAX_TEST_VALUE_2 = 200;
-
- public static final String WRITE_CONNECTIONS_MIN_KEY = Connection.ECLIPSELINK_WRITE_CONNECTIONS_MIN;
- public static final Integer WRITE_CONNECTIONS_MIN_TEST_VALUE = 100;
- public static final Integer WRITE_CONNECTIONS_MIN_TEST_VALUE_2 = 200;
-
- public static final String WRITE_CONNECTIONS_MAX_KEY = Connection.ECLIPSELINK_WRITE_CONNECTIONS_MAX;
- public static final Integer WRITE_CONNECTIONS_MAX_TEST_VALUE = 100;
- public static final Integer WRITE_CONNECTIONS_MAX_TEST_VALUE_2 = 200;
-
- public ConnectionAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.connection = this.persistenceUnitProperties.getConnection();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.connection.addPropertyChangeListener(Connection.TRANSACTION_TYPE_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.JTA_DATA_SOURCE_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.NON_JTA_DATA_SOURCE_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.NATIVE_SQL_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.BATCH_WRITING_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.CACHE_STATEMENTS_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.CACHE_STATEMENTS_SIZE_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.DRIVER_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.URL_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.USER_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.PASSWORD_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.BIND_PARAMETERS_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.READ_CONNECTIONS_SHARED_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.READ_CONNECTIONS_MIN_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.READ_CONNECTIONS_MAX_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.WRITE_CONNECTIONS_MIN_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.WRITE_CONNECTIONS_MAX_PROPERTY, propertyChangeListener);
-
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 14; // EclipseLink properties
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 4; // 4 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- // Initializes EclipseLink properties
- this.persistenceUnitPut("misc.property.1", "value.1");
- this.persistenceUnitPut(NATIVE_SQL_KEY, NATIVE_SQL_TEST_VALUE.toString());
- this.persistenceUnitPut(BATCH_WRITING_KEY, BATCH_WRITING_TEST_VALUE);
- this.persistenceUnitPut(CACHE_STATEMENTS_KEY, CACHE_STATEMENTS_TEST_VALUE.toString());
- this.persistenceUnitPut(CACHE_STATEMENTS_SIZE_KEY, CACHE_STATEMENTS_SIZE_TEST_VALUE.toString());
- this.persistenceUnitPut(DRIVER_KEY, DRIVER_TEST_VALUE.toString());
- this.persistenceUnitPut(URL_KEY, URL_TEST_VALUE.toString());
- this.persistenceUnitPut(USER_KEY, USER_TEST_VALUE.toString());
- this.persistenceUnitPut(PASSWORD_KEY, PASSWORD_TEST_VALUE.toString());
- this.persistenceUnitPut(BIND_PARAMETERS_KEY, BIND_PARAMETERS_TEST_VALUE.toString());
- this.persistenceUnitPut("misc.property.2", "value.2");
- this.persistenceUnitPut("misc.property.3", "value.3");
- this.persistenceUnitPut(READ_CONNECTIONS_SHARED_KEY, READ_CONNECTIONS_SHARED_TEST_VALUE.toString());
- this.persistenceUnitPut(READ_CONNECTIONS_MIN_KEY, READ_CONNECTIONS_MIN_TEST_VALUE.toString());
- this.persistenceUnitPut(READ_CONNECTIONS_MAX_KEY, READ_CONNECTIONS_MAX_TEST_VALUE.toString());
- this.persistenceUnitPut(WRITE_CONNECTIONS_MIN_KEY, WRITE_CONNECTIONS_MIN_TEST_VALUE.toString());
- this.persistenceUnitPut(WRITE_CONNECTIONS_MAX_KEY, WRITE_CONNECTIONS_MAX_TEST_VALUE.toString());
- this.persistenceUnitPut("misc.property.4", "value.4");
-
- // Initializes PU property TransactionType
- this.persistenceUnit().setSpecifiedTransactionType(TRANSACTION_TYPE_TEST_VALUE);
- this.persistenceUnit().setJtaDataSource(JTA_DATA_SOURCE_TEST_VALUE);
- this.persistenceUnit().setNonJtaDataSource(NON_JTA_DATA_SOURCE_TEST_VALUE);
- return;
- }
-
- // ********** Listeners tests **********
- public void testHasListeners() throws Exception {
- // new
- ListAspectAdapter<PersistenceUnit, Property> propertiesAdapter =
- (ListAspectAdapter<PersistenceUnit, Property>) ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertiesAdapter();
- GenericProperty ctdProperty = (GenericProperty) this.persistenceUnit().getProperty(NATIVE_SQL_KEY);
- ListValueModel<Property> propertyListAdapter = ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertyListAdapter();
-
- assertTrue(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(ctdProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- this.verifyHasListeners(this.connection, Connection.NATIVE_SQL_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.BIND_PARAMETERS_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.CACHE_STATEMENTS_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.READ_CONNECTIONS_SHARED_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.BATCH_WRITING_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.TRANSACTION_TYPE_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.JTA_DATA_SOURCE_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.NON_JTA_DATA_SOURCE_PROPERTY);
- this.verifyHasListeners(propertyListAdapter);
-
- EclipseLinkConnection elConnection = (EclipseLinkConnection) this.connection;
- PersistenceUnitPropertyListListener propertyListListener = elConnection.propertyListListener();
- propertyListAdapter.removeListChangeListener(ListValueModel.LIST_VALUES, propertyListListener);
- assertTrue(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES)); // other properties are still listening
- this.verifyHasListeners(this.connection, Connection.NATIVE_SQL_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.BIND_PARAMETERS_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.CACHE_STATEMENTS_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.READ_CONNECTIONS_SHARED_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.BATCH_WRITING_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.TRANSACTION_TYPE_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.JTA_DATA_SOURCE_PROPERTY);
- this.verifyHasListeners(this.connection, Connection.NON_JTA_DATA_SOURCE_PROPERTY);
- }
-
- // ********** TransactionType tests **********
- public void testSetTransactionType() throws Exception {
- this.verifySetPersistenceUnitProperty(Connection.TRANSACTION_TYPE_PROPERTY,
- TRANSACTION_TYPE_TEST_VALUE,
- TRANSACTION_TYPE_TEST_VALUE_2);
- }
-
- // ********** JtaDataSource tests **********
- public void testSetJtaDataSource() throws Exception {
- this.verifySetPersistenceUnitProperty(Connection.JTA_DATA_SOURCE_PROPERTY,
- JTA_DATA_SOURCE_TEST_VALUE,
- JTA_DATA_SOURCE_TEST_VALUE_2);
- }
-
- // ********** NonJtaDataSource tests **********
- public void testSetNonJtaDataSource() throws Exception {
- this.verifySetPersistenceUnitProperty(Connection.NON_JTA_DATA_SOURCE_PROPERTY,
- NON_JTA_DATA_SOURCE_TEST_VALUE,
- NON_JTA_DATA_SOURCE_TEST_VALUE_2);
- }
-
- // ********** NativeSql tests **********
- public void testSetNativeSql() throws Exception {
- this.verifyModelInitialized(
- NATIVE_SQL_KEY,
- NATIVE_SQL_TEST_VALUE);
- this.verifySetProperty(
- NATIVE_SQL_KEY,
- NATIVE_SQL_TEST_VALUE,
- NATIVE_SQL_TEST_VALUE_2);
- }
-
- public void testAddRemoveNativeSql() throws Exception {
- this.verifyAddRemoveProperty(
- NATIVE_SQL_KEY,
- NATIVE_SQL_TEST_VALUE,
- NATIVE_SQL_TEST_VALUE_2);
- }
-
- // ********** BatchWriting tests **********
- public void testSetBatchWriting() throws Exception {
- this.verifyModelInitialized(
- BATCH_WRITING_KEY,
- BATCH_WRITING_TEST_VALUE);
- this.verifySetProperty(
- BATCH_WRITING_KEY,
- BATCH_WRITING_TEST_VALUE,
- BATCH_WRITING_TEST_VALUE_2);
- }
-
- public void testAddRemoveBatchWriting() throws Exception {
- this.verifyAddRemoveProperty(
- BATCH_WRITING_KEY,
- BATCH_WRITING_TEST_VALUE,
- BATCH_WRITING_TEST_VALUE_2);
- }
-
- // ********** CacheStatements tests **********
- public void testSetCacheStatements() throws Exception {
- this.verifyModelInitialized(
- CACHE_STATEMENTS_KEY,
- CACHE_STATEMENTS_TEST_VALUE);
- this.verifySetProperty(
- CACHE_STATEMENTS_KEY,
- CACHE_STATEMENTS_TEST_VALUE,
- CACHE_STATEMENTS_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheStatements() throws Exception {
- this.verifyAddRemoveProperty(
- CACHE_STATEMENTS_KEY,
- CACHE_STATEMENTS_TEST_VALUE,
- CACHE_STATEMENTS_TEST_VALUE_2);
- }
-
- // ********** CacheStatementsSize tests **********
- public void testSetCacheStatementsSize() throws Exception {
- this.verifyModelInitialized(
- CACHE_STATEMENTS_SIZE_KEY,
- CACHE_STATEMENTS_SIZE_TEST_VALUE);
- this.verifySetProperty(
- CACHE_STATEMENTS_SIZE_KEY,
- CACHE_STATEMENTS_SIZE_TEST_VALUE,
- CACHE_STATEMENTS_SIZE_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheStatementsSize() throws Exception {
- this.verifyAddRemoveProperty(
- CACHE_STATEMENTS_SIZE_KEY,
- CACHE_STATEMENTS_SIZE_TEST_VALUE,
- CACHE_STATEMENTS_SIZE_TEST_VALUE_2);
- }
-
- // ********** Driver tests **********
- public void testSetDriver() throws Exception {
- this.verifyModelInitialized(
- DRIVER_KEY,
- DRIVER_TEST_VALUE);
- this.verifySetProperty(
- DRIVER_KEY,
- DRIVER_TEST_VALUE,
- DRIVER_TEST_VALUE_2);
- }
-
- public void testAddRemoveDriver() throws Exception {
- this.verifyAddRemoveProperty(
- DRIVER_KEY,
- DRIVER_TEST_VALUE,
- DRIVER_TEST_VALUE_2);
- }
-
- // ********** Url tests **********
- public void testSetUrl() throws Exception {
- this.verifyModelInitialized(
- URL_KEY,
- URL_TEST_VALUE);
- this.verifySetProperty(
- URL_KEY,
- URL_TEST_VALUE,
- URL_TEST_VALUE_2);
- }
-
- public void testAddRemoveUrl() throws Exception {
- this.verifyAddRemoveProperty(
- URL_KEY,
- URL_TEST_VALUE,
- URL_TEST_VALUE_2);
- }
-
- // ********** User tests **********
- public void testSetUser() throws Exception {
- this.verifyModelInitialized(
- USER_KEY,
- USER_TEST_VALUE);
- this.verifySetProperty(
- USER_KEY,
- USER_TEST_VALUE,
- USER_TEST_VALUE_2);
- }
-
- public void testAddRemoveUser() throws Exception {
- this.verifyAddRemoveProperty(
- USER_KEY,
- USER_TEST_VALUE,
- USER_TEST_VALUE_2);
- }
-
- // ********** Password tests **********
- public void testSetPassword() throws Exception {
- this.verifyModelInitialized(
- PASSWORD_KEY,
- PASSWORD_TEST_VALUE);
- this.verifySetProperty(
- PASSWORD_KEY,
- PASSWORD_TEST_VALUE,
- PASSWORD_TEST_VALUE_2);
- }
-
- public void testAddRemovePassword() throws Exception {
- this.verifyAddRemoveProperty(
- PASSWORD_KEY,
- PASSWORD_TEST_VALUE,
- PASSWORD_TEST_VALUE_2);
- }
-
- // ********** BindParameters tests **********
- public void testSetBindParameters() throws Exception {
- this.verifyModelInitialized(
- BIND_PARAMETERS_KEY,
- BIND_PARAMETERS_TEST_VALUE);
- this.verifySetProperty(
- BIND_PARAMETERS_KEY,
- BIND_PARAMETERS_TEST_VALUE,
- BIND_PARAMETERS_TEST_VALUE_2);
- }
-
- public void testAddRemoveBindParameters() throws Exception {
- this.verifyAddRemoveProperty(
- BIND_PARAMETERS_KEY,
- BIND_PARAMETERS_TEST_VALUE,
- BIND_PARAMETERS_TEST_VALUE_2);
- }
-
- // ********** ReadConnectionsShared tests **********
- public void testSetReadConnectionsShared() throws Exception {
- this.verifyModelInitialized(
- READ_CONNECTIONS_SHARED_KEY,
- READ_CONNECTIONS_SHARED_TEST_VALUE);
- this.verifySetProperty(
- READ_CONNECTIONS_SHARED_KEY,
- READ_CONNECTIONS_SHARED_TEST_VALUE,
- READ_CONNECTIONS_SHARED_TEST_VALUE_2);
- }
-
- public void testAddRemoveReadConnectionsShared() throws Exception {
- this.verifyAddRemoveProperty(
- READ_CONNECTIONS_SHARED_KEY,
- READ_CONNECTIONS_SHARED_TEST_VALUE,
- READ_CONNECTIONS_SHARED_TEST_VALUE_2);
- }
-
- // ********** ReadConnectionsMin tests **********
- public void testSetReadConnectionsMin() throws Exception {
- this.verifyModelInitialized(
- READ_CONNECTIONS_MIN_KEY,
- READ_CONNECTIONS_MIN_TEST_VALUE);
- this.verifySetProperty(
- READ_CONNECTIONS_MIN_KEY,
- READ_CONNECTIONS_MIN_TEST_VALUE,
- READ_CONNECTIONS_MIN_TEST_VALUE_2);
- }
-
- public void testAddRemoveReadConnectionsMin() throws Exception {
- this.verifyAddRemoveProperty(
- READ_CONNECTIONS_MIN_KEY,
- READ_CONNECTIONS_MIN_TEST_VALUE,
- READ_CONNECTIONS_MIN_TEST_VALUE_2);
- }
-
- // ********** ReadConnectionsMax tests **********
- public void testSetReadConnectionsMax() throws Exception {
- this.verifyModelInitialized(
- READ_CONNECTIONS_MAX_KEY,
- READ_CONNECTIONS_MAX_TEST_VALUE);
- this.verifySetProperty(
- READ_CONNECTIONS_MAX_KEY,
- READ_CONNECTIONS_MAX_TEST_VALUE,
- READ_CONNECTIONS_MAX_TEST_VALUE_2);
- }
-
- public void testAddRemoveReadConnectionsMax() throws Exception {
- this.verifyAddRemoveProperty(
- READ_CONNECTIONS_MAX_KEY,
- READ_CONNECTIONS_MAX_TEST_VALUE,
- READ_CONNECTIONS_MAX_TEST_VALUE_2);
- }
-
- // ********** WriteConnectionsMin tests **********
- public void testSetWriteConnectionsMin() throws Exception {
- this.verifyModelInitialized(
- WRITE_CONNECTIONS_MIN_KEY,
- WRITE_CONNECTIONS_MIN_TEST_VALUE);
- this.verifySetProperty(
- WRITE_CONNECTIONS_MIN_KEY,
- WRITE_CONNECTIONS_MIN_TEST_VALUE,
- WRITE_CONNECTIONS_MIN_TEST_VALUE_2);
- }
-
- public void testAddRemoveWriteConnectionsMin() throws Exception {
- this.verifyAddRemoveProperty(
- WRITE_CONNECTIONS_MIN_KEY,
- WRITE_CONNECTIONS_MIN_TEST_VALUE,
- WRITE_CONNECTIONS_MIN_TEST_VALUE_2);
- }
-
- // ********** WriteConnectionsMax tests **********
- public void testSetWriteConnectionsMax() throws Exception {
- this.verifyModelInitialized(
- WRITE_CONNECTIONS_MAX_KEY,
- WRITE_CONNECTIONS_MAX_TEST_VALUE);
- this.verifySetProperty(
- WRITE_CONNECTIONS_MAX_KEY,
- WRITE_CONNECTIONS_MAX_TEST_VALUE,
- WRITE_CONNECTIONS_MAX_TEST_VALUE_2);
- }
-
- public void testAddRemoveWriteConnectionsMax() throws Exception {
- this.verifyAddRemoveProperty(
- WRITE_CONNECTIONS_MAX_KEY,
- WRITE_CONNECTIONS_MAX_TEST_VALUE,
- WRITE_CONNECTIONS_MAX_TEST_VALUE_2);
- }
-
- // ********** get/set property **********
- @Override
- protected synchronized void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(Connection.TRANSACTION_TYPE_PROPERTY))
- this.connection.setTransactionType((PersistenceUnitTransactionType) newValue);
- else if (propertyName.equals(Connection.JTA_DATA_SOURCE_PROPERTY))
- this.connection.setJtaDataSource((String) newValue);
- else if (propertyName.equals(Connection.NON_JTA_DATA_SOURCE_PROPERTY))
- this.connection.setNonJtaDataSource((String) newValue);
- else if (propertyName.equals(Connection.NATIVE_SQL_PROPERTY))
- this.connection.setNativeSql((Boolean) newValue);
- else if (propertyName.equals(Connection.BATCH_WRITING_PROPERTY))
- this.connection.setBatchWriting((BatchWriting) newValue);
- else if (propertyName.equals(Connection.CACHE_STATEMENTS_PROPERTY))
- this.connection.setCacheStatements((Boolean) newValue);
- else if (propertyName.equals(Connection.CACHE_STATEMENTS_SIZE_PROPERTY))
- this.connection.setCacheStatementsSize((Integer) newValue);
- else if (propertyName.equals(Connection.DRIVER_PROPERTY))
- this.connection.setDriver((String) newValue);
- else if (propertyName.equals(Connection.URL_PROPERTY))
- this.connection.setUrl((String) newValue);
- else if (propertyName.equals(Connection.USER_PROPERTY))
- this.connection.setUser((String) newValue);
- else if (propertyName.equals(Connection.PASSWORD_PROPERTY))
- this.connection.setPassword((String) newValue);
- else if (propertyName.equals(Connection.BIND_PARAMETERS_PROPERTY))
- this.connection.setBindParameters((Boolean) newValue);
- else if (propertyName.equals(Connection.READ_CONNECTIONS_SHARED_PROPERTY))
- this.connection.setReadConnectionsShared((Boolean) newValue);
- else if (propertyName.equals(Connection.READ_CONNECTIONS_MIN_PROPERTY))
- this.connection.setReadConnectionsMin((Integer) newValue);
- else if (propertyName.equals(Connection.READ_CONNECTIONS_MAX_PROPERTY))
- this.connection.setReadConnectionsMax((Integer) newValue);
- else if (propertyName.equals(Connection.WRITE_CONNECTIONS_MIN_PROPERTY))
- this.connection.setWriteConnectionsMin((Integer) newValue);
- else if (propertyName.equals(Connection.WRITE_CONNECTIONS_MAX_PROPERTY))
- this.connection.setWriteConnectionsMax((Integer) newValue);
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(Connection.TRANSACTION_TYPE_PROPERTY))
- modelValue = this.connection.getTransactionType();
- else if (propertyName.equals(Connection.JTA_DATA_SOURCE_PROPERTY))
- modelValue = this.connection.getJtaDataSource();
- else if (propertyName.equals(Connection.NON_JTA_DATA_SOURCE_PROPERTY))
- modelValue = this.connection.getNonJtaDataSource();
- else if (propertyName.equals(Connection.NATIVE_SQL_PROPERTY))
- modelValue = this.connection.getNativeSql();
- else if (propertyName.equals(Connection.BATCH_WRITING_PROPERTY))
- modelValue = this.connection.getBatchWriting();
- else if (propertyName.equals(Connection.CACHE_STATEMENTS_PROPERTY))
- modelValue = this.connection.getCacheStatements();
- else if (propertyName.equals(Connection.CACHE_STATEMENTS_SIZE_PROPERTY))
- modelValue = this.connection.getCacheStatementsSize();
- else if (propertyName.equals(Connection.DRIVER_PROPERTY))
- modelValue = this.connection.getDriver();
- else if (propertyName.equals(Connection.URL_PROPERTY))
- modelValue = this.connection.getUrl();
- else if (propertyName.equals(Connection.USER_PROPERTY))
- modelValue = this.connection.getUser();
- else if (propertyName.equals(Connection.PASSWORD_PROPERTY))
- modelValue = this.connection.getPassword();
- else if (propertyName.equals(Connection.BIND_PARAMETERS_PROPERTY))
- modelValue = this.connection.getBindParameters();
- else if (propertyName.equals(Connection.READ_CONNECTIONS_SHARED_PROPERTY))
- modelValue = this.connection.getReadConnectionsShared();
- else if (propertyName.equals(Connection.READ_CONNECTIONS_MIN_PROPERTY))
- modelValue = this.connection.getReadConnectionsMin();
- else if (propertyName.equals(Connection.READ_CONNECTIONS_MAX_PROPERTY))
- modelValue = this.connection.getReadConnectionsMax();
- else if (propertyName.equals(Connection.WRITE_CONNECTIONS_MIN_PROPERTY))
- modelValue = this.connection.getWriteConnectionsMin();
- else if (propertyName.equals(Connection.WRITE_CONNECTIONS_MAX_PROPERTY))
- modelValue = this.connection.getWriteConnectionsMax();
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- @Override
- protected Object getPersistenceUnitProperty(String propertyName) throws NoSuchFieldException {
- if (propertyName.equals(Connection.TRANSACTION_TYPE_PROPERTY)) {
- return this.persistenceUnit().getSpecifiedTransactionType();
- }
- else if (propertyName.equals(Connection.JTA_DATA_SOURCE_PROPERTY)) {
- return this.persistenceUnit().getJtaDataSource();
- }
- else if (propertyName.equals(Connection.NON_JTA_DATA_SOURCE_PROPERTY)) {
- return this.persistenceUnit().getNonJtaDataSource();
- }
- this.throwMissingDefinition("getPersistenceUnitProperty", propertyName);
- return null;
- }
-
- @Override
- protected void setPersistenceUnitProperty(String propertyName, Object newValue) throws NoSuchFieldException {
- if (propertyName.equals(Connection.TRANSACTION_TYPE_PROPERTY))
- this.persistenceUnit().setSpecifiedTransactionType((PersistenceUnitTransactionType) newValue);
- else if (propertyName.equals(Connection.JTA_DATA_SOURCE_PROPERTY))
- this.persistenceUnit().setJtaDataSource((String) newValue);
- else if (propertyName.equals(Connection.NON_JTA_DATA_SOURCE_PROPERTY))
- this.persistenceUnit().setNonJtaDataSource((String) newValue);
- else
- this.throwMissingDefinition("setPersistenceUnitProperty", propertyName);
- }
-
- protected PersistenceUnitProperties model() {
- return this.connection;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/connection/JptEclipseLinkCoreConnectionTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/connection/JptEclipseLinkCoreConnectionTests.java
deleted file mode 100644
index 54d89a156d..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/connection/JptEclipseLinkCoreConnectionTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.connection;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkCoreConnectionTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkCoreConnectionTests.class.getPackage().getName());
-
-// suite.addTestSuite(ConnectionValueModelTests.class);
- suite.addTestSuite(ConnectionAdapterTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkCoreConnectionTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/customization/CustomizationAdapterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/customization/CustomizationAdapterTests.java
deleted file mode 100644
index 5edcf0a68d..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/customization/CustomizationAdapterTests.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.customization;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.Property;
-import org.eclipse.jpt.core.internal.context.persistence.GenericProperty;
-import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkJpaProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitPropertyListListener;
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.CustomizerProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.EclipseLinkCustomization;
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Weaving;
-import org.eclipse.jpt.eclipselink.core.tests.internal.PersistenceUnitTestCase;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Tests the update of model objects by the Customization adapter when the
- * PersistenceUnit changes.
- */
-public class CustomizationAdapterTests extends PersistenceUnitTestCase
-{
- private Customization customization;
- private ListChangeEvent entitiesEvent;
-
- public static final String ENTITY_TEST = "Employee";
- public static final String ENTITY_TEST_2 = "Address";
-
- public static final String THROW_EXCEPTIONS_KEY = Customization.ECLIPSELINK_THROW_EXCEPTIONS;
- public static final Boolean THROW_EXCEPTIONS_TEST_VALUE = false;
- public static final Boolean THROW_EXCEPTIONS_TEST_VALUE_2 = ! THROW_EXCEPTIONS_TEST_VALUE;
-
- public static final String WEAVING_LAZY_KEY = Customization.ECLIPSELINK_WEAVING_LAZY;
- public static final Boolean WEAVING_LAZY_TEST_VALUE = false;
- public static final Boolean WEAVING_LAZY_TEST_VALUE_2 = ! WEAVING_LAZY_TEST_VALUE;
-
- public static final String WEAVING_CHANGE_TRACKING_KEY = Customization.ECLIPSELINK_WEAVING_CHANGE_TRACKING;
- public static final Boolean WEAVING_CHANGE_TRACKING_TEST_VALUE = false;
- public static final Boolean WEAVING_CHANGE_TRACKING_TEST_VALUE_2 = ! WEAVING_CHANGE_TRACKING_TEST_VALUE;
-
- public static final String WEAVING_FETCH_GROUPS_KEY = Customization.ECLIPSELINK_WEAVING_FETCH_GROUPS;
- public static final Boolean WEAVING_FETCH_GROUPS_TEST_VALUE = false;
- public static final Boolean WEAVING_FETCH_GROUPS_TEST_VALUE_2 = ! WEAVING_FETCH_GROUPS_TEST_VALUE;
-
- private static final String SESSION_CUSTOMIZER_KEY = Customization.ECLIPSELINK_SESSION_CUSTOMIZER;
- private static final String SESSION_CUSTOMIZER_TEST_VALUE = "session.customizer.test";
- private static final String SESSION_CUSTOMIZER_TEST_VALUE_2 = "session.customizer-2.test";
-
- public static final String WEAVING_KEY = Customization.ECLIPSELINK_WEAVING;
- public static final Weaving WEAVING_TEST_VALUE = Weaving.false_;
- public static final Weaving WEAVING_TEST_VALUE_2 = Weaving.static_;
-
- public static final String CUSTOMIZER_KEY = Customization.ECLIPSELINK_DESCRIPTOR_CUSTOMIZER + ENTITY_TEST;
- public static final String CUSTOMIZER_TEST_VALUE = "acme.sessions.DescriptorCustomizer";
- public static final String CUSTOMIZER_TEST_VALUE_2 = "acme.sessions.Customizer";
-
- public CustomizationAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.customization = this.persistenceUnitProperties.getCustomization();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.customization.addPropertyChangeListener(Customization.THROW_EXCEPTIONS_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.WEAVING_LAZY_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.WEAVING_CHANGE_TRACKING_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.WEAVING_FETCH_GROUPS_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.SESSION_CUSTOMIZER_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.WEAVING_PROPERTY, propertyChangeListener);
-
- this.customization.addPropertyChangeListener(Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY, propertyChangeListener);
-
- ListChangeListener entitiesChangeListener = this.buildEntitiesChangeListener();
- this.customization.addListChangeListener(Customization.ENTITIES_LIST_PROPERTY, entitiesChangeListener);
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 7;
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 4; // 4 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitPut("misc.property.1", "value.1");
- this.persistenceUnitPut(THROW_EXCEPTIONS_KEY, THROW_EXCEPTIONS_TEST_VALUE.toString());
- this.persistenceUnitPut(WEAVING_LAZY_KEY, WEAVING_LAZY_TEST_VALUE.toString());
- this.persistenceUnitPut(WEAVING_CHANGE_TRACKING_KEY, WEAVING_CHANGE_TRACKING_TEST_VALUE.toString());
- this.persistenceUnitPut(WEAVING_FETCH_GROUPS_KEY, WEAVING_FETCH_GROUPS_TEST_VALUE.toString());
- this.persistenceUnitPut("misc.property.2", "value.2");
- this.persistenceUnitPut(SESSION_CUSTOMIZER_KEY, SESSION_CUSTOMIZER_TEST_VALUE.toString());
- this.persistenceUnitPut(WEAVING_KEY, WEAVING_TEST_VALUE);
- this.persistenceUnitPut("misc.property.3", "value.3");
- this.persistenceUnitPut("misc.property.4", "value.4");
- this.persistenceUnitPut(CUSTOMIZER_KEY, CUSTOMIZER_TEST_VALUE);
- return;
- }
-
- // ********** Listeners **********
- private ListChangeListener buildEntitiesChangeListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent e) {
- CustomizationAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void itemsRemoved(ListChangeEvent e) {
- CustomizationAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void itemsReplaced(ListChangeEvent e) {
- CustomizationAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void itemsMoved(ListChangeEvent e) {
- CustomizationAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void listCleared(ListChangeEvent e) {
- CustomizationAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void listChanged(ListChangeEvent e) {
- CustomizationAdapterTests.this.entityChanged(e);
- }
- };
- }
-
- @Override
- protected void clearEvent() {
- super.clearEvent();
- this.entitiesEvent = null;
- }
-
- void entityChanged(ListChangeEvent e) {
- this.entitiesEvent = e;
- }
-
- // ********** entities list **********
- public void testEntitiesList() throws Exception {
- // add
- this.clearEvent();
- this.customization.addEntity(ENTITY_TEST_2);
-
- // verify event received
- assertNotNull("No Event Fired.", this.entitiesEvent);
- // verify event for the expected property
- assertEquals("Wrong Event.", this.entitiesEvent.getAspectName(), Customization.ENTITIES_LIST_PROPERTY);
-
- // try to add it again
- this.clearEvent();
- this.customization.addEntity(ENTITY_TEST_2);
- // verify event received
- assertNull("Event was Fired.", this.entitiesEvent);
-
- // remove
- this.clearEvent();
- this.customization.removeEntity(ENTITY_TEST_2);
- // verify event received
- assertNotNull("No Event Fired.", this.entitiesEvent);
- // verify event for the expected property
- assertEquals("Wrong Event.", this.entitiesEvent.getAspectName(), Customization.ENTITIES_LIST_PROPERTY);
- }
-
- // ********** Listeners tests **********
- public void testHasListeners() throws Exception {
- // new
- ListAspectAdapter<PersistenceUnit, Property> propertiesAdapter =
- (ListAspectAdapter<PersistenceUnit, Property>) ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertiesAdapter();
- GenericProperty ctdProperty = (GenericProperty) this.persistenceUnit().getProperty(THROW_EXCEPTIONS_KEY);
- ListValueModel<Property> propertyListAdapter = ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertyListAdapter();
-
- assertTrue(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(ctdProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- this.verifyHasListeners(this.customization, Customization.THROW_EXCEPTIONS_PROPERTY);
- this.verifyHasListeners(this.customization, Customization.WEAVING_LAZY_PROPERTY);
- this.verifyHasListeners(this.customization, Customization.WEAVING_CHANGE_TRACKING_PROPERTY);
- this.verifyHasListeners(this.customization, Customization.WEAVING_FETCH_GROUPS_PROPERTY);
- this.verifyHasListeners(propertyListAdapter);
-
- EclipseLinkCustomization elCustomization = (EclipseLinkCustomization) this.customization;
- PersistenceUnitPropertyListListener propertyListListener = elCustomization.propertyListListener();
- propertyListAdapter.removeListChangeListener(ListValueModel.LIST_VALUES, propertyListListener);
- assertTrue(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES)); // other properties are still listening
- this.verifyHasListeners(this.customization, Customization.THROW_EXCEPTIONS_PROPERTY);
- this.verifyHasListeners(this.customization, Customization.WEAVING_LAZY_PROPERTY);
- this.verifyHasListeners(this.customization, Customization.WEAVING_CHANGE_TRACKING_PROPERTY);
- this.verifyHasListeners(this.customization, Customization.WEAVING_FETCH_GROUPS_PROPERTY);
- }
-
-
-
- // ********** ThrowExceptions tests **********
- public void testSetThrowExceptions() throws Exception {
- this.verifyModelInitialized(
- THROW_EXCEPTIONS_KEY,
- THROW_EXCEPTIONS_TEST_VALUE);
- this.verifySetProperty(
- THROW_EXCEPTIONS_KEY,
- THROW_EXCEPTIONS_TEST_VALUE,
- THROW_EXCEPTIONS_TEST_VALUE_2);
- }
-
- public void testAddRemoveThrowExceptions() throws Exception {
- this.verifyAddRemoveProperty(
- THROW_EXCEPTIONS_KEY,
- THROW_EXCEPTIONS_TEST_VALUE,
- THROW_EXCEPTIONS_TEST_VALUE_2);
- }
-
- // ********** WeavingLazy tests **********
- public void testSetWeavingLazy() throws Exception {
- this.verifyModelInitialized(
- WEAVING_LAZY_KEY,
- WEAVING_LAZY_TEST_VALUE);
- this.verifySetProperty(
- WEAVING_LAZY_KEY,
- WEAVING_LAZY_TEST_VALUE,
- WEAVING_LAZY_TEST_VALUE_2);
- }
-
- public void testAddRemoveWeavingLazy() throws Exception {
- this.verifyAddRemoveProperty(
- WEAVING_LAZY_KEY,
- WEAVING_LAZY_TEST_VALUE,
- WEAVING_LAZY_TEST_VALUE_2);
- }
-
- // ********** WeavingChangeTracking tests **********
- public void testSetWeavingChangeTracking() throws Exception {
- this.verifyModelInitialized(
- WEAVING_CHANGE_TRACKING_KEY,
- WEAVING_CHANGE_TRACKING_TEST_VALUE);
- this.verifySetProperty(
- WEAVING_CHANGE_TRACKING_KEY,
- WEAVING_CHANGE_TRACKING_TEST_VALUE,
- WEAVING_CHANGE_TRACKING_TEST_VALUE_2);
- }
-
- public void testAddRemoveWeavingChangeTracking() throws Exception {
- this.verifyAddRemoveProperty(
- WEAVING_CHANGE_TRACKING_KEY,
- WEAVING_CHANGE_TRACKING_TEST_VALUE,
- WEAVING_CHANGE_TRACKING_TEST_VALUE_2);
- }
-
- // ********** WeavingFetchGroups tests **********
- public void testSetWeavingFetchGroups() throws Exception {
- this.verifyModelInitialized(
- WEAVING_FETCH_GROUPS_KEY,
- WEAVING_FETCH_GROUPS_TEST_VALUE);
- this.verifySetProperty(
- WEAVING_FETCH_GROUPS_KEY,
- WEAVING_FETCH_GROUPS_TEST_VALUE,
- WEAVING_FETCH_GROUPS_TEST_VALUE_2);
- }
-
- public void testAddRemoveWeavingFetchGroups() throws Exception {
- this.verifyAddRemoveProperty(
- WEAVING_FETCH_GROUPS_KEY,
- WEAVING_FETCH_GROUPS_TEST_VALUE,
- WEAVING_FETCH_GROUPS_TEST_VALUE_2);
- }
-
- // ********** SessionCustomizer tests **********
- public void testSetSessionCustomizer() throws Exception {
- this.verifyModelInitialized(
- SESSION_CUSTOMIZER_KEY,
- SESSION_CUSTOMIZER_TEST_VALUE);
- this.verifySetProperty(
- SESSION_CUSTOMIZER_KEY,
- SESSION_CUSTOMIZER_TEST_VALUE,
- SESSION_CUSTOMIZER_TEST_VALUE_2);
- }
-
- public void testAddRemoveSessionCustomizer() throws Exception {
- this.verifyAddRemoveProperty(
- SESSION_CUSTOMIZER_KEY,
- SESSION_CUSTOMIZER_TEST_VALUE,
- SESSION_CUSTOMIZER_TEST_VALUE_2);
- }
-
- // ********** Weaving tests **********
- /**
- * Tests the update of Weaving property by the Customization adapter when
- * the PU or the model changes.
- */
- public void testSetWeaving() throws Exception {
- this.verifyModelInitialized(
- WEAVING_KEY,
- WEAVING_TEST_VALUE);
- this.verifySetProperty(
- WEAVING_KEY,
- WEAVING_TEST_VALUE,
- WEAVING_TEST_VALUE_2);
- }
-
- public void testAddRemoveWeaving() throws Exception {
- this.verifyAddRemoveProperty(
- WEAVING_KEY,
- WEAVING_TEST_VALUE,
- WEAVING_TEST_VALUE_2);
- }
-
- // ********** Customization class **********
- /**
- * Tests the update of Customization property by the Customization adapter when the
- * PU or the model changes.
- */
- public void testSetCustomization() throws Exception {
- this.verifyModelInitialized(
- CUSTOMIZER_KEY,
- CUSTOMIZER_TEST_VALUE);
- this.verifySetCustomizationProperty(
- Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY,
- CUSTOMIZER_KEY,
- CUSTOMIZER_TEST_VALUE,
- CUSTOMIZER_TEST_VALUE_2);
- }
-
- public void testAddRemoveCustomization() throws Exception {
- this.verifyAddRemoveCustomizationProperty(
- Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY,
- CUSTOMIZER_KEY,
- CUSTOMIZER_TEST_VALUE,
- CUSTOMIZER_TEST_VALUE_2);
- }
-
-
- // ****** convenience methods *******
-
- // ********** verify entity property **********
- protected void verifySetCustomizationProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- ListValueModel<Property> propertyListAdapter = ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertyListAdapter();
- // Basic
- this.verifyInitialState(propertyName, key, propertyListAdapter);
-
- // Replace
- this.persistenceUnitPut(key, testValue2);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
- this.verifyPutCustomizationProperty(propertyName, ENTITY_TEST, testValue2);
-
- // Replace by setting model object
- this.clearEvent();
- this.setCustomizationProperty(propertyName, ENTITY_TEST, testValue1);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
- this.verifyPutCustomizationProperty(propertyName, ENTITY_TEST, testValue1);
- }
-
- protected void verifyAddRemoveCustomizationProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- ListValueModel<Property> propertyListAdapter = ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertyListAdapter();
- // Remove
- this.clearEvent();
- --this.propertiesTotal;
- --this.modelPropertiesSize;
- this.persistenceUnit().removeProperty(key);
- assertFalse(this.persistenceUnit().containsProperty(key));
- assertEquals(this.modelPropertiesSize, this.modelPropertiesSizeOriginal - 1);
- this.verifyPutCustomizationProperty(propertyName, ENTITY_TEST, null);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
-
- // Add original Property
- ++this.propertiesTotal;
- ++this.modelPropertiesSize;
- this.persistenceUnitPut(key, testValue1);
- this.verifyPutCustomizationProperty(propertyName, ENTITY_TEST, testValue1);
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
-
- // Replace
- this.persistenceUnitPut(key, testValue2);
- this.verifyPutCustomizationProperty(propertyName, ENTITY_TEST, testValue2);
- }
-
- protected void verifyPutCustomizationProperty(String propertyName, String entityName, Object expectedValue) throws Exception {
- this.verifyEvent(propertyName);
- this.verifyCustomizationEvent(propertyName, entityName, expectedValue);
- }
-
- protected void verifyCustomizationEvent(String propertyName, String entityName, Object expectedValue) throws Exception {
- // verify event value
- CustomizerProperties customizer = (CustomizerProperties) this.propertyChangedEvent.getNewValue();
- if (propertyName.equals(Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY)) {
- assertEquals(expectedValue, customizer.getClassName());
- assertEquals(expectedValue, this.customization.getDescriptorCustomizer(entityName));
- }
- else {
- this.throwMissingDefinition("verifyCustomizationEvent", propertyName);
- }
- }
-
- protected void setCustomizationProperty(String propertyName, String entityName, Object newValue) throws NoSuchFieldException {
- if (propertyName.equals(Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY))
- this.customization.setDescriptorCustomizer((String) newValue, entityName);
- else
- this.throwMissingDefinition("setCustomizationProperty", propertyName);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(Customization.THROW_EXCEPTIONS_PROPERTY))
- this.customization.setThrowExceptions((Boolean) newValue);
- else if (propertyName.equals(Customization.WEAVING_LAZY_PROPERTY))
- this.customization.setWeavingLazy((Boolean) newValue);
- else if (propertyName.equals(Customization.WEAVING_CHANGE_TRACKING_PROPERTY))
- this.customization.setWeavingChangeTracking((Boolean) newValue);
- else if (propertyName.equals(Customization.WEAVING_FETCH_GROUPS_PROPERTY))
- this.customization.setWeavingFetchGroups((Boolean) newValue);
- else if (propertyName.equals(Customization.SESSION_CUSTOMIZER_PROPERTY))
- this.customization.setSessionCustomizer((String) newValue);
- else if (propertyName.equals(Customization.WEAVING_PROPERTY))
- this.customization.setWeaving((Weaving) newValue);
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(Customization.THROW_EXCEPTIONS_PROPERTY))
- modelValue = this.customization.getThrowExceptions();
- else if (propertyName.equals(Customization.WEAVING_PROPERTY))
- modelValue = this.customization.getWeaving();
- else if (propertyName.equals(Customization.WEAVING_LAZY_PROPERTY))
- modelValue = this.customization.getWeavingLazy();
- else if (propertyName.equals(Customization.WEAVING_CHANGE_TRACKING_PROPERTY))
- modelValue = this.customization.getWeavingChangeTracking();
- else if (propertyName.equals(Customization.WEAVING_FETCH_GROUPS_PROPERTY))
- modelValue = this.customization.getWeavingFetchGroups();
- else if (propertyName.equals(Customization.SESSION_CUSTOMIZER_PROPERTY))
- modelValue = this.customization.getSessionCustomizer();
- else if (propertyName.equals(Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY))
- modelValue = this.customization.getDescriptorCustomizer(ENTITY_TEST);
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- protected PersistenceUnitProperties model() {
- return this.customization;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/customization/CustomizationValueModelTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/customization/CustomizationValueModelTests.java
deleted file mode 100644
index 8c6bb1f06f..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/customization/CustomizationValueModelTests.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.customization;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization;
-import org.eclipse.jpt.eclipselink.core.tests.internal.PersistenceUnitTestCase;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * CustomizationValueModelTests
- */
-public class CustomizationValueModelTests extends PersistenceUnitTestCase
-{
- private Customization customization;
-
- private WritablePropertyValueModel<Boolean> throwExceptionsHolder;
- private PropertyChangeListener throwExceptionsListener;
- private PropertyChangeEvent throwExceptionsEvent;
-
- public static final String ENTITY_NAME_TEST_VALUE = "Employee";
- public static final Boolean THROW_EXCEPTIONS_TEST_VALUE = Boolean.FALSE;
-
- public CustomizationValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.customization = this.persistenceUnitProperties.getCustomization(); // Subject
- PropertyValueModel<Customization> customizationHolder = new SimplePropertyValueModel<Customization>(this.customization);
-
- this.throwExceptionsHolder = this.buildThrowExceptionsAA(customizationHolder);
- this.throwExceptionsListener = this.buildThrowExceptionsChangeListener();
- this.throwExceptionsHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.throwExceptionsListener);
- this.throwExceptionsEvent = null;
- }
-
- public void testHasListeners() {
- AbstractModel subjectCustomization = (AbstractModel) this.customization; // Subject
-
- PropertyAspectAdapter<Customization, Boolean> throwExceptionsAA =
- (PropertyAspectAdapter<Customization, Boolean>) this.throwExceptionsHolder;
- assertTrue(throwExceptionsAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectCustomization.hasAnyPropertyChangeListeners(Customization.THROW_EXCEPTIONS_PROPERTY));
-
- throwExceptionsAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.throwExceptionsListener);
- assertFalse(subjectCustomization.hasAnyPropertyChangeListeners(Customization.THROW_EXCEPTIONS_PROPERTY));
- assertFalse(throwExceptionsAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- protected void populatePu() {
- this.persistenceUnitPut(
- Customization.ECLIPSELINK_THROW_EXCEPTIONS,
- THROW_EXCEPTIONS_TEST_VALUE);
- return;
- }
-
- protected PersistenceUnitProperties model() {
- return this.customization;
- }
-
- // ****** ThrowExceptions *******
- private WritablePropertyValueModel<Boolean> buildThrowExceptionsAA(PropertyValueModel<Customization> subjectHolder) {
- return new PropertyAspectAdapter<Customization, Boolean>(subjectHolder, Customization.THROW_EXCEPTIONS_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getThrowExceptions();
- }
-
- @Override
- protected void setValue_(Boolean enumValue) {
- this.subject.setThrowExceptions(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildThrowExceptionsChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CustomizationValueModelTests.this.throwExceptionsEvent = e;
- }
- };
- }
-
- // ****** Tests *******
- public void testValue() {
- // ****** ThrowExceptions *******
- this.verifyThrowExceptionsAAValue(THROW_EXCEPTIONS_TEST_VALUE);
- assertEquals(Customization.DEFAULT_THROW_EXCEPTIONS, this.customization.getDefaultThrowExceptions());
- }
-
- public void testSetValue() throws Exception {
- // ****** ThrowExceptions *******
- this.throwExceptionsEvent = null;
- this.verifyHasListeners(this.throwExceptionsHolder, PropertyValueModel.VALUE);
- Boolean newThrowExceptions = !THROW_EXCEPTIONS_TEST_VALUE;
- // Modify the property holder
- this.throwExceptionsHolder.setValue(newThrowExceptions);
- this.verifyThrowExceptionsAAValue(newThrowExceptions);
- assertNotNull(this.throwExceptionsEvent);
- }
-
- public void testSetNullValue() {
- String notDeleted = "Property not deleted";
- // ****** ThrowExceptions *******
- this.throwExceptionsEvent = null;
- // Setting the property holder
- this.throwExceptionsHolder.setValue(null);
- // testing Holder
- this.verifyThrowExceptionsAAValue(null);
- assertNotNull(this.throwExceptionsEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Customization.ECLIPSELINK_THROW_EXCEPTIONS, notDeleted);
- }
-
- // ****** convenience methods *******
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyThrowExceptionsAAValue(Boolean testValue) {
- this.verifyAAValue(
- testValue,
- this.customization.getThrowExceptions(),
- this.throwExceptionsHolder,
- Customization.ECLIPSELINK_THROW_EXCEPTIONS);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/customization/JptEclipseLinkCoreCustomizationTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/customization/JptEclipseLinkCoreCustomizationTests.java
deleted file mode 100644
index 6a3a67f24e..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/customization/JptEclipseLinkCoreCustomizationTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.customization;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkCoreCustomizationTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkCoreCustomizationTests.class.getPackage().getName());
-
- suite.addTestSuite(CustomizationValueModelTests.class);
- suite.addTestSuite(CustomizationAdapterTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkCoreCustomizationTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/logging/JptEclipseLinkCoreLoggingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/logging/JptEclipseLinkCoreLoggingTests.java
deleted file mode 100644
index e0983918ff..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/logging/JptEclipseLinkCoreLoggingTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.logging;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkCoreLoggingTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkCoreLoggingTests.class.getPackage().getName());
-
- suite.addTestSuite(LoggingValueModelTests.class);
- suite.addTestSuite(LoggingAdapterTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkCoreLoggingTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/logging/LoggingAdapterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/logging/LoggingAdapterTests.java
deleted file mode 100644
index fae34ea9ef..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/logging/LoggingAdapterTests.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.logging;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.Property;
-import org.eclipse.jpt.core.internal.context.persistence.GenericProperty;
-import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkJpaProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitPropertyListListener;
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.EclipseLinkLogging;
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logger;
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logging;
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.LoggingLevel;
-import org.eclipse.jpt.eclipselink.core.tests.internal.PersistenceUnitTestCase;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Tests the update of model objects by the Logging adapter when the
- * PersistenceUnit changes.
- */
-public class LoggingAdapterTests extends PersistenceUnitTestCase
-{
- private Logging logging;
-
- public static final String LEVEL_KEY = Logging.ECLIPSELINK_LEVEL;
- public static final LoggingLevel LEVEL_TEST_VALUE = LoggingLevel.fine;
- public static final LoggingLevel LEVEL_TEST_VALUE_2 = LoggingLevel.finest;
-
- public static final String TIMESTAMP_KEY = Logging.ECLIPSELINK_TIMESTAMP;
- public static final Boolean TIMESTAMP_TEST_VALUE = false;
- public static final Boolean TIMESTAMP_TEST_VALUE_2 = ! TIMESTAMP_TEST_VALUE;
-
- public static final String THREAD_KEY = Logging.ECLIPSELINK_THREAD;
- public static final Boolean THREAD_TEST_VALUE = false;
- public static final Boolean THREAD_TEST_VALUE_2 = ! THREAD_TEST_VALUE;
-
- public static final String SESSION_KEY = Logging.ECLIPSELINK_SESSION;
- public static final Boolean SESSION_TEST_VALUE = false;
- public static final Boolean SESSION_TEST_VALUE_2 = ! SESSION_TEST_VALUE;
-
- public static final String EXCEPTIONS_KEY = Logging.ECLIPSELINK_EXCEPTIONS;
- public static final Boolean EXCEPTIONS_TEST_VALUE = false;
- public static final Boolean EXCEPTIONS_TEST_VALUE_2 = ! EXCEPTIONS_TEST_VALUE;
-
- private static final String LOG_FILE_LOCATION_KEY = Logging.ECLIPSELINK_LOG_FILE_LOCATION;
- private static final String LOG_FILE_LOCATION_TEST_VALUE = "C:/temp";
- private static final String LOG_FILE_LOCATION_TEST_VALUE_2 = "C:/tmp";
-
- private static final String LOGGER_KEY = Logging.ECLIPSELINK_LOGGER;
- private static final Logger LOGGER_TEST_VALUE = Logger.java_logger;
- private static final String LOGGER_TEST_VALUE_2 = "custom.logger.test";
-
- public LoggingAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.logging = this.persistenceUnitProperties.getLogging();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.logging.addPropertyChangeListener(Logging.LEVEL_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging.TIMESTAMP_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging.THREAD_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging.SESSION_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging.EXCEPTIONS_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging.LOG_FILE_LOCATION_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging.LOGGER_PROPERTY, propertyChangeListener);
-
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 7;
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 4; // 4 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitPut("misc.property.1", "value.1");
- this.persistenceUnitPut(TIMESTAMP_KEY, TIMESTAMP_TEST_VALUE.toString());
- this.persistenceUnitPut("misc.property.2", "value.2");
- this.persistenceUnitPut(LEVEL_KEY, LEVEL_TEST_VALUE);
- this.persistenceUnitPut("misc.property.3", "value.3");
- this.persistenceUnitPut(THREAD_KEY, THREAD_TEST_VALUE.toString());
- this.persistenceUnitPut(SESSION_KEY, SESSION_TEST_VALUE.toString());
- this.persistenceUnitPut(EXCEPTIONS_KEY, EXCEPTIONS_TEST_VALUE.toString());
- this.persistenceUnitPut("misc.property.4", "value.4");
- this.persistenceUnitPut(LOG_FILE_LOCATION_KEY, LOG_FILE_LOCATION_TEST_VALUE);
- this.persistenceUnitPut(LOGGER_KEY, LOGGER_TEST_VALUE);
- return;
- }
-
- // ********** Listeners **********
-
- // ********** Listeners tests **********
- public void testHasListeners() throws Exception {
- // new
- ListAspectAdapter<PersistenceUnit, Property> propertiesAdapter =
- (ListAspectAdapter<PersistenceUnit, Property>) ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertiesAdapter();
- GenericProperty ctdProperty = (GenericProperty) this.persistenceUnit().getProperty(TIMESTAMP_KEY);
- ListValueModel<Property> propertyListAdapter = ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertyListAdapter();
-
- assertTrue(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(ctdProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- this.verifyHasListeners(this.logging, Logging.TIMESTAMP_PROPERTY);
-//TODO ADD OTHER PROPERTIES
- this.verifyHasListeners(propertyListAdapter);
-
- EclipseLinkLogging elLogging = (EclipseLinkLogging) this.logging;
- PersistenceUnitPropertyListListener propertyListListener = elLogging.propertyListListener();
- propertyListAdapter.removeListChangeListener(ListValueModel.LIST_VALUES, propertyListListener);
- assertTrue(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES)); // other properties are still listening
- this.verifyHasListeners(this.logging, Logging.TIMESTAMP_PROPERTY);
- }
-
-
- // ********** Level tests **********
- public void testSetLevel() throws Exception {
- this.verifyModelInitialized(
- LEVEL_KEY,
- LEVEL_TEST_VALUE);
- this.verifySetProperty(
- LEVEL_KEY,
- LEVEL_TEST_VALUE,
- LEVEL_TEST_VALUE_2);
- }
-
- public void testAddRemoveLevel() throws Exception {
- this.verifyAddRemoveProperty(
- LEVEL_KEY,
- LEVEL_TEST_VALUE,
- LEVEL_TEST_VALUE_2);
- }
-
- // ********** Timestamp tests **********
- public void testSetThrowExceptions() throws Exception {
- this.verifyModelInitialized(
- TIMESTAMP_KEY,
- TIMESTAMP_TEST_VALUE);
- this.verifySetProperty(
- TIMESTAMP_KEY,
- TIMESTAMP_TEST_VALUE,
- TIMESTAMP_TEST_VALUE_2);
- }
-
- public void testAddRemoveThrowExceptions() throws Exception {
- this.verifyAddRemoveProperty(
- TIMESTAMP_KEY,
- TIMESTAMP_TEST_VALUE,
- TIMESTAMP_TEST_VALUE_2);
- }
-
- // ********** Thread tests **********
- public void testSetThread() throws Exception {
- this.verifyModelInitialized(
- THREAD_KEY,
- THREAD_TEST_VALUE);
- this.verifySetProperty(
- THREAD_KEY,
- THREAD_TEST_VALUE,
- THREAD_TEST_VALUE_2);
- }
-
- public void testAddRemoveThread() throws Exception {
- this.verifyAddRemoveProperty(
- THREAD_KEY,
- THREAD_TEST_VALUE,
- THREAD_TEST_VALUE_2);
- }
-
- // ********** Session tests **********
- public void testSetSession() throws Exception {
- this.verifyModelInitialized(
- SESSION_KEY,
- SESSION_TEST_VALUE);
- this.verifySetProperty(
- SESSION_KEY,
- SESSION_TEST_VALUE,
- SESSION_TEST_VALUE_2);
- }
-
- public void testAddRemoveSession() throws Exception {
- this.verifyAddRemoveProperty(
- SESSION_KEY,
- SESSION_TEST_VALUE,
- SESSION_TEST_VALUE_2);
- }
-
- // ********** Exceptions tests **********
- public void testSetExceptions() throws Exception {
- this.verifyModelInitialized(
- EXCEPTIONS_KEY,
- EXCEPTIONS_TEST_VALUE);
- this.verifySetProperty(
- EXCEPTIONS_KEY,
- EXCEPTIONS_TEST_VALUE,
- EXCEPTIONS_TEST_VALUE_2);
- }
-
- public void testAddRemoveExceptions() throws Exception {
- this.verifyAddRemoveProperty(
- EXCEPTIONS_KEY,
- EXCEPTIONS_TEST_VALUE,
- EXCEPTIONS_TEST_VALUE_2);
- }
-
- // ********** LogFileLocation **********
- public void testSetLogFileLocation() throws Exception {
- this.verifyModelInitialized(
- LOG_FILE_LOCATION_KEY,
- LOG_FILE_LOCATION_TEST_VALUE);
- this.verifySetProperty(
- LOG_FILE_LOCATION_KEY,
- LOG_FILE_LOCATION_TEST_VALUE,
- LOG_FILE_LOCATION_TEST_VALUE_2);
- }
-
- public void testAddRemoveLogFileLocation() throws Exception {
- this.verifyAddRemoveProperty(
- LOG_FILE_LOCATION_KEY,
- LOG_FILE_LOCATION_TEST_VALUE,
- LOG_FILE_LOCATION_TEST_VALUE_2);
- }
-
- // ********** Logger tests **********
- public void testSetLogger() throws Exception {
- this.verifyModelInitialized(
- LOGGER_KEY,
- this.getEclipseLinkStringValueOf(LOGGER_TEST_VALUE)); // model is storing EclipseLinkStringValue
- // verify set enum value
- this.verifySetProperty(
- LOGGER_KEY,
- LOGGER_TEST_VALUE,
- LOGGER_TEST_VALUE_2);
- // verify set custom and literal value
- this.verifySetLogger(
- LOGGER_KEY,
- LOGGER_TEST_VALUE,
- LOGGER_TEST_VALUE_2);
- }
-
- public void testAddRemoveLogger() throws Exception {
- this.verifyAddRemoveProperty(
- LOGGER_KEY,
- LOGGER_TEST_VALUE,
- LOGGER_TEST_VALUE_2);
- }
-
- /**
- * Verifies setting custom logger and literals.
- */
- protected void verifySetLogger(String elKey, Object testValue1, Object testValue2) throws Exception {
- Property property = this.persistenceUnit().getProperty(elKey);
- String propertyName = this.model().propertyIdFor(property);
- // test set custom logger.
- this.clearEvent();
- this.setProperty(propertyName, testValue2);
- this.verifyPutProperty(propertyName, testValue2);
-
- // test set (Logger) null
- this.clearEvent();
- this.logging.setLogger((Logger) null);
- assertFalse(this.persistenceUnit().containsProperty(elKey));
- this.verifyPutProperty(propertyName, null);
-
- // test set enum literal
- this.clearEvent();
- this.setProperty(propertyName, testValue1.toString());
- assertTrue(this.persistenceUnit().containsProperty(elKey));
- this.verifyPutProperty(propertyName, this.getEclipseLinkStringValueOf(testValue1));
-
- // test set (String) null
- this.clearEvent();
- this.logging.setLogger((String) null);
- assertFalse(this.persistenceUnit().containsProperty(elKey));
- this.verifyPutProperty(propertyName, null);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(Logging.LEVEL_PROPERTY))
- this.logging.setLevel((LoggingLevel) newValue);
- else if (propertyName.equals(Logging.TIMESTAMP_PROPERTY))
- this.logging.setTimestamp((Boolean) newValue);
- else if (propertyName.equals(Logging.THREAD_PROPERTY))
- this.logging.setThread((Boolean) newValue);
- else if (propertyName.equals(Logging.SESSION_PROPERTY))
- this.logging.setSession((Boolean) newValue);
- else if (propertyName.equals(Logging.EXCEPTIONS_PROPERTY))
- this.logging.setExceptions((Boolean) newValue);
- else if (propertyName.equals(Logging.LOG_FILE_LOCATION_PROPERTY))
- this.logging.setLogFileLocation((String) newValue);
- else if (propertyName.equals(Logging.LOGGER_PROPERTY)) {
- if (newValue.getClass().isEnum())
- this.logging.setLogger((Logger) newValue);
- else
- this.logging.setLogger((String) newValue);
- }
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(Logging.LEVEL_PROPERTY))
- modelValue = this.logging.getLevel();
- else if (propertyName.equals(Logging.TIMESTAMP_PROPERTY))
- modelValue = this.logging.getTimestamp();
- else if (propertyName.equals(Logging.THREAD_PROPERTY))
- modelValue = this.logging.getThread();
- else if (propertyName.equals(Logging.SESSION_PROPERTY))
- modelValue = this.logging.getSession();
- else if (propertyName.equals(Logging.EXCEPTIONS_PROPERTY))
- modelValue = this.logging.getExceptions();
- else if (propertyName.equals(Logging.LOG_FILE_LOCATION_PROPERTY))
- modelValue = this.logging.getLogFileLocation();
- else if (propertyName.equals(Logging.LOGGER_PROPERTY))
- modelValue = this.logging.getLogger();
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- @Override
- protected void verifyPutProperty(String propertyName, Object expectedValue) throws Exception {
- Object expectedValue_ = expectedValue;
- if (propertyName.equals(Logging.LOGGER_PROPERTY)) {
-
- expectedValue_ = (expectedValue != null && expectedValue.getClass().isEnum()) ?
- this.getEclipseLinkStringValueOf(LOGGER_TEST_VALUE) : // model is storing EclipseLinkStringValue
- expectedValue;
- }
- super.verifyPutProperty(propertyName, expectedValue_);
- }
-
- protected PersistenceUnitProperties model() {
- return this.logging;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/logging/LoggingValueModelTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/logging/LoggingValueModelTests.java
deleted file mode 100644
index 77d9bda2f6..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/logging/LoggingValueModelTests.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.logging;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logging;
-import org.eclipse.jpt.eclipselink.core.tests.internal.PersistenceUnitTestCase;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * LoggingValueModelTests
- */
-public class LoggingValueModelTests extends PersistenceUnitTestCase
-{
- private Logging logging;
-
- private WritablePropertyValueModel<Boolean> timestampHolder;
- private PropertyChangeListener timestampListener;
- private PropertyChangeEvent timestampEvent;
-
- public static final Boolean TIMESTAMP_TEST_VALUE = Boolean.FALSE;
-
- public LoggingValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.logging = this.persistenceUnitProperties.getLogging(); // Subject
- PropertyValueModel<Logging> loggingHolder = new SimplePropertyValueModel<Logging>(this.logging);
-
- this.timestampHolder = this.buildTimestampAA(loggingHolder);
- this.timestampListener = this.buildTimestampChangeListener();
- this.timestampHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.timestampListener);
- this.timestampEvent = null;
- }
-
- public void testHasListeners() {
- AbstractModel subjectLogging = (AbstractModel) this.logging; // Subject
-
- PropertyAspectAdapter<Logging, Boolean> timestampAA =
- (PropertyAspectAdapter<Logging, Boolean>) this.timestampHolder;
- assertTrue(timestampAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectLogging.hasAnyPropertyChangeListeners(Logging.TIMESTAMP_PROPERTY));
-
- timestampAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.timestampListener);
- assertFalse(subjectLogging.hasAnyPropertyChangeListeners(Logging.TIMESTAMP_PROPERTY));
- assertFalse(timestampAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- protected void populatePu() {
- this.persistenceUnitPut(
- Logging.ECLIPSELINK_TIMESTAMP,
- TIMESTAMP_TEST_VALUE);
- return;
- }
-
- protected PersistenceUnitProperties model() {
- return this.logging;
- }
-
- // ****** Timestamp *******
- private WritablePropertyValueModel<Boolean> buildTimestampAA(PropertyValueModel<Logging> subjectHolder) {
- return new PropertyAspectAdapter<Logging, Boolean>(subjectHolder, Logging.TIMESTAMP_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getTimestamp();
- }
-
- @Override
- protected void setValue_(Boolean enumValue) {
- this.subject.setTimestamp(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildTimestampChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- LoggingValueModelTests.this.timestampEvent = e;
- }
- };
- }
-
- // ****** Tests *******
- public void testValue() {
- // ****** Timestamp *******
- this.verifyTimestampAAValue(TIMESTAMP_TEST_VALUE);
- assertEquals(Logging.DEFAULT_TIMESTAMP, this.logging.getDefaultTimestamp());
- }
-
- public void testSetValue() throws Exception {
- // ****** Timestamp *******
- this.timestampEvent = null;
- this.verifyHasListeners(this.timestampHolder, PropertyValueModel.VALUE);
- Boolean newTimestamp = !TIMESTAMP_TEST_VALUE;
- // Modify the property holder
- this.timestampHolder.setValue(newTimestamp);
- this.verifyTimestampAAValue(newTimestamp);
- assertNotNull(this.timestampEvent);
- }
-
- public void testSetNullValue() {
- String notDeleted = "Property not deleted";
- // ****** Timestamp *******
- this.timestampEvent = null;
- // Setting the property holder
- this.timestampHolder.setValue(null);
- // testing Holder
- this.verifyTimestampAAValue(null);
- assertNotNull(this.timestampEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Logging.ECLIPSELINK_TIMESTAMP, notDeleted);
- }
-
- // ****** convenience methods *******
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyTimestampAAValue(Boolean testValue) {
- this.verifyAAValue(
- testValue,
- this.logging.getTimestamp(),
- this.timestampHolder,
- Logging.ECLIPSELINK_TIMESTAMP);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/options/JptEclipseLinkCoreOptionsTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/options/JptEclipseLinkCoreOptionsTests.java
deleted file mode 100644
index bf2b40bf64..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/options/JptEclipseLinkCoreOptionsTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.options;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkCoreOptionsTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkCoreOptionsTests.class.getPackage().getName());
-
- suite.addTestSuite(OptionsValueModelTests.class);
- suite.addTestSuite(OptionsAdapterTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkCoreOptionsTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/options/OptionsAdapterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/options/OptionsAdapterTests.java
deleted file mode 100644
index 7cfc1113d5..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/options/OptionsAdapterTests.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.options;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.Property;
-import org.eclipse.jpt.core.internal.context.persistence.GenericProperty;
-import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkJpaProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitPropertyListListener;
-import org.eclipse.jpt.eclipselink.core.internal.context.options.EclipseLinkOptions;
-import org.eclipse.jpt.eclipselink.core.internal.context.options.Options;
-import org.eclipse.jpt.eclipselink.core.internal.context.options.TargetDatabase;
-import org.eclipse.jpt.eclipselink.core.tests.internal.PersistenceUnitTestCase;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Tests the update of model objects by the Logging adapter when the
- * PersistenceUnit changes.
- */
-public class OptionsAdapterTests extends PersistenceUnitTestCase
-{
- private Options options;
-
- private static final String SESSION_NAME_KEY = Options.ECLIPSELINK_SESSION_NAME;
- private static final String SESSION_NAME_TEST_VALUE = "session-name.test";
- private static final String SESSION_NAME_TEST_VALUE_2 = "session-name-2.test";
-
- private static final String SESSIONS_XML_KEY = Options.ECLIPSELINK_SESSIONS_XML;
- private static final String SESSIONS_XML_TEST_VALUE = "sessions-xml.test";
- private static final String SESSIONS_XML_TEST_VALUE_2 = "sessions-xml-2.test";
-
- public static final String TARGET_DATABASE_KEY = Options.ECLIPSELINK_TARGET_DATABASE;
- public static final TargetDatabase TARGET_DATABASE_TEST_VALUE = TargetDatabase.cloudscape;
- public static final TargetDatabase TARGET_DATABASE_TEST_VALUE_2 = TargetDatabase.oracle;
-
- public static final String INCLUDE_DESCRIPTOR_QUERIES_KEY = Options.ECLIPSELINK_SESSION_INCLUDE_DESCRIPTOR_QUERIES;
- public static final Boolean INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE = false;
- public static final Boolean INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE_2 = ! INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE;
-
- public static final String SESSION_EVENT_LISTENER_KEY = Options.ECLIPSELINK_SESSION_EVENT_LISTENER;
- public static final String SESSION_EVENT_LISTENER_TEST_VALUE = "acme.CustomSessionEventListener";
- public static final String SESSION_EVENT_LISTENER_TEST_VALUE_2 = "oracle.sessions.CustomSessionEventListener";
-
- public OptionsAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.options = this.persistenceUnitProperties.getOptions();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.options.addPropertyChangeListener(Options.SESSION_NAME_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(Options.SESSIONS_XML_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(Options.TARGET_DATABASE_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(Options.SESSION_EVENT_LISTENER_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(
- Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY, propertyChangeListener);
-
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 5;
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 4; // 4 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitPut(SESSION_NAME_KEY, SESSION_NAME_TEST_VALUE);
- this.persistenceUnitPut(SESSIONS_XML_KEY, SESSIONS_XML_TEST_VALUE);
- this.persistenceUnitPut("misc.property.1", "value.1");
- this.persistenceUnitPut(INCLUDE_DESCRIPTOR_QUERIES_KEY, INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE.toString());
- this.persistenceUnitPut("misc.property.2", "value.2");
- this.persistenceUnitPut("misc.property.3", "value.3");
- this.persistenceUnitPut(TARGET_DATABASE_KEY, TARGET_DATABASE_TEST_VALUE);
- this.persistenceUnitPut(SESSION_EVENT_LISTENER_KEY, SESSION_EVENT_LISTENER_TEST_VALUE);
- this.persistenceUnitPut("misc.property.4", "value.4");
- return;
- }
-
- // ********** Listeners **********
-
- // ********** Listeners tests **********
- public void testHasListeners() throws Exception {
- // new
- ListAspectAdapter<PersistenceUnit, Property> propertiesAdapter =
- (ListAspectAdapter<PersistenceUnit, Property>) ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertiesAdapter();
- GenericProperty ctdProperty = (GenericProperty) this.persistenceUnit().getProperty(INCLUDE_DESCRIPTOR_QUERIES_KEY);
- ListValueModel<Property> propertyListAdapter = ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertyListAdapter();
-
- assertTrue(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(ctdProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- this.verifyHasListeners(this.options, Options.SESSION_NAME_PROPERTY);
- this.verifyHasListeners(this.options, Options.SESSIONS_XML_PROPERTY);
- this.verifyHasListeners(this.options, Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY);
- this.verifyHasListeners(this.options, Options.TARGET_DATABASE_PROPERTY);
- this.verifyHasListeners(this.options, Options.SESSION_EVENT_LISTENER_PROPERTY);
- this.verifyHasListeners(propertyListAdapter);
-
- EclipseLinkOptions elOptions = (EclipseLinkOptions) this.options;
- PersistenceUnitPropertyListListener propertyListListener = elOptions.propertyListListener();
- propertyListAdapter.removeListChangeListener(ListValueModel.LIST_VALUES, propertyListListener);
- assertTrue(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES)); // other properties are still listening
- this.verifyHasListeners(this.options, Options.SESSION_NAME_PROPERTY);
- this.verifyHasListeners(this.options, Options.SESSIONS_XML_PROPERTY);
- this.verifyHasListeners(this.options, Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY);
- this.verifyHasListeners(this.options, Options.TARGET_DATABASE_PROPERTY);
- this.verifyHasListeners(this.options, Options.SESSION_EVENT_LISTENER_PROPERTY);
- }
-
-
- // ********** SessionName tests **********
- public void testSetSessionName() throws Exception {
- this.verifyModelInitialized(
- SESSION_NAME_KEY,
- SESSION_NAME_TEST_VALUE);
- this.verifySetProperty(
- SESSION_NAME_KEY,
- SESSION_NAME_TEST_VALUE,
- SESSION_NAME_TEST_VALUE_2);
- }
-
- public void testAddRemoveSessionName() throws Exception {
- this.verifyAddRemoveProperty(
- SESSION_NAME_KEY,
- SESSION_NAME_TEST_VALUE,
- SESSION_NAME_TEST_VALUE_2);
- }
-
- // ********** SessionsXml tests **********
- public void testSetSessionsXml() throws Exception {
- this.verifyModelInitialized(
- SESSIONS_XML_KEY,
- SESSIONS_XML_TEST_VALUE);
- this.verifySetProperty(
- SESSIONS_XML_KEY,
- SESSIONS_XML_TEST_VALUE,
- SESSIONS_XML_TEST_VALUE_2);
- }
-
- public void testAddRemoveSessionsXml() throws Exception {
- this.verifyAddRemoveProperty(
- SESSIONS_XML_KEY,
- SESSIONS_XML_TEST_VALUE,
- SESSIONS_XML_TEST_VALUE_2);
- }
-
- // ********** IncludeDescriptorQueries tests **********
- public void testSetIncludeDescriptorQueries() throws Exception {
- this.verifyModelInitialized(
- INCLUDE_DESCRIPTOR_QUERIES_KEY,
- INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE);
- this.verifySetProperty(
- INCLUDE_DESCRIPTOR_QUERIES_KEY,
- INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE,
- INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE_2);
- }
-
- public void testAddRemoveIncludeDescriptorQueries() throws Exception {
- this.verifyAddRemoveProperty(
- INCLUDE_DESCRIPTOR_QUERIES_KEY,
- INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE,
- INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE_2);
- }
-
- // ********** TargetDatabase tests **********
- public void testSetTargetDatabase() throws Exception {
- this.verifyModelInitialized(
- TARGET_DATABASE_KEY,
- TARGET_DATABASE_TEST_VALUE);
- this.verifySetProperty(
- TARGET_DATABASE_KEY,
- TARGET_DATABASE_TEST_VALUE,
- TARGET_DATABASE_TEST_VALUE_2);
- }
-
- public void testAddRemoveTargetDatabase() throws Exception {
- this.verifyAddRemoveProperty(
- TARGET_DATABASE_KEY,
- TARGET_DATABASE_TEST_VALUE,
- TARGET_DATABASE_TEST_VALUE_2);
- }
-
- // ********** EventListener tests **********
- public void testSetEventListener() throws Exception {
- this.verifyModelInitialized(
- SESSION_EVENT_LISTENER_KEY,
- SESSION_EVENT_LISTENER_TEST_VALUE);
- this.verifySetProperty(
- SESSION_EVENT_LISTENER_KEY,
- SESSION_EVENT_LISTENER_TEST_VALUE,
- SESSION_EVENT_LISTENER_TEST_VALUE_2);
- }
-
- public void testAddRemoveEventListener() throws Exception {
- this.verifyAddRemoveProperty(
- SESSION_EVENT_LISTENER_KEY,
- SESSION_EVENT_LISTENER_TEST_VALUE,
- SESSION_EVENT_LISTENER_TEST_VALUE_2);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(Options.SESSION_NAME_PROPERTY))
- this.options.setSessionName((String) newValue);
- else if (propertyName.equals(Options.SESSIONS_XML_PROPERTY))
- this.options.setSessionsXml((String) newValue);
- else if (propertyName.equals(Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY))
- this.options.setIncludeDescriptorQueries((Boolean) newValue);
- else if (propertyName.equals(Options.TARGET_DATABASE_PROPERTY))
- this.options.setTargetDatabase((TargetDatabase) newValue);
- else if (propertyName.equals(Options.SESSION_EVENT_LISTENER_PROPERTY))
- this.options.setEventListener((String) newValue);
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(Options.SESSION_NAME_PROPERTY))
- modelValue = this.options.getSessionName();
- else if (propertyName.equals(Options.SESSIONS_XML_PROPERTY))
- modelValue = this.options.getSessionsXml();
- else if (propertyName.equals(Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY))
- modelValue = this.options.getIncludeDescriptorQueries();
- else if (propertyName.equals(Options.TARGET_DATABASE_PROPERTY))
- modelValue = this.options.getTargetDatabase();
- else if (propertyName.equals(Options.SESSION_EVENT_LISTENER_PROPERTY))
- modelValue = this.options.getEventListener();
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- protected PersistenceUnitProperties model() {
- return this.options;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/options/OptionsValueModelTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/options/OptionsValueModelTests.java
deleted file mode 100644
index d5aab317f2..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/options/OptionsValueModelTests.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.options;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.options.Options;
-import org.eclipse.jpt.eclipselink.core.tests.internal.PersistenceUnitTestCase;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * OptionsValueModelTests
- */
-public class OptionsValueModelTests extends PersistenceUnitTestCase
-{
- private Options options;
-
- private WritablePropertyValueModel<Boolean> includeDescriptorQueriesHolder;
- private PropertyChangeListener includeDescriptorQueriesListener;
- private PropertyChangeEvent includeDescriptorQueriesEvent;
-
- public static final Boolean INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE = Boolean.FALSE;
-
- public OptionsValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.options = this.persistenceUnitProperties.getOptions(); // Subject
- PropertyValueModel<Options> optionsHolder = new SimplePropertyValueModel<Options>(this.options);
-
- this.includeDescriptorQueriesHolder = this.buildIncludeDescriptorQueriesAA(optionsHolder);
- this.includeDescriptorQueriesListener = this.buildIncludeDescriptorQueriesChangeListener();
- this.includeDescriptorQueriesHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.includeDescriptorQueriesListener);
- this.includeDescriptorQueriesEvent = null;
- }
-
- public void testHasListeners() {
- AbstractModel subjectOptions = (AbstractModel) this.options; // Subject
-
- PropertyAspectAdapter<Options, Boolean> includeDescriptorQueriesAA =
- (PropertyAspectAdapter<Options, Boolean>) this.includeDescriptorQueriesHolder;
- assertTrue(includeDescriptorQueriesAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectOptions.hasAnyPropertyChangeListeners(Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY));
-
- includeDescriptorQueriesAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.includeDescriptorQueriesListener);
- assertFalse(subjectOptions.hasAnyPropertyChangeListeners(Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY));
- assertFalse(includeDescriptorQueriesAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- protected void populatePu() {
- this.persistenceUnitPut(
- Options.ECLIPSELINK_SESSION_INCLUDE_DESCRIPTOR_QUERIES,
- INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE);
- return;
- }
-
- protected PersistenceUnitProperties model() {
- return this.options;
- }
-
- // ****** IncludeDescriptorQueries *******
- private WritablePropertyValueModel<Boolean> buildIncludeDescriptorQueriesAA(PropertyValueModel<Options> subjectHolder) {
- return new PropertyAspectAdapter<Options, Boolean>(subjectHolder, Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getIncludeDescriptorQueries();
- }
-
- @Override
- protected void setValue_(Boolean enumValue) {
- this.subject.setIncludeDescriptorQueries(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildIncludeDescriptorQueriesChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- OptionsValueModelTests.this.includeDescriptorQueriesEvent = e;
- }
- };
- }
-
- // ****** Tests *******
- public void testValue() {
- // ****** IncludeDescriptorQueries *******
- this.verifyIncludeDescriptorQueriesAAValue(INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE);
- assertEquals(Options.DEFAULT_SESSION_INCLUDE_DESCRIPTOR_QUERIES, this.options.getDefaultIncludeDescriptorQueries());
- }
-
- public void testSetValue() throws Exception {
- // ****** IncludeDescriptorQueries *******
- this.includeDescriptorQueriesEvent = null;
- this.verifyHasListeners(this.includeDescriptorQueriesHolder, PropertyValueModel.VALUE);
- Boolean newIncludeDescriptorQueries = !INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE;
- // Modify the property holder
- this.includeDescriptorQueriesHolder.setValue(newIncludeDescriptorQueries);
- this.verifyIncludeDescriptorQueriesAAValue(newIncludeDescriptorQueries);
- assertNotNull(this.includeDescriptorQueriesEvent);
- }
-
- public void testSetNullValue() {
- String notDeleted = "Property not deleted";
- // ****** IncludeDescriptorQueries *******
- this.includeDescriptorQueriesEvent = null;
- // Setting the property holder
- this.includeDescriptorQueriesHolder.setValue(null);
- // testing Holder
- this.verifyIncludeDescriptorQueriesAAValue(null);
- assertNotNull(this.includeDescriptorQueriesEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Options.ECLIPSELINK_SESSION_INCLUDE_DESCRIPTOR_QUERIES, notDeleted);
- }
-
- // ****** convenience methods *******
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyIncludeDescriptorQueriesAAValue(Boolean testValue) {
- this.verifyAAValue(
- testValue,
- this.options.getIncludeDescriptorQueries(),
- this.includeDescriptorQueriesHolder,
- Options.ECLIPSELINK_SESSION_INCLUDE_DESCRIPTOR_QUERIES);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/JptEclipseLinkCoreSchemaGenerationTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/JptEclipseLinkCoreSchemaGenerationTests.java
deleted file mode 100644
index c475f9f512..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/JptEclipseLinkCoreSchemaGenerationTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.schema.generation;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkCoreSchemaGenerationTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkCoreSchemaGenerationTests.class.getPackage().getName());
-
- suite.addTestSuite(SchemaGenerationValueModelTests.class);
- suite.addTestSuite(SchemaGenerationBasicAdapterTests.class);
- suite.addTestSuite(SchemaGenerationAdapterTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkCoreSchemaGenerationTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/SchemaGenerationAdapterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/SchemaGenerationAdapterTests.java
deleted file mode 100644
index cccf09a962..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/SchemaGenerationAdapterTests.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.schema.generation;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.Property;
-import org.eclipse.jpt.core.internal.context.persistence.GenericProperty;
-import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkJpaProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitPropertyListListener;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.DdlGenerationType;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.EclipseLinkSchemaGeneration;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.OutputMode;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.eclipselink.core.tests.internal.PersistenceUnitTestCase;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Tests the update of OutputMode model object by the SchemaGeneration adapter
- * when the PersistenceUnit changes.
- */
-public class SchemaGenerationAdapterTests extends PersistenceUnitTestCase
-{
- private SchemaGeneration schemaGeneration;
-
- public static final String DDL_GENERATION_TYPE_KEY = SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE;
- public static final DdlGenerationType DDL_GENERATION_TYPE_TEST_VALUE = DdlGenerationType.drop_and_create_tables;
- public static final DdlGenerationType DDL_GENERATION_TYPE_TEST_VALUE_2 = DdlGenerationType.none;
-
- public static final String OUTPUT_MODE_KEY = SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE;
- public static final OutputMode OUTPUT_MODE_TEST_VALUE = OutputMode.sql_script;
- public static final OutputMode OUTPUT_MODE_TEST_VALUE_2 = OutputMode.database;
-
- private static final String CREATE_FILE_NAME_KEY = SchemaGeneration.ECLIPSELINK_CREATE_FILE_NAME;
- private static final String CREATE_FILE_NAME_TEST_VALUE = "create-file-name.test";
- private static final String CREATE_FILE_NAME_TEST_VALUE_2 = "create-file-name-2.test";
-
- private static final String DROP_FILE_NAME_KEY = SchemaGeneration.ECLIPSELINK_DROP_FILE_NAME;
- private static final String DROP_FILE_NAME_TEST_VALUE = "drop-file-name.test";
- private static final String DROP_FILE_NAME_TEST_VALUE_2 = "drop-file-name-2.test";
-
- private static final String APPLICATION_LOCATION_KEY = SchemaGeneration.ECLIPSELINK_APPLICATION_LOCATION;
- private static final String APPLICATION_LOCATION_TEST_VALUE = "C:/temp";
- private static final String APPLICATION_LOCATION_TEST_VALUE_2 = "C:/tmp";
-
- public SchemaGenerationAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.schemaGeneration = this.persistenceUnitProperties.getSchemaGeneration();
-
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.OUTPUT_MODE_PROPERTY, propertyChangeListener);
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY, propertyChangeListener);
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.CREATE_FILE_NAME_PROPERTY, propertyChangeListener);
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.DROP_FILE_NAME_PROPERTY, propertyChangeListener);
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.APPLICATION_LOCATION_PROPERTY, propertyChangeListener);
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing. Cannot use
- * Property Holder to initialize because it is not created yet
- */
- @Override
- protected void populatePu() {
- this.propertiesTotal = 9;
- this.modelPropertiesSizeOriginal = 5;
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitPut("property.0", "value.0");
- this.persistenceUnitPut(OUTPUT_MODE_KEY, this.getEclipseLinkStringValueOf(OUTPUT_MODE_TEST_VALUE));
- this.persistenceUnitPut("property.2", "value.2");
- this.persistenceUnitPut("property.3", "value.3");
- this.persistenceUnitPut("property.4", "value.4");
- this.persistenceUnitPut(DDL_GENERATION_TYPE_KEY, this.getEclipseLinkStringValueOf(DDL_GENERATION_TYPE_TEST_VALUE));
- this.persistenceUnitPut(CREATE_FILE_NAME_KEY, CREATE_FILE_NAME_TEST_VALUE);
- this.persistenceUnitPut(DROP_FILE_NAME_KEY, DROP_FILE_NAME_TEST_VALUE);
- this.persistenceUnitPut(APPLICATION_LOCATION_KEY, APPLICATION_LOCATION_TEST_VALUE);
- return;
- }
-
- public void testHasListeners() throws Exception {
- ListAspectAdapter<PersistenceUnit, Property> propertiesAdapter = (ListAspectAdapter<PersistenceUnit, Property>) ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertiesAdapter();
- GenericProperty outputModeProperty = (GenericProperty) this.persistenceUnit().getProperty(OUTPUT_MODE_KEY);
- GenericProperty ddlGenTypeProperty = (GenericProperty) this.persistenceUnit().getProperty(DDL_GENERATION_TYPE_KEY);
- ListValueModel<Property> propertyListAdapter = ((EclipseLinkJpaProperties) this.persistenceUnitProperties).propertyListAdapter();
-
- assertTrue(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(outputModeProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- assertTrue(ddlGenTypeProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- this.verifyHasListeners(this.schemaGeneration, SchemaGeneration.OUTPUT_MODE_PROPERTY);
- this.verifyHasListeners(this.schemaGeneration, SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY);
- this.verifyHasListeners(propertyListAdapter);
-
- EclipseLinkSchemaGeneration schemaGen = (EclipseLinkSchemaGeneration) this.schemaGeneration;
- PersistenceUnitPropertyListListener propertyListListener = schemaGen.propertyListListener();
- propertyListAdapter.removeListChangeListener(ListValueModel.LIST_VALUES, propertyListListener);
- this.verifyHasListeners(this.schemaGeneration, SchemaGeneration.OUTPUT_MODE_PROPERTY);
- this.verifyHasListeners(this.schemaGeneration, SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY);
- }
-
- // ********** CreateFileName **********
- /**
- * Tests the update of CreateFileName property by the SchemaGeneration
- * adapter when the PU or the model changes.
- */
- public void testSetCreateFileName() throws Exception {
- this.verifyModelInitialized(
- CREATE_FILE_NAME_KEY,
- CREATE_FILE_NAME_TEST_VALUE);
- this.verifySetProperty(
- CREATE_FILE_NAME_KEY,
- CREATE_FILE_NAME_TEST_VALUE,
- CREATE_FILE_NAME_TEST_VALUE_2);
- }
-
- public void testAddRemoveCreateFileName() throws Exception {
- this.verifyAddRemoveProperty(
- CREATE_FILE_NAME_KEY,
- CREATE_FILE_NAME_TEST_VALUE,
- CREATE_FILE_NAME_TEST_VALUE_2);
- }
-
- // ********** DropFileName **********
- /**
- * Tests the update of DropFileName property by the SchemaGeneration adapter
- * when the PU or the model changes.
- */
- public void testSetDropFileName() throws Exception {
- this.verifyModelInitialized(
- DROP_FILE_NAME_KEY,
- DROP_FILE_NAME_TEST_VALUE);
- this.verifySetProperty(
- DROP_FILE_NAME_KEY,
- DROP_FILE_NAME_TEST_VALUE,
- DROP_FILE_NAME_TEST_VALUE_2);
- }
-
- public void testAddRemoveDropFileName() throws Exception {
- this.verifyAddRemoveProperty(
- DROP_FILE_NAME_KEY,
- DROP_FILE_NAME_TEST_VALUE,
- DROP_FILE_NAME_TEST_VALUE_2);
- }
-
- // ********** ApplicationLocation **********
- /**
- * Tests the update of ApplicationLocation property by the SchemaGeneration
- * adapter when the PU or the model changes.
- */
- public void testSetApplicationLocation() throws Exception {
- this.verifyModelInitialized(
- APPLICATION_LOCATION_KEY,
- APPLICATION_LOCATION_TEST_VALUE);
- this.verifySetProperty(
- APPLICATION_LOCATION_KEY,
- APPLICATION_LOCATION_TEST_VALUE,
- APPLICATION_LOCATION_TEST_VALUE_2);
- }
-
- public void testAddRemoveApplicationLocation() throws Exception {
- this.verifyAddRemoveProperty(
- APPLICATION_LOCATION_KEY,
- APPLICATION_LOCATION_TEST_VALUE,
- APPLICATION_LOCATION_TEST_VALUE_2);
- }
-
- // ********** OutputMode **********
- /**
- * Tests the update of OutputMode property by the SchemaGeneration adapter
- * when the PU or the model changes.
- */
- public void testSetOutputMode() throws Exception {
- this.verifyModelInitialized(
- OUTPUT_MODE_KEY,
- OUTPUT_MODE_TEST_VALUE);
- this.verifySetProperty(
- OUTPUT_MODE_KEY,
- OUTPUT_MODE_TEST_VALUE,
- OUTPUT_MODE_TEST_VALUE_2);
- }
-
- public void testAddRemoveOutputMode() throws Exception {
- this.verifyAddRemoveProperty(
- OUTPUT_MODE_KEY,
- OUTPUT_MODE_TEST_VALUE,
- OUTPUT_MODE_TEST_VALUE_2);
- }
-
- // ********** DdlGenerationType **********
- /**
- * Tests the update of DdlGenerationType property by the SchemaGeneration
- * adapter when the PU or the model changes.
- */
- public void testSetDdlGenerationType() throws Exception {
- this.verifyModelInitialized(
- DDL_GENERATION_TYPE_KEY,
- DDL_GENERATION_TYPE_TEST_VALUE);
- this.verifySetProperty(
- DDL_GENERATION_TYPE_KEY,
- DDL_GENERATION_TYPE_TEST_VALUE,
- DDL_GENERATION_TYPE_TEST_VALUE_2);
- }
-
- public void testAddRemoveDdlGenerationType() throws Exception {
- this.verifyAddRemoveProperty(
- DDL_GENERATION_TYPE_KEY,
- DDL_GENERATION_TYPE_TEST_VALUE,
- DDL_GENERATION_TYPE_TEST_VALUE_2);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws NoSuchFieldException {
- if (propertyName.equals(SchemaGeneration.OUTPUT_MODE_PROPERTY))
- this.schemaGeneration.setOutputMode((OutputMode) newValue);
- // else if( propertyName.equals( Caching.CACHE_SIZE_PROPERTY))
- // TODO
- else if (propertyName.equals(SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY))
- this.schemaGeneration.setDdlGenerationType((DdlGenerationType) newValue);
- else if (propertyName.equals(SchemaGeneration.APPLICATION_LOCATION_PROPERTY))
- this.schemaGeneration.setApplicationLocation((String) newValue);
- else if (propertyName.equals(SchemaGeneration.CREATE_FILE_NAME_PROPERTY))
- this.schemaGeneration.setCreateFileName((String) newValue);
- else if (propertyName.equals(SchemaGeneration.DROP_FILE_NAME_PROPERTY))
- this.schemaGeneration.setDropFileName((String) newValue);
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(SchemaGeneration.OUTPUT_MODE_PROPERTY))
- modelValue = this.schemaGeneration.getOutputMode();
- else if (propertyName.equals(SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY))
- modelValue = this.schemaGeneration.getDdlGenerationType();
- else if (propertyName.equals(SchemaGeneration.APPLICATION_LOCATION_PROPERTY))
- modelValue = this.schemaGeneration.getApplicationLocation();
- else if (propertyName.equals(SchemaGeneration.CREATE_FILE_NAME_PROPERTY))
- modelValue = this.schemaGeneration.getCreateFileName();
- else if (propertyName.equals(SchemaGeneration.DROP_FILE_NAME_PROPERTY))
- modelValue = this.schemaGeneration.getDropFileName();
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- protected PersistenceUnitProperties model() {
- return this.schemaGeneration;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/SchemaGenerationBasicAdapterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/SchemaGenerationBasicAdapterTests.java
deleted file mode 100644
index 2c13374374..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/SchemaGenerationBasicAdapterTests.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.schema.generation;
-
-import java.util.ListIterator;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.Property;
-import org.eclipse.jpt.core.internal.context.persistence.GenericProperty;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitPropertyListListener;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.DdlGenerationType;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.EclipseLinkSchemaGeneration;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.OutputMode;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.eclipselink.core.tests.internal.PersistenceUnitTestCase;
-import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-
-/**
- * Tests the update of OutputMode model object by the SchemaGeneration adapter
- * when the PersistenceUnit changes.
- */
-public class SchemaGenerationBasicAdapterTests extends PersistenceUnitTestCase
-{
- private SchemaGeneration schemaGeneration;
-
- public static final String outputModeKey = SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE;
- public static final String ddlGenTypeKey = SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE;
-
- public static final OutputMode OUTPUT_MODE_TEST_VALUE = OutputMode.sql_script;
- public static final OutputMode OUTPUT_MODE_TEST_VALUE_2 = OutputMode.database;
-
- public static final DdlGenerationType DDL_GENERATION_TYPE_TEST_VALUE = DdlGenerationType.drop_and_create_tables;
- public static final DdlGenerationType DDL_GENERATION_TYPE_TEST_VALUE_2 = DdlGenerationType.none;
-
- public SchemaGenerationBasicAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- this.schemaGeneration = this.persistenceUnitProperties.getSchemaGeneration();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.OUTPUT_MODE_PROPERTY, propertyChangeListener);
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY, propertyChangeListener);
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing. Cannot use
- * Property Holder to initialize because it is not created yet
- */
- @Override
- protected void populatePu() {
- this.propertiesTotal = 6;
- this.modelPropertiesSizeOriginal = 2;
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitPut("property.0", "value.0");
- this.persistenceUnitPut(outputModeKey, this.getEclipseLinkStringValueOf(OUTPUT_MODE_TEST_VALUE));
- this.persistenceUnitPut("property.2", "value.2");
- this.persistenceUnitPut("property.3", "value.3");
- this.persistenceUnitPut("property.4", "value.4");
- this.persistenceUnitPut(ddlGenTypeKey, this.getEclipseLinkStringValueOf(DDL_GENERATION_TYPE_TEST_VALUE));
- return;
- }
-
- /** ****** test methods ******* */
- public void testHasListeners() throws Exception {
- ListAspectAdapter<PersistenceUnit, Property> propertiesAdapter =
- (ListAspectAdapter<PersistenceUnit, Property>) this.buildPropertiesAdapter(this.subjectHolder);
- assertFalse(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- GenericProperty outputModeProperty = (GenericProperty) this.persistenceUnit().getProperty(outputModeKey);
- GenericProperty ddlGenTypeProperty = (GenericProperty) this.persistenceUnit().getProperty(ddlGenTypeKey);
- assertTrue(outputModeProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
-
- ListValueModel<Property> propertyListAdapter =
- new ItemPropertyListValueModelAdapter<Property>(propertiesAdapter, Property.VALUE_PROPERTY, Property.NAME_PROPERTY);
- assertFalse(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(outputModeProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- assertTrue(ddlGenTypeProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- this.verifyHasListeners(this.schemaGeneration, SchemaGeneration.OUTPUT_MODE_PROPERTY);
- this.verifyHasListeners(this.schemaGeneration, SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY);
- this.verifyHasNoListeners(propertyListAdapter);
-
- PersistenceUnitPropertyListListener propertyListListener =
- new PersistenceUnitPropertyListListener(this.schemaGeneration);
- propertyListAdapter.addListChangeListener(ListValueModel.LIST_VALUES, propertyListListener);
- assertTrue(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(outputModeProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- assertTrue(ddlGenTypeProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- this.verifyHasListeners(propertyListAdapter);
-
- propertyListAdapter.removeListChangeListener(ListValueModel.LIST_VALUES, propertyListListener);
- assertFalse(propertiesAdapter.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(outputModeProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- assertTrue(ddlGenTypeProperty.hasAnyPropertyChangeListeners(Property.VALUE_PROPERTY));
- this.verifyHasNoListeners(propertyListAdapter);
- }
-
- /**
- * Tests the update of OutputMode property by the SchemaGeneration adapter
- * when the PU changes.
- */
- public void testOutputModeUpdate() throws Exception {
- ListValueModel<Property> propertiesAdapter = this.buildPropertiesAdapter(this.subjectHolder);
- ListValueModel<Property> propertyListAdapter = new ItemPropertyListValueModelAdapter<Property>(propertiesAdapter, Property.VALUE_PROPERTY);
- PersistenceUnitPropertyListListener propertyListListener = ((EclipseLinkSchemaGeneration) this.schemaGeneration).propertyListListener();
- propertyListAdapter.addListChangeListener(ListValueModel.LIST_VALUES, propertyListListener);
-
- this.verifyHasListeners(propertyListAdapter);
- this.verifyHasListeners(this.schemaGeneration, SchemaGeneration.OUTPUT_MODE_PROPERTY);
-
- // Basic
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
- assertTrue(schemaGeneration.itemIsProperty(this.persistenceUnit().getProperty(outputModeKey)));
- assertEquals(OUTPUT_MODE_TEST_VALUE, this.schemaGeneration.getOutputMode());
-
- // Replace
- this.persistenceUnitPut(outputModeKey, OUTPUT_MODE_TEST_VALUE_2);
- this.verifyPutEvent(SchemaGeneration.OUTPUT_MODE_PROPERTY, OUTPUT_MODE_TEST_VALUE_2, this.schemaGeneration.getOutputMode());
-
- // Remove
- this.clearEvent();
- --this.propertiesTotal;
- --this.modelPropertiesSize;
- this.persistenceUnit().removeProperty(outputModeKey);
- assertFalse(this.persistenceUnit().containsProperty(outputModeKey));
- assertEquals(this.propertiesTotal, propertyListAdapter.size());
- assertEquals(this.modelPropertiesSize, this.modelPropertiesSizeOriginal - 1);
- assertNotNull(this.propertyChangedEvent);
- assertNull(this.propertyChangedEvent.getNewValue());
-
- // Add original OutputMode
- ++this.propertiesTotal;
- ++this.modelPropertiesSize;
- this.persistenceUnitPut(outputModeKey, OUTPUT_MODE_TEST_VALUE);
- this.verifyPutEvent(SchemaGeneration.OUTPUT_MODE_PROPERTY, OUTPUT_MODE_TEST_VALUE, this.schemaGeneration.getOutputMode());
-
- // Replace again
- this.persistenceUnitPut(outputModeKey, OUTPUT_MODE_TEST_VALUE_2);
- this.verifyPutEvent(SchemaGeneration.OUTPUT_MODE_PROPERTY, OUTPUT_MODE_TEST_VALUE_2, this.schemaGeneration.getOutputMode());
-
- // Replace by setting model object
- this.clearEvent();
- this.schemaGeneration.setOutputMode(OUTPUT_MODE_TEST_VALUE);
- this.verifyPutEvent(SchemaGeneration.OUTPUT_MODE_PROPERTY, OUTPUT_MODE_TEST_VALUE, this.schemaGeneration.getOutputMode());
- }
-
- // ****** convenience methods *******
- protected PersistenceUnitProperties model() {
- return this.schemaGeneration;
- }
-
- private ListValueModel<Property> buildPropertiesAdapter(PropertyValueModel<PersistenceUnit> subjectHolder) {
- return new ListAspectAdapter<PersistenceUnit, Property>(subjectHolder, PersistenceUnit.PROPERTIES_LIST) {
- @Override
- protected ListIterator<Property> listIterator_() {
- return this.subject.properties();
- }
-
- @Override
- protected int size_() {
- return this.subject.propertiesSize();
- }
- };
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/SchemaGenerationValueModelTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/SchemaGenerationValueModelTests.java
deleted file mode 100644
index db8ceb2f34..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/schema/generation/SchemaGenerationValueModelTests.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.eclipselink.core.tests.internal.schema.generation;
-
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.DdlGenerationType;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.OutputMode;
-import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.eclipselink.core.tests.internal.PersistenceUnitTestCase;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * SchemaGenerationValueModelTests
- *
- * Tests the PropertyValueModel of SchemaGeneration model and the update of the
- * PersistenceUnit.
- */
-public class SchemaGenerationValueModelTests extends PersistenceUnitTestCase
-{
- private SchemaGeneration schemaGen;
- private PropertyValueModel<SchemaGeneration> schemaGenHolder;
-
- private WritablePropertyValueModel<DdlGenerationType> ddlGenerationTypeHolder;
- private PropertyChangeEvent ddlGenerationTypeEvent;
-
- private WritablePropertyValueModel<OutputMode> outputModeHolder;
- private PropertyChangeEvent outputModeEvent;
-
- public static final DdlGenerationType DDL_GENERATION_TYPE_TEST_VALUE = DdlGenerationType.drop_and_create_tables;
- public static final OutputMode OUTPUT_MODE_TEST_VALUE = OutputMode.sql_script;
-
- public SchemaGenerationValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.schemaGen = this.persistenceUnitProperties.getSchemaGeneration(); // Subject
- this.schemaGenHolder = new SimplePropertyValueModel<SchemaGeneration>(this.schemaGen);
-
- this.ddlGenerationTypeHolder = this.buildDdlGenerationTypeAA(this.schemaGenHolder);
- PropertyChangeListener ddlGenerationTypeListener = this.buildDdlGenerationTypeChangeListener();
- this.ddlGenerationTypeHolder.addPropertyChangeListener(PropertyValueModel.VALUE, ddlGenerationTypeListener);
- this.ddlGenerationTypeEvent = null;
-
- this.outputModeHolder = this.buildOutputModeAA(this.schemaGenHolder);
- PropertyChangeListener outputModeListener = this.buildOutputModeChangeListener();
- this.outputModeHolder.addPropertyChangeListener(PropertyValueModel.VALUE, outputModeListener);
- this.outputModeEvent = null;
- }
-
- /**
- * Initializes directly the PU properties before testing. Cannot use
- * Property Holder to initialize because it is not created yet
- */
- @Override
- protected void populatePu() {
- this.persistenceUnitPut(
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE,
- DDL_GENERATION_TYPE_TEST_VALUE);
- this.persistenceUnitPut(
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE,
- OUTPUT_MODE_TEST_VALUE);
- return;
- }
-
- protected PersistenceUnitProperties model() {
- return this.schemaGen;
- }
-
- /** ****** DdlGenerationType ******* */
- private WritablePropertyValueModel<DdlGenerationType> buildDdlGenerationTypeAA(PropertyValueModel<SchemaGeneration> subjectHolder) {
- return new PropertyAspectAdapter<SchemaGeneration, DdlGenerationType>(subjectHolder, SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY) {
- @Override
- protected DdlGenerationType buildValue_() {
- return this.subject.getDdlGenerationType();
- }
-
- @Override
- protected void setValue_(DdlGenerationType enumValue) {
- this.subject.setDdlGenerationType(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildDdlGenerationTypeChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- SchemaGenerationValueModelTests.this.ddlGenerationTypeEvent = e;
- }
- };
- }
-
- /** ****** OutputMode ******* */
- private WritablePropertyValueModel<OutputMode> buildOutputModeAA(PropertyValueModel<SchemaGeneration> subjectHolder) {
- return new PropertyAspectAdapter<SchemaGeneration, OutputMode>(subjectHolder, SchemaGeneration.OUTPUT_MODE_PROPERTY) {
- @Override
- protected OutputMode buildValue_() {
- return this.subject.getOutputMode();
- }
-
- @Override
- protected void setValue_(OutputMode enumValue) {
- this.subject.setOutputMode(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildOutputModeChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- SchemaGenerationValueModelTests.this.outputModeEvent = e;
- }
- };
- }
-
- public void testValue() {
- /** ****** DdlGenerationType ******* */
- this.verifyDdlGenerationTypeAAValue(DDL_GENERATION_TYPE_TEST_VALUE);
- assertEquals(
- SchemaGeneration.DEFAULT_SCHEMA_GENERATION_DDL_GENERATION_TYPE,
- this.schemaGen.getDefaultDdlGenerationType());
- /** ****** OutputMode ******* */
- this.verifyOutputModeAAValue(OUTPUT_MODE_TEST_VALUE);
- assertEquals(
- SchemaGeneration.DEFAULT_SCHEMA_GENERATION_OUTPUT_MODE,
- this.schemaGen.getDefaultOutputMode());
- }
-
- public void testSetValue() throws Exception {
- /** ****** DdlGenerationType ******* */
- this.ddlGenerationTypeEvent = null;
- this.verifyHasListeners(this.ddlGenerationTypeHolder, PropertyValueModel.VALUE);
- DdlGenerationType newDdlGenerationType = DdlGenerationType.create_tables;
- // Modify the persistenceUnit directly
- this.subject.putProperty(
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE,
- this.getEclipseLinkStringValueOf(newDdlGenerationType),
- false);
- this.verifyDdlGenerationTypeAAValue(newDdlGenerationType);
- assertNotNull(this.ddlGenerationTypeEvent);
-
- /** ****** OutputMode ******* */
- this.outputModeEvent = null;
- this.verifyHasListeners(this.outputModeHolder, PropertyValueModel.VALUE);
- OutputMode newOutputMode = OutputMode.database;
- // Modify the property holder
- this.outputModeHolder.setValue(newOutputMode);
- this.verifyOutputModeAAValue(newOutputMode);
- assertNotNull(this.outputModeEvent);
- }
-
- public void testSetNullValue() {
- /** ****** DdlGenerationType ******* */
- this.ddlGenerationTypeEvent = null;
- // Setting the persistenceUnit directly
- this.subject.putProperty(SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE, null, false);
- this.ddlGenerationTypeHolder.setValue(null);
- // testing Holder
- this.verifyDdlGenerationTypeAAValue(null);
- assertNotNull(this.ddlGenerationTypeEvent);
- // testing PU properties
- boolean containsDdlGenerationTypeProperty =
- this.persistenceUnit().containsProperty(SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE);
- assertFalse(containsDdlGenerationTypeProperty);
-
- /** ****** OutputMode ******* */
- this.outputModeEvent = null;
- // Setting the property holder
- this.outputModeHolder.setValue(null);
- // testing Holder
- this.verifyOutputModeAAValue(null);
- assertNotNull(this.outputModeEvent);
- // testing PU properties
- boolean containsOutputModeProperty =
- this.persistenceUnit().containsProperty(SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE);
- assertFalse(containsOutputModeProperty);
- }
-
- /** ****** convenience methods ******* */
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyDdlGenerationTypeAAValue(DdlGenerationType testValue) {
- this.verifyAAValue(
- testValue,
- this.schemaGen.getDdlGenerationType(),
- this.ddlGenerationTypeHolder,
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE);
- }
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyOutputModeAAValue(OutputMode testValue) {
- this.verifyAAValue(
- testValue,
- this.schemaGen.getOutputMode(),
- this.outputModeHolder,
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/test.xml b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/test.xml
deleted file mode 100644
index 75bde6cc60..0000000000
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/test.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0"?>
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <echo message="basedir ${basedir}" />
- <echo message="eclipse place ${eclipse-home}" />
- <!-- sets the properties plugin-name -->
- <property name="plugin-name" value="org.eclipse.jpt.eclipselink.core.tests"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname" value="org.eclipse.jpt.eclipselink.core.tests.internal.JptEclipseLinkCoreTests" />
- <property name="plugin-path" value="${eclipse-home}/plugins/${plugin-name}"/>
- <property name="extraVMargs" value=""/>
- </ant>
- </target>
-
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init, suite, cleanup">
- </target>
-</project> \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/.classpath b/jpa/tests/org.eclipse.jpt.ui.tests/.classpath
deleted file mode 100644
index 370877baf6..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/.classpath
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/ui/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/core/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/utility/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/.project b/jpa/tests/org.eclipse.jpt.ui.tests/.project
deleted file mode 100644
index 0240774761..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.ui.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/.settings/org.eclipse.core.resources.prefs b/jpa/tests/org.eclipse.jpt.ui.tests/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index d364a0f24e..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Mon Apr 07 14:27:16 EDT 2008
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.ui.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index 4d1a5023be..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,23 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.ui.tests
-Bundle-Version: 1.0.0
-Require-Bundle: org.junit,
- org.junit4;bundle-version="4.3.1",
- org.eclipse.core.runtime,
- org.eclipse.jface,
- org.eclipse.jpt.core.tests,
- org.eclipse.jpt.core.tests.extension.resource,
- org.eclipse.jpt.utility,
- org.eclipse.jpt.core,
- org.eclipse.jpt.ui,
- org.eclipse.ui.workbench;bundle-version="3.4.0",
- org.eclipse.ui.forms;bundle-version="3.3.100"
-Eclipse-LazyStart: true
-Export-Package: org.eclipse.jpt.ui.tests;x-internal:=true,
- org.eclipse.jpt.ui.tests.internal.jface;x-internal:=true,
- org.eclipse.jpt.ui.tests.internal.platform;x-internal:=true,
- org.eclipse.jpt.ui.tests.internal.swt;x-internal:=true,
- org.eclipse.jpt.ui.tests.internal.util;x-internal:=true
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/build.properties b/jpa/tests/org.eclipse.jpt.ui.tests/build.properties
deleted file mode 100644
index 34d2e4d2da..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/build.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/plugin.properties b/jpa/tests/org.eclipse.jpt.ui.tests/plugin.properties
deleted file mode 100644
index ca8ab879ff..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/plugin.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 Oracle. All rights reserved. This
-# program and the accompanying materials are made available under the terms of
-# the Eclipse Public License v1.0 which accompanies this distribution, and is
-# available at http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors: Oracle. - initial API and implementation
-###############################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName=Java Persistence API UI Tests
-providerName=Eclipse.org
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/JptUiTests.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/JptUiTests.java
deleted file mode 100644
index 310abb7607..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/JptUiTests.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.ui.tests.internal.platform.JptUiPlatformTests;
-import org.eclipse.jpt.ui.tests.internal.swt.JptUiSWTTests;
-import org.eclipse.jpt.ui.tests.internal.util.JptUiUtilTests;
-
-/**
- * Runs all JPT UI Tests
- */
-public class JptUiTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUiTests.class.getPackage().getName());
- suite.addTest(JptUiPlatformTests.suite());
- suite.addTest(JptUiSWTTests.suite());
- suite.addTest(JptUiUtilTests.suite());
- return suite;
- }
-
- private JptUiTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/jface/DelegatingLabelProviderUiTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/jface/DelegatingLabelProviderUiTest.java
deleted file mode 100644
index a5a7ec41da..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/jface/DelegatingLabelProviderUiTest.java
+++ /dev/null
@@ -1,589 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.jface;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.BaseLabelProvider;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.ui.internal.jface.AbstractItemLabelProvider;
-import org.eclipse.jpt.ui.internal.jface.AbstractTreeItemContentProvider;
-import org.eclipse.jpt.ui.internal.jface.DelegatingTreeContentAndLabelProvider;
-import org.eclipse.jpt.ui.jface.DelegatingContentAndLabelProvider;
-import org.eclipse.jpt.ui.jface.ItemLabelProvider;
-import org.eclipse.jpt.ui.jface.ItemLabelProviderFactory;
-import org.eclipse.jpt.ui.jface.TreeItemContentProvider;
-import org.eclipse.jpt.ui.jface.TreeItemContentProviderFactory;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.NullListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.StaticListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-public class DelegatingLabelProviderUiTest extends ApplicationWindow
-{
- private TreeViewer tree;
-
- private WritablePropertyValueModel<Vehicle> selectedVehicle;
-
-
- public static void main(String[] args) {
- Window window = new DelegatingLabelProviderUiTest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
-
- private DelegatingLabelProviderUiTest(String[] args) {
- super(null);
- this.selectedVehicle = new SimplePropertyValueModel<Vehicle>();
- }
-
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(ClassTools.shortClassNameForObject(this));
- parent.setSize(400, 400);
- parent.setLayout(new GridLayout());
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
- mainPanel.setLayout(new GridLayout());
- buildTreePanel(mainPanel);
- buildControlPanel(mainPanel);
- return mainPanel;
- }
-
- private void buildTreePanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL_BOTH));
- panel.setLayout(new GridLayout());
-
- Label label = new Label(panel, SWT.NONE);
- label.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
- label.setText("My Vehicles");
-
- tree = new TreeViewer(panel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- tree.getTree().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
- DelegatingContentAndLabelProvider contentAndLabelProvider =
- new DelegatingTreeContentAndLabelProvider(
- new VehicleContentProviderFactory(),
- new VehicleLabelProviderFactory());
- tree.setContentProvider(contentAndLabelProvider);
- tree.setLabelProvider(contentAndLabelProvider);
- tree.setInput(new Root());
- tree.addSelectionChangedListener(buildTreeSelectionChangedListener());
- }
-
- private ISelectionChangedListener buildTreeSelectionChangedListener() {
- return new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- selectedVehicle.setValue((Vehicle) ((IStructuredSelection) event.getSelection()).getFirstElement());
- }
- };
- }
-
- private void buildControlPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- panel.setLayout(new GridLayout());
- buildUpperControlPanel(panel);
- buildLowerControlPanel(panel);
- }
-
- private void buildUpperControlPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- panel.setLayout(new GridLayout(2, true));
- buildVehicleCombo(panel);
- buildColorCombo(panel);
- }
-
- private void buildVehicleCombo(Composite parent) {
- final ComboViewer combo = new ComboViewer(parent, SWT.READ_ONLY);
- combo.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- combo.setContentProvider(new ArrayContentProvider());
- combo.setLabelProvider(new VehicleTypeLabelProvider());
- combo.setInput(
- new VehicleType[] {
- VehicleType.BICYCLE, VehicleType.CAR,
- VehicleType.TRUCK, VehicleType.BOAT
- });
- combo.getCombo().setEnabled(false);
- combo.addSelectionChangedListener(
- new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- selectedVehicle().setVehicleType((VehicleType) ((StructuredSelection) event.getSelection()).getFirstElement());
- }
- });
- selectedVehicle.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- Vehicle vehicle = selectedVehicle();
- combo.getCombo().setEnabled(vehicle != null);
- combo.setSelection(new StructuredSelection((vehicle == null) ? null : vehicle.vehicleType()));
- }
- });
- }
-
- private void buildColorCombo(Composite parent) {
- final ComboViewer combo = new ComboViewer(parent, SWT.READ_ONLY);
- combo.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- combo.setContentProvider(new ArrayContentProvider());
- combo.setLabelProvider(new ColorLabelProvider());
- combo.setInput(new Color[] {Color.RED, Color.BLUE, Color.YELLOW, Color.GREEN});
- combo.addSelectionChangedListener(
- new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- selectedVehicle().setColor((Color) ((StructuredSelection) event.getSelection()).getFirstElement());
- }
- });
- selectedVehicle.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- Vehicle vehicle = selectedVehicle();
- combo.getCombo().setEnabled(vehicle != null);
- combo.setSelection(new StructuredSelection((vehicle == null) ? null : vehicle.color()));
- }
- });
- }
-
- private void buildLowerControlPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- panel.setLayout(new GridLayout(3, false));
- buildEffectsLabel(panel);
- buildGreyedCheckBox(panel);
- buildTranslucentCheckBox(panel);
- buildActionPanel(panel);
- }
-
- private void buildEffectsLabel(Composite parent) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText("Color effects: ");
- label.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1));
- }
-
- private void buildGreyedCheckBox(Composite parent) {
- final Button button = new Button(parent, SWT.CHECK);
- button.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
- button.setText("greyed");
- button.setEnabled(false);
- button.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedVehicle().setGreyed(button.getSelection());
- }
- });
- selectedVehicle.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- Vehicle vehicle = selectedVehicle();
- button.setEnabled(vehicle != null);
- button.setSelection(vehicle != null && vehicle.isGreyed());
- }
- });
- }
-
- private void buildTranslucentCheckBox(Composite parent) {
- final Button button = new Button(parent, SWT.CHECK);
- button.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false));
- button.setText("translucent");
- button.setEnabled(false);
- button.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedVehicle().setTranslucent(button.getSelection());
- }
- });
- selectedVehicle.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- Vehicle vehicle = selectedVehicle();
- button.setEnabled(vehicle != null);
- button.setSelection(vehicle != null && vehicle.isTranslucent());
- }
- });
- }
-
- private void buildActionPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.END, GridData.FILL, false, false));
- panel.setLayout(new GridLayout());
- buildRefreshTreeACI().fill(panel);
- }
-
- private ActionContributionItem buildRefreshTreeACI() {
- Action action = new Action("Refresh tree", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- refreshTree();
- }
- };
- action.setToolTipText("Refresh the tree's labels");
- return new ActionContributionItem(action);
- }
-
- void refreshTree() {
- tree.refresh();
- }
-
- private Vehicle selectedVehicle() {
- return selectedVehicle.getValue();
- }
-
-
- private static class VehicleTypeLabelProvider extends BaseLabelProvider
- implements ILabelProvider
- {
- public Image getImage(Object element) {
- return null;
- }
-
- public String getText(Object element) {
- return ((VehicleType) element).description();
- }
- }
-
-
- private static class ColorLabelProvider extends BaseLabelProvider
- implements ILabelProvider
- {
- public Image getImage(Object element) {
- return null;
- }
-
- public String getText(Object element) {
- return ((Color) element).description();
- }
- }
-
-
- private static class VehicleContentProviderFactory
- implements TreeItemContentProviderFactory
- {
- public TreeItemContentProvider buildItemContentProvider(Object item, DelegatingContentAndLabelProvider contentAndLabelProvider) {
- if (item instanceof Root) {
- return new RootContentProvider(
- (Root) item, (DelegatingTreeContentAndLabelProvider) contentAndLabelProvider);
- }
- return new VehicleContentProvider(
- (Vehicle) item, (DelegatingTreeContentAndLabelProvider) contentAndLabelProvider);
- }
- }
-
-
- private static class RootContentProvider extends AbstractTreeItemContentProvider<Vehicle>
- {
- public RootContentProvider(Root item, DelegatingTreeContentAndLabelProvider contentAndLabelProvider) {
- super(item, contentAndLabelProvider);
- }
-
- @Override
- public Object getParent() {
- return null;
- }
-
- @Override
- protected ListValueModel<Vehicle> buildChildrenModel() {
- return new StaticListValueModel<Vehicle>(CollectionTools.list(((Root) model()).vehicles()));
- }
- }
-
- @SuppressWarnings("unchecked")
- private static class VehicleContentProvider extends AbstractTreeItemContentProvider
- {
- public VehicleContentProvider(Vehicle item, DelegatingTreeContentAndLabelProvider contentAndLabelProvider) {
- super(item, contentAndLabelProvider);
- }
-
- @Override
- public Object getParent() {
- return ((Vehicle) model()).parent();
- }
-
- @Override
- protected ListValueModel buildChildrenModel() {
- return new NullListValueModel();
- }
- }
-
-
- private static class VehicleLabelProviderFactory
- implements ItemLabelProviderFactory
- {
- public ItemLabelProvider buildItemLabelProvider(Object element, DelegatingContentAndLabelProvider labelProvider) {
- return new VehicleLabelProvider((Vehicle) element, labelProvider);
- }
- }
-
-
- private static class VehicleLabelProvider extends AbstractItemLabelProvider
- {
- public VehicleLabelProvider(Vehicle vehicle, DelegatingContentAndLabelProvider labelProvider) {
- super(vehicle, labelProvider);
- }
-
- @Override
- protected PropertyValueModel<String> buildTextModel() {
- return new PropertyAspectAdapter<Vehicle, String>(
- new StaticPropertyValueModel<Vehicle>((Vehicle) model()),
- Vehicle.VEHICLE_TYPE_PROPERTY, Vehicle.COLOR_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.color().description() + ' ' + subject.vehicleType().description();
- }
- };
- }
-
- @Override
- protected PropertyValueModel<Image> buildImageModel() {
- return new PropertyAspectAdapter<Vehicle, Image>(
- new StaticPropertyValueModel<Vehicle>((Vehicle) model()),
- Vehicle.COLOR_PROPERTY, Vehicle.GREYED_PROPERTY, Vehicle.TRANSLUCENT_PROPERTY) {
- @Override
- protected Image buildValue_() {
- return subject.image();
- }
- };
- }
- }
-
-
- private static abstract class TreeNode extends AbstractModel
- {
- private TreeNode parent;
-
-
- public TreeNode(TreeNode parent) {
- this.parent = parent;
- }
-
-
- public TreeNode parent() {
- return parent;
- }
- }
-
-
- private static class Root extends TreeNode
- {
- protected final Vehicle[] vehicles;
-
-
- public Root() {
- super(null);
- vehicles = new Vehicle[] {
- new Vehicle(this, VehicleType.BICYCLE, Color.BLUE),
- new Vehicle(this, VehicleType.CAR, Color.YELLOW),
- new Vehicle(this, VehicleType.TRUCK, Color.RED),
- new Vehicle(this, VehicleType.BOAT, Color.GREEN)};
- }
-
- public Vehicle[] vehicles() {
- return vehicles;
- }
- }
-
-
- private static class Vehicle extends TreeNode
- {
- private VehicleType vehicleType;
- public final static String VEHICLE_TYPE_PROPERTY = "vehicleType";
-
- private Color color;
- public final static String COLOR_PROPERTY = "color";
-
- private boolean greyed = false;
- public final static String GREYED_PROPERTY = "greyed";
-
- private boolean translucent = false;
- public final static String TRANSLUCENT_PROPERTY = "translucent";
-
- private Image image;
-
-
- public Vehicle(TreeNode parent, VehicleType vehicleType, Color color) {
- super(parent);
- this.vehicleType = vehicleType;
- this.color = color;
- }
-
- public VehicleType vehicleType() {
- return vehicleType;
- }
-
- public void setVehicleType(VehicleType newVehicleType) {
- VehicleType oldVehicleType = vehicleType;
- vehicleType = newVehicleType;
- firePropertyChanged(VEHICLE_TYPE_PROPERTY, oldVehicleType, newVehicleType);
- }
-
- public Color color() {
- return color;
- }
-
- public void setColor(Color newColor) {
- Color oldColor = color;
- color = newColor;
- firePropertyChanged(COLOR_PROPERTY, oldColor, newColor);
- }
-
- public boolean isGreyed() {
- return greyed;
- }
-
- public void setGreyed(boolean newGreyed) {
- boolean oldGreyed = greyed;
- greyed = newGreyed;
- firePropertyChanged(GREYED_PROPERTY, oldGreyed, newGreyed);
- }
-
- public boolean isTranslucent() {
- return translucent;
- }
-
- public void setTranslucent(boolean newTranslucent) {
- boolean oldTranslucent = translucent;
- translucent = newTranslucent;
- firePropertyChanged(TRANSLUCENT_PROPERTY, oldTranslucent, newTranslucent);
- }
-
- public Image image() {
- if (image != null) {
- image.dispose();
- }
-
- return ImageFactory.image(color(), greyed, translucent);
- }
- }
-
-
- private static enum VehicleType
- {
- BICYCLE("bicycle"),
- CAR("car"),
- TRUCK("truck"),
- BOAT("boat");
-
- private final String description;
-
- private VehicleType(String description) {
- this.description = description;
- }
-
- public String description() {
- return description;
- }
-
- @Override
- public String toString() {
- return description();
- }
- }
-
-
- private static enum Color
- {
- RED("red", new RGB(255, 0, 0)),
- BLUE("blue", new RGB(0, 0, 255)),
- YELLOW("yellow", new RGB(255, 255, 0)),
- GREEN("green", new RGB(0, 255, 0));
-
- private final String description;
-
- private final RGB rgb;
-
- private Color(String description, RGB rgb) {
- this.description = description;
- this.rgb = rgb;
- }
-
- public String description() {
- return description;
- }
-
- public RGB rgb() {
- return rgb;
- }
-
- @Override
- public String toString() {
- return description();
- }
- }
-
-
- private static class ImageFactory
- {
- private static RGB rgb(Color color, boolean greyed, boolean translucent) {
- RGB rgb = (greyed) ? new RGB(127, 127, 127) : color.rgb();
- if (translucent) {
- rgb = new RGB(translucify(rgb.red), translucify(rgb.green), translucify(rgb.blue));
- }
- return rgb;
- }
-
- private static int translucify(int color) {
- return 255 - (int) ((255 - color) * 0.3);
- }
-
- public static Image image(Color color, boolean greyed, boolean translucent) {
- PaletteData pd = new PaletteData(new RGB[] {rgb(color, greyed, translucent)});
- ImageData id = new ImageData(20, 20, 1, pd);
- for (int x = 0; x < 20; x ++) {
- for (int y = 0; y < 20; y ++) {
- id.setPixel(x, y, 0);
- }
- }
- return new Image(Display.getCurrent(), id);
- }
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/jface/DelegatingTreeContentProviderUiTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/jface/DelegatingTreeContentProviderUiTest.java
deleted file mode 100644
index 87203da17d..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/jface/DelegatingTreeContentProviderUiTest.java
+++ /dev/null
@@ -1,569 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.jface;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.BaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.ui.internal.jface.AbstractTreeItemContentProvider;
-import org.eclipse.jpt.ui.internal.jface.DelegatingTreeContentAndLabelProvider;
-import org.eclipse.jpt.ui.jface.DelegatingContentAndLabelProvider;
-import org.eclipse.jpt.ui.jface.TreeItemContentProvider;
-import org.eclipse.jpt.ui.jface.TreeItemContentProviderFactory;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.CompositeCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.ListCollectionValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.StaticCollectionValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-public class DelegatingTreeContentProviderUiTest extends ApplicationWindow
-{
- private final Root root;
-
- private WritablePropertyValueModel<TreeNode> selectedNode;
-
- private TreeViewer controlTree;
-
- private TreeViewer viewTree;
-
- private Text nodeNameText;
-
-
- public static void main(String[] args) {
- Window window = new DelegatingTreeContentProviderUiTest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
- private DelegatingTreeContentProviderUiTest(String[] args) {
- super(null);
- this.root = new Root();
- this.root.addChild("Parent_1");
- this.selectedNode = new SimplePropertyValueModel<TreeNode>(this.root);
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(ClassTools.shortClassNameForObject(this));
- parent.setSize(800, 400);
- parent.setLayout(new GridLayout());
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
- mainPanel.setLayout(new GridLayout());
- buildTreePanel(mainPanel);
- buildControlPanel(mainPanel);
- return mainPanel;
- }
-
- private void buildTreePanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL_BOTH));
- panel.setLayout(new GridLayout(2, true));
- buildControlTreePanel(panel);
- buildViewTreePanel(panel);
- }
-
- private void buildControlTreePanel(Composite parent) {
- controlTree = buildTreePanel(
- parent, "Control tree",
- new DelegatingTreeContentAndLabelProvider(new ControlTreeItemContentProviderFactory()),
- new LabelProvider());
- controlTree.addSelectionChangedListener(buildTreeSelectionChangedListener());
- selectedNode.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- controlTree.setSelection(new StructuredSelection(event.getNewValue()));
- }
- }
- );
- }
-
- private void buildViewTreePanel(Composite parent) {
- viewTree = buildTreePanel(
- parent, "View tree",
- new DelegatingTreeContentAndLabelProvider(new ViewTreeItemContentProviderFactory()),
- new LabelProvider());
- }
-
- private TreeViewer buildTreePanel(Composite parent, String labelText, ITreeContentProvider contentProvider, ILabelProvider labelProvider) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL_BOTH));
- panel.setLayout(new GridLayout());
-
- Label label = new Label(panel, SWT.LEFT);
- label.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
- label.setText(labelText);
-
- final TreeViewer tree = new TreeViewer(panel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- tree.getTree().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
- tree.setContentProvider(contentProvider);
- tree.setLabelProvider(labelProvider);
- tree.setInput(root);
-
- return tree;
- }
-
- private ISelectionChangedListener buildTreeSelectionChangedListener() {
- return new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- TreeNode selection = (TreeNode) ((IStructuredSelection) event.getSelection()).getFirstElement();
- selectedNode.setValue((selection == null) ? root : selection);
- }
- };
- }
-
- private void buildControlPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
- panel.setLayout(new GridLayout(6, false));
- buildNodeNameText(panel);
- buildAddChildACI().fill(panel);
- buildAddNestedChildACI().fill(panel);
- buildRemoveACI().fill(panel);
- buildClearModelACI().fill(panel);
- buildRestoreModelACI().fill(panel);
- }
-
- private void buildNodeNameText(Composite parent) {
- nodeNameText = new Text(parent, SWT.SINGLE | SWT.BORDER);
- nodeNameText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- }
-
- private ActionContributionItem buildAddChildACI() {
- final Action action = new Action("Add child", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- addChild();
- }
- };
- action.setToolTipText("Add a child with the given name");
- selectedNode.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- action.setEnabled(((TreeNode) event.getNewValue()).canHaveChildren());
- }
- }
- );
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildAddNestedChildACI() {
- final Action action = new Action("Add nested child", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- addNestedChild();
- }
- };
- action.setToolTipText("Add a nested child with the given name");
- action.setEnabled(false);
- selectedNode.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- action.setEnabled(((TreeNode) event.getNewValue()).canHaveNestedChildren());
- }
- }
- );
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildRemoveACI() {
- final Action action = new Action("Remove", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- remove();
- }
- };
- action.setToolTipText("Remove the selected node");
- action.setEnabled(false);
- selectedNode.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- action.setEnabled(event.getNewValue() != root);
- }
- }
- );
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildClearModelACI() {
- Action action = new Action("Clear model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- clearModel();
- }
- };
- action.setToolTipText("Clear the model");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildRestoreModelACI() {
- Action action = new Action("Restore model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- restoreModel();
- }
- };
- action.setToolTipText("Restore the model");
- return new ActionContributionItem(action);
- }
-
- void addChild() {
- String nodeName = nodeNameText.getText();
- if (nodeName.length() != 0) {
- selectedNode.getValue().addChild(nodeName);
- }
- }
-
- void addNestedChild() {
- String nodeName = nodeNameText.getText();
- if (nodeName.length() != 0) {
- selectedNode.getValue().addNestedChild(nodeName);
- }
- }
-
- void remove() {
- TreeNode node = selectedNode.getValue();
- node.parent().removeChild(node);
- }
-
- void clearModel() {
- controlTree.setInput(null);
- viewTree.setInput(null);
- }
-
- void restoreModel() {
- controlTree.setInput(root);
- viewTree.setInput(root);
- }
-
-
- private static abstract class AbstractTreeItemContentProviderFactory
- implements TreeItemContentProviderFactory
- {
- public TreeItemContentProvider buildItemContentProvider(
- Object item, DelegatingContentAndLabelProvider contentAndLabelProvider) {
- return new GenericTreeItemContentProvider(
- (TreeNode) item, (DelegatingTreeContentAndLabelProvider) contentAndLabelProvider);
- }
- }
-
-
- private static class ControlTreeItemContentProviderFactory extends AbstractTreeItemContentProviderFactory
- {
-
- }
-
-
- private static class ViewTreeItemContentProviderFactory
- extends AbstractTreeItemContentProviderFactory
- {
- @Override
- public TreeItemContentProvider buildItemContentProvider(
- Object item, DelegatingContentAndLabelProvider contentAndLabelProvider) {
- if (item instanceof Parent) {
- return new ViewTreeParentItemContentProvider(
- (Parent) item, (DelegatingTreeContentAndLabelProvider) contentAndLabelProvider);
- }
- return super.buildItemContentProvider(item, contentAndLabelProvider);
- }
- }
-
-
- private static class GenericTreeItemContentProvider extends AbstractTreeItemContentProvider<TreeNode>
- {
- public GenericTreeItemContentProvider(
- TreeNode treeNode, DelegatingTreeContentAndLabelProvider treeContentAndLabelProvider) {
- super(treeNode, treeContentAndLabelProvider);
- }
-
- protected TreeNode treeNode() {
- return (TreeNode) model();
- }
-
- @Override
- public TreeNode getParent() {
- return treeNode().parent();
- }
-
- @Override
- protected ListValueModel<TreeNode> buildChildrenModel() {
- return new ListAspectAdapter<TreeNode, TreeNode>(TreeNode.CHILDREN_LIST, treeNode()) {
- @Override
- protected ListIterator<TreeNode> listIterator_() {
- return treeNode().children();
- }
- };
- }
- }
-
- private static class ViewTreeParentItemContentProvider extends GenericTreeItemContentProvider
- {
- public ViewTreeParentItemContentProvider(
- TreeNode treeNode, DelegatingTreeContentAndLabelProvider treeContentAndLabelProvider) {
- super(treeNode, treeContentAndLabelProvider);
- }
-
- @Override
- public TreeNode getParent() {
- TreeNode parent = super.getParent();
- if (parent instanceof Nest) {
- parent = parent.parent();
- }
- return parent;
- }
-
- @Override
- protected ListValueModel<TreeNode> buildChildrenModel() {
- return buildChildrenModel(
- new CompositeCollectionValueModel<TreeNode, TreeNode>(super.buildChildrenModel()) {
- @Override
- protected CollectionValueModel<TreeNode> transform(TreeNode value) {
- if (value instanceof Nest) {
- final Nest nest = (Nest) value;
- return new ListCollectionValueModelAdapter<TreeNode>(
- new ListAspectAdapter<TreeNode, TreeNode>(TreeNode.CHILDREN_LIST, nest) {
- @Override
- protected ListIterator<TreeNode> listIterator_() {
- return nest.children();
- }
- }
- );
- }
- else {
- return new StaticCollectionValueModel<TreeNode>(CollectionTools.collection(value));
- }
- }
- }
- );
- }
- }
-
-
- private static class LabelProvider extends BaseLabelProvider
- implements ILabelProvider
- {
- public Image getImage(Object element) {
- return null;
- }
-
- public String getText(Object element) {
- return ((TreeNode) element).getName();
- }
- }
-
-
- private static abstract class TreeNode extends AbstractModel
- {
- private TreeNode parent;
-
- protected final List<TreeNode> children;
- public final static String CHILDREN_LIST = "children";
-
- protected String name;
- public final static String NAME_PROPERTY = "name";
-
-
- public TreeNode(TreeNode parent, String name) {
- this.parent = parent;
- this.children = new ArrayList<TreeNode>();
- this.name = name;
- }
-
- public TreeNode parent() {
- return parent;
- }
-
- public ListIterator<TreeNode> children() {
- return new ReadOnlyListIterator<TreeNode>(children);
- }
-
- protected void addChild(TreeNode child) {
- addItemToList(child, children, CHILDREN_LIST);
- }
-
- public void removeChild(TreeNode child) {
- removeItemFromList(child, children, CHILDREN_LIST);
- }
-
- public void removeChild(int index) {
- removeItemFromList(index, children, CHILDREN_LIST);
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String newName) {
- String oldName = name;
- name = newName;
- firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
- public boolean canHaveChildren() {
- return false;
- }
-
- public void addChild(String name) {
- throw new UnsupportedOperationException();
- }
-
- public boolean canHaveNestedChildren() {
- return false;
- }
-
- public void addNestedChild(String name) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(getName());
- }
- }
-
-
- private static class Root extends TreeNode
- {
- public Root() {
- super(null, null);
- }
-
- @Override
- public boolean canHaveChildren() {
- return true;
- }
-
- @Override
- public void addChild(String name) {
- addChild(new Parent(this, name));
- }
- }
-
-
- private static class Parent extends TreeNode
- {
- public Parent(TreeNode parent, String name) {
- super(parent, name);
- }
-
- @Override
- public boolean canHaveChildren() {
- return true;
- }
-
- @Override
- public void addChild(String name) {
- addChild(new Child(this, name));
- }
-
- @Override
- public boolean canHaveNestedChildren() {
- return true;
- }
-
- @Override
- public void addNestedChild(String name) {
- TreeNode nest = new Nest(this);
- addChild(nest);
- nest.addChild(name);
- }
-
- public Iterator<Child> nestlessChildren() {
- return new FilteringIterator<Child, Child>(
- new TransformationIterator<TreeNode, Child>(children()) {
- @Override
- protected Child transform(TreeNode next) {
- if (next instanceof Nest) {
- return ((Nest) next).child();
- }
- return (Child) next;
- }
- }) {
- @Override
- protected boolean accept(Child c) {
- return c != null;
- }
- };
- }
- }
-
-
- private static class Nest extends TreeNode
- {
- public Nest(TreeNode parent) {
- super(parent, "nest");
- }
-
- @Override
- public boolean canHaveChildren() {
- return children.size() == 0;
- }
-
- @Override
- public void addChild(String name) {
- addChild(new Child(this, name));
- }
-
- /* can only have one child */
- public Child child() {
- return (children.isEmpty()) ? null : (Child) children.get(0);
- }
- }
-
-
- private static class Child extends TreeNode
- {
- public Child(TreeNode parent, String name) {
- super(parent, name);
- }
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/platform/JpaPlatformUiExtensionTests.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/platform/JpaPlatformUiExtensionTests.java
deleted file mode 100644
index 34428a1107..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/platform/JpaPlatformUiExtensionTests.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.eclipse.jpt.ui.tests.internal.platform;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.internal.platform.JpaPlatformRegistry;
-import org.eclipse.jpt.core.tests.extension.resource.ExtensionTestPlugin;
-import org.eclipse.jpt.core.tests.extension.resource.TestJpaPlatform;
-import org.eclipse.jpt.core.tests.extension.resource.TestJpaPlatformUi;
-import org.eclipse.jpt.core.tests.internal.ProjectUtility;
-import org.eclipse.jpt.core.tests.internal.projects.TestJpaProject;
-
-public class JpaPlatformUiExtensionTests extends TestCase
-{
- protected TestJpaProject testProject;
-
- protected static final String PROJECT_NAME = "ExtensionTestProject";
- protected static final String PACKAGE_NAME = "extension.test";
-
- public static final String TEST_PLUGIN_CLASS = ExtensionTestPlugin.class.getName();
- public static final String TEST_PLUGIN_ID = ExtensionTestPlugin.PLUGIN_ID;
-
- public static final String TEST_PLATFORM_ID = TestJpaPlatform.ID;
- public static final String TEST_PLATFORM_CLASS = TestJpaPlatform.class.getName();
- public static final String TEST_PLATFORM_LABEL = "Test Jpa Platform";
-
- public static final String TEST_UI_PLATFORM_ID = TEST_PLATFORM_ID;
- public static final String TEST_UI_PLATFORM_CLASS = TestJpaPlatformUi.class.getName();
-
- public JpaPlatformUiExtensionTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.testProject = this.buildJpaProject(PROJECT_NAME, false); // false = no auto-build
- }
-
- protected TestJpaProject buildJpaProject(String projectName, boolean autoBuild) throws Exception {
- return new TestJpaProject(projectName, autoBuild); // false = no auto-build
- }
-
- @Override
- protected void tearDown() throws Exception {
- //testProject.dispose();
- ProjectUtility.deleteAllProjects();
- this.testProject = null;
- super.tearDown();
- }
-
- protected JpaProject jpaProject() {
- return this.testProject.getJpaProject();
- }
-
- public void testJpaPlatform() {
- assertNotNull(JpaPlatformRegistry.instance().getJpaPlatform(jpaProject().getJpaPlatform().getId()));
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/platform/JptUiPlatformTests.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/platform/JptUiPlatformTests.java
deleted file mode 100644
index 50bcc99cfc..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/platform/JptUiPlatformTests.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.platform;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptUiPlatformTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUiPlatformTests.class.getPackage().getName());
- suite.addTestSuite(JpaPlatformUiExtensionTests.class);
- return suite;
- }
-
- private JptUiPlatformTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/AbstractComboModelAdapterTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/AbstractComboModelAdapterTest.java
deleted file mode 100644
index eb4c175513..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/AbstractComboModelAdapterTest.java
+++ /dev/null
@@ -1,780 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.swt;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jpt.ui.internal.swt.AbstractComboModelAdapter;
-import org.eclipse.jpt.ui.internal.swt.AbstractComboModelAdapter.SelectionChangeEvent;
-import org.eclipse.jpt.ui.internal.swt.AbstractComboModelAdapter.SelectionChangeListener;
-import org.eclipse.jpt.utility.internal.StringConverter;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.swing.SimpleDisplayable;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-@SuppressWarnings("nls")
-public abstract class AbstractComboModelAdapterTest {
-
- private Model model;
- private WritablePropertyValueModel<SimpleDisplayable> selectedItemHolder;
- private Shell shell;
- private WritablePropertyValueModel<Model> subjectHolder;
-
- protected abstract AbstractComboModelAdapter<SimpleDisplayable> buildEditableComboModelAdapter();
-
- protected final ListValueModel<SimpleDisplayable> buildEmptyListHolder() {
- return new SimpleListValueModel<SimpleDisplayable>();
- }
-
- private List<SimpleDisplayable> buildList() {
- List<SimpleDisplayable> list = new ArrayList<SimpleDisplayable>();
- populateCollection(list);
- return list;
- }
-
- protected final ListValueModel<SimpleDisplayable> buildListHolder() {
- return new ListAspectAdapter<Model, SimpleDisplayable>(subjectHolder, Model.ITEMS_LIST) {
- @Override
- protected ListIterator<SimpleDisplayable> listIterator_() {
- return subject.items();
- }
-
- @Override
- protected int size_() {
- return subject.itemsSize();
- }
- };
- }
-
- protected abstract AbstractComboModelAdapter<SimpleDisplayable> buildReadOnlyComboModelAdapter();
-
- private SimpleDisplayable buildSelectedItem() {
- return new SimpleDisplayable("baz");
- }
-
- private WritablePropertyValueModel<SimpleDisplayable> buildSelectedItemHolder() {
- return new PropertyAspectAdapter<Model, SimpleDisplayable>(subjectHolder, Model.ITEM_PROPERTY) {
- @Override
- protected SimpleDisplayable buildValue_() {
- return subject.getItem();
- }
-
- @Override
- protected void setValue_(SimpleDisplayable value) {
- subject.setItem(value);
- }
- };
- }
-
- protected final StringConverter<SimpleDisplayable> buildStringConverter() {
- return new StringConverter<SimpleDisplayable>() {
- public String convertToString(SimpleDisplayable value) {
- return (value == null) ? "" : value.displayString();
- }
- };
- }
-
- private WritablePropertyValueModel<Model> buildSubjectHolder() {
- return new SimplePropertyValueModel<Model>();
- }
-
- public abstract String comboSelectedItem();
-
- protected abstract boolean emptyComboCanHaveSelectedValue();
-
- protected abstract String itemAt(int index);
-
- protected abstract int itemCounts();
-
- private void populateCollection(Collection<SimpleDisplayable> c) {
- c.add(new SimpleDisplayable("foo"));
- c.add(new SimpleDisplayable("bar"));
- c.add(new SimpleDisplayable("baz"));
- c.add(new SimpleDisplayable("joo"));
- c.add(new SimpleDisplayable("jar"));
- c.add(new SimpleDisplayable("jaz"));
- }
-
- protected final WritablePropertyValueModel<SimpleDisplayable> selectedItemHolder() {
- return selectedItemHolder;
- }
-
- @Before
- public void setUp() throws Exception {
-
- shell = new Shell(Display.getCurrent());
- model = new Model();
- subjectHolder = buildSubjectHolder();
- selectedItemHolder = buildSelectedItemHolder();
- }
-
- protected final Shell shell() {
- return shell;
- }
-
- protected final WritablePropertyValueModel<Model> subjectHolder() {
- return subjectHolder;
- }
-
- @After
- public void tearDown() throws Exception {
-
- if (!shell.isDisposed()) {
- shell.dispose();
- }
-
- shell = null;
- subjectHolder = null;
- selectedItemHolder = null;
- }
-
- private void testItems() {
-
- assertEquals(
- "The count of items is not in sync with the model",
- model.itemsSize(),
- itemCounts()
- );
-
- for (int index = 0; index < model.itemsSize(); index++) {
- assertEquals(
- "The item at index " + index + " is not the same between the model and the combo",
- model.itemAt(index).displayString(),
- itemAt(index)
- );
- }
- }
-
- @Test
- public void testNonNullSubjectAfter_AddedAfter_ReadOnly() throws Exception {
-
- buildReadOnlyComboModelAdapter();
- testRemoveItems_AddedAfter();
- }
-
- @Test
- public void testNonNullSubjectAfter_AddedAfter_RemoveItems_Editable() throws Exception {
-
- buildEditableComboModelAdapter();
- testRemoveItems_AddedAfter();
- }
-
- @Test
- public void testNonNullSubjectAfter_AddedBefore_RemoveItems_Editable() throws Exception {
-
- subjectHolder.setValue(model);
- model.addItems(buildList());
-
- buildEditableComboModelAdapter();
- testSelectedItem(null);
- testItems();
-
- ArrayList<SimpleDisplayable> items = new ArrayList<SimpleDisplayable>();
- items.add(model.itemAt(0));
- items.add(model.itemAt(3));
- model.removeItems(items.iterator());
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_AddedBefore_RemoveItems_ReadOnly() throws Exception {
-
- subjectHolder.setValue(model);
- model.addItems(buildList());
-
- buildReadOnlyComboModelAdapter();
- testSelectedItem(null);
- testItems();
-
- ArrayList<SimpleDisplayable> items = new ArrayList<SimpleDisplayable>();
- items.add(model.itemAt(0));
- items.add(model.itemAt(3));
- model.removeItems(items.iterator());
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_ItemsAfterAfter_Editable() throws Exception {
-
- buildEditableComboModelAdapter();
-
- subjectHolder.setValue(model);
- model.addItems(buildList());
-
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_ItemsAfterAfter_ReadOnly() throws Exception {
-
- buildReadOnlyComboModelAdapter();
-
- subjectHolder.setValue(model);
- model.addItems(buildList());
-
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_ItemsAfterBefore_Editable() throws Exception {
-
- buildEditableComboModelAdapter();
-
- model.addItems(buildList());
- subjectHolder.setValue(model);
-
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_ItemsAfterBefore_ReadOnly() throws Exception {
-
- buildReadOnlyComboModelAdapter();
-
- model.addItems(buildList());
- subjectHolder.setValue(model);
-
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_ItemsBefore_Editable() throws Exception {
-
- model.addItems(buildList());
- buildEditableComboModelAdapter();
-
- subjectHolder.setValue(model);
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_ItemsBefore_ReadOnly() throws Exception {
-
- model.addItems(buildList());
- buildReadOnlyComboModelAdapter();
-
- subjectHolder.setValue(model);
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_NoItems_Editable() throws Exception {
-
- buildEditableComboModelAdapter();
-
- subjectHolder.setValue(model);
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_NoItems_ReadOnly() throws Exception {
-
- buildReadOnlyComboModelAdapter();
-
- subjectHolder.setValue(model);
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_SelectedItemChanged_ReadOnly() throws Exception {
-
- subjectHolder.setValue(model);
- model.addItems(buildList());
-
- SimpleDisplayable selectedItem = model.itemAt(0);
-
- AbstractComboModelAdapter<SimpleDisplayable> adapter = buildEditableComboModelAdapter();
- SelectionListener selectionListener = new SelectionListener();
- adapter.addSelectionChangeListener(selectionListener);
-
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
- testSelectedItem(null);
-
- testSelectedItemChanged(selectedItem, selectionListener);
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemAfter_Editable() throws Exception {
-
- SimpleDisplayable selectedItem = buildSelectedItem();
- subjectHolder.setValue(model);
-
- buildEditableComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemAfter_Items_Editable() throws Exception {
-
- SimpleDisplayable selectedItem = buildSelectedItem();
- subjectHolder.setValue(model);
-
- buildEditableComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemAfter_Items_ReadOnly() throws Exception {
-
- List<SimpleDisplayable> list = buildList();
- SimpleDisplayable selectedItem = list.get(0);
- subjectHolder.setValue(model);
-
- buildReadOnlyComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemAfter_ReadOnly() throws Exception {
-
- List<SimpleDisplayable> list = buildList();
- SimpleDisplayable selectedItem = list.get(0);
- subjectHolder.setValue(model);
-
- buildReadOnlyComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemBefore_Editable() throws Exception {
-
- model.addItems(buildList());
- SimpleDisplayable selectedItem = model.itemAt(0);
- subjectHolder.setValue(model);
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- model.clearItemCalledFlag();
- buildEditableComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemBefore_Items_Editable() throws Exception {
-
- model.addItems(buildList());
- SimpleDisplayable selectedItem = model.itemAt(0);
- subjectHolder.setValue(model);
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- model.clearItemCalledFlag();
- buildEditableComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemBefore_Items_ReadOnly() throws Exception {
-
- List<SimpleDisplayable> list = buildList();
- SimpleDisplayable selectedItem = list.get(0);
- subjectHolder.setValue(model);
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- model.clearItemCalledFlag();
- buildReadOnlyComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemBefore_ReadOnly() throws Exception {
-
- List<SimpleDisplayable> list = buildList();
- SimpleDisplayable selectedItem = list.get(0);
- subjectHolder.setValue(model);
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- model.clearItemCalledFlag();
- buildReadOnlyComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NullSelectedItem_Items_Editable() throws Exception {
-
- subjectHolder.setValue(model);
-
- buildEditableComboModelAdapter();
-
- assertFalse("The item wasn't supposed to be modified", model.isSetItemCalled());
- assertNull("The selected item is supposed to remain null", model.getItem());
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NullSelectedItem_Items_ReadOnly() throws Exception {
-
- subjectHolder.setValue(model);
-
- buildEditableComboModelAdapter();
-
- assertFalse("The item wasn't supposed to be modified", model.isSetItemCalled());
- assertNull("The selected item is supposed to remain null", model.getItem());
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NullSelectedItem_NoItems_Editable() throws Exception {
-
- subjectHolder.setValue(model);
-
- buildEditableComboModelAdapter();
-
- assertFalse("The item wasn't supposed to be modified", model.isSetItemCalled());
- assertNull("The selected item is supposed to remain null", model.getItem());
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NullSelectedItem_NoItems_ReadOnly() throws Exception {
-
- subjectHolder.setValue(model);
-
- buildEditableComboModelAdapter();
-
- assertFalse("The item wasn't supposed to be modified", model.isSetItemCalled());
- assertNull("The selected item is supposed to remain null", model.getItem());
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_SelectedItemChanged_Editable() throws Exception {
-
- model.addItems(buildList());
-
- SimpleDisplayable selectedItem = model.itemAt(3);
- subjectHolder.setValue(model);
-
- AbstractComboModelAdapter<SimpleDisplayable> adapter = buildEditableComboModelAdapter();
- SelectionListener selectionListener = new SelectionListener();
- adapter.addSelectionChangeListener(selectionListener);
-
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
- testSelectedItem(null);
-
- testSelectedItemChanged(selectedItem, selectionListener);
- }
-
- private void testNullSubject() throws Exception {
-
- assertNull("The selected item should be null", selectedItemHolder.getValue());
-
- selectedItemHolder.setValue(buildSelectedItem());
- assertFalse("The item wasn't supposed to be modified", model.isSetItemCalled());
-
- // Null because the subject holder doesn't have the subject set
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNullSubject_NullSelectedItem_Items_Editable() throws Exception {
- buildEditableComboModelAdapter();
- testNullSubject();
- testItems();
- testSelectedItem(null);
- }
-
- @Test
- public void testNullSubject_NullSelectedItem_Items_ReadOnly() throws Exception {
- buildReadOnlyComboModelAdapter();
- testNullSubject();
- testItems();
- testSelectedItem(null);
- }
-
- @Test
- public void testNullSubject_NullSelectedItem_NoItems_Editable() throws Exception {
- buildEditableComboModelAdapter();
- testNullSubject();
- testItems();
- testSelectedItem(null);
- }
-
- @Test
- public void testNullSubject_NullSelectedItem_NoItems_ReadOnly() throws Exception {
- buildReadOnlyComboModelAdapter();
- testNullSubject();
- testItems();
- testSelectedItem(null);
- }
-
- private void testRemoveItems_AddedAfter() {
-
- subjectHolder.setValue(model);
- model.addItems(buildList());
-
- testSelectedItem(null);
- testItems();
- testSelectedItem(null);
-
- ArrayList<SimpleDisplayable> items = new ArrayList<SimpleDisplayable>();
- items.add(model.itemAt(0));
- items.add(model.itemAt(3));
- model.removeItems(items.iterator());
-
- testItems();
- testSelectedItem(null);
- }
-
- private void testSelectedItem(SimpleDisplayable selectedItem) {
-
- if (selectedItem == null) {
-
- assertNull(
- "The selected item is supposed to be null",
- model.getItem()
- );
-
- assertEquals(
- "The combo's selected item should be null",
- "",
- comboSelectedItem()
- );
- }
- else if (!emptyComboCanHaveSelectedValue()) {
-
- assertEquals(
- "The selected item wasn't set correctly",
- selectedItem,
- model.getItem()
- );
-
- assertEquals(
- "The combo's selected item should be null",
- "",
- comboSelectedItem()
- );
- }
- else {
-
- assertEquals(
- "The selected item wasn't set correctly",
- selectedItem,
- model.getItem()
- );
-
- assertEquals(
- "The selected item wasn't set correctly",
- selectedItem.displayString(),
- comboSelectedItem()
- );
- }
- }
-
- private void testSelectedItemChanged(SimpleDisplayable selectedItem,
- SelectionListener selectionListener) {
-
- // Test 1
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
- assertTrue("The SelectionListener was supposed to be notified", selectionListener.isListenerNotified());
- assertSame("The SelectionListener was supposed to be notified", selectedItem, selectionListener.getItem());
- testSelectedItem(selectedItem);
-
- // Test 2
- selectedItem = model.itemAt(1);
- model.clearItemCalledFlag();
- selectionListener.clearInfo();
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
- assertTrue("The SelectionListener was supposed to be notified", selectionListener.isListenerNotified());
- assertSame("The SelectionListener was supposed to be notified", selectedItem, selectionListener.getItem());
- testSelectedItem(selectedItem);
-
- // Test 3
- selectedItem = null;
- model.clearItemCalledFlag();
- selectionListener.clearInfo();
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertNull("The selected item wasn't set properly", model.getItem());
- assertTrue("The SelectionListener was supposed to be notified", selectionListener.isListenerNotified());
- assertSame("The SelectionListener was supposed to be notified", selectedItem, selectionListener.getItem());
- testSelectedItem(selectedItem);
-
- // Test 3
- selectedItem = model.itemAt(2);
- model.clearItemCalledFlag();
- selectionListener.clearInfo();
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
- assertTrue("The SelectionListener was supposed to be notified", selectionListener.isListenerNotified());
- assertSame("The SelectionListener was supposed to be notified", selectedItem, selectionListener.getItem());
- testSelectedItem(selectedItem);
- }
-
- private static class Model extends AbstractModel {
-
- private SimpleDisplayable item;
- private List<SimpleDisplayable> items;
- private boolean setItemCalled;
-
- static final String ITEM_PROPERTY = "item";
- static final String ITEMS_LIST = "items";
-
- void addItems(Iterator<SimpleDisplayable> items) {
- addItemsToList(items, this.items, ITEMS_LIST);
- }
-
- void addItems(List<SimpleDisplayable> items) {
- addItemsToList(items, this.items, ITEMS_LIST);
- }
-
- void clearItemCalledFlag() {
- setItemCalled = false;
- }
-
- SimpleDisplayable getItem() {
- return item;
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- items = new ArrayList<SimpleDisplayable>();
- }
-
- boolean isSetItemCalled() {
- return setItemCalled;
- }
-
- SimpleDisplayable itemAt(int index) {
- return this.items.get(index);
- }
-
- ListIterator<SimpleDisplayable> items() {
- return items.listIterator();
- }
-
- int itemsSize() {
- return items.size();
- }
-
- void removeItems(Iterator<SimpleDisplayable> items) {
- removeItemsFromList(items, this.items, ITEMS_LIST);
- }
-
- void setItem(SimpleDisplayable item) {
- setItemCalled = true;
-
- SimpleDisplayable oldItem = this.item;
- this.item = item;
- firePropertyChanged(ITEM_PROPERTY, oldItem, item);
- }
- }
-
- private class SelectionListener implements SelectionChangeListener<SimpleDisplayable> {
-
- private SimpleDisplayable item;
- private boolean listenerNotified;
-
- void clearInfo() {
- this.listenerNotified = false;
- this.item = null;
- }
-
- SimpleDisplayable getItem() {
- return item;
- }
-
- public boolean isListenerNotified() {
- return listenerNotified;
- }
-
- public void selectionChanged(SelectionChangeEvent<SimpleDisplayable> e) {
- listenerNotified = true;
- item = e.selectedItem();
- }
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/CComboModelAdapterTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/CComboModelAdapterTest.java
deleted file mode 100644
index 4cf143eb90..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/CComboModelAdapterTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.swt;
-
-import org.eclipse.jpt.ui.internal.swt.AbstractComboModelAdapter;
-import org.eclipse.jpt.ui.internal.swt.CComboModelAdapter;
-import org.eclipse.jpt.utility.internal.swing.SimpleDisplayable;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.junit.After;
-
-public class CComboModelAdapterTest extends AbstractComboModelAdapterTest {
-
- private CCombo combo;
-
- @Override
- protected AbstractComboModelAdapter<SimpleDisplayable> buildEditableComboModelAdapter() {
-
- combo = new CCombo(shell(), SWT.NULL);
-
- return CComboModelAdapter.adapt(
- buildListHolder(),
- selectedItemHolder(),
- combo,
- buildStringConverter()
- );
- }
-
- @Override
- protected AbstractComboModelAdapter<SimpleDisplayable> buildReadOnlyComboModelAdapter() {
-
- combo = new CCombo(shell(), SWT.READ_ONLY);
-
- return CComboModelAdapter.adapt(
- buildListHolder(),
- selectedItemHolder(),
- combo,
- buildStringConverter()
- );
- }
-
- @Override
- public String comboSelectedItem() {
- return combo.getText();
- }
-
- @Override
- protected boolean emptyComboCanHaveSelectedValue() {
- return true;
- }
-
- @Override
- protected String itemAt(int index) {
- return this.combo.getItem(index);
- }
-
- @Override
- protected int itemCounts() {
- return combo.getItemCount();
- }
-
- @After
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- combo = null;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/CheckBoxModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/CheckBoxModelAdapterUITest.java
deleted file mode 100644
index d2cf139f45..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/CheckBoxModelAdapterUITest.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.swt;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.ui.internal.swt.BooleanButtonModelAdapter;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Play around with a set of check boxes.
- */
-public class CheckBoxModelAdapterUITest
- extends ApplicationWindow
-{
- private final TestModel testModel;
- private final WritablePropertyValueModel<TestModel> testModelHolder;
- private final WritablePropertyValueModel<Boolean> flag1Holder;
- private final WritablePropertyValueModel<Boolean> flag2Holder;
- private final WritablePropertyValueModel<Boolean> notFlag2Holder;
-
- public static void main(String[] args) throws Exception {
- Window window = new CheckBoxModelAdapterUITest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
- private CheckBoxModelAdapterUITest(String[] args) {
- super(null);
- this.testModel = new TestModel(true, true);
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.flag1Holder = this.buildFlag1Holder(this.testModelHolder);
- this.flag2Holder = this.buildFlag2Holder(this.testModelHolder);
- this.notFlag2Holder = this.buildNotFlag2Holder(this.testModelHolder);
- }
-
- private WritablePropertyValueModel<Boolean> buildFlag1Holder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Boolean>(subjectHolder, TestModel.FLAG1_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isFlag1());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setFlag1(value.booleanValue());
- }
- };
- }
-
- private WritablePropertyValueModel<Boolean> buildFlag2Holder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Boolean>(subjectHolder, TestModel.FLAG2_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isFlag2());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setFlag2(value.booleanValue());
- }
- };
- }
-
- private WritablePropertyValueModel<Boolean> buildNotFlag2Holder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Boolean>(subjectHolder, TestModel.NOT_FLAG2_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isNotFlag2());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setNotFlag2(value.booleanValue());
- }
- };
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(ClassTools.shortClassNameForObject(this));
- parent.setSize(400, 100);
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayout(new FormLayout());
- Control checkBoxPanel = this.buildCheckBoxPanel(mainPanel);
- this.buildControlPanel(mainPanel, checkBoxPanel);
- return mainPanel;
- }
-
- private Control buildCheckBoxPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100, -35);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildFlag1CheckBox(panel);
- this.buildFlag2CheckBox(panel);
- this.buildNotFlag2CheckBox(panel);
- this.buildUnattachedCheckBox(panel);
-
- return panel;
- }
-
- private void buildFlag1CheckBox(Composite parent) {
- Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText("flag 1");
- BooleanButtonModelAdapter.adapt(this.flag1Holder, checkBox);
- }
-
- private void buildFlag2CheckBox(Composite parent) {
- Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText("flag 2");
- BooleanButtonModelAdapter.adapt(this.flag2Holder, checkBox);
- }
-
- private void buildNotFlag2CheckBox(Composite parent) {
- Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText("not flag 2");
- BooleanButtonModelAdapter.adapt(this.notFlag2Holder, checkBox);
- }
-
- private void buildUnattachedCheckBox(Composite parent) {
- Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText("unattached");
- checkBox.addSelectionListener(this.buildUnattachedSelectionListener());
- }
-
- private SelectionListener buildUnattachedSelectionListener() {
- return new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- System.out.println("unattached default selected: " + e);
- }
- public void widgetSelected(SelectionEvent e) {
- System.out.println("unattached selected: " + e);
- }
- };
- }
-
- private void buildControlPanel(Composite parent, Control checkBoxPanel) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(checkBoxPanel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildFlipFlag1Button(panel);
- this.buildNotFlag2ToggleButton(panel);
- this.buildClearModelButton(panel);
- this.buildRestoreModelButton(panel);
- this.buildPrintModelButton(panel);
- }
-
- private void buildFlipFlag1Button(Composite parent) {
- this.buildFlipFlag1ACI().fill(parent);
- }
-
- private ActionContributionItem buildFlipFlag1ACI() {
- Action action = new Action("flip flag 1", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- CheckBoxModelAdapterUITest.this.flipFlag1();
- }
- };
- action.setToolTipText("flip flag 1");
- return new ActionContributionItem(action);
- }
-
- void flipFlag1() {
- this.testModel.setFlag1( ! this.testModel.isFlag1());
- }
-
- private void buildNotFlag2ToggleButton(Composite parent) {
- Button checkBox = new Button(parent, SWT.TOGGLE);
- checkBox.setText("not flag 2");
- BooleanButtonModelAdapter.adapt(this.notFlag2Holder, checkBox);
- }
-
- private void buildClearModelButton(Composite parent) {
- this.buildClearModelACI().fill(parent);
- }
-
- private ActionContributionItem buildClearModelACI() {
- Action action = new Action("clear model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- CheckBoxModelAdapterUITest.this.clearModel();
- }
- };
- action.setToolTipText("clear model");
- return new ActionContributionItem(action);
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private void buildRestoreModelButton(Composite parent) {
- this.buildRestoreModelACI().fill(parent);
- }
-
- private ActionContributionItem buildRestoreModelACI() {
- Action action = new Action("restore model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- CheckBoxModelAdapterUITest.this.restoreModel();
- }
- };
- action.setToolTipText("restore model");
- return new ActionContributionItem(action);
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private void buildPrintModelButton(Composite parent) {
- this.buildPrintModelACI().fill(parent);
- }
-
- private ActionContributionItem buildPrintModelACI() {
- Action action = new Action("print model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- CheckBoxModelAdapterUITest.this.printModel();
- }
- };
- action.setToolTipText("print model");
- return new ActionContributionItem(action);
- }
-
- void printModel() {
- System.out.println("flag 1: " + this.testModel.isFlag1());
- System.out.println("flag 2: " + this.testModel.isFlag2());
- System.out.println("not flag 2: " + this.testModel.isNotFlag2());
- System.out.println("***");
- }
-
-
- private class TestModel extends AbstractModel {
- private boolean flag1;
- public static final String FLAG1_PROPERTY = "flag1";
- private boolean flag2;
- public static final String FLAG2_PROPERTY = "flag2";
- private boolean notFlag2;
- public static final String NOT_FLAG2_PROPERTY = "notFlag2";
-
- public TestModel(boolean flag1, boolean flag2) {
- this.flag1 = flag1;
- this.flag2 = flag2;
- this.notFlag2 = ! flag2;
- }
- public boolean isFlag1() {
- return this.flag1;
- }
- public void setFlag1(boolean flag1) {
- boolean old = this.flag1;
- this.flag1 = flag1;
- this.firePropertyChanged(FLAG1_PROPERTY, old, flag1);
- }
- public boolean isFlag2() {
- return this.flag2;
- }
- public void setFlag2(boolean flag2) {
- boolean old = this.flag2;
- this.flag2 = flag2;
- this.firePropertyChanged(FLAG2_PROPERTY, old, flag2);
-
- old = this.notFlag2;
- this.notFlag2 = ! flag2;
- this.firePropertyChanged(NOT_FLAG2_PROPERTY, old, this.notFlag2);
- }
- public boolean isNotFlag2() {
- return this.notFlag2;
- }
- public void setNotFlag2(boolean notFlag2) {
- this.setFlag2( ! notFlag2);
- }
- @Override
- public String toString() {
- return "TestModel(" + this.isFlag1() + " - " + this.isFlag2() + ")";
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/ComboModelAdapterTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/ComboModelAdapterTest.java
deleted file mode 100644
index 0fb152a17f..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/ComboModelAdapterTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.swt;
-
-import org.eclipse.jpt.ui.internal.swt.AbstractComboModelAdapter;
-import org.eclipse.jpt.ui.internal.swt.ComboModelAdapter;
-import org.eclipse.jpt.utility.internal.swing.SimpleDisplayable;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Combo;
-import org.junit.After;
-
-public class ComboModelAdapterTest extends AbstractComboModelAdapterTest {
-
- private Combo combo;
- private boolean editable;
-
- @Override
- protected AbstractComboModelAdapter<SimpleDisplayable> buildEditableComboModelAdapter() {
-
- combo = new Combo(shell(), SWT.NULL);
- editable = true;
-
- return ComboModelAdapter.adapt(
- buildListHolder(),
- selectedItemHolder(),
- combo,
- buildStringConverter()
- );
- }
-
- @Override
- protected AbstractComboModelAdapter<SimpleDisplayable> buildReadOnlyComboModelAdapter() {
-
- combo = new Combo(shell(), SWT.READ_ONLY);
- editable = false;
-
- return ComboModelAdapter.adapt(
- buildListHolder(),
- selectedItemHolder(),
- combo,
- buildStringConverter()
- );
- }
-
- @Override
- public String comboSelectedItem() {
- return combo.getText();
- }
-
- @Override
- protected boolean emptyComboCanHaveSelectedValue() {
- return editable;
- }
-
- @Override
- protected String itemAt(int index) {
- return this.combo.getItem(index);
- }
-
- @Override
- protected int itemCounts() {
- return combo.getItemCount();
- }
-
- @After
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- combo = null;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/JptUiSWTTests.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/JptUiSWTTests.java
deleted file mode 100644
index 12a8c2fbce..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/JptUiSWTTests.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.swt;
-
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@SuiteClasses
-({
- CComboModelAdapterTest.class,
- ComboModelAdapterTest.class,
- SpinnerModelAdapterTest.class,
- TableModelAdapterTest.class
-})
-@RunWith(Suite.class)
-public final class JptUiSWTTests {
-
- private JptUiSWTTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(JptUiSWTTests.class));
- return suite;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/ListBoxModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/ListBoxModelAdapterUITest.java
deleted file mode 100644
index b3efc50bfa..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/ListBoxModelAdapterUITest.java
+++ /dev/null
@@ -1,641 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.swt;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.ui.internal.swt.ListBoxModelAdapter;
-import org.eclipse.jpt.ui.internal.swt.ListBoxModelAdapter.SelectionChangeEvent;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.CollectionAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * an example UI for testing various permutations of the
- * StructuredContentProviderAdapter
- */
-public class ListBoxModelAdapterUITest
- extends ApplicationWindow
-{
- final TaskList taskList;
- private final WritablePropertyValueModel<TaskList> taskListHolder;
- private Text taskTextField;
-
- public static void main(String[] args) throws Exception {
- Window window = new ListBoxModelAdapterUITest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
- private ListBoxModelAdapterUITest(String[] args) {
- super(null);
- this.taskList = new TaskList();
- this.taskListHolder = new SimplePropertyValueModel<TaskList>(this.taskList);
- this.taskList.addTask("swim");
- this.taskList.addTask("bike");
- this.taskList.addTask("run");
- Task rest = this.taskList.addTask("rest");
- this.taskList.addPriorityTask(rest);
- Task repeat = this.taskList.addTask("repeat");
- this.taskList.addPriorityTask(repeat);
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(ClassTools.shortClassNameForObject(this));
- parent.setSize(800, 400);
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayout(new FormLayout());
- Control taskListPanel = this.buildTaskListPanel(mainPanel);
- this.buildControlPanel(mainPanel, taskListPanel);
- return mainPanel;
- }
-
- private Control buildTaskListPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100, -30);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FormLayout());
- this.buildPrimitiveTaskListPanel(panel);
- this.buildObjectTaskListPanel(panel);
-
- return panel;
- }
-
- private void buildPrimitiveTaskListPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(50);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildUnsortedPrimitiveListPanel(panel);
- this.buildStandardSortedPrimitiveListPanel(panel);
- this.buildCustomSortedPrimitiveListPanel(panel);
- }
-
- private void buildObjectTaskListPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(50);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildUnsortedObjectListPanel(panel);
- this.buildStandardSortedObjectListPanel(panel);
- this.buildCustomSortedObjectListPanel(panel);
- }
-
- private void buildUnsortedPrimitiveListPanel(Composite parent) {
- this.buildListPanel(parent, "primitive unsorted", this.buildUnsortedPrimitiveListModel(), new SimpleCollectionValueModel<String>());
- }
-
- private void buildStandardSortedPrimitiveListPanel(Composite parent) {
- this.buildListPanel(parent, "primitive sorted", this.buildStandardSortedPrimitiveListModel(), new SimpleCollectionValueModel<String>());
- }
-
- private void buildCustomSortedPrimitiveListPanel(Composite parent) {
- this.buildListPanel(parent, "primitive reverse sorted", this.buildCustomSortedPrimitiveListModel(), new SimpleCollectionValueModel<String>());
- }
-
- private void buildUnsortedObjectListPanel(Composite parent) {
- this.buildListPanel2(parent, "object unsorted", this.buildUnsortedObjectListModel(), this.buildPriorityTaskListAdapter());
- }
-
- private void buildStandardSortedObjectListPanel(Composite parent) {
- this.buildListPanel2(parent, "object sorted", this.buildStandardSortedObjectListModel(), this.buildPriorityTaskListAdapter());
- }
-
- private void buildCustomSortedObjectListPanel(Composite parent) {
- this.buildListPanel2(parent, "object reverse sorted", this.buildCustomSortedObjectListModel(), this.buildPriorityTaskListAdapter());
- }
-
- private ListValueModel<String> buildUnsortedPrimitiveListModel() {
- return this.buildPrimitiveTaskListAdapter();
- }
-
- private ListValueModel<String> buildStandardSortedPrimitiveListModel() {
- return new SortedListValueModelAdapter<String>(this.buildPrimitiveTaskListAdapter());
- }
-
- private ListValueModel<String> buildCustomSortedPrimitiveListModel() {
- return new SortedListValueModelAdapter<String>(this.buildPrimitiveTaskListAdapter(), this.buildCustomStringComparator());
- }
-
- private ListValueModel<Task> buildUnsortedObjectListModel() {
- return this.buildObjectTaskListAdapter();
- }
-
- private ListValueModel<Task> buildStandardSortedObjectListModel() {
- return new SortedListValueModelAdapter<Task>(this.buildObjectTaskListAdapter());
- }
-
- private ListValueModel<Task> buildCustomSortedObjectListModel() {
- return new SortedListValueModelAdapter<Task>(this.buildObjectTaskListAdapter(), this.buildCustomTaskComparator());
- }
-
- private <E> ListBoxModelAdapter<E> buildListPanel(Composite parent, String label, ListValueModel<E> model, CollectionValueModel<E> selectedItemsModel) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayout(new FormLayout());
-
- Label listLabel = new Label(panel, SWT.LEFT | SWT.VERTICAL);
- listLabel.setText(label);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0, 3);
- fd.bottom = new FormAttachment(0, 20);
- fd.left = new FormAttachment(0, 5);
- fd.right = new FormAttachment(100);
- listLabel.setLayoutData(fd);
-
- org.eclipse.swt.widgets.List listBox = new org.eclipse.swt.widgets.List(panel, SWT.MULTI | SWT.BORDER);
- fd = new FormData();
- fd.top = new FormAttachment(listLabel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- listBox.setLayoutData(fd);
- return ListBoxModelAdapter.adapt(model, selectedItemsModel, listBox); // use #toString()
- }
-
- private void buildListPanel2(Composite parent, String label, ListValueModel<Task> model, CollectionValueModel<Task> selectedItemsModel) {
- ListBoxModelAdapter<Task> adapter = this.buildListPanel(parent, label, model, selectedItemsModel);
- adapter.addDoubleClickListener(this.buildDoubleClickListener());
- adapter.addSelectionChangeListener(this.buildSelectionChangeListener());
- }
-
- private ListBoxModelAdapter.DoubleClickListener<Task> buildDoubleClickListener() {
- return new ListBoxModelAdapter.DoubleClickListener<Task>() {
- public void doubleClick(ListBoxModelAdapter.DoubleClickEvent<Task> event) {
- System.out.println("double-click: " + event.selection());
- }
- };
- }
-
- private ListBoxModelAdapter.SelectionChangeListener<Task> buildSelectionChangeListener() {
- return new ListBoxModelAdapter.SelectionChangeListener<Task>() {
- public void selectionChanged(SelectionChangeEvent<Task> event) {
- ListBoxModelAdapterUITest.this.taskList.setPriorityTasks(event.selection());
- }
- };
- }
-
- private Comparator<String> buildCustomStringComparator() {
- return new Comparator<String>() {
- public int compare(String s1, String s2) {
- return s2.compareTo(s1);
- }
- };
- }
-
- private Comparator<Task> buildCustomTaskComparator() {
- return new Comparator<Task>() {
- public int compare(Task to1, Task to2) {
- return to2.compareTo(to1);
- }
- };
- }
-
- private ListValueModel<String> buildPrimitiveTaskListAdapter() {
- return new ListAspectAdapter<TaskList, String>(this.taskListHolder, TaskList.TASK_NAMES_LIST) {
- @Override
- protected ListIterator<String> listIterator_() {
- return this.subject.taskNames();
- }
- };
- }
-
- private ListValueModel<Task> buildObjectTaskListAdapter() {
- return new ListAspectAdapter<TaskList, Task>(this.taskListHolder, TaskList.TASKS_LIST) {
- @Override
- protected ListIterator<Task> listIterator_() {
- return this.subject.tasks();
- }
- };
- }
-
- private CollectionValueModel<Task> buildPriorityTaskListAdapter() {
- return new CollectionAspectAdapter<TaskList, Task>(this.taskListHolder, TaskList.PRIORITY_TASKS_COLLECTION) {
- @Override
- protected Iterator<Task> iterator_() {
- return this.subject.priorityTasks();
- }
- };
- }
-
- private void buildControlPanel(Composite parent, Control taskListPanel) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(taskListPanel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FormLayout());
- Control misc = this.buildMiscTaskPanel(panel);
- this.buildAddRemoveTaskPanel(panel, misc);
- }
-
- // is there a better way to associate an ACI with form data?
- private Control buildMiscTaskPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(100, -400);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildClearListACI().fill(panel);
- this.buildClearModelACI().fill(panel);
- this.buildRestoreModelACI().fill(panel);
- this.buildAddPriorityTaskACI().fill(panel);
- this.buildRemovePriorityTaskACI().fill(panel);
- this.buildClearPriorityTasksACI().fill(panel);
- return panel;
- }
-
- private ActionContributionItem buildClearListACI() {
- Action action = new Action("clear list", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelAdapterUITest.this.clearTasks();
- }
- };
- action.setToolTipText("clear all the tasks");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildClearModelACI() {
- Action action = new Action("clear model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelAdapterUITest.this.clearModel();
- }
- };
- action.setToolTipText("clear the task list model");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildRestoreModelACI() {
- Action action = new Action("restore model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelAdapterUITest.this.restoreModel();
- }
- };
- action.setToolTipText("restore the task list model");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildAddPriorityTaskACI() {
- Action action = new Action("add priority", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelAdapterUITest.this.addPriorityTask();
- }
- };
- action.setToolTipText("add a task to the priority tasks");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildRemovePriorityTaskACI() {
- Action action = new Action("remove priority", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelAdapterUITest.this.removePriorityTask();
- }
- };
- action.setToolTipText("remove a task from the priority tasks");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildClearPriorityTasksACI() {
- Action action = new Action("clear priority", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelAdapterUITest.this.clearPriorityTasks();
- }
- };
- action.setToolTipText("clear the priority tasks");
- return new ActionContributionItem(action);
- }
-
- private void buildAddRemoveTaskPanel(Composite parent, Control clearButton) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(clearButton);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FormLayout());
- Control addButton = this.buildAddButton(panel);
- Control removeButton = this.buildRemoveButton(panel);
- this.buildTaskTextField(panel, addButton, removeButton);
- }
-
- // is there a better way to associate an ACI with form data?
- private Control buildAddButton(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(0, 50);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildAddACI().fill(panel);
- return panel;
- }
-
- private ActionContributionItem buildAddACI() {
- Action action = new Action("add", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelAdapterUITest.this.addTask();
- }
- };
- action.setToolTipText("add a task with the name in the entry field");
- return new ActionContributionItem(action);
- }
-
- // is there a better way to associate an ACI with form data?
- private Control buildRemoveButton(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(100, -50);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildRemoveACI().fill(panel);
- return panel;
- }
-
- private ActionContributionItem buildRemoveACI() {
- Action action = new Action("remove", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelAdapterUITest.this.removeTask();
- }
- };
- action.setToolTipText("remove the task with the name in the entry field");
- return new ActionContributionItem(action);
- }
-
- private void buildTaskTextField(Composite parent, Control addButton, Control removeButton) {
- this.taskTextField = new Text(parent, SWT.SINGLE | SWT.BORDER);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(addButton);
- fd.right = new FormAttachment(removeButton);
- this.taskTextField.setLayoutData(fd);
- }
-
- private String taskTextFieldText() {
- return this.taskTextField.getText();
- }
-
- void addTask() {
- String taskText = this.taskTextFieldText();
- if (taskText.length() != 0) {
- this.taskList.addTask(taskText);
- }
- }
-
- void removeTask() {
- String task = this.taskTextFieldText();
- if (task.length() != 0) {
- this.taskList.removeTask(task);
- }
- }
-
- void clearTasks() {
- this.taskList.clearTasks();
- }
-
- void clearModel() {
- this.taskListHolder.setValue(null);
- }
-
- void restoreModel() {
- this.taskListHolder.setValue(this.taskList);
- }
-
- void addPriorityTask() {
- Iterator<Task> tasks = this.taskList.tasks();
- while (tasks.hasNext()) {
- if (this.taskList.addPriorityTask(tasks.next())) {
- return;
- }
- }
- }
-
- void removePriorityTask() {
- Iterator<Task> pTasks = this.taskList.priorityTasks();
- if (pTasks.hasNext()) {
- this.taskList.removePriorityTask(pTasks.next());
- }
- }
-
- void clearPriorityTasks() {
- this.taskList.clearPriorityTasks();
- }
-
-
- // ********** TaskList **********
-
- // note absence of validation...
- private class TaskList extends AbstractModel {
- private final List<String> taskNames = new ArrayList<String>();
- public static final String TASK_NAMES_LIST = "taskNames";
- private final List<Task> tasks = new ArrayList<Task>();
- public static final String TASKS_LIST = "tasks";
- private final Collection<Task> priorityTasks = new HashSet<Task>();
- public static final String PRIORITY_TASKS_COLLECTION = "priorityTasks";
- TaskList() {
- super();
- }
- public ListIterator<String> taskNames() {
- return this.taskNames.listIterator();
- }
- public ListIterator<Task> tasks() {
- return this.tasks.listIterator();
- }
- public Iterator<Task> priorityTasks() {
- return this.priorityTasks.iterator();
- }
- public Task addTask(String taskName) {
- this.addItemToList(taskName, this.taskNames, TASK_NAMES_LIST);
- Task task = new Task(taskName);
- this.addItemToList(task, this.tasks, TASKS_LIST);
- return task;
- }
- public void removeTask(String taskName) {
- int index = this.taskNames.indexOf(taskName);
- if (index != -1) {
- this.removeItemFromList(index, this.taskNames, TASK_NAMES_LIST);
- // assume the indexes match...
- Task removedTask = this.removeItemFromList(index, this.tasks, TASKS_LIST);
- this.removeItemFromCollection(removedTask, this.priorityTasks, PRIORITY_TASKS_COLLECTION);
- }
- }
- public void clearTasks() {
- this.taskNames.clear();
- this.fireListCleared(TASK_NAMES_LIST);
- this.tasks.clear();
- this.fireListCleared(TASKS_LIST);
- }
- public boolean addPriorityTask(Task task) {
- return this.addItemToCollection(task, this.priorityTasks, PRIORITY_TASKS_COLLECTION);
- }
- public void removePriorityTask(Task task) {
- this.removeItemFromCollection(task, this.priorityTasks, PRIORITY_TASKS_COLLECTION);
- }
- public void clearPriorityTasks() {
- this.clearCollection(this.priorityTasks, PRIORITY_TASKS_COLLECTION);
- }
- public void setPriorityTasks(Iterator<Task> tasks) {
- this.priorityTasks.clear();
- while (tasks.hasNext()) {
- this.priorityTasks.add(tasks.next());
- }
- this.fireCollectionChanged(PRIORITY_TASKS_COLLECTION);
- }
- }
-
-
- // ********** Task **********
-
- private class Task extends AbstractModel implements Displayable {
- private String name;
- private Date creationTimeStamp;
- public Task(String name) {
- this.name = name;
- this.creationTimeStamp = new Date();
- }
- public String displayString() {
- return this.name + ": " + this.creationTimeStamp.getTime();
- }
- public int compareTo(Displayable o) {
- return DEFAULT_COMPARATOR.compare(this, o);
- }
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(DISPLAY_STRING_PROPERTY, old, name);
- }
- @Override
- public String toString() {
- return this.displayString();
- }
- }
-
- public interface Displayable extends Model, Comparable<Displayable> {
-
- String displayString();
- String DISPLAY_STRING_PROPERTY = "displayString";
-
-
- // ********** helper implementations **********
-
- Collator DEFAULT_COLLATOR = Collator.getInstance();
-
- Comparator<Displayable> DEFAULT_COMPARATOR =
- new Comparator<Displayable>() {
- public int compare(Displayable d1, Displayable d2) {
- // disallow duplicates based on object identity
- if (d1 == d2) {
- return 0;
- }
-
- // first compare display strings using the default collator
- int result = DEFAULT_COLLATOR.compare(d1.displayString(), d2.displayString());
- if (result != 0) {
- return result;
- }
-
- // then compare using object-id
- result = System.identityHashCode(d1) - System.identityHashCode(d2);
- if (result != 0) {
- return result;
- }
-
- // It's unlikely that we get to this point; but, just in case, we will return -1.
- // Unfortunately, this introduces some mild unpredictability to the sort order
- // (unless the objects are always passed into this method in the same order).
- return -1; // if all else fails, indicate that o1 < o2
- }
- @Override
- public String toString() {
- return "Displayable.DEFAULT_COMPARATOR";
- }
- };
-
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/SpinnerModelAdapterTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/SpinnerModelAdapterTest.java
deleted file mode 100644
index bd343778a7..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/SpinnerModelAdapterTest.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.swt;
-
-import org.eclipse.jpt.ui.internal.swt.SpinnerModelAdapter;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Spinner;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-@SuppressWarnings("nls")
-public class SpinnerModelAdapterTest {
-
- private Model model;
- private Shell shell;
- private WritablePropertyValueModel<Model> subjectHolder;
-
- private WritablePropertyValueModel<Model> buildSubjectHolder() {
- return new SimplePropertyValueModel<Model>();
- }
-
- private WritablePropertyValueModel<Integer> buildValueHolder() {
- return new PropertyAspectAdapter<Model, Integer>(subjectHolder, Model.VALUE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return subject.getValue();
- }
-
- @Override
- protected void setValue_(Integer value) {
- subject.setValue(value);
- }
- };
- }
-
- @Before
- public void setUp() throws Exception {
-
- shell = new Shell(Display.getCurrent());
- model = new Model();
- subjectHolder = buildSubjectHolder();
- }
-
- @After
- public void tearDown() throws Exception {
-
- if (!shell.isDisposed()) {
- shell.dispose();
- }
-
- shell = null;
- subjectHolder = null;
- }
-
- @Test
- public void testDisposed() {
-
- int value = 2;
- model.setValue(value);
- model.clearSetValueCalledFlag();
- subjectHolder.setValue(model);
-
- Spinner spinner = new Spinner(shell, SWT.NULL);
- WritablePropertyValueModel<Integer> numberHolder = buildValueHolder();
- int defaultValue = 1;
-
- SpinnerModelAdapter.adapt(
- numberHolder,
- spinner,
- defaultValue
- );
-
- assertEquals(
- "The spinner's value should be coming from the model",
- value,
- spinner.getSelection()
- );
-
- assertEquals(
- "The number holder's value should be the model's value",
- model.getValue(),
- numberHolder.getValue()
- );
-
- assertFalse(
- "The model should not have received the value during initialization",
- model.isSetValueCalled()
- );
-
- // Change the value in the model
- spinner.dispose();
-
- value = 4;
- model.setValue(value);
-
- assertEquals(
- "The model's value was somehow changed",
- value,
- model.getValue()
- );
- }
-
- @Test
- public void testInitialization_1() {
-
- Spinner spinner = new Spinner(shell, SWT.NULL);
- WritablePropertyValueModel<Integer> numberHolder = new SimplePropertyValueModel<Integer>();
- int defaultValue = 1;
-
- SpinnerModelAdapter.adapt(
- numberHolder,
- spinner,
- defaultValue
- );
-
- assertEquals(
- "The spinner's value should be the default value",
- defaultValue,
- spinner.getSelection()
- );
-
- assertNull(
- "The number holder's value should be null",
- numberHolder.getValue()
- );
- }
-
- @Test
- public void testInitialization_2() {
-
- Spinner spinner = new Spinner(shell, SWT.NULL);
- WritablePropertyValueModel<Integer> numberHolder = buildValueHolder();
- int defaultValue = 1;
-
- SpinnerModelAdapter.adapt(
- numberHolder,
- spinner,
- defaultValue
- );
-
- assertEquals(
- "The spinner's value should be the default value",
- defaultValue,
- spinner.getSelection()
- );
-
- assertNull(
- "The number holder's value should be null",
- numberHolder.getValue()
- );
- }
-
- @Test
- public void testInitialization_3() {
-
- subjectHolder.setValue(model);
-
- Spinner spinner = new Spinner(shell, SWT.NULL);
- WritablePropertyValueModel<Integer> numberHolder = buildValueHolder();
- int defaultValue = 1;
-
- SpinnerModelAdapter.adapt(
- numberHolder,
- spinner,
- defaultValue
- );
-
- assertEquals(
- "The spinner's value should be the default value",
- defaultValue,
- spinner.getSelection()
- );
-
- assertNull(
- "The number holder's value should be null",
- numberHolder.getValue()
- );
-
- assertFalse(
- "The model should not have received the value during initialization",
- model.isSetValueCalled()
- );
- }
-
- @Test
- public void testInitialization_4() {
-
- int value = 2;
- model.setValue(value);
- model.clearSetValueCalledFlag();
- subjectHolder.setValue(model);
-
- Spinner spinner = new Spinner(shell, SWT.NULL);
- WritablePropertyValueModel<Integer> numberHolder = buildValueHolder();
- int defaultValue = 1;
-
- SpinnerModelAdapter.adapt(
- numberHolder,
- spinner,
- defaultValue
- );
-
- assertEquals(
- "The spinner's value should be the value coming from the model",
- value,
- spinner.getSelection()
- );
-
- assertEquals(
- "The number holder's value should be " + value,
- value,
- numberHolder.getValue()
- );
-
- assertFalse(
- "The model should not have received the value during initialization",
- model.isSetValueCalled()
- );
- }
-
- @Test
- public void testValueChanged() {
-
- int value = 2;
- model.setValue(value);
- model.clearSetValueCalledFlag();
- subjectHolder.setValue(model);
-
- Spinner spinner = new Spinner(shell, SWT.NULL);
- WritablePropertyValueModel<Integer> numberHolder = buildValueHolder();
- int defaultValue = 1;
-
- SpinnerModelAdapter.adapt(
- numberHolder,
- spinner,
- defaultValue
- );
-
- assertEquals(
- "The spinner's value should be coming from the model",
- value,
- spinner.getSelection()
- );
-
- assertEquals(
- "The number holder's value should be the model's value",
- model.getValue(),
- numberHolder.getValue()
- );
-
- assertFalse(
- "The model should not have received the value during initialization",
- model.isSetValueCalled()
- );
-
- // Change the value in the model
- value = 4;
- model.setValue(value);
-
- assertEquals(
- "The spinner's value should be coming from the model",
- value,
- spinner.getSelection()
- );
-
- assertEquals(
- "The model's value was somehow changed",
- value,
- model.getValue()
- );
-
- // Change the value from the spinner
- value = 6;
- spinner.setSelection(value);
-
- assertEquals(
- "The spinner's value should be the new value set",
- value,
- spinner.getSelection()
- );
-
- assertEquals(
- "The model's value was supposed to be updated",
- value,
- model.getValue()
- );
-
- // Disconnect from model
- subjectHolder.setValue(null);
-
- assertEquals(
- "The spinner's value should be the default value",
- defaultValue,
- spinner.getSelection()
- );
- }
-
- private static class Model extends AbstractModel {
-
- private boolean setValueCalled;
- private Integer value;
-
- static final String VALUE_PROPERTY = "value";
-
- void clearSetValueCalledFlag() {
- setValueCalled = false;
- }
-
- Integer getValue() {
- return value;
- }
-
- boolean isSetValueCalled() {
- return setValueCalled;
- }
-
- void setValue(Integer value) {
- setValueCalled = true;
-
- Integer oldValue = this.value;
- this.value = value;
- firePropertyChanged(VALUE_PROPERTY, oldValue, value);
- }
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/TableModelAdapterTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/TableModelAdapterTest.java
deleted file mode 100644
index 94da99053b..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/TableModelAdapterTest.java
+++ /dev/null
@@ -1,1203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.swt;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jpt.ui.internal.swt.ColumnAdapter;
-import org.eclipse.jpt.ui.internal.swt.TableModelAdapter;
-import org.eclipse.jpt.ui.internal.swt.TableModelAdapter.SelectionChangeEvent;
-import org.eclipse.jpt.ui.internal.swt.TableModelAdapter.SelectionChangeListener;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyCollectionValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public class TableModelAdapterTest {
-
- private Shell shell;
- private WritablePropertyValueModel<Manager> subjectHolder;
-
- private ColumnAdapter<Employee> buildColumnAdapter() {
- return new TableColumnAdapter();
- }
-
- private WritablePropertyValueModel<Employee> buildEmployeeHolder() {
- return new SimplePropertyValueModel<Employee>();
- }
-
- private SimpleCollectionValueModel<Employee> buildEmployeeHolders() {
- return new SimpleCollectionValueModel<Employee>();
- }
-
- private ListValueModel<Employee> buildEmployeeListHolder() {
- return new ListAspectAdapter<Manager, Employee>(subjectHolder, Manager.EMPLOYEES_LIST) {
- @Override
- protected ListIterator<Employee> listIterator_() {
- return subject.employees();
- }
-
- @Override
- protected int size_() {
- return subject.employeesSize();
- }
- };
- }
-
- private ITableLabelProvider buildLabelProvider() {
- return new TableLabelProvider();
- }
-
- private SelectionChangeListener<Employee> buildSelectionChangeListener(final Collection<Employee> employees) {
- return new SelectionChangeListener<Employee>() {
- public void selectionChanged(SelectionChangeEvent<Employee> e) {
- employees.clear();
- CollectionTools.addAll(employees, e.selection());
- }
- };
- }
-
- private WritablePropertyValueModel<Manager> buildSubjectHolder() {
- return new SimplePropertyValueModel<Manager>();
- }
-
- @Before
- public void setUp() throws Exception {
-
- shell = new Shell(Display.getCurrent());
- subjectHolder = buildSubjectHolder();
- }
-
- @After
- public void tearDown() throws Exception {
-
- if (!shell.isDisposed()) {
- shell.dispose();
- }
-
- shell = null;
- subjectHolder = null;
- }
-
- @Test
- public void testChanged() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- WritablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Make sure the Table was populated
- Assert.assertEquals("The number of TableItems should be 3", 3, table.getItemCount());
-
- // Change the list of Employees
- ArrayList<Employee> employees = new ArrayList<Employee>(3);
- employees.add(employee3);
- employees.add(employee2);
- employees.add(employee1);
- manager.changeEmployees(employees);
-
- Assert.assertEquals("The number of TableItems should be 3", 3, table.getItemCount());
-
- testTableItemProperties(table, 0, expectedName3, expectedManager3, expectedTitle3);
- testTableItemProperties(table, 1, expectedName2, expectedManager2, expectedTitle2);
- testTableItemProperties(table, 2, expectedName1, expectedManager1, expectedTitle1);
- }
-
- @Test
- public void testCleared() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- WritablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Make sure the Table was populated
- Assert.assertEquals("The number of TableItems should be 3", 3, table.getItemCount());
-
- // Test removing them all
- manager.removeAllEmployees();
-
- Assert.assertEquals("The list holder should have been cleared", 0, listHolder.size());
- Assert.assertEquals("The Table should have been cleared", 0, table.getItemCount());
- }
-
- @Test
- public void testItemAdded() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- WritablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create a new Employee
- String expectedName = "Dali";
- String expectedManager = "WTP";
- String expectedTitle = "plug-in";
-
- Employee employee = manager.addEmployee(expectedName, expectedTitle, expectedManager);
- Assert.assertNotNull("The new Employee was not created", employee);
-
- // Retrieve the TableItem representing the new Employee
- int index = tableModel.indexOf(employee);
- Assert.assertEquals("The new Employee was not added to the table model", 0, index);
- Assert.assertEquals("The number of TableItem should be 1", 1, table.getItemCount());
-
- testTableItemProperties(table, index, expectedName, expectedManager, expectedTitle);
- }
-
- @Test
- public void testItemMoved() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- WritablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Make sure the Employees were added to the Table
- Assert.assertEquals("The number of TableItem should be 3", 3, table.getItemCount());
-
- // Move an Employee up the list
- manager.moveEmployeeUp(employee2);
-
- int index1 = tableModel.indexOf(employee1);
- Assert.assertEquals("The Employee 1 was not moved in the table model", 1, index1);
-
- int index2 = tableModel.indexOf(employee2);
- Assert.assertEquals("The Employee 2 was not moved in the table model", 0, index2);
-
- int index3 = tableModel.indexOf(employee3);
- Assert.assertEquals("The Employee 3 should not have been moved in the table model", 2, index3);
-
- testTableItemProperties(table, index1, expectedName1, expectedManager1, expectedTitle1);
- testTableItemProperties(table, index2, expectedName2, expectedManager2, expectedTitle2);
- testTableItemProperties(table, index3, expectedName3, expectedManager3, expectedTitle3);
-
- // Move an Employee down the list
- manager.moveEmployeeDown(employee1);
-
- index1 = tableModel.indexOf(employee1);
- Assert.assertEquals("The Employee 1 should not have been moved in the table model", 2, index1);
-
- index2 = tableModel.indexOf(employee2);
- Assert.assertEquals("The Employee 2 was not moved in the table model", 0, index2);
-
- index3 = tableModel.indexOf(employee3);
- Assert.assertEquals("The Employee 3 was not moved in the table model", 1, index3);
-
- testTableItemProperties(table, index1, expectedName1, expectedManager1, expectedTitle1);
- testTableItemProperties(table, index2, expectedName2, expectedManager2, expectedTitle2);
- testTableItemProperties(table, index3, expectedName3, expectedManager3, expectedTitle3);
- }
-
- @Test
- public void testItemRemoved() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- WritablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create a new Employee
- String expectedName = "Dali";
- String expectedManager = "WTP";
- String expectedTitle = "plug-in";
-
- Employee employee = manager.addEmployee(expectedName, expectedTitle, expectedManager);
- Assert.assertNotNull("The new Employee was not created", employee);
- Assert.assertEquals("The number of TableItem should be 1", 1, table.getItemCount());
-
- // Make sure it was added to the model
- int index = tableModel.indexOf(employee);
- Assert.assertEquals("The new Employee was not added to the table model", 0, index);
- testTableItemProperties(table, index, expectedName, expectedManager, expectedTitle);
-
- // Retrieve the TableItem representing the new Employee
- TableItem tableItem = table.getItem(index);
- Assert.assertNotNull("No TableItem was found for the new Employee", tableItem);
-
- // Now test the item being removed
- manager.removeEmployee(employee);
- index = tableModel.indexOf(employee);
- Assert.assertEquals("The Employee was not removed from the table model", -1, index);
- Assert.assertEquals("The number of TableItem should be 0", 0, table.getItemCount());
- }
-
- @Test
- public void testItemReplaced() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- WritablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create a new Employee
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- Employee employee1 = manager.addEmployee(expectedName1, expectedTitle1, expectedManager1);
- Assert.assertNotNull("The new Employee was not created", employee1);
-
- // Make sure it was added to the model
- int index1 = tableModel.indexOf(employee1);
- Assert.assertEquals("The new Employee was not added to the table model", 0, index1);
- Assert.assertEquals("The number of TableItem should be 1", 1, table.getItemCount());
-
- // Retrieve the TableItem representing the new Employee
- TableItem tableItem = table.getItem(index1);
- Assert.assertNotNull("No TableItem was found for the new Employee", tableItem);
-
- testTableItemProperties(table, index1, expectedName1, expectedManager1, expectedTitle1);
-
- // Replace the Employee
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- manager.replace(employee1, employee2);
-
- int index2 = tableModel.indexOf(employee2);
- Assert.assertSame("The Employee that got replaced should be at index " + index1, index1, index2);
- Assert.assertEquals("The number of TableItem should be 1", 1, table.getItemCount());
-
- testTableItemProperties(table, index2, expectedName2, expectedManager2, expectedTitle2);
- }
-
- @Test
- public void testItemsAdded() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- WritablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Retrieve the TableItems representing the employees
- Assert.assertEquals("The number of TableItem should be 3", 3, table.getItemCount());
-
- int index = tableModel.indexOf(employee1);
- Assert.assertEquals("The Employee 1 was not added to the table model", 0, index);
-
- index = tableModel.indexOf(employee2);
- Assert.assertEquals("The Employee 2 was not added to the table model", 1, index);
-
- index = tableModel.indexOf(employee3);
- Assert.assertEquals("The Employee 3 was not added to the table model", 2, index);
-
- // Make sure the TableItem was correctly populated
- testTableItemProperties(table, 0, expectedName1, expectedManager1, expectedTitle1);
- testTableItemProperties(table, 1, expectedName2, expectedManager2, expectedTitle2);
- testTableItemProperties(table, 2, expectedName3, expectedManager3, expectedTitle3);
- }
-
- @Test
- public void testItemsMoved() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- WritablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- String expectedName4 = "Dali_4";
- String expectedManager4 = "WTP_4";
- String expectedTitle4 = "plug-in_4";
-
- String expectedName5 = "Dali_5";
- String expectedManager5 = "WTP_5";
- String expectedTitle5 = "plug-in_5";
-
- String expectedName6 = "Dali_6";
- String expectedManager6 = "WTP_6";
- String expectedTitle6 = "plug-in_6";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
- Employee employee4 = new Employee(expectedName4, expectedTitle4, expectedManager4);
- Employee employee5 = new Employee(expectedName5, expectedTitle5, expectedManager5);
- Employee employee6 = new Employee(expectedName6, expectedTitle6, expectedManager6);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
- manager.addEmployee(employee4);
- manager.addEmployee(employee5);
- manager.addEmployee(employee6);
-
- // Make sure the Employees were added to the Table
- Assert.assertEquals("The number of TableItem should be 6", 6, table.getItemCount());
-
- // Move an Employee up the list
- ArrayList<Employee> employees = new ArrayList<Employee>(3);
- employees.add(employee3);
- employees.add(employee4);
- employees.add(employee5);
- manager.moveEmployees(employees, 0);
-
- int index1 = tableModel.indexOf(employee1);
- int index2 = tableModel.indexOf(employee2);
- int index3 = tableModel.indexOf(employee3);
- int index4 = tableModel.indexOf(employee4);
- int index5 = tableModel.indexOf(employee5);
- int index6 = tableModel.indexOf(employee6);
-
- Assert.assertEquals("The Employee 1 is not at the right index", 3, index1);
- Assert.assertEquals("The Employee 2 is not at the right index", 4, index2);
- Assert.assertEquals("The Employee 3 is not at the right index", 0, index3);
- Assert.assertEquals("The Employee 4 is not at the right index", 1, index4);
- Assert.assertEquals("The Employee 5 is not at the right index", 2, index5);
- Assert.assertEquals("The Employee 6 is not at the right index", 5, index6);
-
- testTableItemProperties(table, index1, expectedName1, expectedManager1, expectedTitle1);
- testTableItemProperties(table, index2, expectedName2, expectedManager2, expectedTitle2);
- testTableItemProperties(table, index3, expectedName3, expectedManager3, expectedTitle3);
- testTableItemProperties(table, index4, expectedName4, expectedManager4, expectedTitle4);
- testTableItemProperties(table, index5, expectedName5, expectedManager5, expectedTitle5);
- testTableItemProperties(table, index6, expectedName6, expectedManager6, expectedTitle6);
-
- // Move an Employee down the list
- employees = new ArrayList<Employee>(2);
- employees.add(employee1);
- employees.add(employee2);
- manager.moveEmployees(employees, 4);
-
- index1 = tableModel.indexOf(employee1);
- index2 = tableModel.indexOf(employee2);
- index3 = tableModel.indexOf(employee3);
- index4 = tableModel.indexOf(employee4);
- index5 = tableModel.indexOf(employee5);
- index6 = tableModel.indexOf(employee6);
-
- Assert.assertEquals("The Employee 1 is not at the right index", 4, index1);
- Assert.assertEquals("The Employee 2 is not at the right index", 5, index2);
- Assert.assertEquals("The Employee 3 is not at the right index", 0, index3);
- Assert.assertEquals("The Employee 4 is not at the right index", 1, index4);
- Assert.assertEquals("The Employee 5 is not at the right index", 2, index5);
- Assert.assertEquals("The Employee 6 is not at the right index", 3, index6);
-
- testTableItemProperties(table, index1, expectedName1, expectedManager1, expectedTitle1);
- testTableItemProperties(table, index2, expectedName2, expectedManager2, expectedTitle2);
- testTableItemProperties(table, index3, expectedName3, expectedManager3, expectedTitle3);
- testTableItemProperties(table, index4, expectedName4, expectedManager4, expectedTitle4);
- testTableItemProperties(table, index5, expectedName5, expectedManager5, expectedTitle5);
- testTableItemProperties(table, index6, expectedName6, expectedManager6, expectedTitle6);
- }
-
- @Test
- public void testItemsRemoved() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- WritablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Retrieve the TableItems representing the employees
- Assert.assertEquals("The number of TableItem should be 3", 3, table.getItemCount());
-
- int index = tableModel.indexOf(employee1);
- Assert.assertEquals("The Employee 1 was not added to the table model", 0, index);
-
- index = tableModel.indexOf(employee2);
- Assert.assertEquals("The Employee 2 was not added to the table model", 1, index);
-
- index = tableModel.indexOf(employee3);
- Assert.assertEquals("The Employee 3 was not added to the table model", 2, index);
-
- // Remove 2 items
- ArrayList<Employee> employees = new ArrayList<Employee>(2);
- employees.add(employee1);
- employees.add(employee3);
- manager.removeEmployees(employees);
-
- Assert.assertEquals("The number of TableItem should be 1", 1, table.getItemCount());
- }
-
- @Test
- public void testPropertyChanged() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- WritablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create a new Employee
- String expectedName = "Dali";
- String expectedManager = "WTP";
- String expectedTitle = "plug-in";
-
- Employee employee = manager.addEmployee(expectedName, expectedTitle, expectedManager);
- Assert.assertNotNull("The new Employee was not created", employee);
-
- // Make sure it was added to the model
- int index = tableModel.indexOf(employee);
- Assert.assertEquals("The new Employee was not added to the table model", 0, index);
- Assert.assertEquals("The number of TableItem should be 1", 1, table.getItemCount());
-
- // Retrieve the TableItem representing the new Employee
- TableItem tableItem = table.getItem(index);
- Assert.assertNotNull("No TableItem was found for the new Employee", tableItem);
-
- // Name property
- String actualName = tableItem.getText(TableColumnAdapter.NAME_COLUMN);
- Assert.assertEquals("TableItem[NAME_COLUMN] was not set correctly", expectedName, actualName);
-
- expectedName = "Jpt";
- employee.setName(expectedName);
-
- actualName = tableItem.getText(TableColumnAdapter.NAME_COLUMN);
- Assert.assertEquals("TableItem[NAME_COLUMN] was not set correctly", expectedName, actualName);
-
- // Manager property
- String actualManager = tableItem.getText(TableColumnAdapter.MANAGER_COLUMN);
- Assert.assertEquals("TableItem[MANAGER_COLUMN] was not set correctly", expectedManager, actualManager);
-
- expectedManager = "boss";
- employee.setManager(expectedManager);
-
- actualManager = tableItem.getText(TableColumnAdapter.MANAGER_COLUMN);
- Assert.assertEquals("TableItem[MANAGER_COLUMN] was not set correctly", expectedManager, actualManager);
-
- // Title property
- String actualTitle = tableItem.getText(TableColumnAdapter.TITLE_COLUMN);
- Assert.assertEquals("TableItem[TITLE_COLUMN] was not set correctly", expectedTitle, actualTitle);
-
- expectedTitle = "EclipseLink";
- employee.setTitle(expectedTitle);
-
- actualTitle = tableItem.getText(TableColumnAdapter.TITLE_COLUMN);
- Assert.assertEquals("TableItem[TITLE_COLUMN] was not set correctly", expectedTitle, actualTitle);
- }
-
- @Test
- public void testSelectedItemsAddedRemoved() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- SimpleCollectionValueModel<Employee> selectedItemsHolder = buildEmployeeHolders();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemsHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Test adding selected items
- ArrayList<Employee> employees = new ArrayList<Employee>(2);
- employees.add(employee1);
- employees.add(employee3);
- selectedItemsHolder.addAll(employees);
-
- Collection<Employee> actualEmployees = tableModel.selectedItems();
- Assert.assertNotNull("The collection of selected items can't be null", actualEmployees);
- Assert.assertEquals("The count of selected items should be 2", 2, actualEmployees.size());
-
- actualEmployees.remove(employee1);
- actualEmployees.remove(employee3);
-
- Assert.assertTrue("The selected items was not retrieved correctly", actualEmployees.isEmpty());
-
- // Test removing selected items
- selectedItemsHolder.remove(employee1);
-
- actualEmployees = tableModel.selectedItems();
- Assert.assertNotNull("The collection of selected items can't be null", actualEmployees);
- Assert.assertEquals("The count of selected items should be 1", 1, actualEmployees.size());
-
- actualEmployees.remove(employee3);
-
- Assert.assertTrue("The selected items was not retrieved correctly", actualEmployees.isEmpty());
- }
-
- @Test
- public void testSelectedItemsCleared() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- SimpleCollectionValueModel<Employee> selectedItemsHolder = buildEmployeeHolders();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemsHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Test adding selected items
- ArrayList<Employee> employees = new ArrayList<Employee>(2);
- employees.add(employee1);
- employees.add(employee3);
- selectedItemsHolder.addAll(employees);
-
- Collection<Employee> actualEmployees = tableModel.selectedItems();
- Assert.assertNotNull("The collection of selected items can't be null", actualEmployees);
- Assert.assertEquals("The count of selected items should be 2", 2, actualEmployees.size());
-
- actualEmployees.remove(employee1);
- actualEmployees.remove(employee3);
- Assert.assertTrue("The selected items was not retrieved correctly", actualEmployees.isEmpty());
-
- // Test removing selected items
- selectedItemsHolder.clear();
-
- actualEmployees = tableModel.selectedItems();
- Assert.assertNotNull("The collection of selected items can't be null", actualEmployees);
- Assert.assertEquals("The count of selected items should be ", 0, actualEmployees.size());
- }
-
- @Test
- public void testSelectionChangeListener() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- buildEmployeeListHolder(),
- buildEmployeeHolder(),
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- Collection<Employee> employees = new ArrayList<Employee>();
- tableModel.addSelectionChangeListener(buildSelectionChangeListener(employees));
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Test adding selected items
- table.setSelection(new int[] { 0, 2 });
-
- // It seems a manual selection doesn't send any selection event
- tableModel.tableSelectionChanged(null);
-
- Assert.assertNotNull("The collection of selected items can't be null", employees);
- Assert.assertEquals("The count of selected items should be 2", 2, employees.size());
-
- employees.remove(employee1);
- employees.remove(employee3);
- Assert.assertTrue("The selected items was not retrieved correctly", employees.isEmpty());
-
- // Test adding selected items
- employees.add(employee1);
- employees.add(employee3);
- table.deselectAll();
-
- // It seems a manual selection doesn't send any selection event
- tableModel.tableSelectionChanged(null);
-
- Assert.assertNotNull("The collection of selected items can't be null", employees);
- Assert.assertEquals("The count of selected items should be 0", 0, employees.size());
- }
-
- private void testTableItemProperties(Table table,
- int index,
- String expectedName,
- String expectedManager,
- String expectedTitle)
- {
- TableItem tableItem = table.getItem(index);
- Assert.assertNotNull("No TableItem was found for the Employee", tableItem);
-
- String actualName = tableItem.getText(TableColumnAdapter.NAME_COLUMN);
- Assert.assertEquals("TableItem[NAME_COLUMN] was not set correctly", expectedName, actualName);
-
- String actualTitle = tableItem.getText(TableColumnAdapter.TITLE_COLUMN);
- Assert.assertEquals("TableItem[TITLE_COLUMN] was not set correctly", expectedTitle, actualTitle);
-
- String actualManager = tableItem.getText(TableColumnAdapter.MANAGER_COLUMN);
- Assert.assertEquals("TableItem[MANAGER_COLUMN] was not set correctly", expectedManager, actualManager);
- }
-
- private class Employee extends AbstractModel {
-
- private String manager;
- private String name;
- private String title;
-
- static final String MANAGER_PROPERTY = "manager";
- static final String NAME_PROPERTY = "name";
- static final String TITLE_PROPERTY = "title";
-
- Employee(String name, String title, String manager) {
- super();
-
- this.name = name;
- this.title = title;
- this.manager = manager;
- }
-
- String getManager() {
- return manager;
- }
-
- String getName() {
- return name;
- }
-
- String getTitle() {
- return title;
- }
-
- void setManager(String manager) {
- String oldManager = this.manager;
- this.manager = manager;
- firePropertyChanged(MANAGER_PROPERTY, oldManager, manager);
- }
-
- void setName(String name) {
- String oldName = this.name;
- this.name = name;
- firePropertyChanged(NAME_PROPERTY, oldName, name);
- }
-
- void setTitle(String title) {
- String oldTitle = this.title;
- this.title = title;
- firePropertyChanged(TITLE_PROPERTY, oldTitle, title);
- }
- }
-
- private class Manager extends AbstractModel {
-
- private List<Employee> employees;
-
- static final String EMPLOYEES_LIST = "employees";
-
- Manager() {
- super();
- employees = new ArrayList<Employee>();
- }
-
- Employee addEmployee(Employee employee) {
- addItemToList(employee, employees, EMPLOYEES_LIST);
- return employee;
- }
-
- Employee addEmployee(String name, String title, String manager) {
- Employee employee = new Employee(name, title, manager);
- return addEmployee(employee);
- }
-
- void changeEmployees(List<Employee> employees) {
- this.employees.clear();
- this.employees.addAll(employees);
- fireListChanged(EMPLOYEES_LIST);
- }
-
- ListIterator<Employee> employees() {
- return new CloneListIterator<Employee>(employees);
- }
-
- int employeesSize() {
- return employees.size();
- }
-
- void moveEmployeeDown(Employee employee) {
- int index = employees.indexOf(employee);
- moveItemInList(index + 1, index, employees, EMPLOYEES_LIST);
- }
-
- void moveEmployees(Collection<Employee> employees, int targetIndex) {
-
- int sourceIndex = Integer.MAX_VALUE;
-
- for (Employee employee : employees) {
- sourceIndex = Math.min(sourceIndex, this.employees.indexOf(employee));
- }
-
- moveItemsInList(
- targetIndex,
- sourceIndex,
- employees.size(),
- this.employees,
- EMPLOYEES_LIST
- );
- }
-
- void moveEmployeeUp(Employee employee) {
- int index = employees.indexOf(employee);
- moveItemInList(index - 1, index, employees, EMPLOYEES_LIST);
- }
-
- void removeAllEmployees() {
- clearList(employees, EMPLOYEES_LIST);
- }
-
- void removeEmployee(Employee employee) {
- removeItemFromList(employee, employees, EMPLOYEES_LIST);
- }
-
- void removeEmployees(Collection<Employee> employees) {
- removeItemsFromList(employees.iterator(), this.employees, EMPLOYEES_LIST);
- }
-
- void replace(Employee oldEmployee, Employee newEmployee) {
- replaceItemInList(oldEmployee, newEmployee, employees, EMPLOYEES_LIST);
- }
- }
-
- private class TableColumnAdapter implements ColumnAdapter<Employee> {
-
- static final int COLUMN_COUNT = 3;
- static final int MANAGER_COLUMN = 2;
- static final int NAME_COLUMN = 0;
- static final int TITLE_COLUMN = 1;
-
- private WritablePropertyValueModel<String> buildManagerHolder(Employee subject) {
- return new PropertyAspectAdapter<Employee, String>(Employee.MANAGER_PROPERTY, subject) {
- @Override
- protected String buildValue_() {
- return subject.getManager();
- }
-
- @Override
- protected void setValue_(String value) {
- subject.setManager(value);
- }
- };
- }
-
- private WritablePropertyValueModel<String> buildNameHolder(Employee subject) {
- return new PropertyAspectAdapter<Employee, String>(Employee.NAME_PROPERTY, subject) {
- @Override
- protected String buildValue_() {
- return subject.getName();
- }
-
- @Override
- protected void setValue_(String value) {
- subject.setName(value);
- }
- };
- }
-
- private WritablePropertyValueModel<String> buildTitleHolder(Employee subject) {
- return new PropertyAspectAdapter<Employee, String>(Employee.TITLE_PROPERTY, subject) {
- @Override
- protected String buildValue_() {
- return subject.getTitle();
- }
-
- @Override
- protected void setValue_(String value) {
- subject.setTitle(value);
- }
- };
- }
-
- public WritablePropertyValueModel<?>[] cellModels(Employee subject) {
- WritablePropertyValueModel<?>[] holders = new WritablePropertyValueModel<?>[3];
- holders[NAME_COLUMN] = buildNameHolder(subject);
- holders[TITLE_COLUMN] = buildTitleHolder(subject);
- holders[MANAGER_COLUMN] = buildManagerHolder(subject);
- return holders;
- }
-
- public int columnCount() {
- return COLUMN_COUNT;
- }
-
- public String columnName(int columnIndex) {
- return String.valueOf(columnIndex);
- }
- }
-
- private class TableLabelProvider extends LabelProvider
- implements ITableLabelProvider {
-
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- Employee employee = (Employee) element;
-
- if (columnIndex == TableColumnAdapter.NAME_COLUMN) {
- return employee.getName();
- }
-
- if (columnIndex == TableColumnAdapter.TITLE_COLUMN) {
- return employee.getTitle();
- }
-
- return employee.getManager();
- }
- }
-
- private class TableModel extends TableModelAdapter<Employee> {
-
- TableModel(ListValueModel<Employee> listHolder,
- CollectionValueModel<Employee> selectedItemsHolder,
- Table table,
- ColumnAdapter<Employee> columnAdapter,
- ITableLabelProvider labelProvider) {
-
- super(listHolder,
- selectedItemsHolder,
- table,
- columnAdapter,
- labelProvider);
- }
-
- TableModel(ListValueModel<Employee> listHolder,
- WritablePropertyValueModel<Employee> selectedItemHolder,
- Table table,
- ColumnAdapter<Employee> columnAdapter,
- ITableLabelProvider labelProvider) {
-
- super(listHolder,
- new PropertyCollectionValueModelAdapter<Employee>(selectedItemHolder),
- table,
- columnAdapter,
- labelProvider);
- }
-
- @Override
- protected int indexOf(Employee item) {
- return super.indexOf(item);
- }
-
- @Override
- protected Collection<Employee> selectedItems() {
- return super.selectedItems();
- }
-
- @Override
- protected void tableSelectionChanged(SelectionEvent event) {
- super.tableSelectionChanged(event);
- }
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/TextFieldModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/TextFieldModelAdapterUITest.java
deleted file mode 100644
index 6f812805de..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/TextFieldModelAdapterUITest.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.swt;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.ui.internal.swt.TextFieldModelAdapter;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Play around with a set of entry fields.
- */
-public class TextFieldModelAdapterUITest
- extends ApplicationWindow
-{
- private final TestModel testModel;
- private static final String DEFAULT_NAME = "Scooby Doo";
- private final WritablePropertyValueModel<TestModel> testModelHolder;
- private final WritablePropertyValueModel<String> nameHolder;
- private final WritablePropertyValueModel<String> allCapsNameHolder;
-
-
- public static void main(String[] args) throws Exception {
- Window window = new TextFieldModelAdapterUITest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
- private TextFieldModelAdapterUITest(String[] args) {
- super(null);
- this.testModel = new TestModel(DEFAULT_NAME);
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.nameHolder = this.buildNameHolder(this.testModelHolder);
- this.allCapsNameHolder = this.buildAllCapsNameHolder(this.testModelHolder);
- }
-
- private WritablePropertyValueModel<String> buildNameHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, String>(vm, TestModel.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.name();
- }
- @Override
- protected void setValue_(String value) {
- this.subject.setName(value);
- }
- };
- }
-
- private WritablePropertyValueModel<String> buildAllCapsNameHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, String>(vm, TestModel.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.name().toUpperCase();
- }
- @Override
- protected void setValue_(String value) {
- // do nothing
- }
- };
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(ClassTools.shortClassNameForObject(this));
- parent.setSize(400, 100);
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayout(new FormLayout());
- Control textFieldPanel = this.buildTextFieldPanel(mainPanel);
- this.buildControlPanel(mainPanel, textFieldPanel);
- return mainPanel;
- }
-
- private Control buildTextFieldPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100, -35);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildNameTextField(panel);
- this.buildReadOnlyNameTextField(panel);
- this.buildAllCapsNameTextField(panel);
-
- return panel;
- }
-
- private void buildNameTextField(Composite parent) {
- Text textField = new Text(parent, SWT.SINGLE);
- TextFieldModelAdapter.adapt(this.nameHolder, textField);
- }
-
- private void buildReadOnlyNameTextField(Composite parent) {
- Text textField = new Text(parent, SWT.SINGLE);
- textField.setEnabled(false);
- TextFieldModelAdapter.adapt(this.nameHolder, textField);
- }
-
- private void buildAllCapsNameTextField(Composite parent) {
- Text textField = new Text(parent, SWT.SINGLE);
- textField.setEnabled(false);
- TextFieldModelAdapter.adapt(this.allCapsNameHolder, textField);
- }
-
- private void buildControlPanel(Composite parent, Control checkBoxPanel) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(checkBoxPanel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildResetNameButton(panel);
- this.buildClearModelButton(panel);
- this.buildRestoreModelButton(panel);
- this.buildPrintModelButton(panel);
- }
-
- private void buildResetNameButton(Composite parent) {
- this.buildResetNameACI().fill(parent);
- }
-
- private ActionContributionItem buildResetNameACI() {
- Action action = new Action("reset name", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TextFieldModelAdapterUITest.this.resetName();
- }
- };
- action.setToolTipText("reset name");
- return new ActionContributionItem(action);
- }
-
- void resetName() {
- this.testModel.setName(DEFAULT_NAME);
- }
-
- private void buildClearModelButton(Composite parent) {
- this.buildClearModelACI().fill(parent);
- }
-
- private ActionContributionItem buildClearModelACI() {
- Action action = new Action("clear model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TextFieldModelAdapterUITest.this.clearModel();
- }
- };
- action.setToolTipText("clear model");
- return new ActionContributionItem(action);
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private void buildRestoreModelButton(Composite parent) {
- this.buildRestoreModelACI().fill(parent);
- }
-
- private ActionContributionItem buildRestoreModelACI() {
- Action action = new Action("restore model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TextFieldModelAdapterUITest.this.restoreModel();
- }
- };
- action.setToolTipText("restore model");
- return new ActionContributionItem(action);
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private void buildPrintModelButton(Composite parent) {
- this.buildPrintModelACI().fill(parent);
- }
-
- private ActionContributionItem buildPrintModelACI() {
- Action action = new Action("print model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TextFieldModelAdapterUITest.this.printModel();
- }
- };
- action.setToolTipText("print model");
- return new ActionContributionItem(action);
- }
-
- void printModel() {
- System.out.println("name: " + this.testModel.name());
- }
-
-
- // ********** model class **********
-
- class TestModel extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- public TestModel(String name) {
- this.name = name;
- }
- public String name() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
- @Override
- public String toString() {
- return "TestModel(" + this.name + ")";
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/TriStateCheckBoxModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/TriStateCheckBoxModelAdapterUITest.java
deleted file mode 100644
index 80b8840a85..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/swt/TriStateCheckBoxModelAdapterUITest.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.swt;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.ui.internal.swt.TriStateCheckBoxModelAdapter;
-import org.eclipse.jpt.ui.internal.widgets.DefaultWidgetFactory;
-import org.eclipse.jpt.ui.internal.widgets.TriStateCheckBox;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Play around with a set of tri-state check boxes.
- */
-public class TriStateCheckBoxModelAdapterUITest
- extends ApplicationWindow
-{
- private final TestModel testModel;
- private final WritablePropertyValueModel<TestModel> testModelHolder;
- private final WritablePropertyValueModel<Boolean> flag1Holder;
- private final WritablePropertyValueModel<Boolean> flag2Holder;
- private final WritablePropertyValueModel<Boolean> notFlag2Holder;
-
- public static void main(String[] args) throws Exception {
- Window window = new TriStateCheckBoxModelAdapterUITest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
- private TriStateCheckBoxModelAdapterUITest(String[] args) {
- super(null);
- this.testModel = new TestModel(Boolean.TRUE, Boolean.FALSE);
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.flag1Holder = this.buildFlag1Holder(this.testModelHolder);
- this.flag2Holder = this.buildFlag2Holder(this.testModelHolder);
- this.notFlag2Holder = this.buildNotFlag2Holder(this.testModelHolder);
- }
-
- private WritablePropertyValueModel<Boolean> buildFlag1Holder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Boolean>(subjectHolder, TestModel.FLAG1_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.isFlag1();
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setFlag1(value);
- }
- };
- }
-
- private WritablePropertyValueModel<Boolean> buildFlag2Holder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Boolean>(subjectHolder, TestModel.FLAG2_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.isFlag2();
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setFlag2(value);
- }
- };
- }
-
- private WritablePropertyValueModel<Boolean> buildNotFlag2Holder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Boolean>(subjectHolder, TestModel.NOT_FLAG2_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.isNotFlag2();
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setNotFlag2(value);
- }
- };
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(ClassTools.shortClassNameForObject(this));
- parent.setSize(400, 100);
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayout(new FormLayout());
- Control checkBoxPanel = this.buildCheckBoxPanel(mainPanel);
- this.buildControlPanel(mainPanel, checkBoxPanel);
- return mainPanel;
- }
-
- private Control buildCheckBoxPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100, -35);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildFlag1CheckBox(panel);
- this.buildFlag2CheckBox(panel);
- this.buildNotFlag2CheckBox(panel);
- this.buildUnattachedCheckBox(panel);
-
- return panel;
- }
-
- private void buildFlag1CheckBox(Composite parent) {
- TriStateCheckBox checkBox = new TriStateCheckBox(parent, "flag 1", DefaultWidgetFactory.instance());
- TriStateCheckBoxModelAdapter.adapt(this.flag1Holder, checkBox);
- }
-
- private void buildFlag2CheckBox(Composite parent) {
- TriStateCheckBox checkBox = new TriStateCheckBox(parent, "flag 2", DefaultWidgetFactory.instance());
- TriStateCheckBoxModelAdapter.adapt(this.flag2Holder, checkBox);
- }
-
- private void buildNotFlag2CheckBox(Composite parent) {
- TriStateCheckBox checkBox = new TriStateCheckBox(parent, "next flag 2", DefaultWidgetFactory.instance());
- TriStateCheckBoxModelAdapter.adapt(this.notFlag2Holder, checkBox);
- }
-
- private void buildUnattachedCheckBox(Composite parent) {
- TriStateCheckBox checkBox = new TriStateCheckBox(parent, "unattached", DefaultWidgetFactory.instance());
- checkBox.addSelectionListener(this.buildUnattachedSelectionListener());
- }
-
- private SelectionListener buildUnattachedSelectionListener() {
- return new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- System.out.println("unattached default selected: " + e);
- }
- public void widgetSelected(SelectionEvent e) {
- System.out.println("unattached selected: " + e);
- }
- };
- }
-
- private void buildControlPanel(Composite parent, Control checkBoxPanel) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(checkBoxPanel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildFlipFlag1Button(panel);
- this.buildClearModelButton(panel);
- this.buildRestoreModelButton(panel);
- this.buildPrintModelButton(panel);
- }
-
- private void buildFlipFlag1Button(Composite parent) {
- this.buildFlipFlag1ACI().fill(parent);
- }
-
- private ActionContributionItem buildFlipFlag1ACI() {
- Action action = new Action("next flag 1", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TriStateCheckBoxModelAdapterUITest.this.nextFlag1();
- }
- };
- action.setToolTipText("next flag 1");
- return new ActionContributionItem(action);
- }
-
- void nextFlag1() {
- this.testModel.nextFlag1();
- }
-
- private void buildClearModelButton(Composite parent) {
- this.buildClearModelACI().fill(parent);
- }
-
- private ActionContributionItem buildClearModelACI() {
- Action action = new Action("clear model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TriStateCheckBoxModelAdapterUITest.this.clearModel();
- }
- };
- action.setToolTipText("clear model");
- return new ActionContributionItem(action);
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private void buildRestoreModelButton(Composite parent) {
- this.buildRestoreModelACI().fill(parent);
- }
-
- private ActionContributionItem buildRestoreModelACI() {
- Action action = new Action("restore model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TriStateCheckBoxModelAdapterUITest.this.restoreModel();
- }
- };
- action.setToolTipText("restore model");
- return new ActionContributionItem(action);
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private void buildPrintModelButton(Composite parent) {
- this.buildPrintModelACI().fill(parent);
- }
-
- private ActionContributionItem buildPrintModelACI() {
- Action action = new Action("print model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TriStateCheckBoxModelAdapterUITest.this.printModel();
- }
- };
- action.setToolTipText("print model");
- return new ActionContributionItem(action);
- }
-
- void printModel() {
- System.out.println("flag 1: " + this.testModel.isFlag1());
- System.out.println("flag 2: " + this.testModel.isFlag2());
- System.out.println("not flag 2: " + this.testModel.isNotFlag2());
- System.out.println("***");
- }
-
-
- private class TestModel extends AbstractModel {
- private Boolean flag1;
- public static final String FLAG1_PROPERTY = "flag1";
- private Boolean flag2;
- public static final String FLAG2_PROPERTY = "flag2";
- private Boolean notFlag2;
- public static final String NOT_FLAG2_PROPERTY = "notFlag2";
-
- public TestModel(Boolean flag1, Boolean flag2) {
- this.flag1 = flag1;
- this.flag2 = flag2;
- this.notFlag2 = this.next(flag2);
- }
- private Boolean next(Boolean b) {
- return (b == null) ? Boolean.TRUE : b.booleanValue() ? Boolean.FALSE : null;
- }
- public Boolean isFlag1() {
- return this.flag1;
- }
- public void setFlag1(Boolean flag1) {
- Boolean old = this.flag1;
- this.flag1 = flag1;
- this.firePropertyChanged(FLAG1_PROPERTY, old, flag1);
- }
- public void nextFlag1() {
- this.setFlag1(this.next(this.flag1));
- }
- public Boolean isFlag2() {
- return this.flag2;
- }
- public void setFlag2(Boolean flag2) {
- Boolean old = this.flag2;
- this.flag2 = flag2;
- this.firePropertyChanged(FLAG2_PROPERTY, old, flag2);
-
- old = this.notFlag2;
- this.notFlag2 = this.next(flag2);
- this.firePropertyChanged(NOT_FLAG2_PROPERTY, old, this.notFlag2);
- }
- public void nextFlag2() {
- this.setFlag2(this.next(this.flag2));
- }
- public Boolean isNotFlag2() {
- return this.notFlag2;
- }
- public void setNotFlag2(Boolean notFlag2) {
- this.setFlag2(this.next(flag2));
- }
- public void nextNotFlag2() {
- this.setNotFlag2(this.next(this.notFlag2));
- }
- @Override
- public String toString() {
- return "TestModel(" + this.isFlag1() + " - " + this.isFlag2() + ")";
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlAlignerTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlAlignerTest.java
deleted file mode 100644
index 1309b1e27f..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlAlignerTest.java
+++ /dev/null
@@ -1,801 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.util;
-
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jpt.ui.internal.util.ControlAligner;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Shell;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-@SuppressWarnings("nls")
-public final class ControlAlignerTest {
-
- private ControlAligner controlAligner;
- private Composite parent;
- private Shell shell;
-
- private Layout buildSpacerLayout() {
- return new Layout() {
- @Override
- protected Point computeSize(Composite composite,
- int widthHint,
- int heightHint,
- boolean flushCache) {
-
- return new Point(widthHint, heightHint);
- }
-
- @Override
- protected void layout(Composite composite, boolean flushCache) {
- GridData data = (GridData) composite.getLayoutData();
- composite.setBounds(0, 0, data.widthHint, data.heightHint);
- }
- };
- }
-
- @Before
- public void setUp() {
-
- controlAligner = new ControlAligner();
-
- shell = new Shell(Display.getCurrent());
- shell.setLayout(new GridLayout(1, false));
-
- parent = new Composite(shell, SWT.NONE);
- parent.setLayout(new GridLayout(1, false));
- parent.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- }
-
- @After
- public void tearDown() {
-
- if (controlAligner != null) {
- controlAligner.dispose();
- controlAligner = null;
- }
-
- if (shell != null) {
- shell.dispose();
- shell = null;
- }
- }
-
- @Test
- public void testAddControl1() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label label = new Label(pane, SWT.NULL);
- updateGridData(label);
-
- controlAligner.add(label);
-
- assertEquals(
- "The maximum width should be 0,",
- 0,
- controlAligner.getMaximumWidth()
- );
-
- label.setText("This is a ControlAligner");
-// parent.layout(true, true);
-
- Point size = label.getSize();
-
- assertEquals(
- "The width should be " + size.x + ",",
- size.x,
- controlAligner.getMaximumWidth()
- );
- }
-
- @Test
- public void testAddControl2() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Button button = new Button(pane, SWT.NULL);
- button.setText("This is a ControlAligner");
- updateGridData(button);
-
- controlAligner.add(button);
- parent.layout(true, true);
-
- Point size = button.getSize();
-
- assertEquals(
- "The width should be " + size.x + ",",
- size.x,
- controlAligner.getMaximumWidth()
- );
- }
-
- @Test
- public void testAddControl3() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label label = new Label(pane, SWT.NULL);
- label.setText("This is very long text");
- updateGridData(label);
-
- Button button = new Button(pane, SWT.NULL);
- button.setText("Short text");
- updateGridData(button);
-
-// parent.layout(true, true);
-
- controlAligner.add(label);
- controlAligner.add(button);
-
- Point labelSize = label.getSize();
- Point buttonSize = button.getSize();
- int max = Math.max(labelSize.x, buttonSize.x);
-
- assertEquals(
- "The width should be " + max + ",",
- max,
- controlAligner.getMaximumWidth()
- );
- }
-
- @Test
- public void testAddControlAligner1() throws Exception {
-
- Label label1 = new Label(parent, SWT.NULL);
- Label label2 = new Label(parent, SWT.NULL);
-
- updateGridData(label1);
- updateGridData(label2);
-
- controlAligner.add(label1);
-
- ControlAligner controlAligner2 = new ControlAligner();
- controlAligner.add(controlAligner2);
- controlAligner2.add(label2);
-
- label1.setText("This is a ControlAligner");
- label2.setText("This is a very long ControlAligner");
-// parent.layout(true, true);
-
- Point size1 = label1.getSize();
- Point size2 = label2.getSize();
- int width = Math.max(size1.x, size2.x);
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner2.getMaximumWidth()
- );
- }
-
- @Test
- public void testAddControlAligner2() throws Exception {
-
- Label label1 = new Label(parent, SWT.NULL);
- Label label2 = new Label(parent, SWT.NULL);
-
- updateGridData(label1);
- updateGridData(label2);
-
- controlAligner.add(label1);
-
- ControlAligner controlAligner2 = new ControlAligner();
- controlAligner2.add(label2);
-
- label1.setText("This is a ControlAligner");
- label2.setText("This is a very long ControlAligner");
-
- controlAligner.add(controlAligner2);
-// parent.layout(true, true);
-
- Point size1 = label1.getSize();
- Point size2 = label2.getSize();
- int width = Math.max(size1.x, size2.x);
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner2.getMaximumWidth()
- );
- }
-
- @Test(expected=IllegalArgumentException.class)
- public void testAddControlAlignerToItself() throws Exception {
- controlAligner.add(controlAligner);
- fail("A ControlAligner can't be added to itself");
- }
-
- @Test
- public void testDialog_AddControl1() throws Exception {
-
- final int[] maximumWidth = new int[1];
- final int[] size = new int[1];
-
- TitleAreaDialog dialog = new TitleAreaDialog(SWTUtil.getShell()) {
-
- private Label label;
-
- @Override
- protected Control createDialogArea(Composite parent) {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- label = new Label(pane, SWT.LEFT);
- label.setText("This is a ControlAligner");
- updateGridData(label);
-
- controlAligner.add(label);
-
- return parent;
- }
-
- @Override
- protected void initializeBounds() {
- super.initializeBounds();
- size[0] = label.getSize().x;
- maximumWidth[0] = controlAligner.getMaximumWidth();
- }
- };
-
- dialog.create();
- dialog.close();
-
- assertEquals(
- "The width should be " + size[0] + ",",
- size[0],
- maximumWidth[0]
- );
- }
-
- @Test
- public void testDialog_AddControl2() throws Exception {
-
- final int[] maximumWidth = new int[1];
- final int[] sizes = new int[2];
-
- TitleAreaDialog dialog = new TitleAreaDialog(SWTUtil.getShell()) {
-
- private Button button;
- private Label label;
-
- @Override
- protected Control createDialogArea(Composite parent) {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- label = new Label(pane, SWT.NULL);
- label.setText("This is a ControlAligner");
- updateGridData(label);
-
- controlAligner.add(label);
-
- button = new Button(pane, SWT.NULL);
- button.setText("Short text");
- updateGridData(button);
-
- controlAligner.add(button);
-
- return parent;
- }
-
- @Override
- protected void initializeBounds() {
- super.initializeBounds();
- sizes[0] = label.getSize().x;
- sizes[1] = button.getSize().x;
- maximumWidth[0] = controlAligner.getMaximumWidth();
- }
- };
-
- dialog.create();
- dialog.close();
-
- int labelSize = sizes[0];
- int buttonSize = sizes[1];
- int max = Math.max(labelSize, buttonSize);
-
- assertEquals(
- "The width should be " + max + ",",
- max,
- maximumWidth[0]
- );
- }
-
- @Test
- public void testDispose() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label label = new Label(pane, SWT.NULL);
- label.setText("This is very long text");
- updateGridData(label);
-
- Button button = new Button(pane, SWT.NULL);
- button.setText("Short text");
- updateGridData(button);
-
- controlAligner.add(label);
- controlAligner.add(button);
-
- Point labelSize = label.getSize();
- Point buttonSize = button.getSize();
- int max = Math.max(labelSize.x, buttonSize.x);
-
- assertEquals(
- "The width should be " + max + ",",
- max,
- controlAligner.getMaximumWidth()
- );
-
- label.dispose();
-
- Point newButtonSize = button.getSize();
-
- assertNotSame(
- "The old max and new max should not be the same",
- max,
- newButtonSize.x
- );
-
- assertEquals(
- "The ControlAligner doesn't have the right maximum width",
- newButtonSize.x,
- controlAligner.getMaximumWidth()
- );
- }
-
- @Test
- public void testHierarchyOfControlAligners() throws Exception {
-
- // Aligner1
- // ^
- // |-Aligner2
- // ^
- // |-Aligner3
- ControlAligner controlAligner2 = new ControlAligner();
- controlAligner.add(controlAligner2);
-
- ControlAligner controlAligner3 = new ControlAligner();
- controlAligner2.add(controlAligner3);
-
- // Test 1
- Label label1 = new Label(parent, SWT.NULL);
- label1.setText("This is a label widget");
- parent.layout(true, true);
-
- int labelWidth1 = label1.getSize().x;
- controlAligner3.add(label1);
-
- assertEquals(controlAligner3.getMaximumWidth(), labelWidth1);
- assertEquals(controlAligner2.getMaximumWidth(), labelWidth1);
- assertEquals(controlAligner.getMaximumWidth(), labelWidth1);
-
- // Test 2
- Label label2 = new Label(parent, SWT.NULL);
- label2.setText("ShortLabel");
- controlAligner2.add(label2);
- parent.layout(true);
-
- int newLabelWidth1 = label1.getSize().x;
- int newLabelWidth2 = label2.getSize().x;
-
- assertEquals(controlAligner3.getMaximumWidth(), controlAligner2.getMaximumWidth());
- assertEquals(controlAligner2.getMaximumWidth(), controlAligner.getMaximumWidth());
- assertEquals(newLabelWidth1, newLabelWidth2);
- assertEquals(newLabelWidth1, controlAligner.getMaximumWidth());
-
- // Test 3
- Label label3 = new Label(parent, SWT.NULL);
- label3.setText("A very long label that takes a lot of horizontal space");
-// parent.layout(true);
- controlAligner.add(label3);
-
- newLabelWidth1 = label1.getSize().x;
- newLabelWidth2 = label2.getSize().x;
- int newLabelWidth3 = label3.getSize().x;
-
- assertEquals(controlAligner3.getMaximumWidth(), controlAligner2.getMaximumWidth());
- assertEquals(controlAligner2.getMaximumWidth(), controlAligner.getMaximumWidth());
- assertEquals(newLabelWidth1, newLabelWidth2);
- assertEquals(newLabelWidth2, newLabelWidth3);
- assertEquals(newLabelWidth1, controlAligner.getMaximumWidth());
-
- // Make sure all the locked are removed
- assertEquals(ClassTools.attemptToGetFieldValue(controlAligner, "locked"), Boolean.FALSE);
- assertEquals(ClassTools.attemptToGetFieldValue(controlAligner2, "locked"), Boolean.FALSE);
- assertEquals(ClassTools.attemptToGetFieldValue(controlAligner3, "locked"), Boolean.FALSE);
-
- // Change the text of label2
- label2.setText("mm");
-// parent.layout(true);
-
- newLabelWidth1 = label1.getSize().x;
- newLabelWidth2 = label2.getSize().x;
- newLabelWidth3 = label3.getSize().x;
-
- assertEquals(controlAligner3.getMaximumWidth(), controlAligner2.getMaximumWidth());
- assertEquals(controlAligner2.getMaximumWidth(), controlAligner.getMaximumWidth());
- assertEquals(newLabelWidth1, newLabelWidth2);
- assertEquals(newLabelWidth2, newLabelWidth3);
- assertEquals(newLabelWidth1, controlAligner.getMaximumWidth());
-
- assertEquals(ClassTools.attemptToGetFieldValue(controlAligner, "locked"), Boolean.FALSE);
- assertEquals(ClassTools.attemptToGetFieldValue(controlAligner2, "locked"), Boolean.FALSE);
- assertEquals(ClassTools.attemptToGetFieldValue(controlAligner3, "locked"), Boolean.FALSE);
-
- // Change the text of label1
- label1.setText("a");
-// parent.layout(true);
-
- Composite parent1 = new Composite(SWTUtil.getShell(), SWT.NULL);
- parent1.setLayout(new GridLayout());
-
- Label tempLabel = new Label(parent1, SWT.NULL);
- tempLabel.setText("a");
-// parent1.layout(true);
-
- int realWidth = tempLabel.getSize().x;
-
- newLabelWidth1 = label1.getSize().x;
- newLabelWidth2 = label2.getSize().x;
- newLabelWidth3 = label3.getSize().x;
-
- assertEquals(controlAligner3.getMaximumWidth(), controlAligner2.getMaximumWidth());
- assertEquals(controlAligner2.getMaximumWidth(), controlAligner.getMaximumWidth());
- assertEquals(newLabelWidth1, newLabelWidth2);
- assertEquals(newLabelWidth2, newLabelWidth3);
- assertEquals(newLabelWidth1, controlAligner.getMaximumWidth());
- assertFalse(newLabelWidth1 == realWidth);
-
- assertEquals(ClassTools.attemptToGetFieldValue(controlAligner, "locked"), Boolean.FALSE);
- assertEquals(ClassTools.attemptToGetFieldValue(controlAligner2, "locked"), Boolean.FALSE);
- assertEquals(ClassTools.attemptToGetFieldValue(controlAligner3, "locked"), Boolean.FALSE);
-
- // Change the text of label1
- label1.setText("Yes another big long long text so that all the labels will have to take the size of this label to make sure ControlAligner works correctly");
-// parent.layout(true);
-
- // Weird: It seems no notification is sent, fire one manually
- Event event = new Event();
- event.widget = label1;
- event.type = SWT.Resize;
- label1.notifyListeners(SWT.Resize, event);
-
- Composite parent2 = new Composite(SWTUtil.getShell(), SWT.NULL);
- parent2.setLayout(new GridLayout());
-
- tempLabel = new Label(parent2, SWT.NULL);
- tempLabel.setText(label1.getText());
- parent2.layout(true);
-
- realWidth = tempLabel.getSize().x;
-
- newLabelWidth1 = label1.getSize().x;
- newLabelWidth2 = label2.getSize().x;
- newLabelWidth3 = label3.getSize().x;
-
- assertEquals(controlAligner3.getMaximumWidth(), controlAligner2.getMaximumWidth());
- assertEquals(controlAligner2.getMaximumWidth(), controlAligner.getMaximumWidth());
- assertEquals(newLabelWidth1, newLabelWidth2);
- assertEquals(newLabelWidth2, newLabelWidth3);
- assertEquals(controlAligner.getMaximumWidth(), newLabelWidth1);
- assertEquals(realWidth, newLabelWidth1);
-
- assertEquals(ClassTools.attemptToGetFieldValue(controlAligner, "locked"), Boolean.FALSE);
- assertEquals(ClassTools.attemptToGetFieldValue(controlAligner2, "locked"), Boolean.FALSE);
- assertEquals(ClassTools.attemptToGetFieldValue(controlAligner3, "locked"), Boolean.FALSE);
- }
-
- @Test
- public void testRemoveControl1() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Button button = new Button(pane, SWT.NULL);
- button.setText("This is a ControlAligner");
- updateGridData(button);
-
- controlAligner.add(button);
- parent.layout(true, true);
-
- Point size = button.getSize();
-
- assertEquals(
- "The width should be " + size.x + ",",
- size.x,
- controlAligner.getMaximumWidth()
- );
-
- controlAligner.remove(button);
-
- assertEquals(
- "The width should be 0, ",
- 0,
- controlAligner.getMaximumWidth()
- );
- }
-
- @Test
- public void testRemoveControl2() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label label = new Label(pane, SWT.NULL);
- label.setText("This is very long text");
- updateGridData(label);
-
- Button button = new Button(pane, SWT.NULL);
- button.setText("Short text");
- updateGridData(button);
-// parent.layout(true, true);
-
- controlAligner.add(label);
- controlAligner.add(button);
-
- Point labelSize = label.getSize();
- Point buttonSize = button.getSize();
- int max = Math.max(labelSize.x, buttonSize.x);
-
- assertEquals(
- "The width should be " + max + ",",
- max,
- controlAligner.getMaximumWidth()
- );
-
- controlAligner.remove(label);
-
- Point newButtonSize = button.getSize();
-
- assertNotSame(
- "The old max and new max should not be the same",
- max,
- newButtonSize.x
- );
-
- assertEquals(
- "The ControlAligner doesn't have the right maximum width",
- newButtonSize.x,
- controlAligner.getMaximumWidth()
- );
- }
-
- @Test
- public void testRemoveControl4() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Widget 1
- Label label = new Label(pane, SWT.NULL);
- label.setText("This is very long text");
- updateGridData(label);
- controlAligner.add(label);
-
- // Widget 2
- Composite spacer = new Composite(pane, SWT.NULL);
- spacer.setLayout(buildSpacerLayout());
- updateGridData(spacer);
- controlAligner.add(spacer);
-
- // Widget 3
- Button button = new Button(pane, SWT.NULL);
- button.setText("Short text");
- updateGridData(button);
- controlAligner.add(button);
-
-// parent.layout(true, true);
-
- // Make sure the 3 widgets have the same width
- Point labelSize = label.getSize();
- Point spacerSize = spacer.getSize();
- Point buttonSize = button.getSize();
- int max = Math.max(labelSize.x, buttonSize.x);
- max = Math.max(max, spacerSize.x);
-
- assertEquals(
- "The width should be " + max + ",",
- max,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The spacer's width should be " + max + ",",
- max,
- spacerSize.x
- );
-
- // Remove the label (the widest widget) and make sure the width was
- // correctly calculated
- controlAligner.remove(label);
-
- spacerSize = spacer.getSize();
- buttonSize = button.getSize();
- int max2 = Math.max(spacerSize.x, buttonSize.x);
-
- assertNotSame(
- "The old max and new max should not be the same",
- max,
- max2
- );
-
- assertEquals(
- "The ControlAligner doesn't have the right maximum width",
- max2,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The spacer's width should have been adjusted",
- max2,
- spacerSize.x
- );
- }
-
- @Test
- public void testRemoveControlAligner1() throws Exception {
-
- Label label1 = new Label(parent, SWT.NULL);
- Label label2 = new Label(parent, SWT.NULL);
-
- updateGridData(label1);
- updateGridData(label2);
-
- controlAligner.add(label1);
-
- ControlAligner controlAligner2 = new ControlAligner();
- controlAligner.add(controlAligner2);
- controlAligner2.add(label2);
-
- label1.setText("This is a ControlAligner");
- label2.setText("This is a very long ControlAligner");
-// parent.layout(true, true);
-
- Point size1 = label1.getSize();
- Point size2 = label2.getSize();
- int width = Math.max(size1.x, size2.x);
-
- // Test 1
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner2.getMaximumWidth()
- );
-
- // Test 2
- controlAligner.remove(label1);
-
- width = label2.getSize().x;
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner2.getMaximumWidth()
- );
- }
-
- @Test
- public void testRemoveControlAligner2() throws Exception {
-
- Label label1 = new Label(parent, SWT.NULL);
- Label label2 = new Label(parent, SWT.NULL);
-
- updateGridData(label1);
- updateGridData(label2);
-
- controlAligner.add(label1);
-
- ControlAligner controlAligner2 = new ControlAligner();
- controlAligner.add(controlAligner2);
- controlAligner2.add(label2);
-
- label1.setText("This is a ControlAligner");
- label2.setText("This is a very long ControlAligner");
-// parent.layout(true, true);
-
- Point size1 = label1.getSize();
- Point size2 = label2.getSize();
- int width = Math.max(size1.x, size2.x);
-
- // Test 1
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner2.getMaximumWidth()
- );
-
- // Test 2
- controlAligner2.remove(label2);
-
- width = label1.getSize().x;
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner2.getMaximumWidth()
- );
- }
-
- private void updateGridData(Control control) {
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = false;
- control.setLayoutData(data);
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlEnablerTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlEnablerTest.java
deleted file mode 100644
index 7062cc92f7..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlEnablerTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.util;
-
-import org.eclipse.jpt.ui.internal.util.ControlEnabler;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-@SuppressWarnings("nls")
-public final class ControlEnablerTest {
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- }
- }
-
- @Test
- public void testSwitchState() {
-
- SimplePropertyValueModel<Boolean> booleanHolder =
- new SimplePropertyValueModel<Boolean>(true);
-
- Combo combo = new Combo(parent, SWT.BORDER);
-
- new ControlEnabler(booleanHolder, combo);
-
- assertTrue(
- "The Combo should be enabled",
- combo.isEnabled()
- );
-
- // Change state (null)
- booleanHolder.setValue(null);
-
- assertFalse(
- "The Combo should not be enabled",
- combo.isEnabled()
- );
-
- // Change state (true)
- booleanHolder.setValue(true);
-
- assertTrue(
- "The Combo should be enabled",
- combo.isEnabled()
- );
-
- // Change state (false)
- booleanHolder.setValue(false);
-
- assertFalse(
- "The Combo should not be enabled",
- combo.isEnabled()
- );
-
- // Dispose
- combo.dispose();
- booleanHolder.setValue(true);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlSwitcherTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlSwitcherTest.java
deleted file mode 100644
index f43e2bcf63..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlSwitcherTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.util;
-
-import org.eclipse.jpt.ui.internal.util.ControlSwitcher;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.Transformer;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.part.PageBook;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-@SuppressWarnings("nls")
-public final class ControlSwitcherTest {
-
- private PageBook pageBook;
- private Composite pane1;
- private Composite pane2;
- private Composite parent;
-
- private Composite buildPane1() {
-
- if (pane1 == null) {
-
- pane1 = new Composite(pageBook, SWT.NULL);
- pane1.setLayout(new GridLayout(2, false));
-
- Label label = new Label(pane1, SWT.NULL);
- label.setText("&Test2:");
-
- Text text = new Text(pane1, SWT.BORDER);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Combo combo = new Combo(pane1, SWT.BORDER);
-
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 2;
- combo.setLayoutData(data);
- }
-
- return pane1;
- }
-
- private Composite buildPane2() {
-
- if (pane2 == null) {
-
- pane2 = new Composite(pageBook, SWT.NULL);
- pane2.setLayout(new GridLayout(2, false));
-
- Label label = new Label(pane2, SWT.NULL);
- label.setText("&Test1:");
-
- Text text = new Text(pane2, SWT.BORDER);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
-
- return pane2;
- }
-
- private Transformer<Boolean, Control> buildTransformer() {
- return new Transformer<Boolean, Control>() {
- public Control transform(Boolean value) {
- return (value == null) ? null : (value ? pane1 : pane2);
- }
- };
- }
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
-
- pageBook = new PageBook(parent, SWT.NULL);
- pageBook.setLayoutData(new GridData());
- }
-
- @After
- public void tearDown() {
-
- if (parent != null) {
-
- parent.dispose();
-
- parent = null;
- pageBook = null;
- }
- }
-
- @Test
- public void testSwitch() {
-
- SimplePropertyValueModel<Boolean> switchHolder = new SimplePropertyValueModel<Boolean>();
- Transformer<Boolean, Control> transformer = buildTransformer();
-
- pane1 = buildPane1();
- pane1.setVisible(false);
-
- pane2 = buildPane2();
- pane2.setVisible(false);
-
- new ControlSwitcher(
- switchHolder,
- transformer,
- pageBook
- );
-
- // Test 1
- switchHolder.setValue(true);
- Control control = (Control) ClassTools.fieldValue(pageBook, "currentPage");
-
- assertNotNull(
- "The page book's page shouldn't be null",
- control
- );
-
- assertSame(
- "The current pane should be pane1",
- pane1,
- control
- );
-
- Point pane1Size = pane1.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Point pageBookSize = pageBook.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- assertEquals(
- "The width of the PageBook should be the same as the width of pane1",
- pane1Size.x,
- pageBookSize.x
- );
-
- assertEquals(
- "The height of the PageBook should be the same as the height of pane1",
- pane1Size.y,
- pageBookSize.y
- );
-
- // Test 2
- switchHolder.setValue(false);
- control = (Control) ClassTools.fieldValue(pageBook, "currentPage");
-
- assertNotNull(
- "The page book's page shouldn't be null",
- control
- );
-
- assertSame(
- "The current pane should be pane2",
- pane2,
- control
- );
-
- Point pane2Size = pane2.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- pageBookSize = pageBook.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- assertEquals(
- "The width of the PageBook should be the same as the width of pane2",
- pane2Size.x,
- pageBookSize.x
- );
-
- assertEquals(
- "The height of the PageBook should be the same as the height of pane2",
- pane2Size.y,
- pageBookSize.y
- );
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlVisibilityEnablerTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlVisibilityEnablerTest.java
deleted file mode 100644
index 3eaff35309..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/ControlVisibilityEnablerTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.util;
-
-import org.eclipse.jpt.ui.internal.util.ControlVisibilityEnabler;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-@SuppressWarnings("nls")
-public final class ControlVisibilityEnablerTest {
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- }
- }
-
- @Test
- public void testSwitchState() {
-
- SimplePropertyValueModel<Boolean> booleanHolder =
- new SimplePropertyValueModel<Boolean>(true);
-
- Combo combo = new Combo(parent, SWT.BORDER);
-
- new ControlVisibilityEnabler(booleanHolder, combo);
-
- assertTrue(
- "The Combo should be visible",
- combo.isVisible()
- );
-
- // Change state (null)
- booleanHolder.setValue(null);
-
- assertFalse(
- "The Combo should not be visible",
- combo.isVisible()
- );
-
- // Change state (true)
- booleanHolder.setValue(true);
-
- assertTrue(
- "The Combo should be visible",
- combo.isVisible()
- );
-
- // Change state (false)
- booleanHolder.setValue(false);
-
- assertFalse(
- "The Combo should not be visible",
- combo.isVisible()
- );
-
- // Dispose
- combo.dispose();
- booleanHolder.setValue(true);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/JptUiUtilTests.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/JptUiUtilTests.java
deleted file mode 100644
index 81cfb08253..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/JptUiUtilTests.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.util;
-
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@SuiteClasses
-({
- ControlAlignerTest.class,
- ControlSwitcherTest.class,
- ControlEnablerTest.class,
- ControlVisibilityEnablerTest.class,
- LabeledButtonTest.class,
- LabeledLabelTest.class,
- LabeledControlUpdaterTest.class,
- PaneEnablerTest.class,
- PaneVisibilityEnablerTest.class,
-})
-@RunWith(Suite.class)
-public final class JptUiUtilTests {
-
- private JptUiUtilTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(JptUiUtilTests.class));
- return suite;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/LabeledButtonTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/LabeledButtonTest.java
deleted file mode 100644
index 8057d1b29d..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/LabeledButtonTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.util;
-
-import org.eclipse.core.runtime.AssertionFailedException;
-import org.eclipse.jpt.ui.internal.util.LabeledButton;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-@SuppressWarnings("nls")
-public final class LabeledButtonTest {
-
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- parent = null;
- }
- }
-
- @Test
- public void testLabeledButton1() {
- Button button = new Button(parent, SWT.NULL);
- new LabeledButton(button);
- }
-
- @Test(expected=AssertionFailedException.class)
- public void testLabeledButton2() {
- new LabeledButton(null);
- }
-
- @Test
- public void testSetImage() {
-
- Image expected = new Image(parent.getDisplay(), 16, 16);
-
- try {
- Button button = new Button(parent, SWT.NULL);
- LabeledButton labeledButton = new LabeledButton(button);
-
- labeledButton.setImage(expected);
-
- assertEquals(
- "The Button didn't receive the Image",
- expected,
- button.getImage()
- );
- }
- finally {
- expected.dispose();
- }
- }
-
- @Test
- public void testSetImageDispose() {
-
- Image expected = new Image(parent.getDisplay(), 16, 16);
-
- try {
- Button button = new Button(parent, SWT.NULL);
- LabeledButton labeledButton = new LabeledButton(button);
-
- button.dispose();
-
- // This should not fail but simply do nothing
- labeledButton.setImage(expected);
- }
- finally {
- expected.dispose();
- }
- }
-
- @Test
- public void testSetText() {
- Button button = new Button(parent, SWT.NULL);
- LabeledButton labeledButton = new LabeledButton(button);
-
- String expected = "This is a test";
- labeledButton.setText(expected);
-
- assertEquals(
- "The Button didn't receive the text",
- expected,
- button.getText()
- );
- }
-
- @Test
- public void testSetTextDispose() {
- Button button = new Button(parent, SWT.NULL);
- LabeledButton labeledButton = new LabeledButton(button);
-
- button.dispose();
-
- // This should not fail but simply do nothing
- String expected = "This is a test";
- labeledButton.setText(expected);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/LabeledControlUpdaterTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/LabeledControlUpdaterTest.java
deleted file mode 100644
index bb1385264f..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/LabeledControlUpdaterTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.util;
-
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-@SuppressWarnings("nls")
-public final class LabeledControlUpdaterTest {
-
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- parent = null;
- }
- }
-
- @Test
- public void testSetImage() {
-
- Image expected = new Image(parent.getDisplay(), 16, 16);
-
- try {
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- WritablePropertyValueModel<Image> imageHolder = new SimplePropertyValueModel<Image>();
- new LabeledControlUpdater(labeledLabel, null, imageHolder);
-
- labeledLabel.setImage(expected);
-
- assertEquals(
- "The Label didn't receive the Image",
- expected,
- label.getImage()
- );
- }
- finally {
- expected.dispose();
- }
- }
-
- @Test
- public void testSetImageDispose() {
-
- Image expected = new Image(parent.getDisplay(), 16, 16);
-
- try {
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- WritablePropertyValueModel<Image> imageHolder = new SimplePropertyValueModel<Image>();
- new LabeledControlUpdater(labeledLabel, null, imageHolder);
-
- label.dispose();
- labeledLabel.setImage(expected);
- }
- finally {
- expected.dispose();
- }
- }
-
- @Test
- public void testSetText() {
-
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- WritablePropertyValueModel<String> textHolder = new SimplePropertyValueModel<String>();
- new LabeledControlUpdater(labeledLabel, textHolder);
-
- String expected = "This is a test";
- textHolder.setValue(expected);
-
- assertEquals(
- "The Label didn't receive the text",
- expected,
- label.getText()
- );
- }
-
- @Test
- public void testSetTextDispose() {
-
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- WritablePropertyValueModel<String> textHolder = new SimplePropertyValueModel<String>();
- new LabeledControlUpdater(labeledLabel, textHolder);
-
- label.dispose();
-
- String expected = "This is a test";
- textHolder.setValue(expected);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/LabeledLabelTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/LabeledLabelTest.java
deleted file mode 100644
index 5440d3c21d..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/LabeledLabelTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.util;
-
-import org.eclipse.core.runtime.AssertionFailedException;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-@SuppressWarnings("nls")
-public final class LabeledLabelTest {
-
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- parent = null;
- }
- }
-
- @Test
- public void testLabeledButton1() {
- Label label = new Label(parent, SWT.NULL);
- new LabeledLabel(label);
- }
-
- @Test(expected=AssertionFailedException.class)
- public void testLabeledButton2() {
- new LabeledLabel(null);
- }
-
- @Test
- public void testSetImage() {
-
- Image expected = new Image(parent.getDisplay(), 16, 16);
-
- try {
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- labeledLabel.setImage(expected);
-
- assertEquals(
- "The Label didn't receive the Image",
- expected,
- label.getImage()
- );
- }
- finally {
- expected.dispose();
- }
- }
-
- @Test
- public void testSetImageDispose() {
-
- Image expected = new Image(parent.getDisplay(), 16, 16);
-
- try {
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- label.dispose();
-
- // This should not fail but simply do nothing
- labeledLabel.setImage(expected);
- }
- finally {
- expected.dispose();
- }
- }
-
- @Test
- public void testSetText() {
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- String expected = "This is a test";
- labeledLabel.setText(expected);
-
- assertEquals(
- "The Label didn't receive the text",
- expected,
- label.getText()
- );
- }
-
- @Test
- public void testSetTextDispose() {
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- label.dispose();
-
- // This should not fail but simply do nothing
- String expected = "This is a test";
- labeledLabel.setText(expected);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/PaneEnablerTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/PaneEnablerTest.java
deleted file mode 100644
index 53637277fe..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/PaneEnablerTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.util;
-
-import org.eclipse.jpt.ui.internal.util.PaneEnabler;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.ui.internal.widgets.AbstractDialogPane;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.node.Node;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-@SuppressWarnings("nls")
-public final class PaneEnablerTest {
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- }
- }
-
- @Test
- public void testSwitchState() {
-
- SimplePropertyValueModel<Boolean> booleanHolder =
- new SimplePropertyValueModel<Boolean>(true);
-
- AbstractDialogPane<Node> pane = new AbstractDialogPane<Node>(
- new SimplePropertyValueModel<Node>(),
- parent)
- {
- @Override
- protected void initializeLayout(Composite container) {
- }
- };
-
- pane.populate();
- new PaneEnabler(booleanHolder, pane);
-
- assertTrue(
- "The pane should be enabled",
- pane.getControl().isEnabled()
- );
-
- // Change state (null)
- booleanHolder.setValue(null);
-
- assertFalse(
- "The pane should not be enabled",
- pane.getControl().isEnabled()
- );
-
- // Change state (true)
- booleanHolder.setValue(true);
-
- assertTrue(
- "The pane should be enabled",
- pane.getControl().isEnabled()
- );
-
- // Change state (false)
- booleanHolder.setValue(false);
-
- assertFalse(
- "The pane should not be enabled",
- pane.getControl().isEnabled()
- );
-
- // Dispose
- pane.dispose();
- booleanHolder.setValue(true);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/PaneVisibilityEnablerTest.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/PaneVisibilityEnablerTest.java
deleted file mode 100644
index 2d88c9c114..0000000000
--- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/util/PaneVisibilityEnablerTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.tests.internal.util;
-
-import org.eclipse.jpt.ui.internal.util.PaneVisibilityEnabler;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.ui.internal.widgets.AbstractDialogPane;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.node.Node;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-@SuppressWarnings("nls")
-public final class PaneVisibilityEnablerTest {
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- }
- }
-
- @Test
- public void testSwitchState() {
-
- SimplePropertyValueModel<Boolean> booleanHolder =
- new SimplePropertyValueModel<Boolean>(true);
-
- AbstractDialogPane<Node> pane = new AbstractDialogPane<Node>(
- new SimplePropertyValueModel<Node>(),
- parent)
- {
- @Override
- protected void initializeLayout(Composite container) {
- }
- };
-
- pane.populate();
- new PaneVisibilityEnabler(booleanHolder, pane);
-
- assertTrue(
- "The pane should be visible",
- pane.getControl().isVisible()
- );
-
- // Change state (null)
- booleanHolder.setValue(null);
-
- assertFalse(
- "The pane should not be visible",
- pane.getControl().isVisible()
- );
-
- // Change state (true)
- booleanHolder.setValue(true);
-
- assertTrue(
- "The pane should be visible",
- pane.getControl().isVisible()
- );
-
- // Change state (false)
- booleanHolder.setValue(false);
-
- assertFalse(
- "The pane should not be visible",
- pane.getControl().isVisible()
- );
-
- // Dispose
- pane.dispose();
- booleanHolder.setValue(true);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/.classpath b/jpa/tests/org.eclipse.jpt.utility.tests/.classpath
deleted file mode 100644
index ef8d91ca94..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/utility/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/.cvsignore b/jpa/tests/org.eclipse.jpt.utility.tests/.cvsignore
deleted file mode 100644
index c4ba612bad..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-bin
-@dot
-temp.folder
-build.xml
-javaCompiler...args \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/.project b/jpa/tests/org.eclipse.jpt.utility.tests/.project
deleted file mode 100644
index aa5271e003..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.utility.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.core.resources.prefs b/jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index f68f9c2597..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tue Jan 15 11:12:26 EST 2008
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.jdt.core.prefs b/jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 84b5c4c710..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Sun May 27 14:55:58 EDT 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.utility.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index f628cfa1fe..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,18 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.utility.tests
-Bundle-Version: 1.2.0
-Bundle-Localization: plugin
-Require-Bundle: org.eclipse.jpt.utility;bundle-version="[1.2.0,2.0.0)",
- org.junit;bundle-version="[3.0.0,4.0.0)"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.eclipse.jpt.utility.tests.internal;x-internal:=true,
- org.eclipse.jpt.utility.tests.internal.iterators;x-internal:=true,
- org.eclipse.jpt.utility.tests.internal.model;x-internal:=true,
- org.eclipse.jpt.utility.tests.internal.model.listener;x-internal:=true,
- org.eclipse.jpt.utility.tests.internal.model.value;x-internal:=true,
- org.eclipse.jpt.utility.tests.internal.model.value.prefs;x-internal:=true,
- org.eclipse.jpt.utility.tests.internal.model.value.swing;x-internal:=true,
- org.eclipse.jpt.utility.tests.internal.node;x-internal:=true
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/about.html b/jpa/tests/org.eclipse.jpt.utility.tests/about.html
deleted file mode 100644
index 9e73bdabb6..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>June 06, 2007</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/build.properties b/jpa/tests/org.eclipse.jpt.utility.tests/build.properties
deleted file mode 100644
index ebe9c08ef9..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/build.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-################################################################################
-# Copyright (c) 2006, 2007 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-source.. = src/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- about.html,\
- test.xml,\
- plugin.properties
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/plugin.properties b/jpa/tests/org.eclipse.jpt.utility.tests/plugin.properties
deleted file mode 100644
index 9995768587..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/plugin.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-################################################################################
-# Copyright (c) 2006, 2007 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName = Java Persistence API Utility Tests
-providerName = Eclipse.org
-
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java
deleted file mode 100644
index 8f2e9b8492..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.BitTools;
-
-public class BitToolsTests extends TestCase {
-
- public BitToolsTests(String name) {
- super(name);
- }
-
- public void testFlagIsSetIntInt() {
- assertTrue(BitTools.flagIsSet(0x0003, 0x0001));
- assertTrue(BitTools.flagIsSet(0x0303, 0x0001));
- assertTrue(BitTools.flagIsSet(0x0303, 0x0101));
- assertTrue(BitTools.flagIsSet(0x0303, 0x0103));
-
- assertFalse(BitTools.flagIsSet(0x0303, 0x1103));
- assertFalse(BitTools.flagIsSet(0x0000, 0x1103));
- }
-
- public void testFlagIsOffIntInt() {
- assertFalse(BitTools.flagIsOff(0x0003, 0x0001));
- assertFalse(BitTools.flagIsOff(0x0303, 0x0001));
- assertFalse(BitTools.flagIsOff(0x0303, 0x0101));
- assertFalse(BitTools.flagIsOff(0x0303, 0x0103));
-
- assertTrue(BitTools.flagIsOff(0x2204, 0x1103));
- assertTrue(BitTools.flagIsOff(0x0000, 0x1103));
- }
-
- public void testOnlyFlagIsSetIntInt() {
- assertFalse(BitTools.onlyFlagIsSet(0x0003, 0x0001));
- assertTrue(BitTools.onlyFlagIsSet(0x0001, 0x0001));
-
- assertFalse(BitTools.onlyFlagIsSet(0x0303, 0x0001));
- assertTrue(BitTools.onlyFlagIsSet(0x0001, 0x0001));
-
- assertFalse(BitTools.onlyFlagIsSet(0x0303, 0x0101));
- assertTrue(BitTools.onlyFlagIsSet(0x0101, 0x0101));
-
- assertFalse(BitTools.onlyFlagIsSet(0x0303, 0x0103));
- assertTrue(BitTools.onlyFlagIsSet(0x0103, 0x0103));
-
- assertFalse(BitTools.onlyFlagIsSet(0x0303, 0x1103));
- assertTrue(BitTools.onlyFlagIsSet(0x1103, 0x1103));
-
- assertFalse(BitTools.onlyFlagIsSet(0x0000, 0x1103));
- assertTrue(BitTools.onlyFlagIsSet(0x0103, 0x0103));
- }
-
- public void testOnlyFlagIsOffIntInt() {
- assertFalse(BitTools.onlyFlagIsOff(0x0003, 0x0001));
- assertFalse(BitTools.onlyFlagIsOff(0x0303, 0x0001));
- assertTrue(BitTools.onlyFlagIsOff(0xFFFFFFFE, 0x0001));
-
- assertFalse(BitTools.onlyFlagIsOff(0x0303, 0x0101));
- assertTrue(BitTools.onlyFlagIsOff(0xFFFFFEFE, 0x0101));
-
- assertFalse(BitTools.onlyFlagIsOff(0x0303, 0x0103));
- assertTrue(BitTools.onlyFlagIsOff(0xFFFFFEFC, 0x0103));
-
- assertFalse(BitTools.onlyFlagIsOff(0x0303, 0x1103));
- assertTrue(BitTools.onlyFlagIsOff(0xFFFFEEFC, 0x1103));
- }
-
- public void testAllFlagsAreSetIntInt() {
- assertTrue(BitTools.allFlagsAreSet(0x0003, 0x0001));
- assertTrue(BitTools.allFlagsAreSet(0x0303, 0x0001));
- assertTrue(BitTools.allFlagsAreSet(0x0303, 0x0101));
- assertTrue(BitTools.allFlagsAreSet(0x0303, 0x0103));
-
- assertFalse(BitTools.allFlagsAreSet(0x0303, 0x1103));
- assertFalse(BitTools.allFlagsAreSet(0x0000, 0x1103));
- }
-
- public void testAllFlagsAreOffIntInt() {
- assertFalse(BitTools.allFlagsAreOff(0x0003, 0x0001));
- assertFalse(BitTools.allFlagsAreOff(0x0303, 0x0001));
- assertFalse(BitTools.allFlagsAreOff(0x0303, 0x0101));
- assertFalse(BitTools.allFlagsAreOff(0x0303, 0x0103));
-
- assertTrue(BitTools.allFlagsAreOff(0x2204, 0x1103));
- assertTrue(BitTools.allFlagsAreOff(0x0000, 0x1103));
- }
-
- public void testOnlyFlagsAreSetIntInt() {
- assertFalse(BitTools.onlyFlagsAreSet(0x0003, 0x0001));
- assertTrue(BitTools.onlyFlagsAreSet(0x0001, 0x0001));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, 0x0001));
- assertTrue(BitTools.onlyFlagsAreSet(0x0001, 0x0001));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, 0x0101));
- assertTrue(BitTools.onlyFlagsAreSet(0x0101, 0x0101));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, 0x0103));
- assertTrue(BitTools.onlyFlagsAreSet(0x0103, 0x0103));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, 0x1103));
- assertTrue(BitTools.onlyFlagsAreSet(0x1103, 0x1103));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0000, 0x1103));
- assertTrue(BitTools.onlyFlagsAreSet(0x0103, 0x0103));
- }
-
- public void testOnlyFlagsAreOffIntInt() {
- assertFalse(BitTools.onlyFlagsAreOff(0x0003, 0x0001));
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, 0x0001));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFFFFE, 0x0001));
-
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, 0x0101));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFFEFE, 0x0101));
-
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, 0x0103));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFFEFC, 0x0103));
-
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, 0x1103));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFEEFC, 0x1103));
- }
-
- public void testAnyFlagsAreSetIntInt() {
- assertTrue(BitTools.anyFlagsAreSet(0x0003, 0x0001));
- assertTrue(BitTools.anyFlagsAreSet(0xFFFF, 0x0001));
- assertTrue(BitTools.anyFlagsAreSet(0x0003, 0xFFFF));
-
- assertFalse(BitTools.anyFlagsAreSet(0x0303, 0x1010));
- assertFalse(BitTools.anyFlagsAreSet(0x0000, 0xFFFF));
- }
-
- public void testAnyFlagsAreOffIntInt() {
- assertTrue(BitTools.anyFlagsAreOff(0x333E, 0x0001));
- assertTrue(BitTools.anyFlagsAreOff(0xFFFE, 0x0001));
- assertTrue(BitTools.anyFlagsAreOff(0x0003, 0xFFFF));
-
- assertFalse(BitTools.anyFlagsAreOff(0x7373, 0x1010));
- assertFalse(BitTools.anyFlagsAreOff(0xFFFF, 0xFFFF));
- }
-
- public void testAllFlagsAreSetIntIntArray() {
- assertTrue(BitTools.allFlagsAreSet(0x0003, new int[] { 0x0001 }));
- assertTrue(BitTools.allFlagsAreSet(0x0303, new int[] { 0x0001 }));
- assertTrue(BitTools.allFlagsAreSet(0x0303, new int[] { 0x0100, 0x0001 }));
- assertTrue(BitTools.allFlagsAreSet(0x0303, new int[] { 0x0100, 0x0002, 0x0001 }));
-
- assertFalse(BitTools.allFlagsAreSet(0x0303, new int[] { 0x1000, 0x0100, 0x0002, 0x0001 }));
- assertFalse(BitTools.allFlagsAreSet(0x0000, new int[] { 0x1000, 0x0100, 0x0002, 0x0001 }));
- }
-
- public void testAllFlagsAreOffIntIntArray() {
- assertFalse(BitTools.allFlagsAreOff(0x0003, new int[] { 0x0001 }));
- assertFalse(BitTools.allFlagsAreOff(0x0303, new int[] { 0x0001 }));
- assertFalse(BitTools.allFlagsAreOff(0x0303, new int[] { 0x0100, 0x0001 }));
- assertFalse(BitTools.allFlagsAreOff(0x0303, new int[] { 0x0100, 0x0002, 0x0001 }));
-
- assertTrue(BitTools.allFlagsAreOff(0x0303, new int[] { 0x1000, 0x0400, 0x0020, 0x0000 }));
- assertTrue(BitTools.allFlagsAreOff(0x0000, new int[] { 0x1000, 0x0100, 0x0002, 0x0001 }));
- }
-
- public void testOnlyFlagsAreSetIntIntArray() {
- assertFalse(BitTools.onlyFlagsAreSet(0x0003, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreSet(0x0001, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreSet(0x0001, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, new int[] { 0x001, 0x0100, 0x0000, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreSet(0x0101, new int[] { 0x001, 0x0100, 0x0000, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, new int[] { 0x001, 0x0100, 0x0002, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreSet(0x0103, new int[] { 0x001, 0x0100, 0x0002, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, new int[] { 0x011, 0x0100, 0x0002, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreSet(0x1103, new int[] { 0x1100, 0x0100, 0x0002, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0000, new int[] { 0x011, 0x0100, 0x0002, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreSet(0x0103, new int[] { 0x0101, 0x0100, 0x0002, 0x0001 }));
- }
-
- public void testOnlyFlagsAreOffIntIntArray() {
- assertFalse(BitTools.onlyFlagsAreOff(0x0003, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFFFFE, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, new int[] { 0x001, 0x0100, 0x0000, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFFEFE, new int[] { 0x001, 0x0100, 0x0000, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, new int[] { 0x001, 0x0100, 0x0002, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFFEFC, new int[] { 0x001, 0x0100, 0x0002, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, new int[] { 0x1100, 0x0100, 0x0002, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFEEFC, new int[] { 0x1100, 0x0100, 0x0002, 0x0001 }));
- }
-
- public void testAnyFlagsAreSetIntIntArray() {
- assertTrue(BitTools.anyFlagsAreSet(0x0003, new int[] { 0x0001 }));
- assertTrue(BitTools.anyFlagsAreSet(0xFFFF, new int[] { 0x0001 }));
- assertTrue(BitTools.anyFlagsAreSet(0x0303, new int[] { 0xF000, 0x0F00, 0x00F0, 0x000F }));
-
- assertFalse(BitTools.anyFlagsAreSet(0x0303, new int[] { 0x1000, 0x0010 }));
- assertFalse(BitTools.anyFlagsAreSet(0x0000, new int[] { 0xF000, 0x0F00, 0x00F0, 0x000F }));
- }
-
- public void testAnyFlagsAreOffIntIntArray() {
- assertFalse(BitTools.anyFlagsAreOff(0x0003, new int[] { 0x0001 }));
- assertFalse(BitTools.anyFlagsAreOff(0xFFFF, new int[] { 0x0001 }));
- assertFalse(BitTools.anyFlagsAreOff(0x0303, new int[] { 0x0100, 0x0200, 0x0003, 0x0002 }));
-
- assertTrue(BitTools.anyFlagsAreOff(0x0303, new int[] { 0x0100, 0x0010 }));
- assertTrue(BitTools.anyFlagsAreOff(0x0000, new int[] { 0xF000, 0x0F00, 0x00F0, 0x000F }));
- }
-
- public void testOrFlags() {
- assertEquals(0x0001, BitTools.orFlags(new int[] { 0x0001, 0x0000 }));
- assertEquals(0x0011, BitTools.orFlags(new int[] { 0x0001, 0x0011 }));
- assertEquals(0xF011, BitTools.orFlags(new int[] { 0x0001, 0x0011, 0xF000 }));
- }
-
- public void testAndFlags() {
- assertEquals(0x0001, BitTools.andFlags(new int[] { 0x0001, 0x0001 }));
- assertEquals(0x0001, BitTools.andFlags(new int[] { 0x0001, 0x0011 }));
- assertEquals(0x0000, BitTools.andFlags(new int[] { 0x0001, 0x0011, 0xF000 }));
- assertEquals(0x0001, BitTools.andFlags(new int[] { 0x0001, 0x0011, 0xF001 }));
- }
-
- public void testXorFlags() {
- assertEquals(0x0001, BitTools.xorFlags(new int[] { 0x0001, 0x0000 }));
- assertEquals(0x0010, BitTools.xorFlags(new int[] { 0x0001, 0x0011 }));
- assertEquals(0xF010, BitTools.xorFlags(new int[] { 0x0001, 0x0011, 0xF000 }));
- assertEquals(0xFF11, BitTools.xorFlags(new int[] { 0x0001, 0x0011, 0xF000, 0x0F01 }));
- assertEquals(0xF010, BitTools.xorFlags(new int[] { 0x0001, 0x0011, 0xF000, 0x0F01, 0x0F01 }));
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java
deleted file mode 100644
index f2e4eae173..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java
+++ /dev/null
@@ -1,633 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-import java.util.Map.Entry;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-public class ClassToolsTests extends TestCase {
-
- private static String testStaticField;
-
- public ClassToolsTests(String name) {
- super(name);
- }
-
- /**
- * Return the compiler-generated class name. The Eclipse compiler generates
- * "local" classes with names in the form "com.foo.Outer$1$Local"; while the
- * JDK compiler generates "com.foo.Outer$1Local". There might be other
- * differences.... ~bjv
- */
- public static String compilerDependentClassNameFor(String className) {
- int index = className.indexOf("$1$");
- if (index == -1) {
- return className;
- }
- try {
- Class.forName(className);
- } catch (ClassNotFoundException ex) {
- return className.substring(0, index + 2) + className.substring(index + 3);
- }
- return className;
- }
-
- private static String munge(String className) {
- return compilerDependentClassNameFor(className);
- }
-
- public void testAllFields() {
- int fieldCount = 0;
- fieldCount += java.util.Vector.class.getDeclaredFields().length;
- fieldCount += java.util.AbstractList.class.getDeclaredFields().length;
- fieldCount += java.util.AbstractCollection.class.getDeclaredFields().length;
- fieldCount += java.lang.Object.class.getDeclaredFields().length;
- Field[] fields = ClassTools.allFields(java.util.Vector.class);
- assertEquals(fieldCount, fields.length);
- assertTrue(CollectionTools.contains(this.names(fields), "modCount"));
- assertTrue(CollectionTools.contains(this.names(fields), "serialVersionUID"));
- assertTrue(CollectionTools.contains(this.names(fields), "capacityIncrement"));
- assertTrue(CollectionTools.contains(this.names(fields), "elementCount"));
- assertTrue(CollectionTools.contains(this.names(fields), "elementData"));
- assertTrue(fields[0].isAccessible());
- }
-
- public void testAllMethods() {
- int methodCount = 0;
- methodCount += java.util.Vector.class.getDeclaredMethods().length;
- methodCount += java.util.AbstractList.class.getDeclaredMethods().length;
- methodCount += java.util.AbstractCollection.class.getDeclaredMethods().length;
- methodCount += java.lang.Object.class.getDeclaredMethods().length;
- Method[] methods = ClassTools.allMethods(java.util.Vector.class);
- assertEquals(methodCount, methods.length);
- assertTrue(CollectionTools.contains(this.names(methods), "wait"));
- assertTrue(CollectionTools.contains(this.names(methods), "addElement"));
- assertTrue(methods[0].isAccessible());
- }
-
- public void testNewInstanceClass() {
- Vector<?> v = ClassTools.newInstance(java.util.Vector.class);
- assertNotNull(v);
- assertEquals(0, v.size());
- }
-
- public void testNewInstanceClassClassObject() {
- int initialCapacity = 200;
- Vector<?> v = ClassTools.newInstance(java.util.Vector.class, int.class, new Integer(initialCapacity));
- assertNotNull(v);
- assertEquals(0, v.size());
- Object[] elementData = (Object[]) ClassTools.fieldValue(v, "elementData");
- assertEquals(initialCapacity, elementData.length);
- }
-
- public void testNewInstanceClassClassArrayObjectArray() {
- int initialCapacity = 200;
- Class<?>[] parmTypes = new Class[1];
- parmTypes[0] = int.class;
- Object[] parms = new Object[1];
- parms[0] = new Integer(initialCapacity);
- Vector<?> v = ClassTools.newInstance(java.util.Vector.class, parmTypes, parms);
- assertNotNull(v);
- assertEquals(0, v.size());
- Object[] elementData = (Object[]) ClassTools.fieldValue(v, "elementData");
- assertEquals(initialCapacity, elementData.length);
-
- parms[0] = new Integer(-1);
- boolean exCaught = false;
- try {
- v = ClassTools.newInstance(java.util.Vector.class, parmTypes, parms);
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- assertTrue("RuntimeException not thrown", exCaught);
-
- parmTypes[0] = java.lang.String.class;
- parms[0] = "foo";
- exCaught = false;
- try {
- v = ClassTools.attemptNewInstance(java.util.Vector.class, parmTypes, parms);
- } catch (NoSuchMethodException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchMethodException not thrown", exCaught);
- }
-
- public void testFieldValue() {
- int initialCapacity = 200;
- Vector<?> v = new Vector<Object>(initialCapacity);
- Object[] elementData = (Object[]) ClassTools.fieldValue(v, "elementData");
- assertEquals(initialCapacity, elementData.length);
-
- // test inherited field
- Integer modCountInteger = (Integer) ClassTools.fieldValue(v, "modCount");
- int modCount = modCountInteger.intValue();
- assertEquals(0, modCount);
-
- boolean exCaught = false;
- Object bogusFieldValue = null;
- try {
- bogusFieldValue = ClassTools.attemptToGetFieldValue(v, "bogusField");
- } catch (NoSuchFieldException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchFieldException not thrown: " + bogusFieldValue, exCaught);
- }
-
- public void testExecuteMethodObjectString() {
- Vector<String> v = new Vector<String>();
- int size = ((Integer) ClassTools.executeMethod(v, "size")).intValue();
- assertEquals(0, size);
-
- v.addElement("foo");
- size = ((Integer) ClassTools.executeMethod(v, "size")).intValue();
- assertEquals(1, size);
- }
-
- public void testExecuteMethodObjectStringClassObject() {
- Vector<String> v = new Vector<String>();
- boolean booleanResult = ((Boolean) ClassTools.executeMethod(v, "add", Object.class, "foo")).booleanValue();
- assertTrue(booleanResult);
- assertTrue(v.contains("foo"));
- Object voidResult = ClassTools.executeMethod(v, "addElement", Object.class, "bar");
- assertNull(voidResult);
- }
-
- public void testExecuteMethodObjectStringClassArrayObjectArray() {
- Vector<String> v = new Vector<String>();
- Class<?>[] parmTypes = new Class[1];
- parmTypes[0] = java.lang.Object.class;
- Object[] parms = new Object[1];
- parms[0] = "foo";
- boolean booleanResult = ((Boolean) ClassTools.executeMethod(v, "add", parmTypes, parms)).booleanValue();
- assertTrue(booleanResult);
- assertTrue(v.contains("foo"));
-
- boolean exCaught = false;
- Object bogusMethodReturnValue = null;
- try {
- bogusMethodReturnValue = ClassTools.attemptToExecuteMethod(v, "bogusMethod", parmTypes, parms);
- } catch (NoSuchMethodException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchMethodException not thrown: " + bogusMethodReturnValue, exCaught);
- }
-
- public void testExecuteStaticMethodClassString() {
- Double randomObject = (Double) ClassTools.executeStaticMethod(java.lang.Math.class, "random");
- assertNotNull(randomObject);
- double random = randomObject.doubleValue();
- assertTrue(random >= 0);
- assertTrue(random < 1);
- }
-
- public void testExecuteStaticMethodClassStringClassObject() {
- String s = (String) ClassTools.executeStaticMethod(java.lang.String.class, "valueOf", boolean.class, Boolean.TRUE);
- assertNotNull(s);
- assertEquals("true", s);
- }
-
- public void testExecuteStaticMethodClassStringClassArrayObjectArray() {
- Class<?>[] parmTypes = new Class[1];
- parmTypes[0] = boolean.class;
- Object[] parms = new Object[1];
- parms[0] = Boolean.TRUE;
- String s = (String) ClassTools.executeStaticMethod(java.lang.String.class, "valueOf", parmTypes, parms);
- assertNotNull(s);
- assertEquals("true", s);
-
- boolean exCaught = false;
- Object bogusStaticMethodReturnValue = null;
- try {
- bogusStaticMethodReturnValue = ClassTools.attemptToExecuteStaticMethod(java.lang.String.class, "bogusStaticMethod", parmTypes, parms);
- } catch (NoSuchMethodException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchMethodException not thrown: " + bogusStaticMethodReturnValue, exCaught);
-
- // test non-static method
- exCaught = false;
- try {
- bogusStaticMethodReturnValue = ClassTools.attemptToExecuteStaticMethod(java.lang.String.class, "toString");
- } catch (NoSuchMethodException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchMethodException not thrown: " + bogusStaticMethodReturnValue, exCaught);
- }
-
- public void testSetFieldValue() {
- Vector<String> v = new Vector<String>();
- Object[] newElementData = new Object[5];
- newElementData[0] = "foo";
- ClassTools.setFieldValue(v, "elementData", newElementData);
- ClassTools.setFieldValue(v, "elementCount", new Integer(1));
- // test inherited field
- ClassTools.setFieldValue(v, "modCount", new Integer(1));
- assertTrue(v.contains("foo"));
-
- boolean exCaught = false;
- try {
- ClassTools.attemptToSetFieldValue(v, "bogusField", "foo");
- } catch (NoSuchFieldException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchFieldException not thrown", exCaught);
- }
-
- public void testSetStaticFieldValue() {
- ClassTools.setStaticFieldValue(this.getClass(), "testStaticField", "new value");
- assertEquals(testStaticField, "new value");
-
- boolean exCaught = false;
- try {
- ClassTools.attemptToSetStaticFieldValue(this.getClass(), "bogusStaticField", "new value");
- } catch (NoSuchFieldException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchFieldException not thrown", exCaught);
- }
-
- public void testShortName() {
- assertEquals("Vector", ClassTools.shortClassNameForObject(new java.util.Vector<Object>()));
- assertEquals("Vector", ClassTools.shortNameFor(java.util.Vector.class));
- }
-
- public void testNestedName() {
- Map<String, String> map = new HashMap<String, String>();
- map.put("foo", "bar");
- Entry<String, String> entry = map.entrySet().iterator().next();
- assertEquals("Entry", ClassTools.nestedClassNameForObject(entry));
- assertEquals("Entry", ClassTools.nestedNameFor(java.util.Map.Entry.class));
- }
-
- public void testPackageName() {
- assertEquals("java.util", ClassTools.packageNameFor(java.util.Vector.class));
- assertEquals("java.util", ClassTools.packageNameFor(java.util.Map.Entry.class));
- }
-
- public void testArrayDepthFor() {
- assertEquals(0, ClassTools.arrayDepthFor(java.util.Vector.class));
- assertEquals(0, ClassTools.arrayDepthFor(int.class));
- assertEquals(0, ClassTools.arrayDepthFor(void.class));
- assertEquals(1, ClassTools.arrayDepthFor(java.util.Vector[].class));
- assertEquals(1, ClassTools.arrayDepthFor(int[].class));
- assertEquals(3, ClassTools.arrayDepthFor(java.util.Vector[][][].class));
- assertEquals(3, ClassTools.arrayDepthFor(int[][][].class));
- }
-
- public void testArrayDepthForObject() {
- assertEquals(0, ClassTools.arrayDepthForObject(new java.util.Vector<Object>()));
- assertEquals(1, ClassTools.arrayDepthForObject(new java.util.Vector[0]));
- assertEquals(1, ClassTools.arrayDepthForObject(new int[0]));
- assertEquals(3, ClassTools.arrayDepthForObject(new java.util.Vector[0][0][0]));
- assertEquals(3, ClassTools.arrayDepthForObject(new int[0][0][0]));
- }
-
- public void testArrayDepthForClassNamed() {
- assertEquals(0, ClassTools.arrayDepthForClassNamed(java.util.Vector.class.getName()));
- assertEquals(0, ClassTools.arrayDepthForClassNamed(int.class.getName()));
- assertEquals(0, ClassTools.arrayDepthForClassNamed(void.class.getName()));
- assertEquals(1, ClassTools.arrayDepthForClassNamed(java.util.Vector[].class.getName()));
- assertEquals(1, ClassTools.arrayDepthForClassNamed(int[].class.getName()));
- assertEquals(3, ClassTools.arrayDepthForClassNamed(java.util.Vector[][][].class.getName()));
- assertEquals(3, ClassTools.arrayDepthForClassNamed(int[][][].class.getName()));
- }
-
- public void testElementTypeFor() {
- assertEquals(java.util.Vector.class, ClassTools.elementTypeFor(java.util.Vector.class));
- assertEquals(int.class, ClassTools.elementTypeFor(int.class));
- assertEquals(void.class, ClassTools.elementTypeFor(void.class));
- assertEquals(java.util.Vector.class, ClassTools.elementTypeFor(java.util.Vector[].class));
- assertEquals(int.class, ClassTools.elementTypeFor(int[].class));
- assertEquals(java.util.Vector.class, ClassTools.elementTypeFor(java.util.Vector[][][].class));
- assertEquals(int.class, ClassTools.elementTypeFor(int[][][].class));
- }
-
- public void testElementTypeForObject() {
- assertEquals(java.util.Vector.class, ClassTools.elementTypeForObject(new java.util.Vector<Object>()));
- assertEquals(java.util.Vector.class, ClassTools.elementTypeForObject(new java.util.Vector[0]));
- assertEquals(int.class, ClassTools.elementTypeForObject(new int[0]));
- assertEquals(java.util.Vector.class, ClassTools.elementTypeForObject(new java.util.Vector[0][0][0]));
- assertEquals(int.class, ClassTools.elementTypeForObject(new int[0][0][0]));
- }
-
- public void testElementTypeNameFor() {
- assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameFor(java.util.Vector.class));
- assertEquals(int.class.getName(), ClassTools.elementTypeNameFor(int.class));
- assertEquals(void.class.getName(), ClassTools.elementTypeNameFor(void.class));
- assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameFor(java.util.Vector[].class));
- assertEquals(int.class.getName(), ClassTools.elementTypeNameFor(int[].class));
- assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameFor(java.util.Vector[][][].class));
- assertEquals(int.class.getName(), ClassTools.elementTypeNameFor(int[][][].class));
- }
-
- public void testElementTypeNameForClassNamed() {
- assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameForClassNamed(java.util.Vector.class.getName()));
- assertEquals(int.class.getName(), ClassTools.elementTypeNameForClassNamed(int.class.getName()));
- assertEquals(void.class.getName(), ClassTools.elementTypeNameForClassNamed(void.class.getName()));
- assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameForClassNamed(java.util.Vector[].class.getName()));
- assertEquals(int.class.getName(), ClassTools.elementTypeNameForClassNamed(int[].class.getName()));
- assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameForClassNamed(java.util.Vector[][][].class.getName()));
- assertEquals(int.class.getName(), ClassTools.elementTypeNameForClassNamed(int[][][].class.getName()));
- }
-
- public void testClassCodes() {
- assertEquals("byte", ClassTools.classNameForCode('B'));
- assertEquals("char", ClassTools.classNameForCode('C'));
- assertEquals("double", ClassTools.classNameForCode('D'));
- assertEquals("float", ClassTools.classNameForCode('F'));
- assertEquals("int", ClassTools.classNameForCode('I'));
- assertEquals("long", ClassTools.classNameForCode('J'));
- assertEquals("short", ClassTools.classNameForCode('S'));
- assertEquals("boolean", ClassTools.classNameForCode('Z'));
- assertEquals("void", ClassTools.classNameForCode('V'));
-
- boolean exCaught = false;
- try {
- ClassTools.classNameForCode('X');
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue("IllegalArgumentException not thrown", exCaught);
- }
-
- public void testClassNamedIsTopLevel() throws Exception {
- assertTrue(ClassTools.classNamedIsTopLevel(java.util.Map.class.getName())); // top-level
- assertFalse(ClassTools.classNamedIsTopLevel(java.util.Map.Entry.class.getName())); // member
- assertFalse(ClassTools.classNamedIsTopLevel(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName())); // local
- assertFalse(ClassTools.classNamedIsTopLevel(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName()));
- Class<?> localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass")); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName()));
- }
-
- public void testClassNamedIsMember() throws Exception {
- assertFalse(ClassTools.classNamedIsMember(java.util.Map.class.getName())); // top-level
- assertTrue(ClassTools.classNamedIsMember(java.util.Map.Entry.class.getName())); // member
- assertFalse(ClassTools.classNamedIsMember(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName())); // local
- assertFalse(ClassTools.classNamedIsMember(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertFalse(ClassTools.classNamedIsMember(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertFalse(ClassTools.classNamedIsMember(array.getClass().getName()));
- Class<?> localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass")); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertFalse(ClassTools.classNamedIsMember(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertFalse(ClassTools.classNamedIsMember(array.getClass().getName()));
-
- // test a few edge cases
- assertTrue(ClassTools.classNamedIsMember("java.util.Map$a1"));
- assertTrue(ClassTools.classNamedIsMember("java.util.Map$a1$aaa$bbb"));
- assertFalse(ClassTools.classNamedIsMember("java.util.Map$1a1$aaa"));
- assertFalse(ClassTools.classNamedIsMember("java.util.Map$1a"));
- assertTrue(ClassTools.classNamedIsMember("java.util.Map$a12345$b12345"));
- assertFalse(ClassTools.classNamedIsMember("java.util.Map$12345a"));
- assertFalse(ClassTools.classNamedIsMember("java.util.Map$333"));
- assertFalse(ClassTools.classNamedIsMember("java.util.Map3$333"));
- }
-
- public void testClassNamedIsLocal() throws Exception {
- class LocalClass {
- void foo() {
- System.getProperty("foo");
- }
- }
- new LocalClass().foo();
- assertFalse(ClassTools.classNamedIsLocal(java.util.Map.class.getName())); // top-level
- assertFalse(ClassTools.classNamedIsLocal(java.util.Map.Entry.class.getName())); // member
- assertTrue(ClassTools.classNamedIsLocal(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName())); // local
- assertFalse(ClassTools.classNamedIsLocal(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertFalse(ClassTools.classNamedIsLocal(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertFalse(ClassTools.classNamedIsLocal(array.getClass().getName()));
- Class<?> localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass")); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertFalse(ClassTools.classNamedIsLocal(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertFalse(ClassTools.classNamedIsLocal(array.getClass().getName()));
-
- // test a few edge cases
- assertFalse(ClassTools.classNamedIsLocal("java.util.Map$a1"));
- assertFalse(ClassTools.classNamedIsLocal("java.util.Map$a1$aaa$bbb"));
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$11$aaa"));
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$1$a")); // eclipse naming convention
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$2$abc")); // eclipse naming convention
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$2$abc1")); // eclipse naming convention
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$1a")); // jdk naming convention
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$2abc")); // jdk naming convention
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$2abc1")); // jdk naming convention
- assertFalse(ClassTools.classNamedIsLocal("java.util.Map$a12345$b12345"));
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$12345$a1234"));
- assertFalse(ClassTools.classNamedIsLocal("java.util.Map$333"));
- assertFalse(ClassTools.classNamedIsLocal("java.util.Map3$333"));
- }
-
- public void testClassNamedIsAnonymous() throws Exception {
- assertFalse(ClassTools.classNamedIsAnonymous(java.util.Map.class.getName())); // top-level
- assertFalse(ClassTools.classNamedIsAnonymous(java.util.Map.Entry.class.getName())); // member
- assertFalse(ClassTools.classNamedIsAnonymous(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName())); // local
- assertTrue(ClassTools.classNamedIsAnonymous(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertFalse(ClassTools.classNamedIsAnonymous(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertFalse(ClassTools.classNamedIsAnonymous(array.getClass().getName()));
- Class<?> localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass")); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertFalse(ClassTools.classNamedIsAnonymous(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertFalse(ClassTools.classNamedIsAnonymous(array.getClass().getName()));
-
- // test a few edge cases
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$a1"));
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$a1$aaa$bbb"));
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$1a1$aaa"));
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$1$a"));
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$1a"));
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$a12345$b12345"));
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$12345$a1234"));
- assertTrue(ClassTools.classNamedIsAnonymous("java.util.Map$333"));
- assertTrue(ClassTools.classNamedIsAnonymous("java.util.Map3$333"));
- }
-
- public void testCodeForClass() {
- assertEquals('I', ClassTools.codeForClass(int.class));
- assertEquals('B', ClassTools.codeForClass(byte.class));
- }
-
- public void testCodeForClassNamed() {
- assertEquals('I', ClassTools.codeForClassNamed(int.class.getName()));
- assertEquals('I', ClassTools.codeForClassNamed("int"));
- assertEquals('B', ClassTools.codeForClassNamed(byte.class.getName()));
- assertEquals('B', ClassTools.codeForClassNamed("byte"));
- }
-
- public void testClassIsPrimitiveWrapperClass() {
- assertTrue(ClassTools.classIsPrimitiveWrapperClass(java.lang.Void.class));
- assertTrue(ClassTools.classIsPrimitiveWrapperClass(java.lang.Boolean.class));
- assertTrue(ClassTools.classIsPrimitiveWrapperClass(java.lang.Integer.class));
- assertTrue(ClassTools.classIsPrimitiveWrapperClass(java.lang.Float.class));
-
- assertFalse(ClassTools.classIsPrimitiveWrapperClass(java.lang.String.class));
- assertFalse(ClassTools.classIsPrimitiveWrapperClass(void.class));
- assertFalse(ClassTools.classIsPrimitiveWrapperClass(int.class));
- }
-
- public void testClassIsVariablePrimitiveWrapperClass() {
- assertFalse(ClassTools.classIsVariablePrimitiveWrapperClass(java.lang.Void.class));
-
- assertTrue(ClassTools.classIsVariablePrimitiveWrapperClass(java.lang.Boolean.class));
- assertTrue(ClassTools.classIsVariablePrimitiveWrapperClass(java.lang.Integer.class));
- assertTrue(ClassTools.classIsVariablePrimitiveWrapperClass(java.lang.Float.class));
-
- assertFalse(ClassTools.classIsVariablePrimitiveWrapperClass(java.lang.String.class));
- assertFalse(ClassTools.classIsVariablePrimitiveWrapperClass(void.class));
- assertFalse(ClassTools.classIsVariablePrimitiveWrapperClass(int.class));
- }
-
- public void testClassNamedIsPrimitive() {
- assertTrue(void.class.isPrimitive());
-
- assertTrue(ClassTools.classNamedIsPrimitive(void.class.getName()));
- assertTrue(ClassTools.classNamedIsPrimitive(int.class.getName()));
- assertTrue(ClassTools.classNamedIsPrimitive(float.class.getName()));
- assertTrue(ClassTools.classNamedIsPrimitive(boolean.class.getName()));
-
- assertFalse(ClassTools.classNamedIsPrimitive(java.lang.Number.class.getName()));
- assertFalse(ClassTools.classNamedIsPrimitive(java.lang.String.class.getName()));
- assertFalse(ClassTools.classNamedIsPrimitive(java.lang.Boolean.class.getName()));
- assertFalse(ClassTools.classNamedIsPrimitive(java.lang.Integer.class.getName()));
- }
-
- public void testClassNamedIsVariablePrimitive() {
- assertFalse(ClassTools.classNamedIsVariablePrimitive(void.class.getName()));
-
- assertTrue(ClassTools.classNamedIsVariablePrimitive(int.class.getName()));
- assertTrue(ClassTools.classNamedIsVariablePrimitive(float.class.getName()));
- assertTrue(ClassTools.classNamedIsVariablePrimitive(boolean.class.getName()));
-
- assertFalse(ClassTools.classNamedIsVariablePrimitive(java.lang.Number.class.getName()));
- assertFalse(ClassTools.classNamedIsVariablePrimitive(java.lang.String.class.getName()));
- assertFalse(ClassTools.classNamedIsVariablePrimitive(java.lang.Boolean.class.getName()));
- }
-
- public void testClassNamedIsVariablePrimitiveWrapperClass() {
- assertFalse(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.Void.class.getName()));
-
- assertTrue(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.Integer.class.getName()));
- assertTrue(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.Float.class.getName()));
- assertTrue(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.Boolean.class.getName()));
-
- assertFalse(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.Number.class.getName()));
- assertFalse(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.String.class.getName()));
- assertFalse(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.Object.class.getName()));
- }
-
- public void testClassForTypeDeclarationStringInt() throws Exception {
- assertEquals(int.class, ClassTools.classForTypeDeclaration("int", 0));
- assertEquals(int[].class, ClassTools.classForTypeDeclaration("int", 1));
- assertEquals(int[][][].class, ClassTools.classForTypeDeclaration("int", 3));
-
- assertEquals(Object.class, ClassTools.classForTypeDeclaration("java.lang.Object", 0));
- assertEquals(Object[][][].class, ClassTools.classForTypeDeclaration("java.lang.Object", 3));
-
- assertEquals(void.class, ClassTools.classForTypeDeclaration("void", 0));
- try {
- ClassTools.classForTypeDeclaration(void.class.getName(), 1);
- fail("should not get here...");
- } catch (ClassNotFoundException ex) {
- // expected
- }
- }
-
- public void testClassNameForTypeDeclarationString() throws Exception {
- assertEquals("int", ClassTools.classNameForTypeDeclaration("int"));
- assertEquals("[I", ClassTools.classNameForTypeDeclaration("int[]"));
- assertEquals("[[I", ClassTools.classNameForTypeDeclaration("int [ ] [ ]"));
-
- assertEquals("java.lang.Object", ClassTools.classNameForTypeDeclaration("java.lang.Object"));
- assertEquals("[Ljava.lang.Object;", ClassTools.classNameForTypeDeclaration("java.lang.Object\t[]"));
- assertEquals("[[Ljava.lang.Object;", ClassTools.classNameForTypeDeclaration("java.lang.Object\t[]\t[]"));
- }
-
- public void testArrayDepthForTypeDeclarationString() throws Exception {
- assertEquals(0, ClassTools.arrayDepthForTypeDeclaration("java.lang.Object"));
- assertEquals(1, ClassTools.arrayDepthForTypeDeclaration("java.lang.Object[]"));
- assertEquals(3, ClassTools.arrayDepthForTypeDeclaration("java.lang.Object[][][]"));
-
- assertEquals(0, ClassTools.arrayDepthForTypeDeclaration("int"));
- assertEquals(1, ClassTools.arrayDepthForTypeDeclaration("int[]"));
- assertEquals(3, ClassTools.arrayDepthForTypeDeclaration("int[][][]"));
-
- assertEquals(0, ClassTools.arrayDepthForTypeDeclaration("float"));
- assertEquals(1, ClassTools.arrayDepthForTypeDeclaration("float [ ]"));
- assertEquals(3, ClassTools.arrayDepthForTypeDeclaration("float[] [] []"));
- }
-
- public void testClassNameForTypeDeclarationStringInt() throws Exception {
- assertEquals(int.class.getName(), ClassTools.classNameForTypeDeclaration("int", 0));
- assertEquals(int[].class.getName(), ClassTools.classNameForTypeDeclaration("int", 1));
- assertEquals(int[][][].class.getName(), ClassTools.classNameForTypeDeclaration("int", 3));
-
- assertEquals(Object.class.getName(), ClassTools.classNameForTypeDeclaration("java.lang.Object", 0));
- assertEquals(Object[][][].class.getName(), ClassTools.classNameForTypeDeclaration("java.lang.Object", 3));
-
- assertEquals(void.class.getName(), ClassTools.classNameForTypeDeclaration("void", 0));
- try {
- ClassTools.classNameForTypeDeclaration(void.class.getName(), 1);
- fail("should not get here...");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- }
-
- private Iterator<String> names(Field[] fields) {
- return new TransformationIterator<Field, String>(CollectionTools.iterator(fields)) {
- @Override
- protected String transform(Field field) {
- return field.getName();
- }
- };
- }
-
- private Iterator<String> names(Method[] methods) {
- return new TransformationIterator<Method, String>(CollectionTools.iterator(methods)) {
- @Override
- protected String transform(Method method) {
- return method.getName();
- }
- };
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java
deleted file mode 100644
index 4e19dac30c..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.Classpath;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-public class ClasspathTests extends TestCase {
- private static final String JAVA_HOME = System.getProperty("java.home");
-
- public ClasspathTests(String name) {
- super(name);
- }
-
- public void testCompressed() {
- String path = "";
-
- // no changes
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().path();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().path();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar")).compressed().path();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().path();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\i18n.jar;C:\\jdk\\i18n.jar;C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().path();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;;;;C:\\jdk\\jaws.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;;;")).compressed().path();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- // no changes
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().path();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().path();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\..\\jdk\\i18n.jar;C:\\jdk\\jaws.jar")).compressed().path();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk1\\jdk2\\jdk3\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk1\\jdk2\\jdk3\\..\\..\\..\\jdk1\\jdk2\\jdk3\\i18n.jar;C:\\jdk\\jaws.jar")).compressed().path();
- assertEquals(this.morph("C:\\jdk1\\jdk2\\jdk3\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- }
-
- public void testConvertToClassName() {
- String fileName = "java/lang/String.class";
- File file = new File(fileName);
- String className = Classpath.convertToClassName(file);
- assertEquals(java.lang.String.class.getName(), className);
- }
-
- public void testConvertToClass() throws ClassNotFoundException {
- String fileName = "java/lang/String.class";
- File file = new File(fileName);
- Class<?> javaClass = Classpath.convertToClass(file);
- assertEquals(java.lang.String.class, javaClass);
- }
-
- public void testConvertToArchiveClassFileEntryName() {
- String fileName = Classpath.convertToArchiveClassFileEntryName(java.lang.String.class);
- assertEquals("java/lang/String.class", fileName);
- }
-
- public void testConvertToClassFileName() {
- char sc = File.separatorChar;
- String fileName = Classpath.convertToClassFileName(java.lang.String.class);
- assertEquals("java" + sc + "lang" + sc + "String.class", fileName);
- }
-
- public void testConvertToJavaFileName() {
- char sc = File.separatorChar;
- String fileName = Classpath.convertToJavaFileName(java.lang.String.class.getName());
- assertEquals("java" + sc + "lang" + sc + "String.java", fileName);
- }
-
- public void testConvertToURLs() {
- URL[] entries = new Classpath(this.morph("C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).urls();
- int i = 0;
- assertEquals(this.morphURL("/C:/jdk/rt.jar"), entries[i++].getPath());
- assertEquals(this.morphURL("/C:/jdk/i18n.jar"), entries[i++].getPath());
- assertEquals(this.morphURL("/C:/jdk/jaws.jar"), entries[i++].getPath());
- assertEquals(this.morphURL("/C:/foo/classes"), entries[i++].getPath());
- assertEquals(this.morphURL("/C:/bar/bar.jar"), entries[i++].getPath());
- assertEquals(i, entries.length);
- }
-
- public void testEntries() {
- Classpath cp = new Classpath(this.morph("C:\\jdk\\rt.jar;;.;C:\\jdk\\i18n.jar;;;C:\\jdk\\jaws.jar;;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\bar\\bar.jar;"));
- Classpath.Entry[] entries = cp.entries();
- int i = 0;
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entries[i++].fileName());
- assertEquals(this.morph("."), entries[i++].fileName());
- assertEquals(this.morph("C:\\jdk\\i18n.jar"), entries[i++].fileName());
- assertEquals(this.morph("C:\\jdk\\jaws.jar"), entries[i++].fileName());
- assertEquals(this.morph("C:\\foo\\classes"), entries[i++].fileName());
- assertEquals(this.morph("C:\\bar\\bar.jar"), entries[i++].fileName());
- assertEquals(this.morph("C:\\bar\\bar.jar"), entries[i++].fileName());
- assertEquals(i, entries.length);
-
- cp = cp.compressed();
- entries = cp.entries();
- i = 0;
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entries[i++].fileName());
- assertEquals(this.morph("."), entries[i++].fileName());
- assertEquals(this.morph("C:\\jdk\\i18n.jar"), entries[i++].fileName());
- assertEquals(this.morph("C:\\jdk\\jaws.jar"), entries[i++].fileName());
- assertEquals(this.morph("C:\\foo\\classes"), entries[i++].fileName());
- assertEquals(this.morph("C:\\bar\\bar.jar"), entries[i++].fileName());
- assertEquals(i, entries.length);
- }
-
- public void testEntryForFileNamed() {
- Classpath.Entry entry = null;
-
- // in the middle - qualified
- entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
-
- // in the middle - unqualified
- entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;rt.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).entryForFileNamed("rt.jar");
- assertEquals("rt.jar", entry.fileName());
-
- // at the beginning - qualified
- entry = new Classpath(this.morph("C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
-
- // at the beginning - unqualified
- entry = new Classpath(this.morph("rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).entryForFileNamed("rt.jar");
- assertEquals("rt.jar", entry.fileName());
-
- // at the end - qualified
- entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\jdk\\rt.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
-
- // at the end - unqualified
- entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;rt.jar")).entryForFileNamed("rt.jar");
- assertEquals("rt.jar", entry.fileName());
-
- // alone - qualified
- entry = new Classpath(this.morph("C:\\jdk\\rt.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
-
- // alone - unqualified
- entry = new Classpath("rt.jar").entryForFileNamed("rt.jar");
- assertEquals("rt.jar", entry.fileName());
-
- // trick entry at the beginning
- entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
-
- // trick entry in the middle
- entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rtrtrt.jar;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
-
- // trick entry at the end
- entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rtrtrt.jar;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\jdk\\rtrtrt.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
-
- // missing
- entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rtrtrt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\jdk\\rtrtrt.jar")).entryForFileNamed("rt.jar");
- assertEquals("path entry should not be found", null, entry);
-
- }
-
- public void testLocationForClass() {
- Class<?> javaClass = Classpath.class;
- File entry = new File(Classpath.locationFor(javaClass));
- if (entry.isFile() || entry.isDirectory()) {
- assertTrue(entry.exists());
- }
- if (entry.isDirectory()) {
- assertTrue(new File(entry, Classpath.convertToClassFileName(javaClass)).exists());
- }
- }
-
- public void testRtJarName() throws IOException {
- File rtFile = new File(Classpath.rtJarName());
- assertTrue("rt.jar does not exist", rtFile.exists());
-
- JarFile rtJarFile = new JarFile(rtFile);
- JarEntry entry = rtJarFile.getJarEntry("java/lang/Object.class");
- rtJarFile.close();
- assertTrue("bogus rt.jar", entry != null);
- }
-
- public void testJREClassNames() {
- assertTrue("Vector is missing from JRE class names", CollectionTools.contains(Classpath.bootClasspath().classNames(), java.util.Vector.class.getName()));
- assertTrue("File is missing from JRE class names", CollectionTools.contains(Classpath.bootClasspath().classNames(), java.io.File.class.getName()));
- }
-
- public void testJavaExtensionDirectoryNames() {
- char sep = File.separatorChar;
- String stdExtDirName = JAVA_HOME + sep + "lib" + sep + "ext";
- assertTrue("standard extension dir name missing: " + stdExtDirName, CollectionTools.contains(Classpath.javaExtensionDirectoryNames(), stdExtDirName));
- }
-
- public void testJavaExtensionDirectories() {
- char sep = File.separatorChar;
- File stdExtDir = new File(JAVA_HOME + sep + "lib" + sep + "ext");
- assertTrue("standard extension dir missing: " + stdExtDir.getParent(), CollectionTools.contains(Classpath.javaExtensionDirectories(), stdExtDir));
- }
-
- //Commented out due to incompatibility with IBM JDK (used in Eclipse WTP Build)
- //TODO Test should be revised to be compatible with IBM JDK
- // public void testJavaExtensionClasspathEntries() {
- // char sep = File.separatorChar;
- // String jdk = System.getProperty("java.version");
- // if (jdk.startsWith("1.4") || jdk.startsWith("1.5")) {
- // Collection jarNames = new ArrayList();
- // Classpath.Entry[] entries = Classpath.javaExtensionClasspath().getEntries();
- // for (int i = 0; i < entries.length; i++) {
- // jarNames.add(entries[i].fileName());
- // }
- // String stdExtJarName = JAVA_HOME + sep + "lib" + sep + "ext" + sep + "dnsns.jar";
- // assertTrue("jdk 1.4.x standard extension jar missing: " + stdExtJarName, jarNames.contains(stdExtJarName));
- // } else {
- // fail("we need to update this test for the current jdk");
- // }
- // }
-
- //Commented out due to incompatibility with IBM JDK (used in Eclipse WTP Build)
- //TODO Test should be revised to be compatible with IBM JDK
- // public void testJavaExtensionClassNames() {
- // String jdk = System.getProperty("java.version");
- // if (jdk.startsWith("1.4") || jdk.startsWith("1.5")) {
- // String className = "sun.net.spi.nameservice.dns.DNSNameService";
- // assertTrue("jdk 1.4.x standard extension class missing: " + className,
- // CollectionTools.contains(Classpath.javaExtensionClasspath().classNames(), className));
- // } else {
- // fail("we need to update this test for the current jdk");
- // }
- // }
-
- public void testJavaClasspathClassNames() {
- String className = this.getClass().getName();
- ClassLoader cl = this.getClass().getClassLoader();
- // make sure we are running under the "normal" class loader;
- // when the tests are executed as an ANT task, they are run under
- // an ANT class loader and the "Java" classpath does not include this class
- if (cl.getClass().getName().startsWith("sun.misc")) {
- assertTrue("class missing: " + className, CollectionTools.contains(Classpath.javaClasspath().classNames(), className));
- }
- }
-
- /**
- * morph the specified path to a platform-independent path
- */
- private String morph(String path) {
- String result = path;
- result = result.replace('\\', File.separatorChar);
- result = result.replace(';', File.pathSeparatorChar);
- if (!CollectionTools.contains(File.listRoots(), new File("C:\\"))) {
- result = result.replaceAll("C:", "");
- }
- return result;
- }
-
- /**
- * morph the specified URL to a platform-independent path
- */
- private String morphURL(String url) {
- String result = url;
- if (!CollectionTools.contains(File.listRoots(), new File("C:\\"))) {
- result = result.replaceAll("/C:", "");
- }
- return result;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java
deleted file mode 100644
index a9c4ef3268..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java
+++ /dev/null
@@ -1,3881 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.Vector;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.EmptyIterable;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.Range;
-import org.eclipse.jpt.utility.internal.ReverseComparator;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyEnumeration;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-
-public class CollectionToolsTests extends TestCase {
-
- public CollectionToolsTests(String name) {
- super(name);
- }
-
- public void testAddObjectArrayObject_Object() {
- Object[] a = CollectionTools.add(this.buildObjectArray1(), "twenty");
- assertEquals(4, a.length);
- assertTrue(CollectionTools.contains(a, "twenty"));
- assertEquals("twenty", a[a.length-1]);
- }
-
- public void testAddObjectArrayObject_String() {
- String[] a = CollectionTools.add(this.buildStringArray1(), "twenty");
- assertEquals(4, a.length);
- assertTrue(CollectionTools.contains(a, "twenty"));
- assertEquals("twenty", a[a.length-1]);
- }
-
- public void testAddObjectArrayObject_EmptyArray() {
- String[] a = new String[0];
- a = CollectionTools.add(a, "twenty");
- assertEquals(1, a.length);
- assertTrue(CollectionTools.contains(a, "twenty"));
- assertEquals("twenty", a[0]);
- }
-
- public void testAddObjectArrayIntObject_Object() {
- Object[] a = new Object[] { "a", "b", "c", "d" };
- a = CollectionTools.add(a, 2, "X");
- assertEquals(5, a.length);
- assertTrue(CollectionTools.contains(a, "X"));
- assertTrue(Arrays.equals(new Object[] { "a", "b", "X", "c", "d" }, a));
- }
-
- public void testAddObjectArrayIntObject_String() {
- String[] a = new String[] { "a", "b", "c", "d" };
- a = CollectionTools.add(a, 2, "X");
- assertEquals(5, a.length);
- assertTrue(CollectionTools.contains(a, "X"));
- assertTrue(Arrays.equals(new String[] { "a", "b", "X", "c", "d" }, a));
- }
-
- public void testAddObjectArrayIntObject_End() {
- String[] a = new String[] { "a", "b", "c", "d" };
- a = CollectionTools.add(a, 4, "X");
- assertEquals(5, a.length);
- assertTrue(CollectionTools.contains(a, "X"));
- assertTrue(Arrays.equals(new String[] { "a", "b", "c", "d", "X" }, a));
- }
-
- public void testAddObjectArrayIntObject_Zero() {
- String[] a = new String[] { "a", "b", "c", "d" };
- a = CollectionTools.add(a, 0, "X");
- assertEquals(5, a.length);
- assertTrue(CollectionTools.contains(a, "X"));
- assertTrue(Arrays.equals(new String[] { "X", "a", "b", "c", "d" }, a));
- }
-
- public void testAddObjectArrayIntObject_Exception() {
- Object[] a = new Object[] { "a", "b", "c", "d" };
- boolean exCaught = false;
- try {
- a = CollectionTools.add(a, 33, "X");
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddCharArrayChar() {
- char[] a = CollectionTools.add(this.buildCharArray(), 'd');
- assertEquals(4, a.length);
- assertTrue(CollectionTools.contains(a, 'd'));
- }
-
- public void testAddCharArrayChar_Empty() {
- char[] a = new char[0];
- a = CollectionTools.add(a, 'd');
- assertEquals(1, a.length);
- assertTrue(CollectionTools.contains(a, 'd'));
- assertTrue(Arrays.equals(new char[] { 'd' }, a));
- }
-
- public void testAddCharArrayIntChar() {
- char[] a = new char[] { 'a', 'b', 'c', 'd' };
- a = CollectionTools.add(a, 2, 'X');
- assertEquals(5, a.length);
- assertTrue(CollectionTools.contains(a, 'X'));
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'X', 'c', 'd' }, a));
- }
-
- public void testAddCharArrayIntChar_Zero() {
- char[] a = new char[] { 'a', 'b', 'c', 'd' };
- a = CollectionTools.add(a, 0, 'X');
- assertEquals(5, a.length);
- assertTrue(CollectionTools.contains(a, 'X'));
- assertTrue(Arrays.equals(new char[] { 'X', 'a', 'b', 'c', 'd' }, a));
- }
-
- public void testAddCharArrayIntChar_End() {
- char[] a = new char[] { 'a', 'b', 'c', 'd' };
- a = CollectionTools.add(a, 4, 'X');
- assertEquals(5, a.length);
- assertTrue(CollectionTools.contains(a, 'X'));
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'c', 'd', 'X' }, a));
- }
-
- public void testAddIntArrayInt() {
- int[] a = CollectionTools.add(this.buildIntArray(), 30);
- assertEquals(4, a.length);
- assertTrue(CollectionTools.contains(a, 30));
- }
-
- public void testAddIntArrayInt_Empty() {
- int[] a = new int[0];
- a = CollectionTools.add(a, 30);
- assertEquals(1, a.length);
- assertTrue(CollectionTools.contains(a, 30));
- assertTrue(Arrays.equals(new int[] { 30 }, a));
- }
-
- public void testAddIntArrayIntInt() {
- int[] a = new int[] { 1, 2, 3, 4 };
- a = CollectionTools.add(a, 2, 99);
- assertEquals(5, a.length);
- assertTrue(CollectionTools.contains(a, 99));
- assertTrue(Arrays.equals(new int[] { 1, 2, 99, 3, 4 }, a));
- }
-
- public void testAddIntArrayIntInt_Zero() {
- int[] a = new int[] { 1, 2, 3, 4 };
- a = CollectionTools.add(a, 0, 99);
- assertEquals(5, a.length);
- assertTrue(CollectionTools.contains(a, 99));
- assertTrue(Arrays.equals(new int[] { 99, 1, 2, 3, 4 }, a));
- }
-
- public void testAddIntArrayIntInt_End() {
- int[] a = new int[] { 1, 2, 3, 4 };
- a = CollectionTools.add(a, 4, 99);
- assertEquals(5, a.length);
- assertTrue(CollectionTools.contains(a, 99));
- assertTrue(Arrays.equals(new int[] { 1, 2, 3, 4, 99 }, a));
- }
-
- public void testAddAllCollectionIterable_StringModified() {
- List<String> list1 = this.buildStringList1();
- Iterable<String> iterable2 = this.buildStringList2();
- assertTrue(CollectionTools.addAll(list1, iterable2.iterator()));
- assertEquals(6, list1.size());
- assertTrue(list1.containsAll(this.buildStringList2()));
- }
-
- public void testAddAllCollectionIterable_StringUnmodified() {
- Set<String> set1 = this.buildStringSet1();
- Iterable<String> iterable3 = this.buildStringList1(); // same elements as set1
- assertFalse(CollectionTools.addAll(set1, iterable3.iterator()));
- assertEquals(3, set1.size());
- assertTrue(set1.containsAll(this.buildStringList1()));
- }
-
- public void testAddAllCollectionIterable_ObjectModified() {
- List<Object> list1 = this.buildObjectList1();
- Iterable<String> iterable2 = this.buildStringList2();
- assertTrue(CollectionTools.addAll(list1, iterable2));
- assertEquals(6, list1.size());
- assertTrue(list1.containsAll((List<String>) iterable2));
- }
-
- public void testAddAllCollectionIterable_ObjectUnmodified() {
- Set<Object> set1 = this.buildObjectSet1();
- Iterable<String> iterable3 = this.buildStringList1(); // same elements as set1
- assertFalse(CollectionTools.addAll(set1, iterable3));
- assertEquals(3, set1.size());
- assertTrue(set1.containsAll((List<String>) iterable3));
- }
-
- public void testAddAllCollectionIterable_EmptyIterable() {
- Set<Object> set1 = this.buildObjectSet1();
- assertFalse(CollectionTools.addAll(set1, EmptyIterable.instance()));
- assertEquals(3, set1.size());
- }
-
- public void testAddAllCollectionIterableInt_Modified() {
- List<String> list1 = this.buildStringList1();
- List<String> list2 = this.buildStringList2();
- Iterable<String> iterable2 = list2;
- assertTrue(CollectionTools.addAll(list1, iterable2.iterator(), list2.size()));
- assertEquals(6, list1.size());
- assertTrue(list1.containsAll(this.buildStringList2()));
- }
-
- public void testAddAllCollectionIterableInt_Unmodified() {
- Set<String> set1 = this.buildStringSet1();
- List<String> list1 = this.buildStringList1(); // same elements as set1
- Iterable<String> iterable3 = list1;
- assertFalse(CollectionTools.addAll(set1, iterable3.iterator(), list1.size()));
- assertEquals(3, set1.size());
- assertTrue(set1.containsAll(this.buildStringList1()));
- }
-
- public void testAddAllCollectionIterator_StringModified() {
- List<String> list1 = this.buildStringList1();
- List<String> list2 = this.buildStringList2();
- assertTrue(CollectionTools.addAll(list1, list2.iterator()));
- assertEquals(6, list1.size());
- assertTrue(list1.containsAll(list2));
- }
-
- public void testAddAllCollectionIterator_StringUnmodified() {
- Set<String> set1 = this.buildStringSet1();
- List<String> list3 = this.buildStringList1(); // same elements as s1
- assertFalse(CollectionTools.addAll(set1, list3.iterator()));
- assertEquals(3, set1.size());
- assertTrue(set1.containsAll(list3));
- }
-
- public void testAddAllCollectionIterator_ObjectModified() {
- List<Object> list1 = this.buildObjectList1();
- List<String> list2 = this.buildStringList2();
- assertTrue(CollectionTools.addAll(list1, list2.iterator()));
- assertEquals(6, list1.size());
- assertTrue(list1.containsAll(list2));
- }
-
- public void testAddAllCollectionIterator_ObjectUnmodified() {
- Set<Object> set1 = this.buildObjectSet1();
- List<String> list3 = this.buildStringList1(); // same elements as s1
- assertFalse(CollectionTools.addAll(set1, list3.iterator()));
- assertEquals(3, set1.size());
- assertTrue(set1.containsAll(list3));
- }
-
- public void testAddAllCollectionIterator_EmptyIterator() {
- List<String> list1 = this.buildStringList1();
- assertFalse(CollectionTools.addAll(list1, EmptyIterator.<String>instance()));
- assertEquals(3, list1.size());
- }
-
- public void testAddAllCollectionIteratorInt_Modified() {
- List<String> list1 = this.buildStringList1();
- List<String> list2 = this.buildStringList2();
- assertTrue(CollectionTools.addAll(list1, list2.iterator(), 3));
- assertEquals(6, list1.size());
- assertTrue(list1.containsAll(list2));
- }
-
- public void testAddAllCollectionIteratorInt_Unmodified() {
- Set<String> set1 = this.buildStringSet1();
- List<String> list3 = this.buildStringList1(); // same elements as s1
- assertFalse(CollectionTools.addAll(set1, list3.iterator(), 3));
- assertEquals(3, set1.size());
- assertTrue(set1.containsAll(list3));
- }
-
- public void testAddAllCollectionIteratorInt_EmptyIterator() {
- List<String> list1 = this.buildStringList1();
- assertFalse(CollectionTools.addAll(list1, EmptyIterator.<String>instance(), 0));
- assertEquals(3, list1.size());
- }
-
- public void testAddAllCollectionObjectArray_StringModified() {
- List<String> list = this.buildStringList1();
- String[] a = this.buildStringArray1();
- assertTrue(CollectionTools.addAll(list, a));
- assertEquals(6, list.size());
- assertTrue(list.containsAll(CollectionTools.collection(a)));
- }
-
- public void testAddAllCollectionObjectArray_StringListEmptyArray() {
- List<String> list = this.buildStringList1();
- assertFalse(CollectionTools.addAll(list, new String[0]));
- }
-
- public void testAddAllCollectionObjectArray_StringUnmodified() {
- Set<String> set = this.buildStringSet1();
- String[] a = this.buildStringArray1();
- assertFalse(CollectionTools.addAll(set, a));
- assertEquals(3, set.size());
- assertTrue(set.containsAll(CollectionTools.collection(a)));
-
- assertFalse(CollectionTools.addAll(set, new String[0]));
- }
-
- public void testAddAllCollectionObjectArray_StringSetEmptyArray() {
- Set<String> set = this.buildStringSet1();
- assertFalse(CollectionTools.addAll(set, new String[0]));
- }
-
- public void testAddAllCollectionObjectArray_ObjectModified() {
- List<Object> list = this.buildObjectList1();
- String[] a = this.buildStringArray1();
-
- assertTrue(CollectionTools.addAll(list, a));
- assertEquals(6, list.size());
- assertTrue(list.containsAll(CollectionTools.collection(a)));
- }
-
- public void testAddAllCollectionObjectArray_ObjectUnmodified() {
- String[] a = this.buildStringArray1();
- Set<Object> set = this.buildObjectSet1();
- assertFalse(CollectionTools.addAll(set, a));
- assertEquals(3, set.size());
- assertTrue(set.containsAll(CollectionTools.collection(a)));
- }
-
- public void testAddAllListIntObjectArray() {
- List<String> list = this.buildStringList1();
- CollectionTools.addAll(list, 2, new String[] { "X", "X", "X" });
- assertEquals(6, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "X", "X", "X", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntObjectArray_Zero() {
- List<String> list = new ArrayList<String>();
- CollectionTools.addAll(list, 0, new String[] { "X", "X", "X" });
- assertEquals(3, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "X", "X", "X" }, list.toArray()));
- }
-
- public void testAddAllListIntObjectArray_EmptyArray() {
- List<String> list = this.buildStringList1();
- CollectionTools.addAll(list, 2, new String[0]);
- assertEquals(3, list.size());
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIterable() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = Arrays.asList(new String[] { "X", "X", "X" });
- CollectionTools.addAll(list, 2, iterable);
- assertEquals(6, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "X", "X", "X", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIterable_Zero() {
- List<String> list = new ArrayList<String>();
- Iterable<String> iterable = Arrays.asList(new String[] { "X", "X", "X" });
- CollectionTools.addAll(list, 0, iterable);
- assertEquals(3, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "X", "X", "X" }, list.toArray()));
- }
-
- public void testAddAllListIntIterable_EmptyIterable() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = EmptyIterable.instance();
- CollectionTools.addAll(list, 2, iterable);
- assertEquals(3, list.size());
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIterableInt() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = Arrays.asList(new String[] { "X", "X", "X" });
- CollectionTools.addAll(list, 2, iterable, 3);
- assertEquals(6, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "X", "X", "X", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIterableInt_Zero() {
- List<String> list = new ArrayList<String>();
- Iterable<String> iterable = Arrays.asList(new String[] { "X", "X", "X" });
- CollectionTools.addAll(list, 0, iterable, 3);
- assertEquals(3, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "X", "X", "X" }, list.toArray()));
- }
-
- public void testAddAllListIntIterableInt_EmptyIterable() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = EmptyIterable.instance();
- CollectionTools.addAll(list, 2, iterable, 0);
- assertEquals(3, list.size());
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIterator() {
- List<String> list = this.buildStringList1();
- Iterator<String> iterator = Arrays.asList(new String[] { "X", "X", "X" }).iterator();
- CollectionTools.addAll(list, 2, iterator);
- assertEquals(6, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "X", "X", "X", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIterator_Zero() {
- List<String> list = new ArrayList<String>();
- Iterator<String> iterator = Arrays.asList(new String[] { "X", "X", "X" }).iterator();
- CollectionTools.addAll(list, 0, iterator);
- assertEquals(3, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "X", "X", "X" }, list.toArray()));
- }
-
- public void testAddAllListIntIterator_EmptyIterator() {
- List<String> list = this.buildStringList1();
- Iterator<String> iterator = EmptyIterator.instance();
- CollectionTools.addAll(list, 2, iterator);
- assertEquals(3, list.size());
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIteratorInt() {
- List<String> list = this.buildStringList1();
- Iterator<String> iterator = Arrays.asList(new String[] { "X", "X", "X" }).iterator();
- CollectionTools.addAll(list, 2, iterator, 3);
- assertEquals(6, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "X", "X", "X", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIteratorInt_Zero() {
- List<String> list = new ArrayList<String>();
- Iterator<String> iterator = Arrays.asList(new String[] { "X", "X", "X" }).iterator();
- CollectionTools.addAll(list, 0, iterator, 3);
- assertEquals(3, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "X", "X", "X" }, list.toArray()));
- }
-
- public void testAddAllListIntIteratorInt_EmptyIterator() {
- List<String> list = this.buildStringList1();
- Iterator<String> iterator = EmptyIterator.instance();
- CollectionTools.addAll(list, 2, iterator, 0);
- assertEquals(3, list.size());
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "two" }, list.toArray()));
- }
-
- public void testAddAllObjectArrayCollection_String() {
- String[] a = this.buildStringArray1();
- Collection<String> c = this.buildStringList2();
- String[] newArray = CollectionTools.addAll(a, c);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, c));
- }
-
- public void testAddAllObjectArrayCollection_Object() {
- Object[] a = this.buildObjectArray1();
- Collection<String> c = this.buildStringList2();
- Object[] newArray = CollectionTools.addAll(a, c);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, c));
- }
-
- public void testAddAllObjectArrayCollection_EmptyArray() {
- String[] a = new String[0];
- Collection<String> c = this.buildStringList2();
- String[] newArray = CollectionTools.addAll(a, c);
-
- assertEquals(3, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, c));
- }
-
- public void testAddAllObjectArrayCollection_EmptyCollection() {
- String[] a = this.buildStringArray1();
- Collection<String> c = new ArrayList<String>();
- String[] newArray = CollectionTools.addAll(a, c);
-
- assertEquals(3, newArray.length);
- }
-
- public void testAddAllObjectArrayIntCollection_String() {
- String[] a = this.buildStringArray1();
- Collection<String> c = this.buildStringList2();
- String[] newArray = CollectionTools.addAll(a, 1, c);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, c));
- }
-
- public void testAddAllObjectArrayIntCollection_EmptyArray() {
- String[] a = new String[0];
- Collection<String> c = this.buildStringList2();
- String[] newArray = CollectionTools.addAll(a, 0, c);
-
- assertEquals(3, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, c));
- }
-
- public void testAddAllObjectArrayIntCollection_EmptyCollection() {
- String[] a = this.buildStringArray1();
- Collection<String> c = new ArrayList<String>();
- String[] newArray = CollectionTools.addAll(a, 1, c);
-
- assertEquals(3, newArray.length);
- }
-
- public void testAddAllObjectArrayIntIterable_String() {
- String[] a = this.buildStringArray1();
- Iterable<String> iterable = this.buildStringList2();
- String[] newArray = CollectionTools.addAll(a, 1, iterable);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, iterable));
- }
-
- public void testAddAllObjectArrayIntIterable_EmptyArray() {
- String[] a = new String[0];
- Iterable<String> iterable = this.buildStringList2();
- String[] newArray = CollectionTools.addAll(a, 0, iterable);
-
- assertEquals(3, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, iterable));
- }
-
- public void testAddAllObjectArrayIntIterable_EmptyIterable() {
- String[] a = this.buildStringArray1();
- Iterable<String> iterable = new ArrayList<String>();
- String[] newArray = CollectionTools.addAll(a, 1, iterable);
-
- assertEquals(3, newArray.length);
- }
-
- public void testAddAllObjectArrayIntIterableInt_String() {
- String[] a = this.buildStringArray1();
- Iterable<String> iterable = this.buildStringList2();
- String[] newArray = CollectionTools.addAll(a, 1, iterable, 3);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, iterable));
- }
-
- public void testAddAllObjectArrayIntIterableInt_EmptyArray() {
- String[] a = new String[0];
- Iterable<String> iterable = this.buildStringList2();
- String[] newArray = CollectionTools.addAll(a, 0, iterable, 3);
-
- assertEquals(3, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, iterable));
- }
-
- public void testAddAllObjectArrayIntIterableInt_EmptyIterable() {
- String[] a = this.buildStringArray1();
- Iterable<String> iterable = new ArrayList<String>();
- String[] newArray = CollectionTools.addAll(a, 1, iterable, 0);
-
- assertEquals(3, newArray.length);
- }
-
- public void testAddAllObjectArrayIntIterator_String() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = this.buildStringList2().iterator();
- String[] newArray = CollectionTools.addAll(a, 1, iterator);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, this.buildStringList2()));
- }
-
- public void testAddAllObjectArrayIntIterator_EmptyArray() {
- String[] a = new String[0];
- Iterator<String> iterator = this.buildStringList2().iterator();
- String[] newArray = CollectionTools.addAll(a, 0, iterator);
-
- assertEquals(3, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, this.buildStringList2()));
- }
-
- public void testAddAllObjectArrayIntIterator_EmptyIterable() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = EmptyIterator.instance();
- String[] newArray = CollectionTools.addAll(a, 1, iterator);
-
- assertEquals(3, newArray.length);
- }
-
- public void testAddAllObjectArrayIntIteratorInt_String() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = this.buildStringList2().iterator();
- String[] newArray = CollectionTools.addAll(a, 1, iterator, 3);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, this.buildStringList2()));
- }
-
- public void testAddAllObjectArrayIntIteratorInt_EmptyArray() {
- String[] a = new String[0];
- Iterator<String> iterator = this.buildStringList2().iterator();
- String[] newArray = CollectionTools.addAll(a, 0, iterator, 3);
-
- assertEquals(3, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, this.buildStringList2()));
- }
-
- public void testAddAllObjectArrayIntIteratorInt_EmptyIterator() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = EmptyIterator.instance();
- String[] newArray = CollectionTools.addAll(a, 1, iterator, 0);
-
- assertEquals(3, newArray.length);
- }
-
- public void testAddAllObjectArrayIterable() {
- String[] a = this.buildStringArray1();
- Iterable<String> iterable = this.buildStringList1();
- String[] newArray = CollectionTools.addAll(a, iterable);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, this.buildStringList1()));
- }
-
- public void testAddAllObjectArrayIterableInt() {
- String[] a = this.buildStringArray1();
- Iterable<String> iterable = this.buildStringList1();
- String[] newArray = CollectionTools.addAll(a, iterable, 33);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, this.buildStringList1()));
- }
-
- public void testAddAllObjectArrayIterator_String() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = this.buildStringList1().iterator();
- String[] newArray = CollectionTools.addAll(a, iterator);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, this.buildStringList1()));
- }
-
- public void testAddAllObjectArrayIterator_Object() {
- String[] a = this.buildStringArray1();
- Iterator<Object> iterator = this.buildObjectList1().iterator();
- Object[] newArray = CollectionTools.addAll(a, iterator);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, this.buildObjectList1()));
- }
-
- public void testAddAllObjectArrayIterator_EmptyIterator() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = EmptyIterator.instance();
- String[] newArray = CollectionTools.addAll(a, iterator);
-
- assertEquals(3, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, this.buildStringList1()));
- }
-
- public void testAddAllObjectArrayIteratorInt() {
- String[] a = this.buildStringArray1();
- Iterator<Object> iterator = this.buildObjectList1().iterator();
- Object[] newArray = CollectionTools.addAll(a, iterator, 3);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, this.buildObjectList1()));
- }
-
- public void testAddAllObjectArrayIteratorInt_EmptyIterator() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = EmptyIterator.instance();
- String[] newArray = CollectionTools.addAll(a, iterator, 0);
-
- assertEquals(3, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, this.buildStringList1()));
- }
-
- public void testAddAllObjectArrayObjectArray_Object() {
- Object[] a1 = this.buildObjectArray1();
- Object[] a2 = this.buildObjectArray2();
- Object[] newArray = CollectionTools.addAll(a1, a2);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, a1));
- assertTrue(CollectionTools.containsAll(newArray, a2));
- }
-
- public void testAddAllObjectArrayObjectArray_String() {
- String[] a1 = this.buildStringArray1();
- String[] a2 = this.buildStringArray2();
- String[] newArray = CollectionTools.addAll(a1, a2);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, a1));
- assertTrue(CollectionTools.containsAll(newArray, a2));
- }
-
- public void testAddAllObjectArrayObjectArray_ObjectString() {
- Object[] a1 = this.buildObjectArray1();
- String[] a2 = this.buildStringArray2();
- Object[] newArray = CollectionTools.addAll(a1, a2);
-
- assertEquals(6, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, a1));
- assertTrue(CollectionTools.containsAll(newArray, a2));
- }
-
- public void testAddAllObjectArrayObjectArray_EmptyArray1() {
- Object[] a1 = new Object[0];
- Object[] a2 = this.buildObjectArray2();
- Object[] newArray = CollectionTools.addAll(a1, a2);
-
- assertEquals(3, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, a2));
- }
-
- public void testAddAllObjectArrayObjectArray_EmptyArray2() {
- Object[] a1 = this.buildObjectArray1();
- Object[] a2 = new Object[0];
- Object[] newArray = CollectionTools.addAll(a1, a2);
-
- assertEquals(3, newArray.length);
- assertTrue(CollectionTools.containsAll(newArray, a1));
- }
-
- public void testAddAllObjectArrayIntObjectArray_Object() {
- Object[] a = new Object[] { "a", "b", "c", "d" };
- a = CollectionTools.addAll(a, 2, new Object[] { "X", "X", "X" });
- assertEquals(7, a.length);
- assertTrue(CollectionTools.contains(a, "X"));
- assertTrue(Arrays.equals(new Object[] { "a", "b", "X", "X", "X", "c", "d" }, a));
- }
-
- public void testAddAllObjectArrayIntObjectArray_String() {
- String[] a = new String[] { "a", "b", "c", "d" };
- a = CollectionTools.addAll(a, 2, new String[] { "X", "X", "X" });
- assertEquals(7, a.length);
- assertTrue(CollectionTools.contains(a, "X"));
- assertTrue(Arrays.equals(new String[] { "a", "b", "X", "X", "X", "c", "d" }, a));
- }
-
- public void testAddAllObjectArrayIntObjectArray_ObjectString() {
- Object[] a = new Object[] { "a", "b", "c", "d" };
- a = CollectionTools.addAll(a, 2, new String[] { "X", "X", "X" });
- assertEquals(7, a.length);
- assertTrue(CollectionTools.contains(a, "X"));
- assertTrue(Arrays.equals(new Object[] { "a", "b", "X", "X", "X", "c", "d" }, a));
- }
-
- public void testAddAllObjectArrayIntObjectArray_End() {
- Object[] a = new Object[] { "a", "b", "c", "d" };
- a = CollectionTools.addAll(a, 4, new String[] { "X", "X", "X" });
- assertEquals(7, a.length);
- assertTrue(CollectionTools.contains(a, "X"));
- assertTrue(Arrays.equals(new Object[] { "a", "b", "c", "d", "X", "X", "X" }, a));
- }
-
- public void testAddAllObjectArrayIntObjectArray_Zero() {
- Object[] a = new Object[0];
- a = CollectionTools.addAll(a, 0, new String[] { "X", "X", "X" });
- assertEquals(3, a.length);
- assertTrue(CollectionTools.contains(a, "X"));
- assertTrue(Arrays.equals(new Object[] { "X", "X", "X" }, a));
- }
-
- public void testAddAllObjectArrayIntObjectArray_EmptyArray2() {
- Object[] a = new Object[] { "a", "b", "c", "d" };
- a = CollectionTools.addAll(a, 4, new String[0]);
- assertEquals(4, a.length);
- assertTrue(Arrays.equals(new Object[] { "a", "b", "c", "d" }, a));
- }
-
- public void testAddAllObjectArrayIntObjectArray_EmptyArray1() {
- Object[] a = new String[0];
- a = CollectionTools.addAll(a, 0, new Object[] { "a", "b", "c", "d" });
- assertEquals(4, a.length);
- assertTrue(Arrays.equals(new Object[] { "a", "b", "c", "d" }, a));
- }
-
- public void testAddAllCharArrayCharArray() {
- char[] a = CollectionTools.addAll(this.buildCharArray(), new char[] { 'd', 'e' });
- assertEquals(5, a.length);
- assertTrue(CollectionTools.contains(a, 'd'));
- assertTrue(CollectionTools.contains(a, 'e'));
- }
-
- public void testAddAllCharArrayCharArray_EmptyArray2() {
- char[] a = CollectionTools.addAll(this.buildCharArray(), new char[0]);
- assertEquals(3, a.length);
- }
-
- public void testAddAllCharArrayCharArrayEmptyArray1() {
- char[] a = CollectionTools.addAll(new char[0], new char[] { 'd', 'e' });
- assertEquals(2, a.length);
- assertTrue(CollectionTools.contains(a, 'd'));
- assertTrue(CollectionTools.contains(a, 'e'));
- }
-
- public void testAddAllCharArrayIntCharArray() {
- char[] a = new char[] { 'a', 'b', 'c', 'd' };
- a = CollectionTools.addAll(a, 2, new char[] { 'X', 'X', 'X' });
- assertEquals(7, a.length);
- assertTrue(CollectionTools.contains(a, 'X'));
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'X', 'X', 'X', 'c', 'd' }, a));
- }
-
- public void testAddAllCharArrayIntCharArray_End() {
- char[] a = new char[] { 'a', 'b', 'c', 'd' };
- a = CollectionTools.addAll(a, 4, new char[] { 'X', 'X', 'X' });
- assertEquals(7, a.length);
- assertTrue(CollectionTools.contains(a, 'X'));
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'c', 'd', 'X', 'X', 'X' }, a));
- }
-
- public void testAddAllCharArrayIntCharArray_EmptyArray1() {
- char[] a = new char[0];
- a = CollectionTools.addAll(a, 0, new char[] { 'X', 'X', 'X' });
- assertEquals(3, a.length);
- assertTrue(CollectionTools.contains(a, 'X'));
- assertTrue(Arrays.equals(new char[] { 'X', 'X', 'X' }, a));
- }
-
- public void testAddAllCharArrayIntCharArray_EmptyArray2() {
- char[] a = new char[] { 'a', 'b', 'c', 'd' };
- a = CollectionTools.addAll(a, 2, new char[0]);
- assertEquals(4, a.length);
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'c', 'd' }, a));
- }
-
- public void testAddAllIntArrayIntArray() {
- int[] a = CollectionTools.addAll(this.buildIntArray(), new int[] { 30, 40 });
- assertEquals(5, a.length);
- assertTrue(CollectionTools.contains(a, 30));
- assertTrue(CollectionTools.contains(a, 40));
- }
-
- public void testAddAllIntArrayIntArray_EmptyArray2() {
- int[] a = CollectionTools.addAll(this.buildIntArray(), new int[0]);
- assertEquals(3, a.length);
- }
-
- public void testAddAllIntArrayIntArray_EmptyArray1() {
- int[] a = CollectionTools.addAll(new int[0], new int[] { 30, 40 });
- assertEquals(2, a.length);
- assertTrue(CollectionTools.contains(a, 30));
- assertTrue(CollectionTools.contains(a, 40));
- }
-
- public void testAddAllIntArrayIntIntArray() {
- int[] a = new int[] { 1, 2, 3, 4 };
- a = CollectionTools.addAll(a, 2, new int[] { 99, 99, 99 });
- assertEquals(7, a.length);
- assertTrue(CollectionTools.contains(a, 99));
- assertTrue(Arrays.equals(new int[] { 1, 2, 99, 99, 99, 3, 4 }, a));
- }
-
- public void testAddAllIntArrayIntIntArray_End() {
- int[] a = new int[] { 1, 2, 3, 4 };
- a = CollectionTools.addAll(a, 4, new int[] { 99, 99, 99 });
- assertEquals(7, a.length);
- assertTrue(CollectionTools.contains(a, 99));
- assertTrue(Arrays.equals(new int[] { 1, 2, 3, 4, 99, 99, 99 }, a));
- }
-
- public void testAddAllIntArrayIntIntArray_EmptyArray2() {
- int[] a = new int[] { 1, 2, 3, 4 };
- a = CollectionTools.addAll(a, 2, new int[0]);
- assertEquals(4, a.length);
- assertTrue(Arrays.equals(new int[] { 1, 2, 3, 4 }, a));
- }
-
- public void testAddAllIntArrayIntIntArray_EmptyArray1() {
- int[] a = new int[0];
- a = CollectionTools.addAll(a, 0, new int[] { 99, 99, 99 });
- assertEquals(3, a.length);
- assertTrue(CollectionTools.contains(a, 99));
- assertTrue(Arrays.equals(new int[] { 99, 99, 99 }, a));
- }
-
- public void testArrayIterable() {
- Iterable<String> iterable = this.buildStringList1();
- Object[] a = CollectionTools.array(iterable);
- assertEquals(3, a.length);
- assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIterableInt() {
- Iterable<String> iterable = this.buildStringList1();
- Object[] a = CollectionTools.array(iterable, 3);
- assertEquals(3, a.length);
- assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIterableObjectArray_String() {
- Iterable<String> iterable = this.buildStringList1();
- String[] a = CollectionTools.array(iterable, new String[0]);
- assertEquals(3, a.length);
- assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIterableObjectArray_Object() {
- Iterable<String> iterable = this.buildStringList1();
- Object[] a = CollectionTools.array(iterable, new Object[0]);
- assertEquals(3, a.length);
- assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIterableIntObjectArray() {
- Iterable<String> iterable = this.buildStringList1();
- String[] a = CollectionTools.array(iterable, 3, new String[0]);
- assertEquals(3, a.length);
- assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIterator() {
- Object[] a = CollectionTools.array(this.buildStringList1().iterator());
- assertEquals(3, a.length);
- assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIterator_Empty() {
- Object[] a = CollectionTools.array(EmptyIterator.instance());
- assertEquals(0, a.length);
- }
-
- public void testArrayIteratorInt() {
- Object[] a = CollectionTools.array(this.buildStringList1().iterator(), 3);
- assertEquals(3, a.length);
- assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIteratorInt_Empty() {
- Object[] a = CollectionTools.array(EmptyIterator.instance(), 3);
- assertEquals(0, a.length);
- }
-
- public void testArrayIteratorObjectArray_String() {
- String[] a = CollectionTools.array(this.buildStringList1().iterator(), new String[0]);
- assertEquals(3, a.length);
- assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIteratorObjectArray_Empty() {
- String[] a = CollectionTools.array(EmptyIterator.<String>instance(), new String[0]);
- assertEquals(0, a.length);
- }
-
- public void testArrayIteratorObjectArray_Object() {
- Object[] a = CollectionTools.array(this.buildStringList1().iterator(), new Object[0]);
- assertEquals(3, a.length);
- assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIteratorIntObjectArray() {
- String[] a = CollectionTools.array(this.buildStringList1().iterator(), 3, new String[0]);
- assertEquals(3, a.length);
- assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIteratorIntObjectArray_Empty() {
- String[] a = CollectionTools.array(EmptyIterator.<String>instance(), 3, new String[0]);
- assertEquals(0, a.length);
- }
-
- public void testBagEnumeration_String() {
- Bag<String> b = CollectionTools.bag(this.buildStringVector1().elements());
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringVector1()));
- }
-
- public void testBagEnumeration_Object() {
- Bag<Object> b = CollectionTools.<Object>bag(this.buildStringVector1().elements());
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringVector1()));
- }
-
- public void testBagEnumeration_Empty() {
- Bag<Object> b = CollectionTools.<Object>bag(EmptyEnumeration.instance());
- assertEquals(0, b.size());
- }
-
- public void testBagEnumerationInt() {
- Bag<String> b = CollectionTools.bag(this.buildStringVector1().elements(), 3);
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringVector1()));
- }
-
- public void testBagEnumerationInt_Empty() {
- Bag<String> b = CollectionTools.bag(EmptyEnumeration.<String>instance(), 3);
- assertEquals(0, b.size());
- }
-
- public void testBagIterable() {
- Iterable<String> iterable = this.buildStringList1();
- Bag<String> b = CollectionTools.bag(iterable);
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringList1()));
- }
-
- public void testBagIterableInt() {
- Iterable<String> iterable = this.buildStringList1();
- Bag<String> b = CollectionTools.bag(iterable, 3);
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringList1()));
- }
-
- public void testBagIterator_String() {
- Bag<String> b = CollectionTools.bag(this.buildStringList1().iterator());
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringList1()));
- }
-
- public void testBagIterator_StringObject() {
- Collection<String> c = new ArrayList<String>();
- c.add("zero");
- c.add("one");
- c.add("two");
- c.add("three");
- Bag<Object> b = CollectionTools.<Object>bag(c.iterator());
- assertEquals(4, b.size());
- assertTrue(b.containsAll(c));
- }
-
- public void testBagIterator_Empty() {
- Bag<String> b = CollectionTools.bag(EmptyIterator.<String>instance());
- assertEquals(0, b.size());
- }
-
- public void testBagIteratorInt() {
- Bag<String> b = CollectionTools.bag(this.buildStringList1().iterator(), 3);
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringList1()));
- }
-
- public void testBagIteratorInt_Empty() {
- Bag<String> b = CollectionTools.bag(EmptyIterator.<String>instance(), 3);
- assertEquals(0, b.size());
- }
-
- public void testBagObjectArray() {
- Bag<String> b = CollectionTools.bag(this.buildStringArray1());
- assertEquals(3, b.size());
- assertTrue(CollectionTools.containsAll(b, this.buildStringArray1()));
- }
-
- public void testBagObjectArray_Vararg() {
- Bag<String> b = CollectionTools.bag("foo", "bar", "baz");
- assertEquals(3, b.size());
- assertTrue(CollectionTools.containsAll(b, new Object[]{"foo", "bar", "baz"}));
- }
-
- public void testBagObjectArray_Empty() {
- Bag<String> b = CollectionTools.bag(Bag.Empty.<String>instance());
- assertEquals(0, b.size());
- }
-
- public void testCollectionEnumeration() {
- Collection<String> c = CollectionTools.collection(this.buildStringVector1().elements());
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringVector1()));
- }
-
- public void testCollectionEnumeration_ObjectString() {
- Collection<Object> c = CollectionTools.<Object>collection(this.buildStringVector1().elements());
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringVector1()));
- }
-
- public void testCollectionEnumerationInt() {
- Collection<String> c = CollectionTools.collection(this.buildStringVector1().elements(), 3);
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringVector1()));
- }
-
- public void testCollectionIterable() {
- Iterable<String> iterable = this.buildStringList1();
- Collection<String> c = CollectionTools.collection(iterable);
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringList1()));
- }
-
- public void testCollectionIterableInt() {
- Iterable<String> iterable = this.buildStringList1();
- Collection<String> c = CollectionTools.collection(iterable, 3);
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringList1()));
- }
-
- public void testCollectionIterator() {
- Collection<String> c = CollectionTools.collection(this.buildStringList1().iterator());
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringList1()));
- }
-
- public void testCollectionIterator_ObjectString() {
- Collection<Object> c = CollectionTools.<Object>collection(this.buildStringList1().iterator());
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringList1()));
- }
-
- public void testCollectionIteratorInt() {
- Collection<String> c = CollectionTools.collection(this.buildStringList1().iterator(), 3);
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringList1()));
- }
-
- public void testCollectionObjectArray() {
- Collection<String> c = CollectionTools.collection(this.buildStringArray1());
- assertEquals(3, c.size());
- assertTrue(CollectionTools.containsAll(c, this.buildStringArray1()));
- }
-
- public void testContainsEnumerationObject_String() {
- Vector<String> v = this.buildStringVector1();
- assertTrue(CollectionTools.contains(v.elements(), "one"));
- assertFalse(CollectionTools.contains(v.elements(), null));
- v.add(null);
- assertTrue(CollectionTools.contains(v.elements(), null));
- }
-
- public void testContainsEnumerationObject_Object() {
- Vector<Object> c = new Vector<Object>();
- c.add("zero");
- c.add("one");
- c.add("two");
- c.add("three");
- String one = "one";
- assertTrue(CollectionTools.contains(c.elements(), one));
- assertFalse(CollectionTools.contains(c.elements(), null));
- c.add(null);
- assertTrue(CollectionTools.contains(c.elements(), null));
- }
-
- public void testContainsIterableObject() {
- Collection<String> c = this.buildStringList1();
- Iterable<String> iterable = c;
- assertTrue(CollectionTools.contains(iterable, "one"));
- assertFalse(CollectionTools.contains(iterable, null));
- c.add(null);
- assertTrue(CollectionTools.contains(iterable, null));
- }
-
- public void testContainsIteratorObject_String() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.contains(c.iterator(), "one"));
- assertFalse(CollectionTools.contains(c.iterator(), null));
- c.add(null);
- assertTrue(CollectionTools.contains(c.iterator(), null));
- }
-
- public void testContainsIteratorObject_Object() {
- Collection<Object> c = new HashBag<Object>();
- c.add("zero");
- c.add("one");
- c.add("two");
- c.add("three");
- String one = "one";
- assertTrue(CollectionTools.contains(c.iterator(), one));
- assertFalse(CollectionTools.contains(c.iterator(), null));
- c.add(null);
- assertTrue(CollectionTools.contains(c.iterator(), null));
- }
-
- public void testContainsObjectArrayObject() {
- Object[] a = this.buildObjectArray1();
- assertTrue(CollectionTools.contains(a, "one"));
- assertFalse(CollectionTools.contains(a, null));
- Object[] a2 = CollectionTools.add(a, null);
- assertTrue(CollectionTools.contains(a2, null));
- }
-
- public void testContainsCharArrayChar() {
- char[] a = this.buildCharArray();
- assertTrue(CollectionTools.contains(a, 'a'));
- assertFalse(CollectionTools.contains(a, 'z'));
- char[] a2 = CollectionTools.add(a, 'z');
- assertTrue(CollectionTools.contains(a2, 'z'));
- }
-
- public void testContainsIntArrayInt() {
- int[] a = this.buildIntArray();
- assertTrue(CollectionTools.contains(a, 10));
- assertFalse(CollectionTools.contains(a, 55));
- int[] a2 = CollectionTools.add(a, 55);
- assertTrue(CollectionTools.contains(a2, 55));
- }
-
- public void testContainsAllCollectionIterable() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(this.buildStringList1(), iterable));
- }
-
- public void testContainsAllCollectionIterator_String() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1(), this.buildStringList1().iterator()));
- }
-
- public void testContainsAllCollectionIterator_Object() {
- Collection<Object> c1 = new ArrayList<Object>();
- c1.add("zero");
- c1.add("one");
- c1.add("two");
- Collection<String> c2 = new ArrayList<String>();
- c2.add("two");
- c2.add("zero");
- c2.add("one");
- assertTrue(CollectionTools.containsAll(c1, c2.iterator()));
- }
-
- public void testContainsAllCollectionObjectArray_StringObject() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1(), this.buildObjectArray1()));
- }
-
- public void testContainsAllCollectionObjectArray() {
- Object[] a = new Object[] { "zero", "one", "two" };
- assertTrue(CollectionTools.containsAll(this.buildStringList1(), a));
- }
-
- public void testContainsAllIterableCollection() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable, this.buildStringList1()));
- }
-
- public void testContainsAllIterableIntCollection() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable, 3, this.buildStringList1()));
- }
-
- public void testContainsAllIterableIterable() {
- Iterable<String> iterable1 = this.buildStringList1();
- Iterable<String> iterable2 = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable1, iterable2));
- }
-
- public void testContainsAllIterableIntIterable() {
- Iterable<String> iterable1 = this.buildStringList1();
- Iterable<String> iterable2 = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable1, 3, iterable2));
- }
-
- public void testContainsAllIterableIterator() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable, this.buildStringList1().iterator()));
- }
-
- public void testContainsAllIterableIntIterator() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable, 3, this.buildStringList1().iterator()));
- }
-
- public void testContainsAllIterableObjectArray() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable, this.buildObjectArray1()));
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.containsAll(iterable, this.buildObjectArray1()));
- }
-
- public void testContainsAllIterableIntObjectArray() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable, 3, this.buildObjectArray1()));
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.containsAll(iterable, 3, this.buildObjectArray1()));
- }
-
- public void testContainsAllIteratorCollection_StringString() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildStringList1()));
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildStringList2()));
- }
-
- public void testContainsAllIteratorCollection_ObjectString() {
- Collection<Object> c1 = new ArrayList<Object>();
- c1.add("zero");
- c1.add("one");
- c1.add("two");
- Collection<String> c2 = new ArrayList<String>();
- c2.add("zero");
- c2.add("one");
- c2.add("two");
- assertTrue(CollectionTools.containsAll(c1.iterator(), c2));
- }
-
- public void testContainsAllIteratorIntCollection() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), 5, this.buildStringList1()));
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), 5, this.buildStringList2()));
- }
-
- public void testContainsAllIteratorIterable() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), iterable));
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), iterable));
- }
-
- public void testContainsAllIteratorIntIterable() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), 3, iterable));
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), 3, iterable));
- }
-
- public void testContainsAllIteratorIterator_StringString() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildStringList1().iterator()));
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildStringList2().iterator()));
- }
-
- public void testContainsAllIteratorIterator_ObjectString() {
- Collection<Object> c1 = new ArrayList<Object>();
- c1.add("zero");
- c1.add("one");
- c1.add("two");
- Collection<String> c2 = new ArrayList<String>();
- c2.add("zero");
- c2.add("one");
- c2.add("two");
- assertTrue(CollectionTools.containsAll(c1.iterator(), c2.iterator()));
- }
-
- public void testContainsAllIteratorIntIterator() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), 3, this.buildStringList1().iterator()));
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), 3, this.buildStringList2().iterator()));
- }
-
- public void testContainsAllIteratorObjectArray() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildObjectArray1()));
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildObjectArray2()));
- }
-
- public void testContainsAllIteratorIntObjectArray() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), 3, this.buildObjectArray1()));
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), 3, this.buildObjectArray2()));
- }
-
- public void testContainsAllObjectArrayCollection() {
- assertTrue(CollectionTools.containsAll(this.buildObjectArray1(), this.buildStringList1()));
- assertFalse(CollectionTools.containsAll(this.buildObjectArray1(), this.buildStringList2()));
- }
-
- public void testContainsAllObjectArrayIterable() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(this.buildObjectArray1(), iterable));
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.containsAll(this.buildObjectArray1(), iterable));
- }
-
- public void testContainsAllObjectArrayIterator() {
- assertTrue(CollectionTools.containsAll(this.buildObjectArray1(), this.buildStringList1().iterator()));
- assertFalse(CollectionTools.containsAll(this.buildObjectArray1(), this.buildStringList2().iterator()));
- }
-
- public void testContainsAllObjectArrayIterator_Empty() {
- assertTrue(CollectionTools.containsAll(this.buildObjectArray1(), EmptyIterator.instance()));
- }
-
- public void testContainsAllObjectArrayObjectArray() {
- assertTrue(CollectionTools.containsAll(this.buildObjectArray1(), this.buildObjectArray1()));
- assertFalse(CollectionTools.containsAll(this.buildObjectArray1(), this.buildObjectArray2()));
- }
-
- public void testContainsAllCharArrayCharArray() {
- assertTrue(CollectionTools.containsAll(this.buildCharArray(), this.buildCharArray()));
- assertFalse(CollectionTools.containsAll(this.buildCharArray(), new char[] { 'x', 'y' }));
- }
-
- public void testContainsAllIntArrayIntArray() {
- assertTrue(CollectionTools.containsAll(this.buildIntArray(), this.buildIntArray()));
- assertFalse(CollectionTools.containsAll(this.buildIntArray(), new int[] { 444, 888 }));
- }
-
- public void testDiffEnd() {
- String a = "a";
- String b = "b";
- String c = "c";
- String d = "d";
- String e = "e";
- String a_ = new String("a");
- String b_ = new String("b");
- String c_ = new String("c");
- String d_ = new String("d");
- String e_ = new String("e");
- assertTrue((a != a_) && a.equals(a_));
- assertTrue((b != b_) && b.equals(b_));
- assertTrue((c != c_) && c.equals(c_));
- assertTrue((d != d_) && d.equals(d_));
- assertTrue((e != e_) && e.equals(e_));
- String[] array1;
- String[] array2;
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(-1, CollectionTools.diffEnd(array1, array2));
-
- array1 = new String[] { a };
- array2 = new String[] { a_ };
- assertEquals(-1, CollectionTools.diffEnd(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(4, CollectionTools.diffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, d_, e_ };
- assertEquals(4, CollectionTools.diffEnd(array1, array2));
-
- array1 = new String[0];
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(4, CollectionTools.diffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[0];
- assertEquals(4, CollectionTools.diffEnd(array1, array2));
-
- array1 = new String[0];
- array2 = new String[0];
- assertEquals(-1, CollectionTools.diffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, a_, d_, e_ };
- assertEquals(2, CollectionTools.diffEnd(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, c_, d_, e_ };
- assertEquals(0, CollectionTools.diffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(3, CollectionTools.diffEnd(array1, array2));
-
- String c__ = new String(c);
- assertTrue((c != c__) && c.equals(c_));
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c__, d_, e_ };
- assertEquals(-1, CollectionTools.diffEnd(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(2, CollectionTools.diffEnd(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, null, d_, e_ };
- assertEquals(-1, CollectionTools.diffEnd(array1, array2));
- }
-
- public void testDiffRange() {
- String a = "a";
- String b = "b";
- String c = "c";
- String d = "d";
- String e = "e";
- String a_ = a;
- String b_ = b;
- String c_ = c;
- String d_ = d;
- String e_ = e;
- assertTrue((a == a_) && a.equals(a_));
- assertTrue((b == b_) && b.equals(b_));
- assertTrue((c == c_) && c.equals(c_));
- assertTrue((d == d_) && d.equals(d_));
- assertTrue((e == e_) && e.equals(e_));
- String[] array1;
- String[] array2;
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(5, -1), CollectionTools.diffRange(array1, array2));
-
- array1 = new String[] { a };
- array2 = new String[] { a_ };
- assertEquals(new Range(1, -1), CollectionTools.diffRange(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(0, 4), CollectionTools.diffRange(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, d_, e_ };
- assertEquals(new Range(0, 4), CollectionTools.diffRange(array1, array2));
-
- array1 = new String[0];
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(0, 4), CollectionTools.diffRange(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[0];
- assertEquals(new Range(0, 4), CollectionTools.diffRange(array1, array2));
-
- array1 = new String[0];
- array2 = new String[0];
- assertEquals(new Range(0, -1), CollectionTools.diffRange(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, a_, d_, e_ };
- assertEquals(new Range(0, 2), CollectionTools.diffRange(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, c_, d_, e_ };
- assertEquals(new Range(0, 0), CollectionTools.diffRange(array1, array2));
-
- array1 = new String[] { a, b, c, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(new Range(3, 3), CollectionTools.diffRange(array1, array2));
-
- String c__ = new String(c);
- assertTrue((c != c__) && c.equals(c_));
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c__, d_, e_ };
- assertEquals(new Range(5, -1), CollectionTools.diffRange(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(2, 2), CollectionTools.diffRange(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, null, d_, e_ };
- assertEquals(new Range(5, -1), CollectionTools.diffRange(array1, array2));
- }
-
- public void testDiffStart() {
- String a = "a";
- String b = "b";
- String c = "c";
- String d = "d";
- String e = "e";
- String a_ = new String("a");
- String b_ = new String("b");
- String c_ = new String("c");
- String d_ = new String("d");
- String e_ = new String("e");
- assertTrue((a != a_) && a.equals(a_));
- assertTrue((b != b_) && b.equals(b_));
- assertTrue((c != c_) && c.equals(c_));
- assertTrue((d != d_) && d.equals(d_));
- assertTrue((e != e_) && e.equals(e_));
- String[] array1;
- String[] array2;
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(5, CollectionTools.diffStart(array1, array2));
-
- array1 = new String[] { a };
- array2 = new String[] { a_ };
- assertEquals(1, CollectionTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(4, CollectionTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(4, CollectionTools.diffStart(array1, array2));
-
- array1 = new String[0];
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(0, CollectionTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[0];
- assertEquals(0, CollectionTools.diffStart(array1, array2));
-
- array1 = new String[0];
- array2 = new String[0];
- assertEquals(0, CollectionTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, e_, c_, d_ };
- assertEquals(2, CollectionTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, c, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(3, CollectionTools.diffStart(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, c_, d_, e_ };
- assertEquals(0, CollectionTools.diffStart(array1, array2));
-
- String c__ = new String(c);
- assertTrue((c != c__) && c.equals(c__));
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c__, d_, e_ };
- assertEquals(5, CollectionTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(2, CollectionTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, null, d_, e_ };
- assertEquals(5, CollectionTools.diffStart(array1, array2));
- }
-
- public void testEqualsIteratorIterator() {
- List<String> list1 = new ArrayList<String>();
- list1.add("1000");
- list1.add("2000");
- list1.add("3000");
- list1.add("4000");
-
- List<String> list2 = new ArrayList<String>();
- for (int i = 0; i < list1.size(); i++) {
- list2.add(String.valueOf((i + 1) * 1000));
- }
- assertFalse(CollectionTools.identical(list1.listIterator(), list2.listIterator()));
- assertTrue(CollectionTools.equals(list1.listIterator(), list2.listIterator()));
- }
-
- public void testGetListIteratorInt() {
- List<String> list = this.buildStringList1();
- String o = CollectionTools.get(list.listIterator(), 1);
- assertEquals("one", o);
- list.add(null);
- o = CollectionTools.get(list.listIterator(), list.size() - 1);
- assertNull(o);
-
- boolean exCaught = false;
- try {
- CollectionTools.get(list.listIterator(), list.size());
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testIdenticalObjectArrayObjectArray() {
- Object[] a1 = new Object[4];
- for (int i = 0; i < a1.length; i++) {
- a1[i] = String.valueOf(i * 1000);
- }
-
- Object[] a2 = new Object[a1.length];
- for (int i = 0; i < a2.length; i++) {
- a2[i] = a1[i];
- }
-
- assertTrue(CollectionTools.identical(a1, a2));
- a2[2] = "2000";
- assertFalse(CollectionTools.identical(a1, a2));
- assertTrue(Arrays.equals(a1, a2));
- }
-
- public void testIdenticalObjectArrayObjectArray_BothNull() {
- Object[] a1 = null;
- Object[] a2 = null;
- assertTrue(CollectionTools.identical(a1, a2));
- }
-
- public void testIdenticalObjectArrayObjectArray_OneNull() {
- Object[] a1 = null;
- Object[] a2 = new Object[0];
- assertFalse(CollectionTools.identical(a1, a2));
- }
-
- public void testIdenticalObjectArrayObjectArray_DifferentLengths() {
- Object[] a1 = new String[] {"foo", "bar"};
- Object[] a2 = new String[] {"foo", "bar", "baz"};
- assertFalse(CollectionTools.identical(a1, a2));
- }
-
- public void testIdenticalListIteratorListIterator() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
-
- List<String> list2 = new ArrayList<String>();
- for (String s : list1) {
- list2.add(s);
- }
- assertTrue(CollectionTools.identical(list1.listIterator(), list2.listIterator()));
- assertTrue(CollectionTools.equals(list1.listIterator(), list2.listIterator()));
- }
-
- public void testIdenticalListIteratorListIterator_Not() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
-
- List<String> list2 = new ArrayList<String>();
- for (String s : list1) {
- list2.add(s);
- }
- list2.remove(0);
- assertFalse(CollectionTools.identical(list1.listIterator(), list2.listIterator()));
- assertFalse(CollectionTools.equals(list1.listIterator(), list2.listIterator()));
- }
-
- public void testIdenticalListIteratorListIterator_DifferentSizes() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
-
- List<String> list2 = new ArrayList<String>();
- for (String s : list1) {
- list2.add(s);
- }
- list2.remove(3);
- assertFalse(CollectionTools.identical(list1.listIterator(), list2.listIterator()));
- assertFalse(CollectionTools.equals(list1.listIterator(), list2.listIterator()));
- }
-
- public void testIdentityDiffEnd() {
- String a = "a";
- String b = "b";
- String c = "c";
- String d = "d";
- String e = "e";
- String a_ = a;
- String b_ = b;
- String c_ = c;
- String d_ = d;
- String e_ = e;
- assertTrue((a == a_) && a.equals(a_));
- assertTrue((b == b_) && b.equals(b_));
- assertTrue((c == c_) && c.equals(c_));
- assertTrue((d == d_) && d.equals(d_));
- assertTrue((e == e_) && e.equals(e_));
- String[] array1;
- String[] array2;
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(-1, CollectionTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a };
- array2 = new String[] { a_ };
- assertEquals(-1, CollectionTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(4, CollectionTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, d_, e_ };
- assertEquals(4, CollectionTools.identityDiffEnd(array1, array2));
-
- array1 = new String[0];
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(4, CollectionTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[0];
- assertEquals(4, CollectionTools.identityDiffEnd(array1, array2));
-
- array1 = new String[0];
- array2 = new String[0];
- assertEquals(-1, CollectionTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, a_, d_, e_ };
- assertEquals(2, CollectionTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, c_, d_, e_ };
- assertEquals(0, CollectionTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(3, CollectionTools.identityDiffEnd(array1, array2));
-
- String c__ = new String(c);
- assertTrue((c != c__) && c.equals(c_));
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c__, d_, e_ };
- assertEquals(2, CollectionTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(2, CollectionTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, null, d_, e_ };
- assertEquals(-1, CollectionTools.identityDiffEnd(array1, array2));
- }
-
- public void testIdentityDiffRange() {
- String a = "a";
- String b = "b";
- String c = "c";
- String d = "d";
- String e = "e";
- String a_ = a;
- String b_ = b;
- String c_ = c;
- String d_ = d;
- String e_ = e;
- assertTrue((a == a_) && a.equals(a_));
- assertTrue((b == b_) && b.equals(b_));
- assertTrue((c == c_) && c.equals(c_));
- assertTrue((d == d_) && d.equals(d_));
- assertTrue((e == e_) && e.equals(e_));
- String[] array1;
- String[] array2;
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(5, -1), CollectionTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a };
- array2 = new String[] { a_ };
- assertEquals(new Range(1, -1), CollectionTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(0, 4), CollectionTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, d_, e_ };
- assertEquals(new Range(0, 4), CollectionTools.identityDiffRange(array1, array2));
-
- array1 = new String[0];
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(0, 4), CollectionTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[0];
- assertEquals(new Range(0, 4), CollectionTools.identityDiffRange(array1, array2));
-
- array1 = new String[0];
- array2 = new String[0];
- assertEquals(new Range(0, -1), CollectionTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, a_, d_, e_ };
- assertEquals(new Range(0, 2), CollectionTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, c_, d_, e_ };
- assertEquals(new Range(0, 0), CollectionTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a, b, c, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(new Range(3, 3), CollectionTools.identityDiffRange(array1, array2));
-
- String c__ = new String(c);
- assertTrue((c != c__) && c.equals(c_));
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c__, d_, e_ };
- assertEquals(new Range(2, 2), CollectionTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(2, 2), CollectionTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, null, d_, e_ };
- assertEquals(new Range(5, -1), CollectionTools.identityDiffRange(array1, array2));
- }
-
- public void testIdentityDiffStart() {
- String a = "a";
- String b = "b";
- String c = "c";
- String d = "d";
- String e = "e";
- String a_ = a;
- String b_ = b;
- String c_ = c;
- String d_ = d;
- String e_ = e;
- assertTrue((a == a_) && a.equals(a_));
- assertTrue((b == b_) && b.equals(b_));
- assertTrue((c == c_) && c.equals(c_));
- assertTrue((d == d_) && d.equals(d_));
- assertTrue((e == e_) && e.equals(e_));
- String[] array1;
- String[] array2;
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(5, CollectionTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a };
- array2 = new String[] { a_ };
- assertEquals(1, CollectionTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(4, CollectionTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(4, CollectionTools.identityDiffStart(array1, array2));
-
- array1 = new String[0];
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(0, CollectionTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[0];
- assertEquals(0, CollectionTools.identityDiffStart(array1, array2));
-
- array1 = new String[0];
- array2 = new String[0];
- assertEquals(0, CollectionTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, e_, c_, d_ };
- assertEquals(2, CollectionTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, c, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(3, CollectionTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, c_, d_, e_ };
- assertEquals(0, CollectionTools.identityDiffStart(array1, array2));
-
- String c__ = new String(c);
- assertTrue((c != c__) && c.equals(c_));
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c__, d_, e_ };
- assertEquals(2, CollectionTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(2, CollectionTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, null, d_, e_ };
- assertEquals(5, CollectionTools.identityDiffStart(array1, array2));
- }
-
- public void testIndexOfListIteratorObject_String() {
- List<String> list = this.buildStringList1();
- assertEquals(1, CollectionTools.indexOf(list.listIterator(), "one"));
- }
-
- public void testIndexOfListIteratorObject_Null() {
- List<String> list = this.buildStringList1();
- list.add(null);
- assertEquals(list.size() - 1, CollectionTools.indexOf(list.listIterator(), null));
- }
-
- public void testIndexOfListIteratorObject_Object() {
- List<Object> list = new ArrayList<Object>();
- list.add("0");
- list.add("1");
- list.add("2");
- list.add("3");
-
- String one = "1";
- assertEquals(1, CollectionTools.indexOf(list.listIterator(), one));
- list.add(null);
- assertEquals(list.size() - 1, CollectionTools.indexOf(list.listIterator(), null));
- }
-
- public void testIndexOfObjectArrayObject() {
- Object[] a = this.buildObjectArray1();
- assertEquals(1, CollectionTools.indexOf(a, "one"));
- }
-
- public void testIndexOfObjectArrayObject_Null() {
- Object[] a = this.buildObjectArray1();
- a = CollectionTools.add(a, null);
- assertEquals(a.length - 1, CollectionTools.indexOf(a, null));
- }
-
- public void testIndexOfCharArrayChar() {
- char[] a = this.buildCharArray();
- assertEquals(1, CollectionTools.indexOf(a, 'b'));
- a = CollectionTools.add(a, 'd');
- assertEquals(a.length - 1, CollectionTools.indexOf(a, 'd'));
- }
-
- public void testIndexOfIntArrayInt() {
- int[] a = this.buildIntArray();
- assertEquals(1, CollectionTools.indexOf(a, 10));
- a = CollectionTools.add(a, 30);
- assertEquals(a.length - 1, CollectionTools.indexOf(a, 30));
- }
-
- public void testInsertionIndexOfListComparable() {
- List<String> list = Arrays.asList(new String[] { "A", "C", "D" });
- assertEquals(1, CollectionTools.insertionIndexOf(list, "B"));
-
- list = Arrays.asList(new String[] { "A", "B", "C", "D" });
- assertEquals(2, CollectionTools.insertionIndexOf(list, "B"));
-
- list = Arrays.asList(new String[] { "A", "B", "B", "B", "C", "D" });
- assertEquals(4, CollectionTools.insertionIndexOf(list, "B"));
-
- list = Arrays.asList(new String[] { "A", "B", "B", "B", "C", "D" });
- assertEquals(6, CollectionTools.insertionIndexOf(list, "E"));
-
- list = Arrays.asList(new String[] { "B", "B", "B", "C", "D" });
- assertEquals(0, CollectionTools.insertionIndexOf(list, "A"));
-
- list = Arrays.asList(new String[] { "A", "A", "B", "B", "C", "D" });
- assertEquals(2, CollectionTools.insertionIndexOf(list, "A"));
- }
-
- public void testInsertionIndexOfListObjectComparator() {
- Comparator<String> c = new ReverseComparator<String>();
- List<String> list = Arrays.asList(new String[] { "D", "C", "A" });
- assertEquals(2, CollectionTools.insertionIndexOf(list, "B", c));
-
- list = Arrays.asList(new String[] { "D", "C", "B", "A" });
- assertEquals(3, CollectionTools.insertionIndexOf(list, "B", c));
-
- list = Arrays.asList(new String[] { "D", "C", "B", "B", "B", "A" });
- assertEquals(5, CollectionTools.insertionIndexOf(list, "B", c));
-
- list = Arrays.asList(new String[] { "D", "C", "B", "B", "B", "A" });
- assertEquals(0, CollectionTools.insertionIndexOf(list, "E", c));
-
- list = Arrays.asList(new String[] { "D", "C", "B", "B", "B" });
- assertEquals(5, CollectionTools.insertionIndexOf(list, "A", c));
-
- list = Arrays.asList(new String[] { "D", "C", "B", "B", "A", "A" });
- assertEquals(6, CollectionTools.insertionIndexOf(list, "A", c));
- }
-
- public void testInsertionIndexOfObjectArrayComparable() {
- String[] a = new String[] { "A", "C", "D" };
- assertEquals(1, CollectionTools.insertionIndexOf(a, "B"));
-
- a = new String[] { "A", "B", "C", "D" };
- assertEquals(2, CollectionTools.insertionIndexOf(a, "B"));
-
- a = new String[] { "A", "B", "B", "B", "C", "D" };
- assertEquals(4, CollectionTools.insertionIndexOf(a, "B"));
-
- a = new String[] { "A", "B", "B", "B", "C", "D" };
- assertEquals(6, CollectionTools.insertionIndexOf(a, "E"));
-
- a = new String[] { "B", "B", "B", "C", "D" };
- assertEquals(0, CollectionTools.insertionIndexOf(a, "A"));
-
- a = new String[] { "A", "A", "B", "B", "C", "D" };
- assertEquals(2, CollectionTools.insertionIndexOf(a, "A"));
- }
-
- public void testInsertionIndexOfObjectArrayObjectComparator() {
- Comparator<String> c = new ReverseComparator<String>();
- String[] a = new String[] { "D", "C", "A" };
- assertEquals(2, CollectionTools.insertionIndexOf(a, "B", c));
-
- a = new String[] { "D", "C", "B", "A" };
- assertEquals(3, CollectionTools.insertionIndexOf(a, "B", c));
-
- a = new String[] { "D", "C", "B", "B", "B", "A" };
- assertEquals(5, CollectionTools.insertionIndexOf(a, "B", c));
-
- a = new String[] { "D", "C", "B", "B", "B", "A" };
- assertEquals(0, CollectionTools.insertionIndexOf(a, "E", c));
-
- a = new String[] { "D", "C", "B", "B", "B" };
- assertEquals(5, CollectionTools.insertionIndexOf(a, "A", c));
-
- a = new String[] { "D", "C", "B", "B", "A", "A" };
- assertEquals(6, CollectionTools.insertionIndexOf(a, "A", c));
- }
-
- public void testIterableIterator() {
- Iterator<Object> emptyIterator = EmptyIterator.instance();
- Iterable<Object> emptyIterable = CollectionTools.iterable(emptyIterator);
-
- assertFalse(emptyIterable.iterator().hasNext());
-
- boolean exceptionThrown = false;
- try {
- emptyIterator = emptyIterable.iterator();
- fail("invalid iterator: " + emptyIterator);
- } catch (IllegalStateException ise) {
- exceptionThrown = true;
- }
- assertTrue("IllegalStateException not thrown.", exceptionThrown);
-
- }
-
- public void testIterableObjectArray() {
- String[] strings = this.buildStringArray1();
- int i = 0;
- for (String string : CollectionTools.iterable(strings)) {
- assertEquals(strings[i++], string);
- }
- }
-
- public void testIteratorObjectArray() {
- String[] a = this.buildStringArray1();
- int i = 0;
- for (Iterator<String> stream = CollectionTools.iterator(a); stream.hasNext(); i++) {
- assertEquals(a[i], stream.next());
- }
- }
-
- public void testLastIndexOfIteratorObject() {
- List<String> list = this.buildStringList1();
- assertEquals(1, CollectionTools.lastIndexOf(list.listIterator(), "one"));
- list.add(null);
- assertEquals(list.size() - 1, CollectionTools.lastIndexOf(list.listIterator(), null));
- }
-
- public void testLastIndexOfIteratorObject_Empty() {
- assertEquals(-1, CollectionTools.lastIndexOf(EmptyIterator.instance(), "foo"));
- }
-
- public void testLastIndexOfObjectArrayObject() {
- Object[] a = this.buildObjectArray1();
- assertEquals(1, CollectionTools.lastIndexOf(a, "one"));
- }
-
- public void testLastIndexOfObjectArrayObject_Null() {
- Object[] a = this.buildObjectArray1();
- a = CollectionTools.add(a, null);
- assertEquals(a.length - 1, CollectionTools.lastIndexOf(a, null));
- }
-
- public void testLastIndexOfCharArrayChar() {
- char[] a = this.buildCharArray();
- assertEquals(1, CollectionTools.lastIndexOf(a, 'b'));
- a = CollectionTools.add(a, 'd');
- assertEquals(a.length - 1, CollectionTools.lastIndexOf(a, 'd'));
- }
-
- public void testLastIndexOfIntArrayInt() {
- int[] a = this.buildIntArray();
- assertEquals(1, CollectionTools.lastIndexOf(a, 10));
- a = CollectionTools.add(a, 30);
- assertEquals(a.length - 1, CollectionTools.lastIndexOf(a, 30));
- }
-
- public void testListIterable() {
- Iterable<String> iterable = this.buildStringList1();
- assertEquals(this.buildStringList1(), CollectionTools.list(iterable));
- }
-
- public void testListIterableInt() {
- Iterable<String> iterable = this.buildStringList1();
- assertEquals(this.buildStringList1(), CollectionTools.list(iterable, 3));
- }
-
- public void testListIterator_String() {
- List<String> list = CollectionTools.list(this.buildStringList1().iterator());
- assertEquals(this.buildStringList1(), list);
- }
-
- public void testListIterator_StringObject() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
-
- List<Object> list2 = CollectionTools.<Object>list(list1.iterator());
- assertEquals(list1, list2);
- }
-
- public void testListIterator_Empty() {
- assertEquals(0, CollectionTools.list(EmptyIterator.instance()).size());
- }
-
- public void testListIteratorInt() {
- List<String> list = CollectionTools.list(this.buildStringList1().iterator(), 3);
- assertEquals(this.buildStringList1(), list);
- }
-
- public void testListIteratorInt_Empty() {
- assertEquals(0, CollectionTools.list(EmptyIterator.instance(), 5).size());
- }
-
- public void testListObjectArray() {
- List<String> list = CollectionTools.list(this.buildStringArray1());
- assertEquals(this.buildStringList1(), list);
- }
-
- public void testListIteratorObjectArray() {
- String[] a = this.buildStringArray1();
- int i = 0;
- for (ListIterator<String> stream = CollectionTools.listIterator(a); stream.hasNext(); i++) {
- assertEquals(a[i], stream.next());
- }
- }
-
- public void testListIteratorObjectArrayInt() {
- String[] a = this.buildStringArray1();
- int i = 1;
- for (ListIterator<String> stream = CollectionTools.listIterator(a, 1); stream.hasNext(); i++) {
- assertEquals(a[i], stream.next());
- }
- }
-
- public void testMaxCharArray() {
- assertEquals('c', CollectionTools.max(this.buildCharArray()));
- }
-
- public void testMaxIntArray() {
- assertEquals(20, CollectionTools.max(this.buildIntArray()));
- }
-
- public void testMinCharArray() {
- assertEquals('a', CollectionTools.min(this.buildCharArray()));
- }
-
- public void testMinIntArray() {
- assertEquals(0, CollectionTools.min(this.buildIntArray()));
- }
-
- public void testMoveObjectArrayIntInt() {
- String[] array = new String[] { "0", "1", "2", "3", "4", "5" };
-
- String[] result = CollectionTools.move(array, 4, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "1", "3", "4", "2", "5" }, result));
-
- result = CollectionTools.move(array, 0, 5);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "1", "3", "4", "2" }, result));
-
- result = CollectionTools.move(array, 2, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result));
-
- result = CollectionTools.move(array, 4, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result));
- }
-
- public void testMoveObjectArrayIntIntInt() {
- String[] array = new String[] { "0", "1", "2", "3", "4", "5" };
-
- String[] result = CollectionTools.move(array, 4, 2, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "1", "3", "4", "2", "5" }, result));
-
- result = CollectionTools.move(array, 0, 5, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "1", "3", "4", "2" }, result));
-
- result = CollectionTools.move(array, 2, 4, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result));
-
- result = CollectionTools.move(array, 2, 4, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result));
-
- result = CollectionTools.move(array, 0, 1, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "3", "2", "4", "5", "1" }, result));
-
- result = CollectionTools.move(array, 1, 0, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result));
-
- result = CollectionTools.move(array, 1, 1, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result));
-
- result = CollectionTools.move(array, 1, 0, 0);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result));
- }
-
- public void testMoveIntArrayIntInt() {
- int[] array = new int[] { 0, 1, 2, 3, 4, 5 };
-
- int[] result = CollectionTools.move(array, 4, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 0, 1, 3, 4, 2, 5 }, result));
-
- result = CollectionTools.move(array, 0, 5);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 1, 3, 4, 2 }, result));
-
- result = CollectionTools.move(array, 2, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 4, 1, 3, 2 }, result));
-
- result = CollectionTools.move(array, 2, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 4, 1, 3, 2 }, result));
- }
-
- public void testMoveIntArrayIntIntInt() {
- int[] array = new int[] { 0, 1, 2, 3, 4, 5 };
-
- int[] result = CollectionTools.move(array, 4, 2, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 0, 1, 3, 4, 2, 5 }, result));
-
- result = CollectionTools.move(array, 0, 5, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 1, 3, 4, 2 }, result));
-
- result = CollectionTools.move(array, 2, 4, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 4, 1, 3, 2 }, result));
-
- result = CollectionTools.move(array, 2, 4, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 3, 2, 4, 1 }, result));
-
- result = CollectionTools.move(array, 0, 1, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 0, 3, 2, 4, 5, 1 }, result));
-
- result = CollectionTools.move(array, 1, 0, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 3, 2, 4, 1 }, result));
-
- result = CollectionTools.move(array, 1, 1, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 3, 2, 4, 1 }, result));
-
- result = CollectionTools.move(array, 1, 0, 0);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 3, 2, 4, 1 }, result));
- }
-
- public void testMoveCharArrayIntInt() {
- char[] array = new char[] { 'a', 'b', 'c', 'd', 'e', 'f' };
-
- char[] result = CollectionTools.move(array, 4, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'd', 'e', 'c', 'f' }, result));
-
- result = CollectionTools.move(array, 0, 5);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'f', 'a', 'b', 'd', 'e', 'c' }, result));
-
- result = CollectionTools.move(array, 2, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'f', 'a', 'e', 'b', 'd', 'c' }, result));
-
- result = CollectionTools.move(array, 2, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'f', 'a', 'e', 'b', 'd', 'c' }, result));
- }
-
- public void testMoveCharArrayIntIntInt() {
- char[] array = new char[] { 'a', 'b', 'b', 'c', 'd', 'e' };
-
- char[] result = CollectionTools.move(array, 4, 2, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'c', 'd', 'b', 'e' }, result));
-
- result = CollectionTools.move(array, 0, 5, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'e', 'a', 'b', 'c', 'd', 'b' }, result));
-
- result = CollectionTools.move(array, 2, 4, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'e', 'a', 'd', 'b', 'c', 'b' }, result));
-
- result = CollectionTools.move(array, 2, 4, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'e', 'a', 'c', 'b', 'd', 'b' }, result));
-
- result = CollectionTools.move(array, 0, 1, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'a', 'c', 'b', 'd', 'e', 'b' }, result));
-
- result = CollectionTools.move(array, 1, 0, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'e', 'a', 'c', 'b', 'd', 'b' }, result));
-
- result = CollectionTools.move(array, 1, 1, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'e', 'a', 'c', 'b', 'd', 'b' }, result));
-
- result = CollectionTools.move(array, 1, 0, 0);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'e', 'a', 'c', 'b', 'd', 'b' }, result));
- }
-
- public void testMoveListIntIntRandomAccess() {
- List<String> list = new ArrayList<String>();
- CollectionTools.addAll(list, new String[] { "0", "1", "2", "3", "4", "5" });
-
- List<String> result = CollectionTools.move(list, 4, 2);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "1", "3", "4", "2", "5" }, result.toArray()));
-
- result = CollectionTools.move(list, 0, 5);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "1", "3", "4", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 2);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result.toArray()));
- }
-
- public void testMoveListIntIntSequentialAccess() {
- List<String> list = new LinkedList<String>();
- CollectionTools.addAll(list, new String[] { "0", "1", "2", "3", "4", "5" });
-
- List<String> result = CollectionTools.move(list, 4, 2);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "1", "3", "4", "2", "5" }, result.toArray()));
-
- result = CollectionTools.move(list, 0, 5);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "1", "3", "4", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 2);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result.toArray()));
- }
-
- public void testMoveListIntIntIntRandomAccess() {
- List<String> list = new ArrayList<String>(Arrays.asList(new String[] { "0", "1", "2", "3", "4", "5" }));
-
- List<String> result = CollectionTools.move(list, 4, 2, 1);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "1", "3", "4", "2", "5" }, result.toArray()));
-
- result = CollectionTools.move(list, 0, 5, 1);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "1", "3", "4", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 4, 1);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 4, 2);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 0, 1, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "3", "2", "4", "5", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 1, 0, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 1, 1, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 1, 0, 0);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
- }
-
- public void testMoveListIntIntIntSequentialAccess() {
- List<String> list = new LinkedList<String>(Arrays.asList(new String[] { "0", "1", "2", "3", "4", "5" }));
-
- List<String> result = CollectionTools.move(list, 4, 2, 1);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "1", "3", "4", "2", "5" }, result.toArray()));
-
- result = CollectionTools.move(list, 0, 5, 1);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "1", "3", "4", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 4, 1);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 4, 2);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 0, 1, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "3", "2", "4", "5", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 1, 0, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 1, 1, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 1, 0, 0);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
- }
-
- public void testRemoveAllObjectArrayObjectArray() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- String[] a2 = new String[] { "E", "B" };
- String[] a3 = CollectionTools.removeAll(a1, a2);
- assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, a3));
- }
-
- public void testRemoveAllObjectArrayObjectArray_Empty() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- String[] a2 = new String[0];
- String[] a3 = CollectionTools.removeAll(a1, a2);
- assertTrue(Arrays.equals(a1, a3));
- }
-
- public void testRemoveAllObjectArrayObjectArray_NoMatches() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- String[] a2 = new String[] { "X", "Y", "Z" };
- String[] a3 = CollectionTools.removeAll(a1, a2);
- assertTrue(Arrays.equals(a1, a3));
- }
-
- public void testRemoveAllObjectArrayIterable() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterable<?> iterable = Arrays.asList(new String[] { "E", "B" });
- String[] a3 = CollectionTools.removeAll(a1, iterable);
- assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, a3));
- }
-
- public void testRemoveAllObjectArrayIterableInt() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterable<?> iterable = Arrays.asList(new String[] { "E", "B" });
- String[] a3 = CollectionTools.removeAll(a1, iterable, 7);
- assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, a3));
- }
-
- public void testRemoveAllObjectArrayIterator() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterable<?> iterable = Arrays.asList(new String[] { "E", "B" });
- String[] a3 = CollectionTools.removeAll(a1, iterable.iterator());
- assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, a3));
- }
-
- public void testRemoveAllObjectArrayIteratorInt() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterable<?> iterable = Arrays.asList(new String[] { "E", "B" });
- String[] a3 = CollectionTools.removeAll(a1, iterable.iterator(), 7);
- assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, a3));
- }
-
- public void testRemoveAllObjectArrayCollection() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Collection<String> collection = Arrays.asList(new String[] { "E", "B" });
- String[] a3 = CollectionTools.removeAll(a1, collection);
- assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, a3));
- }
-
- public void testRemoveAllObjectArrayCollection_Empty() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Collection<String> collection = new ArrayList<String>();
- String[] a3 = CollectionTools.removeAll(a1, collection);
- assertTrue(Arrays.equals(a1, a3));
- }
-
- public void testRemoveAllObjectArrayCollection_NoMatches() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Collection<String> collection = Arrays.asList(new String[] { "X", "Y", "Z" });
- String[] a3 = CollectionTools.removeAll(a1, collection);
- assertTrue(Arrays.equals(a1, a3));
- }
-
- public void testRemoveAllCharArrayCharArray() {
- char[] a1 = new char[] { 'A', 'A', 'B', 'B', 'C', 'C', 'D', 'D', 'E', 'E', 'F', 'F' };
- char[] a2 = new char[] { 'E', 'B' };
- assertTrue(Arrays.equals(new char[] { 'A', 'A', 'C', 'C', 'D', 'D', 'F', 'F' }, CollectionTools.removeAll(a1, a2)));
- }
-
- public void testRemoveAllCharArrayCharArray_Empty() {
- char[] a1 = new char[] { 'A', 'A', 'B', 'B', 'C', 'C', 'D', 'D', 'E', 'E', 'F', 'F' };
- char[] a2 = new char[0];
- assertTrue(Arrays.equals(a1, CollectionTools.removeAll(a1, a2)));
- }
-
- public void testRemoveAllCharArrayCharArray_NoMatches() {
- char[] a1 = new char[] { 'A', 'A', 'B', 'B', 'C', 'C', 'D', 'D', 'E', 'E', 'F', 'F' };
- char[] a2 = new char[] { 'X', 'Z' };
- assertTrue(Arrays.equals(a1, CollectionTools.removeAll(a1, a2)));
- }
-
- public void testRemoveAllIntArrayIntArray() {
- int[] a1 = new int[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6 };
- int[] a2 = new int[] { 5, 2 };
- assertTrue(Arrays.equals(new int[] { 1, 1, 3, 3, 4, 4, 6, 6 }, CollectionTools.removeAll(a1, a2)));
- }
-
- public void testRemoveAllIntArrayIntArray_Empty() {
- int[] a1 = new int[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6 };
- int[] a2 = new int[0];
- assertTrue(Arrays.equals(a1, CollectionTools.removeAll(a1, a2)));
- }
-
- public void testRemoveAllIntArrayIntArray_NoMatches() {
- int[] a1 = new int[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6 };
- int[] a2 = new int[] { 52, 67 };
- assertTrue(Arrays.equals(a1, CollectionTools.removeAll(a1, a2)));
- }
-
- public void testRemoveObjectArrayObject_Object() {
- Object[] a = this.buildObjectArray1();
- a = CollectionTools.add(a, "three");
- a = CollectionTools.add(a, "four");
- a = CollectionTools.add(a, "five");
-
- assertEquals(6, a.length);
- assertTrue(CollectionTools.contains(a, "three"));
- a = CollectionTools.remove(a, "three");
- assertEquals(5, a.length);
- assertFalse(CollectionTools.contains(a, "three"));
- assertTrue(CollectionTools.contains(a, "four"));
- assertTrue(CollectionTools.contains(a, "five"));
- }
-
- public void testRemoveObjectArrayObject_String() {
- String[] a = this.buildStringArray1();
- a = CollectionTools.add(a, "three");
- a = CollectionTools.add(a, "four");
- a = CollectionTools.add(a, "five");
-
- assertEquals(6, a.length);
- assertTrue(CollectionTools.contains(a, "three"));
- a = CollectionTools.remove(a, "three");
- assertEquals(5, a.length);
- assertFalse(CollectionTools.contains(a, "three"));
- assertTrue(CollectionTools.contains(a, "four"));
- assertTrue(CollectionTools.contains(a, "five"));
- }
-
- public void testRemoveCharArrayChar() {
- char[] a = this.buildCharArray();
- a = CollectionTools.add(a, 'd');
- a = CollectionTools.add(a, 'e');
- a = CollectionTools.add(a, 'f');
-
- assertEquals(6, a.length);
- assertTrue(CollectionTools.contains(a, 'd'));
- a = CollectionTools.remove(a, 'd');
- assertEquals(5, a.length);
- assertFalse(CollectionTools.contains(a, 'd'));
- assertTrue(CollectionTools.contains(a, 'e'));
- assertTrue(CollectionTools.contains(a, 'f'));
- }
-
- public void testRemoveIntArrayInt() {
- int[] a = this.buildIntArray();
- a = CollectionTools.add(a, 30);
- a = CollectionTools.add(a, 40);
- a = CollectionTools.add(a, 50);
-
- assertEquals(6, a.length);
- assertTrue(CollectionTools.contains(a, 30));
- a = CollectionTools.remove(a, 30);
- assertEquals(5, a.length);
- assertFalse(CollectionTools.contains(a, 30));
- assertTrue(CollectionTools.contains(a, 40));
- assertTrue(CollectionTools.contains(a, 50));
- }
-
- public void testRemoveAllCollectionIterable() {
- Collection<String> c = this.buildStringList1();
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.removeAll(c, iterable));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
-
- c = this.buildStringList1();
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.removeAll(c, iterable));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
- }
-
- public void testRemoveAllCollectionIterableInt() {
- Collection<String> c = this.buildStringList1();
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.removeAll(c, iterable, 3));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
-
- c = this.buildStringList1();
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.removeAll(c, iterable, 3));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
- }
-
- public void testRemoveAllCollectionIterator_Empty() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.removeAll(c, this.buildStringList1().iterator()));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
-
- c = this.buildStringList1();
- assertFalse(CollectionTools.removeAll(c, this.buildStringList2().iterator()));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
- }
-
- public void testRemoveAllCollectionIterator_Duplicates() {
- Collection<String> c = new ArrayList<String>();
- c.add("a");
- c.add("a");
- c.add("b");
- c.add("c");
- c.add("d");
- c.add("d");
- String[] a = new String[] { "a", "d" };
- Iterator<String> iterator = new ArrayIterator<String>(a);
- assertTrue(CollectionTools.removeAll(c, iterator));
- assertEquals(2, c.size());
- assertFalse(c.contains("a"));
- assertTrue(c.contains("b"));
- assertTrue(c.contains("c"));
- assertFalse(c.contains("d"));
-
- iterator = new ArrayIterator<String>(a);
- assertFalse(CollectionTools.removeAll(c, iterator));
- }
-
- public void testRemoveAllCollectionIterator_ObjectString() {
- Collection<Object> c = new ArrayList<Object>();
- c.add("a");
- c.add("a");
- c.add("b");
- c.add("c");
- c.add("d");
- c.add("d");
- String[] a = new String[] { "a", "d" };
- Iterator<String> iterator = new ArrayIterator<String>(a);
- assertTrue(CollectionTools.removeAll(c, iterator));
- assertEquals(2, c.size());
- assertFalse(c.contains("a"));
- assertTrue(c.contains("b"));
- assertTrue(c.contains("c"));
- assertFalse(c.contains("d"));
-
- iterator = new ArrayIterator<String>(a);
- assertFalse(CollectionTools.removeAll(c, iterator));
- }
-
- public void testRemoveAllCollectionIteratotInt() {
- Collection<String> c = new ArrayList<String>();
- c.add("a");
- c.add("a");
- c.add("b");
- c.add("c");
- c.add("d");
- c.add("d");
- String[] a = new String[] { "a", "d" };
- Iterator<String> iterator = new ArrayIterator<String>(a);
- assertTrue(CollectionTools.removeAll(c, iterator, 2));
- assertEquals(2, c.size());
- assertFalse(c.contains("a"));
- assertTrue(c.contains("b"));
- assertTrue(c.contains("c"));
- assertFalse(c.contains("d"));
-
- iterator = new ArrayIterator<String>(a);
- assertFalse(CollectionTools.removeAll(c, iterator));
- }
-
- public void testRemoveAllCollectionObjectArray_Empty() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.removeAll(c, this.buildObjectArray1()));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
-
- c = this.buildStringList1();
- assertFalse(CollectionTools.removeAll(c, this.buildObjectArray2()));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
- }
-
- public void testRemoveAllCollectionObjectArray_Duplicates() {
- Collection<String> c = new ArrayList<String>();
- c.add("a");
- c.add("a");
- c.add("b");
- c.add("c");
- c.add("d");
- c.add("d");
- String[] a = new String[] { "a", "d" };
- assertTrue(CollectionTools.removeAll(c, a));
- assertEquals(2, c.size());
- assertFalse(c.contains("a"));
- assertTrue(c.contains("b"));
- assertTrue(c.contains("c"));
- assertFalse(c.contains("d"));
-
- assertFalse(CollectionTools.removeAll(c, a));
- }
-
- public void testRemoveAllCollectionObjectArray_MoreDuplicates() {
- Collection<String> c = new ArrayList<String>();
- c.add("a");
- c.add("b");
- c.add("c");
- c.add("d");
- c.add("a");
- c.add("d");
- c.add("d");
- c.add("a");
- c.add("c");
- String[] a = new String[] { "a", "d" };
- assertTrue(CollectionTools.removeAll(c, a));
- assertEquals(3, c.size());
- assertFalse(c.contains("a"));
- assertTrue(c.contains("b"));
- assertTrue(c.contains("c"));
- assertFalse(c.contains("d"));
-
- assertFalse(CollectionTools.removeAll(c, a));
- }
-
- public void testRemoveAllOccurrencesCollectionObject() {
- Collection<String> c = this.buildStringList1();
- assertEquals(3, c.size());
- assertFalse(CollectionTools.removeAllOccurrences(c, "three"));
- assertTrue(CollectionTools.removeAllOccurrences(c, "two"));
- assertFalse(CollectionTools.removeAllOccurrences(c, "two"));
- assertEquals(2, c.size());
-
- c.add("five");
- c.add("five");
- c.add("five");
- assertEquals(5, c.size());
- assertTrue(CollectionTools.removeAllOccurrences(c, "five"));
- assertFalse(CollectionTools.removeAllOccurrences(c, "five"));
- assertEquals(2, c.size());
-
- c.add(null);
- c.add(null);
- c.add(null);
- assertEquals(5, c.size());
- assertTrue(CollectionTools.removeAllOccurrences(c, null));
- assertFalse(CollectionTools.removeAllOccurrences(c, null));
- assertEquals(2, c.size());
- }
-
- public void testRemoveAllOccurrencesObjectArrayObject() {
- String[] a = this.buildStringArray1();
- assertEquals(3, a.length);
- a = CollectionTools.removeAllOccurrences(a, "three");
- assertEquals(3, a.length);
- a = CollectionTools.removeAllOccurrences(a, "two");
- assertEquals(2, a.length);
- a = CollectionTools.removeAllOccurrences(a, "two");
- assertEquals(2, a.length);
-
- a = CollectionTools.add(a, "five");
- a = CollectionTools.add(a, "five");
- a = CollectionTools.add(a, "five");
- assertEquals(5, a.length);
- a = CollectionTools.removeAllOccurrences(a, "five");
- assertEquals(2, a.length);
- a = CollectionTools.removeAllOccurrences(a, "five");
- assertEquals(2, a.length);
-
- a = CollectionTools.add(a, null);
- a = CollectionTools.add(a, null);
- a = CollectionTools.add(a, null);
- assertEquals(5, a.length);
- a = CollectionTools.removeAllOccurrences(a, null);
- assertEquals(2, a.length);
- a = CollectionTools.removeAllOccurrences(a, null);
- assertEquals(2, a.length);
- }
-
- public void testRemoveAllOccurrencesCharArrayChar() {
- char[] a = this.buildCharArray();
- assertEquals(3, a.length);
- a = CollectionTools.removeAllOccurrences(a, 'd');
- assertEquals(3, a.length);
- a = CollectionTools.removeAllOccurrences(a, 'b');
- assertEquals(2, a.length);
- a = CollectionTools.removeAllOccurrences(a, 'b');
- assertEquals(2, a.length);
-
- a = CollectionTools.add(a, 'g');
- a = CollectionTools.add(a, 'g');
- a = CollectionTools.add(a, 'g');
- assertEquals(5, a.length);
- a = CollectionTools.removeAllOccurrences(a, 'g');
- assertEquals(2, a.length);
- a = CollectionTools.removeAllOccurrences(a, 'g');
- assertEquals(2, a.length);
- }
-
- public void testRemoveAllOccurrencesIntArrayInt() {
- int[] a = this.buildIntArray();
- assertEquals(3, a.length);
- a = CollectionTools.removeAllOccurrences(a, 55);
- assertEquals(3, a.length);
- a = CollectionTools.removeAllOccurrences(a, 10);
- assertEquals(2, a.length);
- a = CollectionTools.removeAllOccurrences(a, 10);
- assertEquals(2, a.length);
-
- a = CollectionTools.add(a, 77);
- a = CollectionTools.add(a, 77);
- a = CollectionTools.add(a, 77);
- assertEquals(5, a.length);
- a = CollectionTools.removeAllOccurrences(a, 77);
- assertEquals(2, a.length);
- a = CollectionTools.removeAllOccurrences(a, 77);
- assertEquals(2, a.length);
- }
-
- public void testRemoveElementAtIndexObjectArrayInt() {
- String[] a = new String[] { "A", "B", "A", "C", "A", "D" };
- a = CollectionTools.removeElementAtIndex(a, 3);
- assertTrue(Arrays.equals(new String[] { "A", "B", "A", "A", "D" }, a));
- }
-
- public void testRemoveElementAtIndexCharArrayInt() {
- char[] a = new char[] { 'A', 'B', 'A', 'C', 'A', 'D' };
- a = CollectionTools.removeElementAtIndex(a, 3);
- assertTrue(Arrays.equals(new char[] { 'A', 'B', 'A', 'A', 'D' }, a));
- }
-
- public void testRemoveElementAtIndexIntArrayInt() {
- int[] a = new int[] { 8, 6, 7, 33, 2, 11 };
- a = CollectionTools.removeElementsAtIndex(a, 3, 3);
- assertTrue(Arrays.equals(new int[] { 8, 6, 7 }, a));
- }
-
- public void testRemoveElementsAtIndexListIntInt() {
- List<String> list = new ArrayList<String>(Arrays.asList(new String[] { "A", "B", "A", "C", "A", "D" }));
- List<String> removed = CollectionTools.removeElementsAtIndex(list, 3, 2);
- assertTrue(Arrays.equals(new String[] { "A", "B", "A", "D" }, list.toArray()));
- assertTrue(Arrays.equals(new String[] { "C", "A" }, removed.toArray()));
-
- list = new ArrayList<String>(Arrays.asList(new String[] { "A", "B", "C", "D", "E", "F" }));
- removed = CollectionTools.removeElementsAtIndex(list, 3, 3);
- assertTrue(Arrays.equals(new String[] { "A", "B", "C" }, list.toArray()));
- assertTrue(Arrays.equals(new String[] { "D", "E", "F" }, removed.toArray()));
-
- list = new ArrayList<String>(Arrays.asList(new String[] { "A", "B", "C", "D", "E", "F" }));
- removed = CollectionTools.removeElementsAtIndex(list, 0, 3);
- assertTrue(Arrays.equals(new String[] { "D", "E", "F" }, list.toArray()));
- assertTrue(Arrays.equals(new String[] { "A", "B", "C" }, removed.toArray()));
- }
-
- public void testRemoveElementsAtIndexObjectArrayIntInt() {
- String[] a = new String[] { "A", "B", "A", "C", "A", "D" };
- a = CollectionTools.removeElementsAtIndex(a, 3, 2);
- assertTrue(Arrays.equals(new String[] { "A", "B", "A", "D" }, a));
- }
-
- public void testRemoveElementsAtIndexObjectArrayIntInt_Empty() {
- String[] a = new String[] { "A", "B", "A", "C", "A", "D" };
- a = CollectionTools.removeElementsAtIndex(a, 0, 6);
- assertEquals(0, a.length);
- }
-
- public void testRemoveElementsAtIndexCharArrayIntInt() {
- char[] a = new char[] { 'A', 'B', 'A', 'C', 'A', 'D' };
- a = CollectionTools.removeElementsAtIndex(a, 0, 5);
- assertTrue(Arrays.equals(new char[] { 'D' }, a));
- }
-
- public void testRemoveElementsAtIndexCharArrayIntInt_Empty() {
- char[] a = new char[] { 'A', 'B', 'A', 'C', 'A', 'D' };
- a = CollectionTools.removeElementsAtIndex(a, 0, 6);
- assertEquals(0, a.length);
- }
-
- public void testRemoveElementsAtIndexIntArrayIntInt() {
- int[] a = new int[] { 8, 6, 7, 33, 2, 11 };
- a = CollectionTools.removeElementsAtIndex(a, 3, 3);
- assertTrue(Arrays.equals(new int[] { 8, 6, 7 }, a));
- }
-
- public void testRemoveElementsAtIndexIntArrayIntInt_Empty() {
- int[] a = new int[] { 8, 6, 7, 33, 2, 11 };
- a = CollectionTools.removeElementsAtIndex(a, 0, 6);
- assertEquals(0, a.length);
- }
-
- public void testReplaceAllObjectArrayObjectObject_Object() {
- Object[] a = new Object[] { "A", "B", "A", "C", "A", "D" };
- a = CollectionTools.replaceAll(a, "A", "Z");
- assertTrue(Arrays.equals(new Object[] { "Z", "B", "Z", "C", "Z", "D" }, a));
- }
-
- public void testReplaceAllObjectArrayObjectObject_String() {
- String[] a = new String[] { "A", "B", "A", "C", "A", "D" };
- a = CollectionTools.replaceAll(a, "A", "Z");
- assertTrue(Arrays.equals(new String[] { "Z", "B", "Z", "C", "Z", "D" }, a));
- }
-
- public void testReplaceAllObjectArrayObjectObject_Null() {
- String[] a = new String[] { null, "B", null, "C", null, "D" };
- a = CollectionTools.replaceAll(a, null, "Z");
- assertTrue(Arrays.equals(new String[] { "Z", "B", "Z", "C", "Z", "D" }, a));
- }
-
- public void testReplaceAllCharArrayCharChar() {
- char[] a = new char[] { 'A', 'B', 'A', 'C', 'A', 'D' };
- a = CollectionTools.replaceAll(a, 'A', 'Z');
- assertTrue(Arrays.equals(new char[] { 'Z', 'B', 'Z', 'C', 'Z', 'D' }, a));
- }
-
- public void testReplaceAllIntArrayIntInt() {
- int[] a = new int[] { 0, 1, 0, 7, 0, 99 };
- a = CollectionTools.replaceAll(a, 0, 13);
- assertTrue(Arrays.equals(new int[] { 13, 1, 13, 7, 13, 99 }, a));
- }
-
- public void testRetainAllCollectionIterable() {
- Collection<String> c = this.buildStringList1();
- Iterable<String> iterable = this.buildStringList1();
- assertFalse(CollectionTools.retainAll(c, iterable));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- iterable = this.buildStringList2();
- assertTrue(CollectionTools.retainAll(c, iterable));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
- }
-
- public void testRetainAllCollectionIterableInt() {
- Collection<String> c = this.buildStringList1();
- Iterable<String> iterable = this.buildStringList1();
- assertFalse(CollectionTools.retainAll(c, iterable));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- iterable = this.buildStringList2();
- assertTrue(CollectionTools.retainAll(c, iterable, 7));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
- }
-
- public void testRetainAllCollectionIterator() {
- Collection<String> c = this.buildStringList1();
- assertFalse(CollectionTools.retainAll(c, this.buildStringList1().iterator()));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- assertTrue(CollectionTools.retainAll(c, this.buildStringList2().iterator()));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
- }
-
- public void testRetainAllCollectionIterator_ObjectString() {
- Collection<Object> c1 = new ArrayList<Object>();
- c1.add("zero");
- c1.add("one");
- c1.add("two");
-
- Collection<String> c2 = new ArrayList<String>();
- c2.add("zero");
- c2.add("one");
- c2.add("two");
-
- assertFalse(CollectionTools.retainAll(c1, c2.iterator()));
- assertEquals(c2.size(), c1.size());
- assertEquals(c2, c1);
-
- Collection<String> c3 = new ArrayList<String>();
- c3.add("three");
- c3.add("four");
- c3.add("five");
- }
-
- public void testRetainAllCollectionIterator_EmptyIterator() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.retainAll(c, EmptyIterator.instance()));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionIterator_EmptyCollection() {
- Collection<String> c = new ArrayList<String>();
- assertFalse(CollectionTools.retainAll(c, this.buildStringList1().iterator()));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionIteratorInt() {
- Collection<String> c = this.buildStringList1();
- assertFalse(CollectionTools.retainAll(c, this.buildStringList1().iterator(), 8));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- assertTrue(CollectionTools.retainAll(c, this.buildStringList2().iterator(), 9));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
- }
-
- public void testRetainAllCollectionIteratorInt_EmptyIterator() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.retainAll(c, EmptyIterator.instance(), 0));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionIteratorInt_EmptyCollection() {
- Collection<String> c = new ArrayList<String>();
- assertFalse(CollectionTools.retainAll(c, this.buildStringList1().iterator(), 3));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionObjectArray() {
- Collection<String> c = this.buildStringList1();
- assertFalse(CollectionTools.retainAll(c, this.buildObjectArray1()));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- assertTrue(CollectionTools.retainAll(c, this.buildObjectArray2()));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
- }
-
- public void testRetainAllCollectionObjectArray_EmptyObjectArray() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.retainAll(c, new Object[0]));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionObjectArray_EmptyCollection() {
- Collection<String> c = new ArrayList<String>();
- assertFalse(CollectionTools.retainAll(c, new String[] { "foo" }));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllObjectArrayObjectArray() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Object[] a2 = new Object[] { "E", "B", new Integer(7) };
- assertTrue(Arrays.equals(new String[] { "B", "B", "E", "E" }, CollectionTools.retainAll(a1, a2)));
- }
-
- public void testRetainAllObjectArrayObjectArray_EmptyObjectArray1() {
- String[] a1 = new String[0];
- String[] a2 = new String[] { "E", "B", "" };
- String[] a3 = CollectionTools.retainAll(a1, a2);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayObjectArray_EmptyObjectArray2() {
- String[] a1 = new String[] { "E", "B", "" };
- String[] a2 = new String[0];
- String[] a3 = CollectionTools.retainAll(a1, a2);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayObjectArray_BothEmpty() {
- String[] a1 = new String[0];
- String[] a2 = new String[0];
- String[] a3 = CollectionTools.retainAll(a1, a2);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayIterable() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterable<String> iterable = Arrays.asList(new String[] { "E", "B", "" });
- assertTrue(Arrays.equals(new String[] { "B", "B", "E", "E" }, CollectionTools.retainAll(a1, iterable)));
- }
-
- public void testRetainAllObjectArrayIterable_EmptyObjectArray() {
- String[] a1 = new String[0];
- Iterable<String> iterable = Arrays.asList(new String[] { "E", "B", "" });
- String[] a3 = CollectionTools.retainAll(a1, iterable);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayIterableInt() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterable<String> iterable = Arrays.asList(new String[] { "E", "B", "" });
- assertTrue(Arrays.equals(new String[] { "B", "B", "E", "E" }, CollectionTools.retainAll(a1, iterable, 3)));
- }
-
- public void testRetainAllObjectArrayIterableInt_EmptyObjectArray() {
- String[] a1 = new String[0];
- Iterable<String> iterable = Arrays.asList(new String[] { "E", "B", "" });
- String[] a3 = CollectionTools.retainAll(a1, iterable, 3);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayIterator() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterator<String> iterator = Arrays.asList(new String[] { "E", "B", "" }).iterator();
- assertTrue(Arrays.equals(new String[] { "B", "B", "E", "E" }, CollectionTools.retainAll(a1, iterator)));
- }
-
- public void testRetainAllObjectArrayIterator_EmptyObjectArray() {
- String[] a1 = new String[0];
- Iterator<String> iterator = Arrays.asList(new String[] { "E", "B", "" }).iterator();
- String[] a3 = CollectionTools.retainAll(a1, iterator);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayIteratorInt() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterator<String> iterator = Arrays.asList(new String[] { "E", "B", "" }).iterator();
- assertTrue(Arrays.equals(new String[] { "B", "B", "E", "E" }, CollectionTools.retainAll(a1, iterator, 3)));
- }
-
- public void testRetainAllObjectArrayIteratorInt_EmptyObjectArray() {
- String[] a1 = new String[0];
- Iterator<String> iterator = Arrays.asList(new String[] { "E", "B", "" }).iterator();
- String[] a3 = CollectionTools.retainAll(a1, iterator, 3);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayCollection() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Collection<String> collection = Arrays.asList(new String[] { "E", "B", "" });
- assertTrue(Arrays.equals(new String[] { "B", "B", "E", "E" }, CollectionTools.retainAll(a1, collection)));
- }
-
- public void testRetainAllObjectArrayCollection_EmptyObjectArray() {
- String[] a1 = new String[0];
- Collection<String> collection = Arrays.asList(new String[] { "E", "B", "" });
- String[] a3 = CollectionTools.retainAll(a1, collection);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayCollection_EmptyCollection() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Collection<String> collection = new ArrayList<String>();
- String[] a3 = CollectionTools.retainAll(a1, collection);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayCollection_All() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Collection<String> collection = Arrays.asList(new String[] { "A", "B", "C", "D", "E", "F" });
- assertTrue(Arrays.equals(a1, CollectionTools.retainAll(a1, collection)));
- }
-
- public void testRetainAllCharArrayCharArray() {
- char[] a1 = new char[] { 'A', 'A', 'B', 'B', 'C', 'C', 'D', 'D', 'E', 'E', 'F', 'F' };
- char[] a2 = new char[] { 'E', 'B' };
- assertTrue(Arrays.equals(new char[] { 'B', 'B', 'E', 'E' }, CollectionTools.retainAll(a1, a2)));
- }
-
- public void testRetainAllCharArrayCharArray_EmptyCharArray1() {
- char[] a1 = new char[0];
- char[] a2 = new char[] { 'E', 'B' };
- assertSame(a1, CollectionTools.retainAll(a1, a2));
- }
-
- public void testRetainAllCharArrayCharArray_EmptyCharArray2() {
- char[] a1 = new char[] { 'E', 'B' };
- char[] a2 = new char[0];
- assertEquals(0, CollectionTools.retainAll(a1, a2).length);
- }
-
- public void testRetainAllCharArrayCharArray_RetainAll() {
- char[] a1 = new char[] { 'E', 'B', 'E', 'B', 'E', 'B', 'E', 'B', 'E' };
- char[] a2 = new char[] { 'E', 'B' };
- assertSame(a1, CollectionTools.retainAll(a1, a2));
- }
-
- public void testRetainAllIntArrayIntArray() {
- int[] a1 = new int[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6 };
- int[] a2 = new int[] { 5, 2 };
- assertTrue(Arrays.equals(new int[] { 2, 2, 5, 5 }, CollectionTools.retainAll(a1, a2)));
- }
-
- public void testRetainAllIntArrayIntArray_EmptyIntArray1() {
- int[] a1 = new int[0];
- int[] a2 = new int[] { 5, 2 };
- assertSame(a1, CollectionTools.retainAll(a1, a2));
- }
-
- public void testRetainAllIntArrayIntArray_EmptyIntArray2() {
- int[] a1 = new int[] { 5, 2 };
- int[] a2 = new int[0];
- assertEquals(0, CollectionTools.retainAll(a1, a2).length);
- }
-
- public void testRetainAllIntArrayIntArray_RetainAll() {
- int[] a1 = new int[] { 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5 };
- int[] a2 = new int[] { 5, 2 };
- assertSame(a1, CollectionTools.retainAll(a1, a2));
- }
-
- public void testReverseObjectArray_Object() {
- Object[] a = this.buildObjectArray1();
- a = CollectionTools.reverse(a);
- assertEquals("two", a[0]);
- assertEquals("one", a[1]);
- assertEquals("zero", a[2]);
- }
-
- public void testReverseObjectArray_String() {
- String[] a = this.buildStringArray1();
- a = CollectionTools.reverse(a);
- assertEquals("two", a[0]);
- assertEquals("one", a[1]);
- assertEquals("zero", a[2]);
- }
-
- public void testReverseCharArray() {
- char[] a = this.buildCharArray();
- a = CollectionTools.reverse(a);
- assertEquals('c', a[0]);
- assertEquals('b', a[1]);
- assertEquals('a', a[2]);
- }
-
- public void testReverseIntArray() {
- int[] a = this.buildIntArray();
- a = CollectionTools.reverse(a);
- assertEquals(20, a[0]);
- assertEquals(10, a[1]);
- assertEquals(0, a[2]);
- }
-
- public void testReverseListIterable() {
- Iterable<String> iterable = this.buildStringList1();
- List<String> actual = CollectionTools.reverseList(iterable);
- List<String> expected = this.buildStringList1();
- Collections.reverse(expected);
- assertEquals(expected, actual);
- }
-
- public void testReverseListIterableInt() {
- Iterable<String> iterable = this.buildStringList1();
- List<String> actual = CollectionTools.reverseList(iterable, 10);
- List<String> expected = this.buildStringList1();
- Collections.reverse(expected);
- assertEquals(expected, actual);
- }
-
- public void testReverseListIterator_String() {
- List<String> actual = CollectionTools.reverseList(this.buildStringList1().iterator());
- List<String> expected = this.buildStringList1();
- Collections.reverse(expected);
- assertEquals(expected, actual);
- }
-
- public void testReverseListIterator_Object() {
- List<Object> actual = CollectionTools.<Object>reverseList(this.buildStringList1().iterator());
- List<Object> expected = this.buildObjectList1();
- Collections.reverse(expected);
- assertEquals(expected, actual);
- }
-
- public void testReverseListIteratorInt() {
- List<String> actual = CollectionTools.reverseList(this.buildStringList1().iterator(), 33);
- List<String> expected = this.buildStringList1();
- Collections.reverse(expected);
- assertEquals(expected, actual);
- }
-
- public void testRotateObjectArray() {
- String[] a = this.buildStringArray1();
- a = CollectionTools.rotate(a);
- assertEquals("two", a[0]);
- assertEquals("zero", a[1]);
- assertEquals("one", a[2]);
- }
-
- public void testRotateObjectArray_Zero() {
- String[] a1 = new String[0];
- String[] a2 = CollectionTools.rotate(a1);
- assertSame(a1, a2);
- }
-
- public void testRotateObjectArray_One() {
- String[] a1 = new String[] { "foo " };
- String[] a2 = CollectionTools.rotate(a1);
- assertSame(a1, a2);
- }
-
- public void testRotateObjectArrayInt() {
- String[] a = this.buildStringArray1();
- a = CollectionTools.rotate(a, 2);
- assertEquals("one", a[0]);
- assertEquals("two", a[1]);
- assertEquals("zero", a[2]);
- }
-
- public void testRotateObjectArrayInt_ZeroDistance() {
- String[] a1 = this.buildStringArray1();
- String[] a2 = CollectionTools.rotate(a1, 0);
- assertSame(a1, a2);
- }
-
- public void testRotateObjectArrayInt_Zero() {
- String[] a1 = new String[0];
- String[] a2 = CollectionTools.rotate(a1, 7);
- assertSame(a1, a2);
- }
-
- public void testRotateObjectArrayInt_One() {
- String[] a1 = new String[] { "foo " };
- String[] a2 = CollectionTools.rotate(a1, 8);
- assertSame(a1, a2);
- }
-
- public void testRotateCharArray() {
- char[] a = this.buildCharArray();
- a = CollectionTools.rotate(a);
- assertEquals('c', a[0]);
- assertEquals('a', a[1]);
- assertEquals('b', a[2]);
- }
-
- public void testRotateCharArray_Zero() {
- char[] a1 = new char[0];
- char[] a2 = CollectionTools.rotate(a1);
- assertSame(a1, a2);
- }
-
- public void testRotateCharArray_One() {
- char[] a1 = new char[] { 'a' };
- char[] a2 = CollectionTools.rotate(a1);
- assertSame(a1, a2);
- }
-
- public void testRotateCharArrayInt() {
- char[] a = this.buildCharArray();
- a = CollectionTools.rotate(a, 2);
- assertEquals('b', a[0]);
- assertEquals('c', a[1]);
- assertEquals('a', a[2]);
- }
-
- public void testRotateCharArrayInt_ZeroDistance() {
- char[] a1 = new char[] { 'a', 'b', 'c' };
- char[] a2 = CollectionTools.rotate(a1, 0);
- assertSame(a1, a2);
- }
-
- public void testRotateCharArrayInt_Zero() {
- char[] a1 = new char[0];
- char[] a2 = CollectionTools.rotate(a1, 2001);
- assertSame(a1, a2);
- }
-
- public void testRotateCharArrayInt_One() {
- char[] a1 = new char[] { 'a' };
- char[] a2 = CollectionTools.rotate(a1, 22);
- assertSame(a1, a2);
- }
-
- public void testRotateIntArray() {
- int[] a = this.buildIntArray();
- a = CollectionTools.rotate(a);
- assertEquals(20, a[0]);
- assertEquals(0, a[1]);
- assertEquals(10, a[2]);
- }
-
- public void testRotateIntArray_Zero() {
- int[] a1 = new int[0];
- int[] a2 = CollectionTools.rotate(a1);
- assertSame(a1, a2);
- }
-
- public void testRotateIntArray_One() {
- int[] a1 = new int[] { 77 };
- int[] a2 = CollectionTools.rotate(a1);
- assertSame(a1, a2);
- }
-
- public void testRotateIntArrayInt() {
- int[] a = this.buildIntArray();
- a = CollectionTools.rotate(a, 2);
- assertEquals(10, a[0]);
- assertEquals(20, a[1]);
- assertEquals(0, a[2]);
- }
-
- public void testRotateIntArrayInt_ZeroDistance() {
- int[] a1 = new int[] { 3, 2, 1 };
- int[] a2 = CollectionTools.rotate(a1, 0);
- assertSame(a1, a2);
- }
-
- public void testRotateIntArrayInt_Zero() {
- int[] a1 = new int[0];
- int[] a2 = CollectionTools.rotate(a1, 3);
- assertSame(a1, a2);
- }
-
- public void testRotateIntArrayInt_One() {
- int[] a1 = new int[] { 77 };
- int[] a2 = CollectionTools.rotate(a1, 44);
- assertSame(a1, a2);
- }
-
- public void testSetIterable() {
- Iterable<String> iterable = this.buildStringSet1();
- assertEquals(this.buildStringSet1(), CollectionTools.set(iterable));
- }
-
- public void testSetIterableInt() {
- Iterable<String> iterable = this.buildStringSet1();
- assertEquals(this.buildStringSet1(), CollectionTools.set(iterable, 22));
- }
-
- public void testSetIterator_String() {
- assertEquals(this.buildStringSet1(), CollectionTools.set(this.buildStringSet1().iterator()));
- }
-
- public void testSetIterator_Object() {
- Set<String> set1 = new HashSet<String>();
- set1.add("0");
- set1.add("1");
- set1.add("2");
- set1.add("3");
-
- Set<Object> set2 = CollectionTools.<Object>set(set1.iterator());
- assertEquals(set1, set2);
- }
-
- public void testSetIteratorInt() {
- assertEquals(this.buildStringSet1(), CollectionTools.set(this.buildStringSet1().iterator(), 3));
- }
-
- public void testSetObjectArray() {
- assertEquals(this.buildStringSet1(), CollectionTools.set(this.buildStringSet1().toArray()));
- }
-
- public void testShuffleObjectArray() {
- String[] array1 = this.buildStringArray1();
- String[] array2 = CollectionTools.shuffle(this.buildStringArray1());
- assertEquals(array1.length, array2.length);
- assertTrue(CollectionTools.containsAll(array1, array2));
- }
-
- public void testShuffleCharArray() {
- char[] array1 = this.buildCharArray();
- char[] array2 = CollectionTools.shuffle(this.buildCharArray());
- assertEquals(array1.length, array2.length);
- assertTrue(CollectionTools.containsAll(array1, array2));
- }
-
- public void testShuffleIntArray() {
- int[] array1 = this.buildIntArray();
- int[] array2 = CollectionTools.shuffle(this.buildIntArray());
- assertEquals(array1.length, array2.length);
- assertTrue(CollectionTools.containsAll(array1, array2));
- }
-
- public void testSingletonIterator_String() {
- Iterator<String> stream = CollectionTools.singletonIterator("foo");
- assertTrue(stream.hasNext());
- assertEquals("foo", stream.next());
- }
-
- public void testSingletonIterator_Object() {
- Iterator<Object> stream = CollectionTools.<Object>singletonIterator("foo");
- assertTrue(stream.hasNext());
- assertEquals("foo", stream.next());
- }
-
- public void testSingletonIterator_Cast() {
- Iterator<Object> stream = CollectionTools.singletonIterator((Object) "foo");
- assertTrue(stream.hasNext());
- assertEquals("foo", stream.next());
- }
-
- public void testSizeIterable() {
- Iterable<Object> iterable = this.buildObjectList1();
- assertEquals(3, CollectionTools.size(iterable));
- }
-
- public void testSizeIterator() {
- assertEquals(3, CollectionTools.size(this.buildObjectList1().iterator()));
- }
-
- public void testSortedSetIterable() {
- SortedSet<String> ss1 = new TreeSet<String>();
- ss1.add("0");
- ss1.add("2");
- ss1.add("3");
- ss1.add("1");
-
- Iterable<String> iterable = ss1;
- SortedSet<String> set2 = CollectionTools.<String>sortedSet(iterable);
- assertEquals(ss1, set2);
- }
-
- public void testSortedSetIterableInt() {
- SortedSet<String> ss1 = new TreeSet<String>();
- ss1.add("0");
- ss1.add("2");
- ss1.add("3");
- ss1.add("1");
-
- Iterable<String> iterable = ss1;
- SortedSet<String> set2 = CollectionTools.<String>sortedSet(iterable, 5);
- assertEquals(ss1, set2);
- }
-
- public void testSortedSetIterator() {
- assertEquals(this.buildSortedStringSet1(), CollectionTools.sortedSet(this.buildSortedStringSet1().iterator()));
- }
-
- public void testSortedSetIterator_TreeSet() {
- SortedSet<String> ss1 = new TreeSet<String>();
- ss1.add("0");
- ss1.add("2");
- ss1.add("3");
- ss1.add("1");
-
- SortedSet<String> set2 = CollectionTools.<String>sortedSet(ss1.iterator());
- assertEquals(ss1, set2);
- }
-
- public void testSortedSetIteratorInt() {
- assertEquals(this.buildSortedStringSet1(), CollectionTools.sortedSet(this.buildSortedStringSet1().iterator(), 8));
- }
-
- public void testSortedSetObjectArray() {
- assertEquals(this.buildSortedStringSet1(), CollectionTools.set(this.buildSortedStringSet1().toArray()));
- }
-
- public void testSubArrayObjectArrayIntInt() {
- String[] array = new String[] {"foo", "bar", "baz", "joo", "jar", "jaz"};
- String[] result = new String[] {"foo", "bar", "baz", "joo"};
- assertTrue(Arrays.equals(result, CollectionTools.subArray(array, 0, 4)));
-
- result = new String[] {"jar"};
- assertTrue(Arrays.equals(result, CollectionTools.subArray(array, 4, 1)));
-
- result = new String[0];
- assertTrue(Arrays.equals(result, CollectionTools.subArray(array, 5, 0)));
-
- result = new String[] {"joo", "jar", "jaz"};
- assertTrue(Arrays.equals(result, CollectionTools.subArray(array, 3, 3)));
- }
-
- public void testSubArrayIntArrayIntInt() {
- int[] array = new int[] {77, 99, 333, 4, 9090, 42};
- int[] result = new int[] {77, 99, 333, 4};
- assertTrue(Arrays.equals(result, CollectionTools.subArray(array, 0, 4)));
-
- result = new int[] {9090};
- assertTrue(Arrays.equals(result, CollectionTools.subArray(array, 4, 1)));
-
- result = new int[0];
- assertTrue(Arrays.equals(result, CollectionTools.subArray(array, 5, 0)));
-
- result = new int[] {4, 9090, 42};
- assertTrue(Arrays.equals(result, CollectionTools.subArray(array, 3, 3)));
- }
-
- public void testSubArrayCharArrayIntInt() {
- char[] array = new char[] {'a', 'b', 'c', 'd', 'e', 'f'};
- char[] result = new char[] {'a', 'b', 'c', 'd'};
- assertTrue(Arrays.equals(result, CollectionTools.subArray(array, 0, 4)));
-
- result = new char[] {'e'};
- assertTrue(Arrays.equals(result, CollectionTools.subArray(array, 4, 1)));
-
- result = new char[0];
- assertTrue(Arrays.equals(result, CollectionTools.subArray(array, 5, 0)));
-
- result = new char[] {'d', 'e', 'f'};
- assertTrue(Arrays.equals(result, CollectionTools.subArray(array, 3, 3)));
- }
-
- public void testSwapObjectArray() {
- String[] a = this.buildStringArray1();
- a = CollectionTools.swap(a, 1, 2);
- assertEquals("zero", a[0]);
- assertEquals("two", a[1]);
- assertEquals("one", a[2]);
- }
-
- public void testSwapCharArray() {
- char[] a = this.buildCharArray();
- a = CollectionTools.swap(a, 1, 2);
- assertEquals('a', a[0]);
- assertEquals('c', a[1]);
- assertEquals('b', a[2]);
- }
-
- public void testSwapIntArray() {
- int[] a = this.buildIntArray();
- a = CollectionTools.swap(a, 1, 2);
- assertEquals(0, a[0]);
- assertEquals(20, a[1]);
- assertEquals(10, a[2]);
- }
-
- public void testRemoveDuplicateElementsList() {
- List<String> list = this.buildStringVector1();
- list.add("zero");
- list.add("zero");
- list.add("two");
- list.add("zero");
- list = CollectionTools.removeDuplicateElements(list);
- int i = 0;
- assertEquals("zero", list.get(i++));
- assertEquals("one", list.get(i++));
- assertEquals("two", list.get(i++));
- assertEquals(i, list.size());
- }
-
- public void testRemoveDuplicateElementsList_Empty() {
- List<String> list = new ArrayList<String>();
- list = CollectionTools.removeDuplicateElements(list);
- assertEquals(0, list.size());
- }
-
- public void testRemoveDuplicateElementsList_SingleElement() {
- List<String> list = new ArrayList<String>();
- list.add("zero");
- list = CollectionTools.removeDuplicateElements(list);
- assertEquals(1, list.size());
- }
-
- public void testRemoveDuplicateElementsObjectArray() {
- List<String> list = this.buildStringVector1();
- list.add("zero");
- list.add("zero");
- list.add("two");
- list.add("zero");
- String[] array = CollectionTools.removeDuplicateElements(list.toArray(new String[list.size()]));
- int i = 0;
- assertEquals("zero", array[i++]);
- assertEquals("one", array[i++]);
- assertEquals("two", array[i++]);
- assertEquals(i, array.length);
- }
-
- public void testRemoveDuplicateElementsObjectArray_Empty() {
- String[] array = CollectionTools.removeDuplicateElements(new String[0]);
- assertEquals(0, array.length);
- }
-
- public void testRemoveDuplicateElementsObjectArray_SingleElement() {
- String[] array = CollectionTools.removeDuplicateElements(new String[] { "foo" });
- assertEquals(1, array.length);
- }
-
- public void testVectorIterable() {
- Iterable<String> iterable = this.buildStringList1();
- Vector<String> v = CollectionTools.vector(iterable);
- assertEquals(3, v.size());
- assertTrue(v.containsAll(this.buildStringList1()));
- }
-
- public void testVectorIterableInt() {
- Iterable<String> iterable = this.buildStringList1();
- Vector<String> v = CollectionTools.vector(iterable, 8);
- assertEquals(3, v.size());
- assertTrue(v.containsAll(this.buildStringList1()));
- }
-
- public void testVectorIterator_String() {
- Vector<String> v = CollectionTools.vector(this.buildStringList1().iterator());
- assertEquals(3, v.size());
- assertTrue(v.containsAll(this.buildStringList1()));
- }
-
- public void testVectorIterator_Object() {
- Vector<Object> v = CollectionTools.<Object>vector(this.buildStringList1().iterator());
- assertEquals(3, v.size());
- assertTrue(v.containsAll(this.buildStringList1()));
- }
-
- public void testVectorIteratorInt() {
- Vector<String> v = CollectionTools.vector(this.buildStringList1().iterator(), 7);
- assertEquals(3, v.size());
- assertTrue(v.containsAll(this.buildStringList1()));
- }
-
- public void testVectorObjectArray() {
- Vector<String> v = CollectionTools.vector(this.buildStringArray1());
- assertEquals(3, v.size());
- assertTrue(v.containsAll(this.buildStringList1()));
- }
-
- private Object[] buildObjectArray1() {
- return new Object[] { "zero", "one", "two" };
- }
-
- private String[] buildStringArray1() {
- return new String[] { "zero", "one", "two" };
- }
-
- private char[] buildCharArray() {
- return new char[] { 'a', 'b', 'c' };
- }
-
- private int[] buildIntArray() {
- return new int[] { 0, 10, 20 };
- }
-
- private Object[] buildObjectArray2() {
- return new Object[] { "three", "four", "five" };
- }
-
- private String[] buildStringArray2() {
- return new String[] { "three", "four", "five" };
- }
-
- private Vector<String> buildStringVector1() {
- Vector<String> v = new Vector<String>();
- this.addToCollection1(v);
- return v;
- }
-
- private List<String> buildStringList1() {
- List<String> l = new ArrayList<String>();
- this.addToCollection1(l);
- return l;
- }
-
- private List<Object> buildObjectList1() {
- List<Object> l = new ArrayList<Object>();
- this.addToCollection1(l);
- return l;
- }
-
- private void addToCollection1(Collection<? super String> c) {
- c.add("zero");
- c.add("one");
- c.add("two");
- }
-
- private List<String> buildStringList2() {
- List<String> l = new ArrayList<String>();
- this.addToCollection2(l);
- return l;
- }
-
- private void addToCollection2(Collection<? super String> c) {
- c.add("three");
- c.add("four");
- c.add("five");
- }
-
- private Set<String> buildStringSet1() {
- Set<String> s = new HashSet<String>();
- this.addToCollection1(s);
- return s;
- }
-
- private Set<Object> buildObjectSet1() {
- Set<Object> s = new HashSet<Object>();
- this.addToCollection1(s);
- return s;
- }
-
- private SortedSet<String> buildSortedStringSet1() {
- SortedSet<String> s = new TreeSet<String>();
- this.addToCollection1(s);
- return s;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CounterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CounterTests.java
deleted file mode 100644
index 243149c612..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CounterTests.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import org.eclipse.jpt.utility.internal.Counter;
-
-import junit.framework.TestCase;
-
-public class CounterTests extends TestCase {
-
- public CounterTests(String name) {
- super(name);
- }
-
- public void testCtors() {
- Counter counter;
- counter = new Counter();
- assertEquals(0, counter.count());
- counter = new Counter(7);
- assertEquals(7, counter.count());
- counter = new Counter(-7);
- assertEquals(-7, counter.count());
- }
-
- public void testIncrement() {
- Counter counter;
- int count;
- counter = new Counter();
- assertEquals(0, counter.count());
-
- count = counter.increment(3);
- assertEquals(3, count);
- assertEquals(3, counter.count());
-
- count = counter.increment();
- assertEquals(4, count);
- assertEquals(4, counter.count());
-
- count = counter.increment(-7);
- assertEquals(-3, count);
- assertEquals(-3, counter.count());
- }
-
- public void testDecrement() {
- Counter counter;
- int count;
- counter = new Counter();
- assertEquals(0, counter.count());
-
- count = counter.decrement(3);
- assertEquals(-3, count);
- assertEquals(-3, counter.count());
-
- count = counter.decrement();
- assertEquals(-4, count);
- assertEquals(-4, counter.count());
-
- count = counter.decrement(-7);
- assertEquals(3, count);
- assertEquals(3, counter.count());
- }
-
- public void testClone() {
- Counter counter = new Counter(44);
- Counter counter2 = (Counter) counter.clone();
- assertEquals(44, counter2.count());
- assertEquals(counter, counter2);
- assertNotSame(counter, counter2);
- }
-
- public void testEquals() {
- Counter counter = new Counter(44);
- Counter counter2 = new Counter(44);
- assertEquals(counter, counter2);
- assertEquals(counter.hashCode(), counter2.hashCode());
- }
-
- public void testSerialization() throws Exception {
- Counter counter = new Counter(44);
- Counter counter2 = TestTools.serialize(counter);
- assertEquals(44, counter2.count());
- assertEquals(counter, counter2);
- assertNotSame(counter, counter2);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/EmptyIterableTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/EmptyIterableTests.java
deleted file mode 100644
index 25692053c8..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/EmptyIterableTests.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import org.eclipse.jpt.utility.internal.EmptyIterable;
-
-import junit.framework.TestCase;
-
-public class EmptyIterableTests extends TestCase {
-
- public EmptyIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- int i = 0;
- for (String string : EmptyIterable.<String>instance()) {
- fail("bogus string: " + string);
- i++;
- }
- assertEquals(0, i);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java
deleted file mode 100644
index adcccf0992..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java
+++ /dev/null
@@ -1,594 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.FileTools;
-
-public class FileToolsTests extends TestCase {
- private File tempDir;
-
- public FileToolsTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.tempDir = this.buildTempDir();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- this.deleteDir(this.tempDir);
- }
-
- public void testFilesIn() {
- Collection<File> files = CollectionTools.collection(FileTools.filesIn(this.tempDir.getPath()));
- assertEquals("invalid file count", 3, files.size());
- }
-
- public void testDirectoriesIn() {
- Collection<File> files = CollectionTools.collection(FileTools.directoriesIn(this.tempDir.getPath()));
- assertEquals("invalid directory count", 2, files.size());
- }
-
- public void testFilesInTree() {
- Collection<File> files = CollectionTools.collection(FileTools.filesInTree(this.tempDir.getPath()));
- assertEquals("invalid file count", 9, files.size());
- }
-
- public void testDirectoriesInTree() {
- Collection<File> files = CollectionTools.collection(FileTools.directoriesInTree(this.tempDir.getPath()));
- assertEquals("invalid directory count", 3, files.size());
- }
-
- public void testDeleteDirectory() throws IOException {
- // build another temporary directory just for this test
- File dir = this.buildTempDir();
- assertTrue("temporary directory not created", dir.exists());
- FileTools.deleteDirectory(dir.getPath());
- assertFalse("temporary directory not deleted", dir.exists());
- }
-
- public void testDeleteDirectoryContents() throws IOException {
- // build another temporary directory just for this test
- File dir = this.buildTempDir();
- assertTrue("temporary directory not created", dir.exists());
- FileTools.deleteDirectoryContents(dir.getPath());
- assertTrue("temporary directory should not have been deleted", dir.exists());
- assertTrue("temporary directory contents not deleted", dir.listFiles().length == 0);
- dir.delete();
- }
-
- public void testCopyToFile() throws IOException {
- File destFile = new File(this.tempDir, "destfile.txt");
- this.copyToFile(destFile, "testCopyToFile");
- }
-
- public void testCopyToPreExistingFile() throws IOException {
- File destFile = new File(this.tempDir, "destfile.txt");
- Writer writer = new OutputStreamWriter(new FileOutputStream(destFile));
- writer.write("this text should be replaced...");
- writer.close();
- this.copyToFile(destFile, "testCopyToPreExistingFile");
- }
-
- private void copyToFile(File destFile, String writeString) throws IOException {
- File sourceFile = new File(this.tempDir, "sourcefile.txt");
- char[] readBuffer = new char[writeString.length()];
-
- Writer writer = new OutputStreamWriter(new FileOutputStream(sourceFile));
- writer.write(writeString);
- writer.close();
-
- FileTools.copyToFile(sourceFile, destFile);
-
- Reader reader = new InputStreamReader(new FileInputStream(destFile));
- reader.read(readBuffer);
- reader.close();
- String readString = new String(readBuffer);
- assertEquals(writeString, readString);
- }
-
- public void testCopyToDirectory() throws IOException {
- File sourceFile = new File(this.tempDir, "sourcefile.txt");
- String writeString = "testCopyToDirectory";
-
- File destDir = new File(this.tempDir, "destdir");
- destDir.mkdir();
- File destFile = new File(destDir, "sourcefile.txt");
- char[] readBuffer = new char[writeString.length()];
-
- Writer writer = new OutputStreamWriter(new FileOutputStream(sourceFile));
- writer.write(writeString);
- writer.close();
-
- FileTools.copyToDirectory(sourceFile, destDir);
-
- Reader reader = new InputStreamReader(new FileInputStream(destFile));
- reader.read(readBuffer);
- reader.close();
- String readString = new String(readBuffer);
- assertEquals(writeString, readString);
- }
-
- public void testFilter() throws IOException {
- String prefix = "XXXtestFileXXX";
- File testFile1 = new File(this.tempDir, prefix + "1");
- testFile1.createNewFile();
- File testFile2 = new File(this.tempDir, prefix + "2");
- testFile2.createNewFile();
-
- FileFilter filter = this.buildFileFilter(prefix);
- Iterator<File> filteredFilesIterator = FileTools.filter(FileTools.filesIn(this.tempDir), filter);
- Collection<File> filteredFiles = CollectionTools.collection(filteredFilesIterator);
- assertEquals(2, filteredFiles.size());
- assertTrue(filteredFiles.contains(testFile1));
- assertTrue(filteredFiles.contains(testFile2));
- }
-
- private FileFilter buildFileFilter(final String prefix) {
- return new FileFilter() {
- public boolean accept(File file) {
- return file.getName().startsWith(prefix);
- }
- };
- }
-
- public void testStripExtension() {
- assertEquals("foo", FileTools.stripExtension("foo.xml"));
- assertEquals("foo.bar", FileTools.stripExtension("foo.bar.xml"));
- assertEquals("foo", FileTools.stripExtension("foo"));
- assertEquals("foo", FileTools.stripExtension("foo."));
- }
-
- public void testExtension() {
- assertEquals(".xml", FileTools.extension("foo.xml"));
- assertEquals(".xml", FileTools.extension("foo.bar.xml"));
- assertEquals("", FileTools.extension("foo"));
- assertEquals("", FileTools.extension("foo,xml"));
- assertEquals(".", FileTools.extension("foo."));
- }
-
- public void testEmptyTemporaryDirectory() throws IOException {
- File tempDir1 = FileTools.temporaryDirectory();
- File testFile1 = new File(tempDir1, "junk");
- testFile1.createNewFile();
-
- File tempDir2 = FileTools.emptyTemporaryDirectory();
- assertEquals(tempDir1, tempDir2);
- assertTrue(tempDir2.isDirectory());
- assertEquals(0, tempDir2.listFiles().length);
- tempDir2.delete();
- }
-
- public void testCanonicalFileName() {
- File file1 = new File("foo");
- file1 = new File(file1, "bar");
- file1 = new File(file1, "baz");
- file1 = new File(file1, "..");
- file1 = new File(file1, "..");
- file1 = new File(file1, "bar");
- file1 = new File(file1, "baz");
- File file2 = new File(System.getProperty("user.dir"));
- file2 = new File(file2, "foo");
- file2 = new File(file2, "bar");
- file2 = new File(file2, "baz");
- File file3 = FileTools.canonicalFile(file1);
- assertEquals(file2, file3);
- }
-
- private boolean isExecutingOnWindows() {
- return this.isExecutingOn("Windows");
- }
-
- // private boolean isExecutingOnLinux() {
- // return this.isExecutingOn("Linux");
- // }
- //
- private boolean isExecutingOn(String osName) {
- return System.getProperty("os.name").indexOf(osName) != -1;
- }
-
- public void testPathFiles() {
- File[] expected;
- File[] actual;
-
- if (this.isExecutingOnWindows()) {
- expected = new File[] { new File("C:/"), new File("C:/foo"), new File("C:/foo/bar"), new File("C:/foo/bar/baz.txt") };
- actual = this.pathFiles(new File("C:/foo/bar/baz.txt"));
- assertTrue(Arrays.equals(expected, actual));
- }
-
- expected = new File[] { new File("/"), new File("/foo"), new File("/foo/bar"), new File("/foo/bar/baz.txt") };
- actual = this.pathFiles(new File("/foo/bar/baz.txt"));
- assertTrue(Arrays.equals(expected, actual));
-
- expected = new File[] { new File("foo"), new File("foo/bar"), new File("foo/bar/baz.txt") };
- actual = this.pathFiles(new File("foo/bar/baz.txt"));
- assertTrue(Arrays.equals(expected, actual));
-
- expected = new File[] { new File(".."), new File("../foo"), new File("../foo/bar"), new File("../foo/bar/baz.txt") };
- actual = this.pathFiles(new File("../foo/bar/baz.txt"));
- assertTrue(Arrays.equals(expected, actual));
-
- expected = new File[] { new File("."), new File("./foo"), new File("./foo/bar"), new File("./foo/bar/baz.txt") };
- actual = this.pathFiles(new File("./foo/bar/baz.txt"));
- assertTrue(Arrays.equals(expected, actual));
- }
-
- private File[] pathFiles(File file) {
- return (File[]) ClassTools.executeStaticMethod(FileTools.class, "pathFiles", File.class, file);
- }
-
- public void testRelativeParentFile() {
- assertEquals(new File(".."), this.relativeParentFile(1));
- assertEquals(new File("../.."), this.relativeParentFile(2));
- assertEquals(new File("../../.."), this.relativeParentFile(3));
-
- boolean exCaught = false;
- try {
- File file = this.relativeParentFile(0);
- fail("invalid return: " + file);
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof InvocationTargetException) {
- InvocationTargetException ite = (InvocationTargetException) ex.getCause();
- if (ite.getTargetException() instanceof IllegalArgumentException) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
- private File relativeParentFile(int len) {
- return (File) ClassTools.executeStaticMethod(FileTools.class, "relativeParentFile", int.class, new Integer(len));
- }
-
- public void testConvertToRelativeFile() {
- String prefix = this.isExecutingOnWindows() ? "C:" : "";
- File file;
- File dir;
- File relativeFile;
-
- if (this.isExecutingOnWindows()) {
- // on Windows, a drive must be specified for a file to be absolute (i.e. not relative)
- this.verifyUnchangedRelativeFile("/dir1/dir2/file.txt", "C:/dir1/dir2");
- // different drives
- this.verifyUnchangedRelativeFile("D:/dir1/dir2/file.txt", "C:/dir1/dir2");
- }
- this.verifyUnchangedRelativeFile("dir1/dir2/file.txt", prefix + "/dir1/dir2");
- this.verifyUnchangedRelativeFile("./dir1/dir2/file.txt", prefix + "/dir1/dir2");
- this.verifyUnchangedRelativeFile("../../dir1/dir2/file.txt", prefix + "/dir1/dir2");
-
- file = new File(prefix + "/dir1/dir2");
- dir = new File(prefix + "/dir1/dir2");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("."), relativeFile);
-
- file = new File(prefix + "/dir1/dir2/file.txt");
- dir = new File(prefix + "/dir1/dir2");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("file.txt"), relativeFile);
-
- file = new File(prefix + "/dir1/dir2/../dir2/file.txt");
- dir = new File(prefix + "/dir1/dir2");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("file.txt"), relativeFile);
-
- file = new File(prefix + "/dir1/dir2/dir3/dir4/dir5/file.txt");
- dir = new File(prefix + "/dir1/dir2");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("dir3/dir4/dir5/file.txt"), relativeFile);
-
- file = new File(prefix + "/dir1/dir2/file.txt");
- dir = new File(prefix + "/dir1/dir2/dir3/dir4/dir5");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("../../../file.txt"), relativeFile);
-
- file = new File(prefix + "/dir1/dir2/file.txt");
- dir = new File(prefix + "/dir1/dir2/dir3");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("../file.txt"), relativeFile);
-
- file = new File(prefix + "/dir1/dir2/dirA/dirB/dirC/file.txt");
- dir = new File(prefix + "/dir1/dir2/dir3/dir4/dir5");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("../../../dirA/dirB/dirC/file.txt"), relativeFile);
-
- file = new File(prefix + "/dir1/dir2");
- dir = new File(prefix + "/dir1/dir2/dir3/dir4/dir5");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("../../.."), relativeFile);
-
- file = new File(prefix + "/My Documents/My Workspace/Project 1/lib/toplink.jar");
- dir = new File(prefix + "/My Documents/My Workspace/Project 1");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("lib/toplink.jar"), relativeFile);
- }
-
- private void verifyUnchangedRelativeFile(String fileName, String dirName) {
- File file = new File(fileName);
- File dir = new File(dirName);
- File relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(file, relativeFile);
- }
-
- public void testConvertToAbsoluteFile() {
- String prefix = this.isExecutingOnWindows() ? "C:" : "";
- File file;
- File dir;
- File absoluteFile;
-
- if (this.isExecutingOnWindows()) {
- // on Windows, a drive must be specified for a file to be absolute (i.e. not relative)
- this.verifyUnchangedAbsoluteFile("C:/dir1/dir2/file.txt", "C:/dir1/dir2");
- // different drives
- this.verifyUnchangedAbsoluteFile("D:/dir1/dir2/file.txt", "C:/dir1/dir2");
- }
- this.verifyUnchangedAbsoluteFile(prefix + "/dir1/dir2/file.txt", prefix + "/dir1/dir2");
- this.verifyUnchangedAbsoluteFile(prefix + "/./dir1/dir2/file.txt", prefix + "/dir1/dir2");
- this.verifyUnchangedAbsoluteFile(prefix + "/dir1/dir2/../../dir1/dir2/file.txt", prefix + "/dir1/dir2");
-
- file = new File(".");
- dir = new File(prefix + "/dir1/dir2");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2"), absoluteFile);
-
- file = new File("./file.txt");
- dir = new File(prefix + "/dir1/dir2");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/file.txt"), absoluteFile);
-
- file = new File("file.txt");
- dir = new File(prefix + "/dir1/dir2");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/file.txt"), absoluteFile);
-
- file = new File("../dir2/file.txt");
- dir = new File(prefix + "/dir1/dir2");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/file.txt"), absoluteFile);
-
- file = new File("dir3/dir4/dir5/file.txt");
- dir = new File(prefix + "/dir1/dir2");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/dir3/dir4/dir5/file.txt"), absoluteFile);
-
- file = new File("../../../file.txt");
- dir = new File(prefix + "/dir1/dir2/dir3/dir4/dir5");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/file.txt"), absoluteFile);
-
- // too many ".." directories will resolve to the root;
- // this is consistent with Windows and Linux command shells
- file = new File("../../../../../../../../file.txt");
- dir = new File(prefix + "/dir1/dir2");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/file.txt"), absoluteFile);
-
- file = new File("../file.txt");
- dir = new File(prefix + "/dir1/dir2/dir3");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/file.txt"), absoluteFile);
-
- file = new File("../../../dirA/dirB/dirC/file.txt");
- dir = new File(prefix + "/dir1/dir2/dir3/dir4/dir5");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/dirA/dirB/dirC/file.txt"), absoluteFile);
-
- file = new File("../../..");
- dir = new File(prefix + "/dir1/dir2/dir3/dir4/dir5");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2"), absoluteFile);
-
- file = new File("lib/toplink.jar");
- dir = new File(prefix + "/My Documents/My Workspace/Project 1");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/My Documents/My Workspace/Project 1/lib/toplink.jar"), absoluteFile);
- }
-
- public void testFileNameIsReserved() {
- boolean expected = this.isExecutingOnWindows();
- assertEquals(expected, FileTools.fileNameIsReserved("CON"));
- assertEquals(expected, FileTools.fileNameIsReserved("con"));
- assertEquals(expected, FileTools.fileNameIsReserved("cON"));
- assertEquals(expected, FileTools.fileNameIsReserved("AUX"));
- assertEquals(expected, FileTools.fileNameIsReserved("COM3"));
- assertEquals(expected, FileTools.fileNameIsReserved("LPT3"));
- assertEquals(expected, FileTools.fileNameIsReserved("nUL"));
- assertEquals(expected, FileTools.fileNameIsReserved("Prn"));
- }
-
- public void testFileHasAnyReservedComponents() {
- boolean expected = this.isExecutingOnWindows();
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("C:/CON")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("/con/foo")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("c:/temp/cON")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("bar//baz//AUX")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("COM3//ttt")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("d:/LPT3/xxx")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("c:/my docs and stuff/tuesday/nUL")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("Prn")));
- }
-
- public void testShortenFileNameFile() {
- if (this.isExecutingOnWindows()) {
- this.verifyShortenFileNameFileWin();
- } else {
- this.verifyShortenFileNameFileNonWin();
- }
- }
-
- private void verifyShortenFileNameFileWin() {
- File file = new File("C:\\Documents and Settings\\Administrator\\Desktop\\Project\\Text.txt");
- String fileName = FileTools.shortenFileName(file);
- assertEquals("C:\\Documents and Settings\\...\\Desktop\\Project\\Text.txt", fileName);
- assertTrue(fileName.length() <= FileTools.MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
-
- file = new File("C:/");
- fileName = FileTools.shortenFileName(file);
- assertEquals("C:\\", fileName);
- assertTrue(fileName.length() <= FileTools.MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
- }
-
- private void verifyShortenFileNameFileNonWin() {
- File file = new File("/home/administrator/documents and settings/desktop/Project/Text.txt");
- String fileName = FileTools.shortenFileName(file);
- assertEquals("/home/administrator/.../desktop/Project/Text.txt", fileName);
- assertTrue(fileName.length() <= FileTools.MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
-
- file = new File("/home");
- fileName = FileTools.shortenFileName(file);
- assertEquals("/home", fileName);
- assertTrue(fileName.length() <= FileTools.MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
- }
-
- public void testShortenFileNameFileInt() {
- if (this.isExecutingOnWindows()) {
- this.verifyShortenFileNameFileIntWin();
- } else {
- this.verifyShortenFileNameFileIntNonWin();
- }
- }
-
- private void verifyShortenFileNameFileIntWin() {
- File file = new File("C:\\Documents and Settings\\Administrator\\Desktop\\Project\\Text.txt");
- String fileName = FileTools.shortenFileName(file, 31);
- assertEquals("C:\\...\\Desktop\\Project\\Text.txt", fileName);
- assertEquals(31, fileName.length());
-
- file = new File("C:/This is the file name.txt");
- fileName = FileTools.shortenFileName(file, 10);
- assertEquals("C:\\This is the file name.txt", fileName);
- assertEquals(28, fileName.length());
- }
-
- private void verifyShortenFileNameFileIntNonWin() {
- File file = new File("/home/administrator/documents and settings/desktop/Project/Text.txt");
- String fileName = FileTools.shortenFileName(file, 31);
- assertEquals("/home/.../desktop/Project/Text.txt", fileName);
- assertEquals(34, fileName.length());
-
- file = new File("/This is the file name.txt");
- fileName = FileTools.shortenFileName(file, 10);
- assertEquals("/This is the file name.txt", fileName);
- assertEquals(26, fileName.length());
- }
-
- public void testShortenFileNameURL() throws Exception {
- if (this.isExecutingOnWindows()) {
- this.verifyShortenFileNameURLWin();
- } else {
- this.verifyShortenFileNameURLNonWin();
- }
- }
-
- private void verifyShortenFileNameURLWin() throws Exception {
- URL url = new URL("file", "", "C:/Documents and Settings/Administrator/Desktop/Project/Text.txt");
- String fileName = FileTools.shortenFileName(url);
- assertEquals("C:\\Documents and Settings\\...\\Desktop\\Project\\Text.txt", fileName);
- assertTrue(fileName.length() <= FileTools.MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
- }
-
- private void verifyShortenFileNameURLNonWin() throws Exception {
- URL url = new URL("file", "", "/home/administrator/documents and settings/desktop/Project/Text.txt");
- String fileName = FileTools.shortenFileName(url);
- assertEquals("/home/administrator/.../desktop/Project/Text.txt", fileName);
- assertTrue(fileName.length() <= FileTools.MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
- }
-
- public void testShortenFileNameURLInt() throws Exception {
- if (this.isExecutingOnWindows()) {
- this.verifyShortenFileNameURLIntWin();
- } else {
- this.verifyShortenFileNameURLIntNonWin();
- }
- }
-
- private void verifyShortenFileNameURLIntWin() throws Exception {
- URL url = new URL("file", "", "/C:/Documents and Settings/Administrator/Desktop/Project/Text.txt");
- String fileName = FileTools.shortenFileName(url, 31);
- assertEquals("C:\\...\\Desktop\\Project\\Text.txt", fileName);
- assertEquals(31, fileName.length());
- }
-
- private void verifyShortenFileNameURLIntNonWin() throws Exception {
- URL url = new URL("file", "", "/home/administrator/documents and settings/desktop/Project/Text.txt");
- String fileName = FileTools.shortenFileName(url, 31);
- assertEquals("/home/.../desktop/Project/Text.txt", fileName);
- assertEquals(34, fileName.length());
- }
-
- private void verifyUnchangedAbsoluteFile(String fileName, String dirName) {
- File file = new File(fileName);
- File dir = new File(dirName);
- File absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(file, absoluteFile);
- }
-
- private File buildTempDir() throws IOException {
- // build a new directory for each test, to prevent any cross-test effects
- File dir = FileTools.newTemporaryDirectory(ClassTools.shortClassNameForObject(this) + "." + this.getName());
-
- File file0a = new File(dir, "file0a");
- file0a.createNewFile();
- File file0b = new File(dir, "file0b");
- file0b.createNewFile();
- File file0c = new File(dir, "file0c");
- file0c.createNewFile();
-
- File subdir1 = new File(dir, "subdir1");
- subdir1.mkdir();
- File file1a = new File(subdir1, "file1a");
- file1a.createNewFile();
- File file1b = new File(subdir1, "file1b");
- file1b.createNewFile();
-
- File subdir2 = new File(dir, "subdir2");
- subdir2.mkdir();
- File file2a = new File(subdir2, "file2a");
- file2a.createNewFile();
- File file2b = new File(subdir2, "file2b");
- file2b.createNewFile();
-
- File subdir3 = new File(subdir2, "subdir3");
- subdir3.mkdir();
- File file3a = new File(subdir3, "file3a");
- file3a.createNewFile();
- File file3b = new File(subdir3, "file3b");
- file3b.createNewFile();
-
- return dir;
- }
-
- private void deleteDir(File dir) {
- FileTools.deleteDirectory(dir);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java
deleted file mode 100644
index 96df7b6daa..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java
+++ /dev/null
@@ -1,493 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-
-import junit.framework.TestCase;
-
-public class HashBagTests extends TestCase {
- private HashBag<String> bag;
-
- public HashBagTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.bag = this.buildBag();
- }
-
- private HashBag<String> buildBag() {
- HashBag<String> b = new HashBag<String>();
- b.add(null);
- b.add(new String("one"));
- b.add(new String("two"));
- b.add(new String("two"));
- b.add(new String("three"));
- b.add(new String("three"));
- b.add(new String("three"));
- b.add(new String("four"));
- b.add(new String("four"));
- b.add(new String("four"));
- b.add(new String("four"));
- return b;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- private Collection<String> buildCollection() {
- Collection<String> c = new ArrayList<String>();
- c.add(new String("foo"));
- c.add(new String("foo"));
- c.add(new String("bar"));
- c.add(new String("bar"));
- c.add(new String("bar"));
- return c;
- }
-
- public void testCtorCollection() {
- Collection<String> c = this.buildCollection();
- Bag<String> b = new HashBag<String>(c);
- for (String s : c) {
- assertTrue(b.contains(s));
- }
- }
-
- public void testCtorIntFloat() {
- boolean exCaught;
-
- exCaught = false;
- try {
- this.bag = new HashBag<String>(-20, 0.66f);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- this.bag = new HashBag<String>(20, -0.66f);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAdd() {
- // the other adds took place in setUp
- assertTrue(this.bag.add("five"));
-
- assertTrue(this.bag.contains("one"));
- assertTrue(this.bag.contains("two"));
- assertTrue(this.bag.contains("three"));
- assertTrue(this.bag.contains("four"));
- assertTrue(this.bag.contains("five"));
- }
-
- public void testAddCount() {
- // the other adds took place in setUp
- this.bag.add("minus3", -3);
- this.bag.add("zero", 0);
- this.bag.add("five", 5);
-
- assertFalse(this.bag.contains("minus3"));
- assertFalse(this.bag.contains("zero"));
- assertEquals(1, this.bag.count("one"));
- assertEquals(2, this.bag.count("two"));
- assertEquals(3, this.bag.count("three"));
- assertEquals(4, this.bag.count("four"));
- assertEquals(5, this.bag.count("five"));
-
- this.bag.add("three", 2);
- assertEquals(5, this.bag.count("three"));
- }
-
- public void testAddAll() {
- Collection<String> c = this.buildCollection();
- assertTrue(this.bag.addAll(c));
- for (String s : c) {
- assertTrue(this.bag.contains(s));
- }
- }
-
- public void testClear() {
- assertTrue(this.bag.contains("one"));
- assertTrue(this.bag.contains("two"));
- assertTrue(this.bag.contains("three"));
- assertTrue(this.bag.contains("four"));
- assertTrue(this.bag.contains(null));
- assertEquals(11, this.bag.size());
- this.bag.clear();
- assertFalse(this.bag.contains("one"));
- assertFalse(this.bag.contains("two"));
- assertFalse(this.bag.contains("three"));
- assertFalse(this.bag.contains("four"));
- assertFalse(this.bag.contains(null));
- assertEquals(0, this.bag.size());
- }
-
- public void testClone() {
- Bag<String> bag2 = this.bag.clone();
- assertTrue(this.bag != bag2);
- assertEquals(this.bag, bag2);
- assertTrue(this.bag.hashCode() == bag2.hashCode());
- }
-
- public void testContains() {
- assertTrue(this.bag.contains(null));
- assertTrue(this.bag.contains("one"));
- assertTrue(this.bag.contains("two"));
- assertTrue(this.bag.contains("three"));
- assertTrue(this.bag.contains("four"));
- assertTrue(this.bag.contains(new String("four")));
- assertTrue(this.bag.contains("fo" + "ur"));
- assertFalse(this.bag.contains("five"));
- }
-
- public void testContainsAll() {
- Collection<String> c = new ArrayList<String>();
- c.add(null);
- c.add(new String("one"));
- c.add(new String("two"));
- c.add(new String("three"));
- c.add(new String("four"));
- assertTrue(this.bag.containsAll(c));
- }
-
- public void testCount() {
- assertEquals(0, this.bag.count("zero"));
- assertEquals(1, this.bag.count("one"));
- assertEquals(2, this.bag.count("two"));
- assertEquals(3, this.bag.count("three"));
- assertEquals(4, this.bag.count("four"));
- assertEquals(0, this.bag.count("five"));
- }
-
- public void testEquals() {
- Bag<String> bag2 = this.buildBag();
- assertEquals(this.bag, bag2);
- bag2.add("five");
- assertFalse(this.bag.equals(bag2));
- Collection<String> c = new ArrayList<String>(this.bag);
- assertFalse(this.bag.equals(c));
- }
-
- public void testHashCode() {
- Bag<String> bag2 = this.buildBag();
- assertEquals(this.bag.hashCode(), bag2.hashCode());
- }
-
- public void testIsEmpty() {
- assertFalse(this.bag.isEmpty());
- this.bag.clear();
- assertTrue(this.bag.isEmpty());
- this.bag.add("foo");
- assertFalse(this.bag.isEmpty());
- }
-
- public void testEmptyIterator() {
- this.bag.clear();
- Iterator<String> iterator = this.bag.iterator();
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- fail(element.toString());
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testIterator() {
- int i = 0;
- Iterator<String> iterator = this.bag.iterator();
- assertTrue(iterator.hasNext());
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(11, i);
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- fail(element.toString());
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- iterator.remove();
- assertEquals(10, this.bag.size());
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.iterator();
- this.bag.add("five");
- exCaught = false;
- try {
- iterator.next();
- } catch (ConcurrentModificationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testUniqueIterator() {
- int i = 0;
- Iterator<String> iterator = this.bag.uniqueIterator();
- assertTrue(iterator.hasNext());
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(5, i);
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- fail(element.toString());
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.uniqueIterator();
- Object next = null;
- while (iterator.hasNext() && !"four".equals(next)) {
- next = iterator.next();
- }
- iterator.remove();
- assertEquals(7, this.bag.size());
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.uniqueIterator();
- this.bag.add("five");
- exCaught = false;
- try {
- iterator.next();
- } catch (ConcurrentModificationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-//TODO - poor load factor is seen in the Eclipse build environment for some reason
-// public void testHashingDistribution() throws Exception {
-// Bag<String> bigBag = new HashBag<String>();
-// for (int i = 0; i < 10000; i++) {
-// bigBag.add("object" + i);
-// }
-//
-// java.lang.reflect.Field field = bigBag.getClass().getDeclaredField("table");
-// field.setAccessible(true);
-// Object[] table = (Object[]) field.get(bigBag);
-// int bucketCount = table.length;
-// int filledBucketCount = 0;
-// for (Object o : table) {
-// if (o != null) {
-// filledBucketCount++;
-// }
-// }
-// float loadFactor = ((float) filledBucketCount) / ((float) bucketCount);
-// assertTrue("WARNING - poor load factor: " + loadFactor, loadFactor > 0.20);
-// assertTrue("WARNING - poor load factor: " + loadFactor, loadFactor < 0.75);
-// }
-
- public void testRemove() {
- assertTrue(this.bag.remove("one"));
- assertFalse(this.bag.contains("one"));
- assertFalse(this.bag.remove("one"));
-
- assertTrue(this.bag.remove("two"));
- assertTrue(this.bag.remove("two"));
- assertFalse(this.bag.contains("two"));
- assertFalse(this.bag.remove("two"));
- }
-
- public void testRemoveCount() {
- assertFalse(this.bag.remove("one", 0));
- assertTrue(this.bag.contains("one"));
-
- assertTrue(this.bag.remove("one", 1));
- assertFalse(this.bag.contains("one"));
- assertFalse(this.bag.remove("one"));
-
- assertFalse(this.bag.remove("two", -3));
- assertTrue(this.bag.remove("two", 1));
- assertTrue(this.bag.contains("two"));
-
- assertTrue(this.bag.remove("two", 1));
- assertFalse(this.bag.contains("two"));
- assertFalse(this.bag.remove("two"));
-
- assertTrue(this.bag.remove("three", 3));
- assertFalse(this.bag.contains("three"));
- assertFalse(this.bag.remove("three"));
- }
-
- public void testRemoveAll() {
- Collection<String> c = new ArrayList<String>();
- c.add("one");
- c.add("three");
- assertTrue(this.bag.removeAll(c));
- assertFalse(this.bag.contains("one"));
- assertFalse(this.bag.contains("three"));
- assertFalse(this.bag.remove("one"));
- assertFalse(this.bag.remove("three"));
- assertFalse(this.bag.removeAll(c));
- }
-
- public void testRetainAll() {
- Collection<String> c = new ArrayList<String>();
- c.add("one");
- c.add("three");
- assertTrue(this.bag.retainAll(c));
- assertTrue(this.bag.contains("one"));
- assertTrue(this.bag.contains("three"));
- assertFalse(this.bag.contains("two"));
- assertFalse(this.bag.contains("four"));
- assertFalse(this.bag.remove("two"));
- assertFalse(this.bag.remove("four"));
- assertFalse(this.bag.retainAll(c));
- }
-
- public void testSize() {
- assertTrue(this.bag.size() == 11);
- this.bag.add("five");
- this.bag.add("five");
- this.bag.add("five");
- this.bag.add("five");
- this.bag.add("five");
- assertEquals(16, this.bag.size());
- }
-
- public void testSerialization() throws Exception {
- Bag<String> bag2 = TestTools.serialize(this.bag);
-
- assertTrue("same object?", this.bag != bag2);
- assertEquals(11, bag2.size());
- assertEquals(this.bag, bag2);
- // look for similar elements
- assertTrue(bag2.contains(null));
- assertTrue(bag2.contains("one"));
- assertTrue(bag2.contains("two"));
- assertTrue(bag2.contains("three"));
- assertTrue(bag2.contains("four"));
-
- int nullCount = 0, oneCount = 0, twoCount = 0, threeCount = 0, fourCount = 0;
- for (String s : bag2) {
- if (s == null) {
- nullCount++;
- } else if (s.equals("one")) {
- oneCount++;
- } else if (s.equals("two")) {
- twoCount++;
- } else if (s.equals("three")) {
- threeCount++;
- } else if (s.equals("four")) {
- fourCount++;
- }
- }
- assertEquals(1, nullCount);
- assertEquals(1, oneCount);
- assertEquals(2, twoCount);
- assertEquals(3, threeCount);
- assertEquals(4, fourCount);
- }
-
- public void testToArray() {
- Object[] a = this.bag.toArray();
- assertEquals(11, a.length);
- assertTrue(CollectionTools.contains(a, null));
- assertTrue(CollectionTools.contains(a, "one"));
- assertTrue(CollectionTools.contains(a, "two"));
- assertTrue(CollectionTools.contains(a, "three"));
- assertTrue(CollectionTools.contains(a, "four"));
- }
-
- public void testToArrayObjectArray() {
- String[] a = new String[12];
- a[11] = "not null";
- String[] b = this.bag.toArray(a);
- assertEquals(a, b);
- assertEquals(12, a.length);
- assertTrue(CollectionTools.contains(a, null));
- assertTrue(CollectionTools.contains(a, "one"));
- assertTrue(CollectionTools.contains(a, "two"));
- assertTrue(CollectionTools.contains(a, "three"));
- assertTrue(CollectionTools.contains(a, "four"));
- assertTrue(a[11] == null);
- }
-
- public void testToString() {
- String s = this.bag.toString();
- assertTrue(s.startsWith("["));
- assertTrue(s.endsWith("]"));
- int commaCount = 0;
- for (int i = 0; i < s.length(); i++) {
- if (s.charAt(i) == ',') {
- commaCount++;
- }
- }
- assertEquals(10, commaCount);
- assertTrue(s.indexOf("one") != -1);
- assertTrue(s.indexOf("two") != -1);
- assertTrue(s.indexOf("three") != -1);
- assertTrue(s.indexOf("four") != -1);
- assertTrue(s.indexOf("null") != -1);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IdentityHashBagTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IdentityHashBagTests.java
deleted file mode 100644
index a819b29fba..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IdentityHashBagTests.java
+++ /dev/null
@@ -1,511 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.IdentityHashBag;
-
-import junit.framework.TestCase;
-
-public class IdentityHashBagTests extends TestCase {
- private IdentityHashBag<String> bag;
- private String one = "one";
- private String two = "two";
- private String three = "three";
- private String four = "four";
- private String foo = "foo";
- private String bar = "bar";
-
- public IdentityHashBagTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.bag = this.buildBag();
- }
-
- protected IdentityHashBag<String> buildBag() {
- IdentityHashBag<String> result = new IdentityHashBag<String>();
- result.add(null);
- result.add(this.one);
- result.add(this.two);
- result.add(this.two);
- result.add(this.three);
- result.add(this.three);
- result.add(this.three);
- result.add(this.four);
- result.add(this.four);
- result.add(this.four);
- result.add(this.four);
- return result;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- private Collection<String> buildCollection() {
- Collection<String> c = new ArrayList<String>();
- c.add(this.foo);
- c.add(this.foo);
- c.add(this.bar);
- c.add(this.bar);
- c.add(this.bar);
- return c;
- }
-
- public void testCtorCollection() {
- Collection<String> c = this.buildCollection();
- IdentityHashBag<String> localBag = new IdentityHashBag<String>(c);
- for (String s : c) {
- assertTrue(localBag.contains(s));
- }
- }
-
- public void testCtorIntFloat() {
- boolean exCaught;
-
- exCaught = false;
- try {
- this.bag = new IdentityHashBag<String>(-20, 0.66f);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue("IllegalArgumentException not thrown", exCaught);
-
- exCaught = false;
- try {
- this.bag = new IdentityHashBag<String>(20, -0.66f);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue("IllegalArgumentException not thrown", exCaught);
- }
-
- public void testAdd() {
- // the other adds took place in setUp
- String five = "five";
- assertTrue(this.bag.add(five));
-
- assertTrue(this.bag.contains(this.one));
- assertTrue(this.bag.contains(this.two));
- assertTrue(this.bag.contains(this.three));
- assertTrue(this.bag.contains(this.four));
- assertTrue(this.bag.contains(five));
- }
-
- public void testAddCount() {
- String minus3 = "minus3";
- String zero = "zero";
- String five = "five";
- // the other adds took place in setUp
- this.bag.add(minus3, -3);
- this.bag.add(zero, 0);
- this.bag.add(five, 5);
-
- assertFalse(this.bag.contains(minus3));
- assertFalse(this.bag.contains(zero));
- assertEquals(1, this.bag.count(this.one));
- assertEquals(2, this.bag.count(this.two));
- assertEquals(3, this.bag.count(this.three));
- assertEquals(4, this.bag.count(this.four));
- assertEquals(5, this.bag.count(five));
-
- this.bag.add(this.three, 2);
- assertEquals(5, this.bag.count(this.three));
- }
-
- public void testAddAll() {
- Collection<String> c = this.buildCollection();
- assertTrue(this.bag.addAll(c));
- for (String s : c) {
- assertTrue(this.bag.contains(s));
- }
- }
-
- public void testClear() {
- assertTrue(this.bag.contains(this.one));
- assertTrue(this.bag.contains(this.two));
- assertTrue(this.bag.contains(this.three));
- assertTrue(this.bag.contains(this.four));
- assertTrue(this.bag.contains(null));
- assertEquals(11, this.bag.size());
- this.bag.clear();
- assertFalse(this.bag.contains(this.one));
- assertFalse(this.bag.contains(this.two));
- assertFalse(this.bag.contains(this.three));
- assertFalse(this.bag.contains(this.four));
- assertFalse(this.bag.contains(null));
- assertEquals(0, this.bag.size());
- }
-
- public void testClone() {
- IdentityHashBag<String> bag2 = this.bag.clone();
- assertTrue("bad clone", this.bag != bag2);
- assertEquals("bad clone", this.bag, bag2);
- assertTrue("bad clone", this.bag.hashCode() == bag2.hashCode());
- }
-
- public void testContains() {
- assertTrue(this.bag.contains(null));
- assertTrue(this.bag.contains(this.one));
- assertTrue(this.bag.contains(this.two));
- assertTrue(this.bag.contains(this.three));
- assertTrue(this.bag.contains(this.four));
-
- assertFalse(this.bag.contains(new String("four")));
- assertFalse(this.bag.contains("five"));
- }
-
- public void testContainsAll() {
- Collection<String> c = new ArrayList<String>();
- c.add(null);
- c.add(this.one);
- c.add(this.two);
- c.add(this.three);
- c.add(this.four);
- assertTrue(this.bag.containsAll(c));
- c.add(new String(this.four));
- assertFalse(this.bag.containsAll(c));
- }
-
- public void testCount() {
- assertEquals(0, this.bag.count("zero"));
- assertEquals(1, this.bag.count("one"));
- assertEquals(2, this.bag.count("two"));
- assertEquals(3, this.bag.count("three"));
- assertEquals(4, this.bag.count("four"));
- assertEquals(0, this.bag.count("five"));
- }
-
- public void testEquals() {
- IdentityHashBag<String> bag2 = this.buildBag();
- assertEquals(this.bag, bag2);
- bag2.add("five");
- assertFalse(this.bag.equals(bag2));
- Collection<String> c = new ArrayList<String>(this.bag);
- assertFalse(this.bag.equals(c));
- }
-
- public void testHashCode() {
- IdentityHashBag<String> bag2 = this.buildBag();
- assertEquals(this.bag.hashCode(), bag2.hashCode());
- }
-
- public void testIsEmpty() {
- assertFalse(this.bag.isEmpty());
- this.bag.clear();
- assertTrue(this.bag.isEmpty());
- this.bag.add("foo");
- assertFalse(this.bag.isEmpty());
- }
-
- public void testEmptyIterator() {
- this.bag.clear();
- Iterator<String> iterator = this.bag.iterator();
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + element, exCaught);
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
-
- public void testIterator() {
- int i = 0;
- Iterator<String> iterator = this.bag.iterator();
- assertTrue(iterator.hasNext());
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(11, i);
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + element, exCaught);
-
- iterator.remove();
- assertEquals(10, this.bag.size());
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
-
- // start over
- iterator = this.bag.iterator();
- this.bag.add("five");
- exCaught = false;
- try {
- iterator.next();
- } catch (ConcurrentModificationException ex) {
- exCaught = true;
- }
- assertTrue("ConcurrentModificationException not thrown", exCaught);
- }
-
- public void testUniqueIterator() {
- int i = 0;
- Iterator<String> iterator = this.bag.uniqueIterator();
- assertTrue(iterator.hasNext());
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(5, i);
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- fail(element.toString());
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.uniqueIterator();
- Object next = null;
- while (iterator.hasNext() && !this.four.equals(next)) {
- next = iterator.next();
- }
- iterator.remove();
- assertEquals(7, this.bag.size());
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.uniqueIterator();
- String five = "five";
- this.bag.add(five);
- exCaught = false;
- try {
- iterator.next();
- } catch (ConcurrentModificationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- // Commenting out this test as it is also failing in the Eclipse build
- // apparenly there are some hashing issues that need to be looked into.
-// public void testHashingDistribution() throws Exception {
-// IdentityHashBag<String> bigBag = new IdentityHashBag<String>();
-// for (int i = 0; i < 10000; i++) {
-// bigBag.add("object" + i);
-// }
-//
-// java.lang.reflect.Field field = bigBag.getClass().getDeclaredField("table");
-// field.setAccessible(true);
-// Object[] table = (Object[]) field.get(bigBag);
-// int bucketCount = table.length;
-// int filledBucketCount = 0;
-// for (int i = 0; i < bucketCount; i++) {
-// if (table[i] != null) {
-// filledBucketCount++;
-// }
-// }
-// float loadFactor = ((float) filledBucketCount)/((float) bucketCount);
-// // System.out.println("load factor: " + loadFactor + " (" + filledBucketCount + "/" + bucketCount + ")");
-// assertTrue("WARNING - poor load factor: " + loadFactor, loadFactor > 0.20);
-// assertTrue("WARNING - poor load factor: " + loadFactor, loadFactor < 0.75);
-// }
-
- public void testRemove() {
- assertTrue(this.bag.remove(this.one));
- assertFalse(this.bag.contains(this.one));
- assertFalse(this.bag.remove(this.one));
-
- assertTrue(this.bag.remove(this.two));
- assertTrue(this.bag.remove(this.two));
- assertFalse(this.bag.contains(this.two));
- assertFalse(this.bag.remove(this.two));
-
- assertFalse(this.bag.remove(new String(this.three)));
- }
-
- public void testRemoveCount() {
- assertFalse(this.bag.remove(this.one, 0));
- assertTrue(this.bag.contains(this.one));
-
- assertTrue(this.bag.remove(this.one, 1));
- assertFalse(this.bag.contains(this.one));
- assertFalse(this.bag.remove(this.one));
-
- assertFalse(this.bag.remove(this.two, -3));
- assertTrue(this.bag.remove(this.two, 1));
- assertTrue(this.bag.contains(this.two));
-
- assertTrue(this.bag.remove(this.two, 1));
- assertFalse(this.bag.contains(this.two));
- assertFalse(this.bag.remove(this.two));
-
- assertTrue(this.bag.remove(this.three, 3));
- assertFalse(this.bag.contains(this.three));
- assertFalse(this.bag.remove(this.three));
- }
-
- public void testRemoveAll() {
- Collection<String> c = new ArrayList<String>();
- c.add(this.one);
- c.add(new String(this.two));
- c.add(this.three);
- assertTrue(this.bag.removeAll(c));
- assertFalse(this.bag.contains(this.one));
- assertTrue(this.bag.contains(this.two));
- assertFalse(this.bag.contains(this.three));
- assertFalse(this.bag.remove(this.one));
- assertTrue(this.bag.remove(this.two));
- assertFalse(this.bag.remove(this.three));
- assertFalse(this.bag.removeAll(c));
- }
-
- public void testRetainAll() {
- Collection<String> c = new ArrayList<String>();
- c.add(this.one);
- c.add(new String(this.two));
- c.add(this.three);
- assertTrue(this.bag.retainAll(c));
- assertTrue(this.bag.contains(this.one));
- assertFalse(this.bag.contains(this.two));
- assertTrue(this.bag.contains(this.three));
- assertFalse(this.bag.contains(this.four));
- assertFalse(this.bag.remove(this.two));
- assertFalse(this.bag.remove(this.four));
- assertFalse(this.bag.retainAll(c));
- }
-
- public void testSize() {
- assertTrue(this.bag.size() == 11);
- String five = "five";
- this.bag.add(five);
- this.bag.add(five);
- this.bag.add(five);
- this.bag.add(five);
- this.bag.add(new String(five));
- assertEquals(16, this.bag.size());
- }
-
- public void testSerialization() throws Exception {
- IdentityHashBag<String> bag2 = TestTools.serialize(this.bag);
-
- assertTrue("same object?", this.bag != bag2);
- assertEquals(11, bag2.size());
- assertEquals(CollectionTools.bag(this.bag.iterator()), CollectionTools.bag(bag2.iterator()));
- // look for similar elements
- assertTrue(CollectionTools.bag(bag2.iterator()).contains(null));
- assertTrue(CollectionTools.bag(bag2.iterator()).contains("one"));
- assertTrue(CollectionTools.bag(bag2.iterator()).contains("two"));
- assertTrue(CollectionTools.bag(bag2.iterator()).contains("three"));
- assertTrue(CollectionTools.bag(bag2.iterator()).contains("four"));
-
- int nullCount = 0, oneCount = 0, twoCount = 0, threeCount = 0, fourCount = 0;
- for (String next : bag2) {
- if (next == null)
- nullCount++;
- else if (next.equals("one"))
- oneCount++;
- else if (next.equals("two"))
- twoCount++;
- else if (next.equals("three"))
- threeCount++;
- else if (next.equals("four"))
- fourCount++;
- }
- assertEquals(1, nullCount);
- assertEquals(1, oneCount);
- assertEquals(2, twoCount);
- assertEquals(3, threeCount);
- assertEquals(4, fourCount);
- }
-
- public void testToArray() {
- Object[] a = this.bag.toArray();
- assertEquals(11, a.length);
- assertTrue(CollectionTools.contains(a, null));
- assertTrue(CollectionTools.contains(a, this.one));
- assertTrue(CollectionTools.contains(a, this.two));
- assertTrue(CollectionTools.contains(a, this.three));
- assertTrue(CollectionTools.contains(a, this.four));
- }
-
- public void testToArrayObjectArray() {
- String[] a = new String[12];
- a[11] = "not null";
- String[] b = this.bag.toArray(a);
- assertEquals(a, b);
- assertEquals(12, a.length);
- assertTrue(CollectionTools.contains(a, null));
- assertTrue(CollectionTools.contains(a, this.one));
- assertTrue(CollectionTools.contains(a, this.two));
- assertTrue(CollectionTools.contains(a, this.three));
- assertTrue(CollectionTools.contains(a, this.four));
- assertTrue(a[11] == null);
- }
-
- public void testToString() {
- String s = this.bag.toString();
- assertTrue(s.startsWith("["));
- assertTrue(s.endsWith("]"));
- int commaCount = 0;
- for (int i = 0; i < s.length(); i++) {
- if (s.charAt(i) == ',') {
- commaCount++;
- }
- }
- assertEquals("invalid number of commas", 10, commaCount);
- assertTrue(s.indexOf("one") != -1);
- assertTrue(s.indexOf("two") != -1);
- assertTrue(s.indexOf("three") != -1);
- assertTrue(s.indexOf("four") != -1);
- assertTrue(s.indexOf("null") != -1);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IndentingPrintWriterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IndentingPrintWriterTests.java
deleted file mode 100644
index b971895bc1..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IndentingPrintWriterTests.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.io.StringWriter;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.IndentingPrintWriter;
-
-public class IndentingPrintWriterTests extends TestCase {
- StringWriter sw1;
- StringWriter sw2;
- IndentingPrintWriter ipw1;
- IndentingPrintWriter ipw2;
-
- static final String CR = System.getProperty("line.separator");
-
- public IndentingPrintWriterTests(String name) {
- super(name);
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- this.sw1 = new StringWriter();
- this.ipw1 = new IndentingPrintWriter(this.sw1);
- this.sw2 = new StringWriter();
- this.ipw2 = new IndentingPrintWriter(this.sw2, " "); // indent with 4 spaces instead of a tab
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIndent() {
- assertEquals("wrong indent level", 0, this.ipw1.indentLevel());
- this.ipw1.indent();
- assertEquals("wrong indent level", 1, this.ipw1.indentLevel());
- }
-
- public void testUndent() {
- assertEquals("wrong indent level", 0, this.ipw1.indentLevel());
- this.ipw1.indent();
- assertEquals("wrong indent level", 1, this.ipw1.indentLevel());
- this.ipw1.undent();
- assertEquals("wrong indent level", 0, this.ipw1.indentLevel());
- }
-
- public void testIncrementIndentLevel() {
- assertEquals("wrong indent level", 0, this.ipw1.indentLevel());
- this.ipw1.incrementIndentLevel();
- assertEquals("wrong indent level", 1, this.ipw1.indentLevel());
- }
-
- public void testDecrementIndentLevel() {
- assertEquals("wrong indent level", 0, this.ipw1.indentLevel());
- this.ipw1.incrementIndentLevel();
- assertEquals("wrong indent level", 1, this.ipw1.indentLevel());
- this.ipw1.decrementIndentLevel();
- assertEquals("wrong indent level", 0, this.ipw1.indentLevel());
- }
-
- public void testPrintTab() {
- String expected = "foo0" + CR + "\tfoo1" + CR + "\tfoo1" + CR + "\t\tfoo2" + CR + "\tfoo1" + CR + "\tfoo1" + CR + "foo0" + CR;
-
- this.ipw1.println("foo0");
- this.ipw1.indent();
- this.ipw1.println("foo1");
- this.ipw1.println("foo1");
- this.ipw1.indent();
- this.ipw1.println("foo2");
- this.ipw1.undent();
- this.ipw1.println("foo1");
- this.ipw1.println("foo1");
- this.ipw1.undent();
- this.ipw1.println("foo0");
-
- assertEquals("bogus output", expected, this.sw1.toString());
- }
-
- public void testPrintSpaces() {
- String expected = "foo0" + CR + " foo1" + CR + " foo1" + CR + " foo2" + CR + " foo1" + CR + " foo1" + CR + "foo0" + CR;
-
- this.ipw2.println("foo0");
- this.ipw2.indent();
- this.ipw2.println("foo1");
- this.ipw2.println("foo1");
- this.ipw2.indent();
- this.ipw2.println("foo2");
- this.ipw2.undent();
- this.ipw2.println("foo1");
- this.ipw2.println("foo1");
- this.ipw2.undent();
- this.ipw2.println("foo0");
-
- assertEquals("bogus output", expected, this.sw2.toString());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java
deleted file mode 100644
index 07dad198b5..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.sql.Types;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.JDBCType;
-
-public class JDBCTypeTests extends TestCase {
-
- public JDBCTypeTests(String name) {
- super(name);
- }
-
- public void testTypesSize() {
- assertEquals(Types.class.getDeclaredFields().length, JDBCType.types().length);
- }
-
- public void testName() {
- JDBCType jdbcType;
- jdbcType = JDBCType.type(Types.VARCHAR);
- assertEquals("VARCHAR", jdbcType.name());
-
- jdbcType = JDBCType.type(Types.INTEGER);
- assertEquals("INTEGER", jdbcType.name());
- }
-
- public void testCode() {
- JDBCType jdbcType;
- jdbcType = JDBCType.type(Types.VARCHAR);
- assertEquals(Types.VARCHAR, jdbcType.code());
-
- jdbcType = JDBCType.type(Types.INTEGER);
- assertEquals(Types.INTEGER, jdbcType.code());
- }
-
- public void testInvalidTypeCode() throws Exception {
- boolean exCaught = false;
- try {
- JDBCType jdbcType = JDBCType.type(55);
- fail("invalid JDBCType: " + jdbcType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidTypeName() throws Exception {
- boolean exCaught = false;
- try {
- JDBCType jdbcType = JDBCType.type("VARCHAR2");
- fail("invalid JDBCType: " + jdbcType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JavaTypeTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JavaTypeTests.java
deleted file mode 100644
index e26336ab6c..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JavaTypeTests.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import org.eclipse.jpt.utility.JavaType;
-import org.eclipse.jpt.utility.internal.SimpleJavaType;
-
-import junit.framework.TestCase;
-
-public class JavaTypeTests extends TestCase {
-
- public JavaTypeTests(String name) {
- super(name);
- }
-
- public void testInvalidElementTypeNull() throws Exception {
- boolean exCaught = false;
- try {
- JavaType javaType = new SimpleJavaType(null, 0);
- fail("invalid JavaType: " + javaType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidElementTypeEmpty() throws Exception {
- boolean exCaught = false;
- try {
- JavaType javaType = new SimpleJavaType("", 0);
- fail("invalid JavaType: " + javaType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidElementTypeArray() throws Exception {
- boolean exCaught = false;
- try {
- JavaType javaType = new SimpleJavaType(java.lang.Object[].class.getName(), 0);
- fail("invalid JavaType: " + javaType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidArrayDepthNegative() throws Exception {
- boolean exCaught = false;
- try {
- JavaType javaType = new SimpleJavaType(java.lang.Object.class.getName(), -2);
- fail("invalid JavaType: " + javaType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidVoidArray() throws Exception {
- boolean exCaught = false;
- try {
- JavaType javaType = new SimpleJavaType(void.class.getName(), 2);
- fail("invalid JavaType: " + javaType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testElementTypeName() throws Exception {
- JavaType javaType;
- javaType = new SimpleJavaType(java.lang.Object.class);
- assertEquals("java.lang.Object", javaType.getElementTypeName());
-
- javaType = new SimpleJavaType(java.lang.Object[].class);
- assertEquals("java.lang.Object", javaType.getElementTypeName());
-
- javaType = new SimpleJavaType(int.class);
- assertEquals("int", javaType.getElementTypeName());
-
- javaType = new SimpleJavaType(int[].class);
- assertEquals("int", javaType.getElementTypeName());
-
- javaType = new SimpleJavaType(void.class);
- assertEquals("void", javaType.getElementTypeName());
-
- javaType = new SimpleJavaType(java.util.Map.Entry.class);
- assertEquals("java.util.Map$Entry", javaType.getElementTypeName());
-
- javaType = new SimpleJavaType(java.util.Map.Entry[][].class);
- assertEquals("java.util.Map$Entry", javaType.getElementTypeName());
- }
-
- public void testArrayDepth() throws Exception {
- JavaType javaType;
- javaType = new SimpleJavaType(java.lang.Object.class);
- assertEquals(0, javaType.getArrayDepth());
-
- javaType = new SimpleJavaType(java.lang.Object[].class);
- assertEquals(1, javaType.getArrayDepth());
-
- javaType = new SimpleJavaType(int.class);
- assertEquals(0, javaType.getArrayDepth());
-
- javaType = new SimpleJavaType(int[].class);
- assertEquals(1, javaType.getArrayDepth());
-
- javaType = new SimpleJavaType(void.class);
- assertEquals(0, javaType.getArrayDepth());
-
- javaType = new SimpleJavaType(java.util.Map.Entry.class);
- assertEquals(0, javaType.getArrayDepth());
-
- javaType = new SimpleJavaType(java.util.Map.Entry[][].class);
- assertEquals(2, javaType.getArrayDepth());
- }
-
- public void testIsArray() throws Exception {
- JavaType javaType;
- javaType = new SimpleJavaType(java.lang.Object.class);
- assertFalse(javaType.isArray());
-
- javaType = new SimpleJavaType(java.lang.Object[].class);
- assertTrue(javaType.isArray());
-
- javaType = new SimpleJavaType(int.class);
- assertFalse(javaType.isArray());
-
- javaType = new SimpleJavaType(int[].class);
- assertTrue(javaType.isArray());
-
- javaType = new SimpleJavaType(void.class);
- assertFalse(javaType.isArray());
-
- javaType = new SimpleJavaType(java.util.Map.Entry.class);
- assertFalse(javaType.isArray());
-
- javaType = new SimpleJavaType(java.util.Map.Entry[][].class);
- assertTrue(javaType.isArray());
- }
-
- public void testJavaClass() throws Exception {
- this.verifyJavaClass(java.lang.Object.class);
- this.verifyJavaClass(java.lang.Object[].class);
- this.verifyJavaClass(int.class);
- this.verifyJavaClass(int[].class);
- this.verifyJavaClass(void.class);
- this.verifyJavaClass(java.util.Map.Entry.class);
- this.verifyJavaClass(java.util.Map.Entry[][].class);
- }
-
- private void verifyJavaClass(Class<?> javaClass) throws Exception {
- JavaType javaType = new SimpleJavaType(javaClass);
- assertEquals(javaClass, javaType.getJavaClass());
- }
-
- public void testJavaClassName() throws Exception {
- JavaType javaType;
- javaType = new SimpleJavaType(java.lang.Object.class);
- assertEquals("java.lang.Object", javaType.getJavaClassName());
-
- javaType = new SimpleJavaType(java.lang.Object[].class);
- assertEquals("[Ljava.lang.Object;", javaType.getJavaClassName());
-
- javaType = new SimpleJavaType(int.class);
- assertEquals("int", javaType.getJavaClassName());
-
- javaType = new SimpleJavaType(int[].class);
- assertEquals("[I", javaType.getJavaClassName());
-
- javaType = new SimpleJavaType(void.class);
- assertEquals("void", javaType.getJavaClassName());
-
- javaType = new SimpleJavaType(java.util.Map.Entry.class);
- assertEquals("java.util.Map$Entry", javaType.getJavaClassName());
-
- javaType = new SimpleJavaType(java.util.Map.Entry[][].class);
- assertEquals("[[Ljava.util.Map$Entry;", javaType.getJavaClassName());
- }
-
- public void testDescribes() throws Exception {
- this.verifyDescribes(java.lang.Object.class);
- this.verifyDescribes(java.lang.Object[].class);
- this.verifyDescribes(int.class);
- this.verifyDescribes(int[].class);
- this.verifyDescribes(void.class);
- this.verifyDescribes(java.util.Map.Entry.class);
- this.verifyDescribes(java.util.Map.Entry[][].class);
- }
-
- private void verifyDescribes(Class<?> javaClass) throws Exception {
- JavaType javaType = new SimpleJavaType(javaClass);
- assertTrue(javaType.describes(javaClass));
- }
-
- public void testDeclaration() throws Exception {
- JavaType javaType;
- javaType = new SimpleJavaType(java.lang.Object.class);
- assertEquals("java.lang.Object", javaType.declaration());
-
- javaType = new SimpleJavaType(java.lang.Object[].class);
- assertEquals("java.lang.Object[]", javaType.declaration());
-
- javaType = new SimpleJavaType(int.class);
- assertEquals("int", javaType.declaration());
-
- javaType = new SimpleJavaType(int[].class);
- assertEquals("int[]", javaType.declaration());
-
- javaType = new SimpleJavaType(void.class);
- assertEquals("void", javaType.declaration());
-
- javaType = new SimpleJavaType(java.util.Map.Entry.class);
- assertEquals("java.util.Map.Entry", javaType.declaration());
-
- javaType = new SimpleJavaType(java.util.Map.Entry[][].class);
- assertEquals("java.util.Map.Entry[][]", javaType.declaration());
- }
-
- public void testIsPrimitive() throws Exception {
- JavaType javaType;
- javaType = new SimpleJavaType(java.lang.Object.class);
- assertFalse(javaType.isPrimitive());
-
- javaType = new SimpleJavaType(java.lang.Object[].class);
- assertFalse(javaType.isPrimitive());
-
- javaType = new SimpleJavaType(int.class);
- assertTrue(javaType.isPrimitive());
-
- javaType = new SimpleJavaType(int[].class);
- assertFalse(javaType.isPrimitive());
-
- javaType = new SimpleJavaType(void.class);
- assertTrue(javaType.isPrimitive());
-
- javaType = new SimpleJavaType(java.util.Map.Entry.class);
- assertFalse(javaType.isPrimitive());
-
- javaType = new SimpleJavaType(java.util.Map.Entry[][].class);
- assertFalse(javaType.isPrimitive());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java
deleted file mode 100644
index c411aaf4f4..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import org.eclipse.jpt.utility.tests.internal.iterators.JptUtilityIteratorsTests;
-import org.eclipse.jpt.utility.tests.internal.model.JptUtilityModelTests;
-import org.eclipse.jpt.utility.tests.internal.node.JptUtilityNodeTests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptUtilityTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityTests.class.getPackage().getName());
-
- suite.addTest(JptUtilityIteratorsTests.suite());
- suite.addTest(JptUtilityModelTests.suite());
- suite.addTest(JptUtilityNodeTests.suite());
-
- suite.addTestSuite(BitToolsTests.class);
- suite.addTestSuite(ClasspathTests.class);
- suite.addTestSuite(ClassToolsTests.class);
- suite.addTestSuite(CollectionToolsTests.class);
- suite.addTestSuite(CounterTests.class);
- suite.addTestSuite(EmptyIterableTests.class);
- suite.addTestSuite(FileToolsTests.class);
- suite.addTestSuite(HashBagTests.class);
- suite.addTestSuite(IdentityHashBagTests.class);
- suite.addTestSuite(IndentingPrintWriterTests.class);
- suite.addTestSuite(JavaTypeTests.class);
- suite.addTestSuite(JDBCTypeTests.class);
- suite.addTestSuite(NameToolsTests.class);
- suite.addTestSuite(ReverseComparatorTests.class);
- suite.addTestSuite(SimpleAssociationTests.class);
- suite.addTestSuite(SimpleStackTests.class);
- suite.addTestSuite(StringToolsTests.class);
- suite.addTestSuite(SynchronizedBooleanTests.class);
- suite.addTestSuite(SynchronizedObjectTests.class);
- suite.addTestSuite(SynchronizedStackTests.class);
- suite.addTestSuite(XMLStringEncoderTests.class);
-
- return suite;
- }
-
- private JptUtilityTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/NameToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/NameToolsTests.java
deleted file mode 100644
index 52b30b49c3..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/NameToolsTests.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.NameTools;
-
-public class NameToolsTests extends TestCase {
-
- public NameToolsTests(String name) {
- super(name);
- }
-
- public void testStringAbsentIgnoreCase() {
- List<String> colorCollection = this.buildColorCollection();
- String returned = NameTools.uniqueNameForIgnoreCase("Taupe", colorCollection);
- assertEquals("Taupe", returned);
- }
-
- public void testStringPresentCaseDiffers() {
- List<String> colorCollection = this.buildColorCollection();
- String returned = NameTools.uniqueNameFor("green", colorCollection);
- assertEquals("green", returned);
- }
-
- public void testStringPresentIgnoreCase() {
- List<String> colorCollection = this.buildColorCollection();
- String returned = NameTools.uniqueNameForIgnoreCase("green", colorCollection);
- assertEquals("green2", returned);
- }
-
- public void testStringPresentWithAppendices() {
- List<String> colorCollection = this.buildColorCollection();
- colorCollection.add("Red1");
- colorCollection.add("red2");
- String returned = NameTools.uniqueNameForIgnoreCase("red", colorCollection);
- colorCollection.remove("Red1");
- colorCollection.remove("red2");
- assertEquals("red3", returned);
- }
-
- private List<String> buildColorCollection() {
- List<String> colorCollection = new ArrayList<String>();
- colorCollection.add("Red");
- colorCollection.add("Orange");
- colorCollection.add("Yellow");
- colorCollection.add("Green");
- colorCollection.add("Blue");
- colorCollection.add("Indigo");
- colorCollection.add("Violet");
- return colorCollection;
- }
-
- public void testUniqueNameForCollection1() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("Oracle Corporation");
- strings.add("Oracle2");
- strings.add("oracle1");
- strings.add("Oracl");
-
- assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings));
- assertEquals("Test", NameTools.uniqueNameFor("Test", strings));
-
- assertEquals("Oracle3", NameTools.uniqueNameForIgnoreCase("Oracle", strings));
- assertEquals("oracle3", NameTools.uniqueNameForIgnoreCase("oracle", strings));
- assertEquals("Test", NameTools.uniqueNameForIgnoreCase("Test", strings));
- }
-
- public void testUniqueNameForCollection2() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("oracle");
- strings.add("Oracle2");
- strings.add("Oracle1");
-
- assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings));
- assertEquals("Test", NameTools.uniqueNameFor("Test", strings));
-
- strings.add("Oracle Corporation");
- assertEquals("Oracle3", NameTools.uniqueNameForIgnoreCase("Oracle", strings));
- assertEquals("oracle3", NameTools.uniqueNameForIgnoreCase("oracle", strings));
- assertEquals("Test", NameTools.uniqueNameForIgnoreCase("Test", strings));
- }
-
- public void testUniqueNameForCollection3() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("Oracle");
- strings.add("Oracle2");
- strings.add("Oracle1");
-
- assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings));
- }
-
- public void testUniqueNameForIterator1() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("Oracle Corporation");
- strings.add("Oracle2");
- strings.add("oracle1");
- strings.add("Oracl");
-
- assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings.iterator()));
- assertEquals("Test", NameTools.uniqueNameFor("Test", strings.iterator()));
-
- assertEquals("Oracle3", NameTools.uniqueNameForIgnoreCase("Oracle", strings.iterator()));
- assertEquals("oracle3", NameTools.uniqueNameForIgnoreCase("oracle", strings.iterator()));
- assertEquals("Test", NameTools.uniqueNameForIgnoreCase("Test", strings.iterator()));
- }
-
- public void testUniqueNameForIterator2() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("oracle");
- strings.add("Oracle2");
- strings.add("Oracle1");
-
- assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings.iterator()));
- assertEquals("Test", NameTools.uniqueNameFor("Test", strings.iterator()));
-
- strings.add("Oracle Corporation");
- assertEquals("Oracle3", NameTools.uniqueNameForIgnoreCase("Oracle", strings.iterator()));
- assertEquals("oracle3", NameTools.uniqueNameForIgnoreCase("oracle", strings.iterator()));
- assertEquals("Test", NameTools.uniqueNameForIgnoreCase("Test", strings.iterator()));
- }
-
- public void testUniqueNameForIterator3() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("Oracle");
- strings.add("Oracle2");
- strings.add("Oracle1");
-
- assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings.iterator()));
- }
-
- public void testUniqueJavaNameForCollection() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("Oracle");
- strings.add("Oracle2");
- strings.add("Oracle1");
-
- assertEquals("private2", NameTools.uniqueJavaNameFor("private", strings.iterator()));
- assertEquals("class2", NameTools.uniqueJavaNameFor("class", strings.iterator()));
- }
-
- public void testBuildQualifiedDatabaseObjectName() {
- assertEquals("catalog.schema.name", NameTools.buildQualifiedDatabaseObjectName("catalog", "schema", "name"));
- assertEquals("catalog..name", NameTools.buildQualifiedDatabaseObjectName("catalog", null, "name"));
- assertEquals("schema.name", NameTools.buildQualifiedDatabaseObjectName(null, "schema", "name"));
- assertEquals("name", NameTools.buildQualifiedDatabaseObjectName(null, null, "name"));
- }
-
- public void testJavaReservedWords() {
- assertTrue(CollectionTools.contains(NameTools.javaReservedWords(), "class"));
- assertFalse(CollectionTools.contains(NameTools.javaReservedWords(), "Class"));
- assertTrue(CollectionTools.contains(NameTools.javaReservedWords(), "private"));
- }
-
- public void testconvertToJavaIdentifierString() {
- assertEquals("foo", NameTools.convertToJavaIdentifier("foo"));
- assertEquals("foo1", NameTools.convertToJavaIdentifier("foo1"));
- assertEquals("private_", NameTools.convertToJavaIdentifier("private"));
- assertEquals("throw_", NameTools.convertToJavaIdentifier("throw"));
- assertEquals("_foo", NameTools.convertToJavaIdentifier("1foo"));
- assertEquals("foo_", NameTools.convertToJavaIdentifier("foo%"));
- assertEquals("foo__bar__", NameTools.convertToJavaIdentifier("foo bar "));
- }
-
- public void testconvertToJavaIdentifierStringChar() {
- assertEquals("foo", NameTools.convertToJavaIdentifier("foo", '$'));
- assertEquals("foo1", NameTools.convertToJavaIdentifier("foo1", '$'));
- assertEquals("private$", NameTools.convertToJavaIdentifier("private", '$'));
- assertEquals("throwss", NameTools.convertToJavaIdentifier("throw", 's'));
- assertEquals("$foo", NameTools.convertToJavaIdentifier("1foo", '$'));
- assertEquals("foo$", NameTools.convertToJavaIdentifier("foo%", '$'));
- assertEquals("foo$$bar$$", NameTools.convertToJavaIdentifier("foo bar ", '$'));
-
- boolean exCaught = false;
- try {
- String s = NameTools.convertToJavaIdentifier("1foo", '7');
- fail("invalid string: \"" + s + "\"");
- } catch (IllegalArgumentException ex) {
- if (ex.getMessage().indexOf('7') != -1) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- String s = NameTools.convertToJavaIdentifier("foo%", '^');
- fail("invalid string: \"" + s + "\"");
- } catch (IllegalArgumentException ex) {
- if (ex.getMessage().indexOf('^') != -1) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- String s = NameTools.convertToJavaIdentifier("private", '^');
- fail("invalid string: \"" + s + "\"");
- } catch (IllegalArgumentException ex) {
- if (ex.getMessage().indexOf('^') != -1) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
-
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/RangeTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/RangeTests.java
deleted file mode 100644
index d7f2cce428..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/RangeTests.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.Range;
-
-public class RangeTests extends TestCase {
-
- public RangeTests(String name) {
- super(name);
- }
-
- public void testIncludes() {
- Range range = new Range(5, 17);
- assertFalse(range.includes(-55));
- assertFalse(range.includes(0));
- assertFalse(range.includes(4));
- assertTrue(range.includes(5));
- assertTrue(range.includes(6));
- assertTrue(range.includes(16));
- assertTrue(range.includes(17));
- assertFalse(range.includes(18));
- assertFalse(range.includes(200));
- }
-
- public void testEquals() {
- Range range1 = new Range(5, 17);
- Range range2 = new Range(5, 17);
- assertNotSame(range1, range2);
- assertEquals(range1, range1);
- assertEquals(range1, range2);
- assertEquals(range2, range1);
- assertEquals(range1.hashCode(), range2.hashCode());
-
- range2 = new Range(17, 5);
- assertFalse(range1.equals(range2));
- assertFalse(range2.equals(range1));
- // although they are unequal, they can have the same hash code
- assertEquals(range1.hashCode(), range2.hashCode());
-
- range2 = new Range(5, 15);
- assertFalse(range1.equals(range2));
- assertFalse(range2.equals(range1));
- }
-
- public void testClone() {
- Range range1 = new Range(5, 17);
- Range range2 = range1.clone();
- assertNotSame(range1, range2);
- assertEquals(range1, range1);
- assertEquals(range1, range2);
- assertEquals(range2, range1);
- assertEquals(range1.hashCode(), range2.hashCode());
- }
-
- public void testSerialization() throws Exception {
- Range range1 = new Range(5, 17);
- Range range2 = TestTools.serialize(range1);
- assertNotSame(range1, range2);
- assertEquals(range1, range1);
- assertEquals(range1, range2);
- assertEquals(range2, range1);
- assertEquals(range1.hashCode(), range2.hashCode());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java
deleted file mode 100644
index 7ae00fdc2e..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ReverseComparator;
-
-public class ReverseComparatorTests extends TestCase {
- private Comparator<String> naturalReverseComparator;
- private Comparator<String> customComparator;
- private Comparator<String> customReverseComparator;
-
- public ReverseComparatorTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.naturalReverseComparator = new ReverseComparator<String>();
- this.customComparator = this.buildCustomComparator();
- this.customReverseComparator = new ReverseComparator<String>(this.customComparator);
- }
-
- private Comparator<String> buildCustomComparator() {
- return new Comparator<String>() {
- public int compare(String s1, String s2) {
- String lower1 = s1.toLowerCase();
- String lower2 = s2.toLowerCase();
- int result = lower1.compareTo(lower2);
- if (result == 0) {
- return s1.compareTo(s2); // use case to differentiate "equal" strings
- }
- return result;
- }
- };
- }
-
- private List<String> buildUnsortedList() {
- List<String> result = new ArrayList<String>();
- result.add("T");
- result.add("Z");
- result.add("Y");
- result.add("M");
- result.add("m");
- result.add("a");
- result.add("B");
- result.add("b");
- result.add("A");
- return result;
- }
-
- private List<String> buildNaturallySortedList() {
- List<String> result = new ArrayList<String>(this.buildUnsortedList());
- Collections.sort(result);
- return result;
- }
-
- private List<String> buildCustomSortedList() {
- List<String> result = new ArrayList<String>(this.buildUnsortedList());
- Collections.sort(result, this.customComparator);
- return result;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testNatural() {
- List<String> list = this.buildUnsortedList();
- Collections.sort(list, this.naturalReverseComparator);
- this.verifyList(this.buildNaturallySortedList(), list);
- }
-
- public void testCustom() {
- List<String> list = this.buildUnsortedList();
- Collections.sort(list, this.customReverseComparator);
- this.verifyList(this.buildCustomSortedList(), list);
- }
-
- private void verifyList(List<String> normal, List<String> reverse) {
- int size = normal.size();
- int max = size - 1;
- for (int i = 0; i < size; i++) {
- assertEquals(normal.get(i), reverse.get(max - i));
- }
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleAssociationTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleAssociationTests.java
deleted file mode 100644
index 3f3200b267..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleAssociationTests.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import org.eclipse.jpt.utility.internal.Association;
-import org.eclipse.jpt.utility.internal.SimpleAssociation;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class SimpleAssociationTests extends TestCase {
- private SimpleAssociation<String, String> assoc;
-
- public static Test suite() {
- return new TestSuite(SimpleAssociationTests.class);
- }
-
- public SimpleAssociationTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.assoc = new SimpleAssociation<String, String>("foo", "bar");
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGetKey() {
- assertEquals("foo", this.assoc.key());
- }
-
- public void testGetValue() {
- assertEquals("bar", this.assoc.value());
- }
-
- public void testSetValue() {
- assertEquals("bar", this.assoc.value());
- this.assoc.setValue("baz");
- assertEquals("baz", this.assoc.value());
- }
-
- public void testEquals() {
- assertEquals(this.assoc, this.copy(this.assoc));
-
- SimpleAssociation<String, String> assoc2 = new SimpleAssociation<String, String>("foo", "baz");
- assertFalse(this.assoc.equals(assoc2));
-
- assoc2 = new SimpleAssociation<String, String>("fop", "bar");
- assertFalse(this.assoc.equals(assoc2));
- }
-
- public void testHashCode() {
- assertEquals(this.assoc.hashCode(), this.copy(this.assoc).hashCode());
- }
-
- public void testClone() {
- this.verifyClone(this.assoc, this.assoc.clone());
- }
-
- private void verifyClone(Association<String, String> expected, Association<String, String> actual) {
- assertEquals(expected, actual);
- assertNotSame(expected, actual);
- assertEquals(expected.key(), actual.key());
- assertSame(expected.key(), actual.key());
- assertEquals(expected.value(), actual.value());
- assertSame(expected.value(), actual.value());
- }
-
- public void testSerialization() throws Exception {
- @SuppressWarnings("cast")
- Association<String, String> assoc2 = (Association<String, String>) TestTools.serialize(this.assoc);
-
- assertEquals(this.assoc, assoc2);
- assertNotSame(this.assoc, assoc2);
- assertEquals(this.assoc.key(), assoc2.key());
- assertNotSame(this.assoc.key(), assoc2.key());
- assertEquals(this.assoc.value(), assoc2.value());
- assertNotSame(this.assoc.value(), assoc2.value());
- }
-
- private SimpleAssociation<String, String> copy(SimpleAssociation<String, String> sa) {
- return new SimpleAssociation<String, String>(sa.key(), sa.value());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleStackTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleStackTests.java
deleted file mode 100644
index f229797565..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleStackTests.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.util.EmptyStackException;
-
-import org.eclipse.jpt.utility.internal.SimpleStack;
-import org.eclipse.jpt.utility.internal.Stack;
-
-import junit.framework.TestCase;
-
-public class SimpleStackTests extends TestCase {
-
- public SimpleStackTests(String name) {
- super(name);
- }
-
- public void testIsEmpty() {
- Stack<String> stack = new SimpleStack<String>();
- assertTrue(stack.isEmpty());
- stack.push("first");
- assertFalse(stack.isEmpty());
- stack.push("second");
- assertFalse(stack.isEmpty());
- stack.pop();
- assertFalse(stack.isEmpty());
- stack.pop();
- assertTrue(stack.isEmpty());
- }
-
- public void testPushAndPop() {
- Stack<String> stack = new SimpleStack<String>();
- String first = "first";
- String second = "second";
-
- stack.push(first);
- stack.push(second);
- assertEquals(second, stack.pop());
- assertEquals(first, stack.pop());
- }
-
- public void testPushAndPeek() {
- Stack<String> stack = new SimpleStack<String>();
- String first = "first";
- String second = "second";
-
- stack.push(first);
- stack.push(second);
- assertEquals(second, stack.peek());
- assertEquals(second, stack.peek());
- assertEquals(second, stack.pop());
- assertEquals(first, stack.peek());
- assertEquals(first, stack.peek());
- assertEquals(first, stack.pop());
- }
-
- public void testEmptyStackExceptionPeek() {
- Stack<String> stack = new SimpleStack<String>();
- String first = "first";
- String second = "second";
-
- stack.push(first);
- stack.push(second);
- assertEquals(second, stack.peek());
- assertEquals(second, stack.pop());
- assertEquals(first, stack.peek());
- assertEquals(first, stack.pop());
-
- boolean exCaught = false;
- try {
- stack.peek();
- } catch (EmptyStackException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testEmptyStackExceptionPop() {
- Stack<String> stack = new SimpleStack<String>();
- String first = "first";
- String second = "second";
-
- stack.push(first);
- stack.push(second);
- assertEquals(second, stack.peek());
- assertEquals(second, stack.pop());
- assertEquals(first, stack.peek());
- assertEquals(first, stack.pop());
-
- boolean exCaught = false;
- try {
- stack.pop();
- } catch (EmptyStackException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testClone() {
- SimpleStack<String> stack = new SimpleStack<String>();
- stack.push("first");
- stack.push("second");
- stack.push("third");
-
- this.verifyClone(stack, stack.clone());
- }
-
- public void testSerialization() throws Exception {
- SimpleStack<String> stack = new SimpleStack<String>();
- stack.push("first");
- stack.push("second");
- stack.push("third");
-
- this.verifyClone(stack, TestTools.serialize(stack));
- }
-
- private void verifyClone(Stack<String> original, Stack<String> clone) {
- assertNotSame(original, clone);
- assertEquals(original.peek(), clone.peek());
- assertEquals(original.pop(), clone.pop());
- assertEquals(original.peek(), clone.peek());
- assertEquals(original.pop(), clone.pop());
- assertEquals(original.isEmpty(), clone.isEmpty());
- assertEquals(original.peek(), clone.peek());
- assertEquals(original.pop(), clone.pop());
- assertTrue(original.isEmpty());
- assertEquals(original.isEmpty(), clone.isEmpty());
-
- original.push("fourth");
- assertFalse(original.isEmpty());
- // clone should still be empty
- assertTrue(clone.isEmpty());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java
deleted file mode 100644
index 42f6936eb1..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java
+++ /dev/null
@@ -1,1176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.io.StringWriter;
-import java.io.Writer;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-public class StringToolsTests extends TestCase {
-
- public StringToolsTests(String name) {
- super(name);
- }
-
- // ********** padding/truncating **********
-
- public void testPad() {
- assertEquals("fred", StringTools.pad("fred", 4));
- assertEquals("fred ", StringTools.pad("fred", 6));
- boolean exThrown = false;
- try {
- assertEquals("fr", StringTools.pad("fred", 2));
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testPadCharArray() {
- assertEquals("fred", new String(StringTools.pad(new char[] { 'f', 'r', 'e', 'd' }, 4)));
- assertEquals("fred ", new String(StringTools.pad(new char[] { 'f', 'r', 'e', 'd' }, 6)));
- boolean exThrown = false;
- try {
- assertEquals("fr", new String(StringTools.pad(new char[] { 'f', 'r', 'e', 'd' }, 2)));
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testPadOnWriter() {
- Writer writer;
- writer = new StringWriter();
- StringTools.padOn("fred", 4, writer);
- assertEquals("fred", writer.toString());
-
- writer = new StringWriter();
- StringTools.padOn("fred", 6, writer);
- assertEquals("fred ", writer.toString());
-
- writer = new StringWriter();
- boolean exThrown = false;
- try {
- StringTools.padOn("fred", 2, writer);
- fail();
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testPadOnStringBuffer() {
- StringBuffer sb;
- sb = new StringBuffer();
- StringTools.padOn("fred", 4, sb);
- assertEquals("fred", sb.toString());
-
- sb = new StringBuffer();
- StringTools.padOn("fred", 6, sb);
- assertEquals("fred ", sb.toString());
-
- sb = new StringBuffer();
- boolean exThrown = false;
- try {
- StringTools.padOn("fred", 2, sb);
- fail();
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testPadOnStringBuilder() {
- StringBuilder sb;
- sb = new StringBuilder();
- StringTools.padOn("fred", 4, sb);
- assertEquals("fred", sb.toString());
-
- sb = new StringBuilder();
- StringTools.padOn("fred", 6, sb);
- assertEquals("fred ", sb.toString());
-
- sb = new StringBuilder();
- boolean exThrown = false;
- try {
- StringTools.padOn("fred", 2, sb);
- fail();
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testPadOrTruncate() {
- assertEquals("fred", StringTools.padOrTruncate("fred", 4));
- assertEquals("fred ", StringTools.padOrTruncate("fred", 6));
- assertEquals("fr", StringTools.padOrTruncate("fred", 2));
- }
-
- public void testPadOrTruncateCharArray() {
- assertEquals("fred", new String(StringTools.padOrTruncate(new char[] { 'f', 'r', 'e', 'd' }, 4)));
- assertEquals("fred ", new String(StringTools.padOrTruncate(new char[] { 'f', 'r', 'e', 'd' }, 6)));
- assertEquals("fr", new String(StringTools.padOrTruncate(new char[] { 'f', 'r', 'e', 'd' }, 2)));
- }
-
- public void testPadOrTruncateOnWriter() {
- this.verifyPadOrTruncateOnWriter("fred", "fred", 4);
- this.verifyPadOrTruncateOnWriter("fred ", "fred", 6);
- this.verifyPadOrTruncateOnWriter("fr", "fred", 2);
- }
-
- private void verifyPadOrTruncateOnWriter(String expected, String string, int length) {
- Writer writer = new StringWriter();
- StringTools.padOrTruncateOn(string, length, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testPadOrTruncateOnStringBuffer() {
- this.verifyPadOrTruncateOnStringBuffer("fred", "fred", 4);
- this.verifyPadOrTruncateOnStringBuffer("fred ", "fred", 6);
- this.verifyPadOrTruncateOnStringBuffer("fr", "fred", 2);
- }
-
- private void verifyPadOrTruncateOnStringBuffer(String expected, String string, int length) {
- StringBuffer sb = new StringBuffer();
- StringTools.padOrTruncateOn(string, length, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testPadOrTruncateOnStringBuilder() {
- this.verifyPadOrTruncateOnStringBuilder("fred", "fred", 4);
- this.verifyPadOrTruncateOnStringBuilder("fred ", "fred", 6);
- this.verifyPadOrTruncateOnStringBuilder("fr", "fred", 2);
- }
-
- private void verifyPadOrTruncateOnStringBuilder(String expected, String string, int length) {
- StringBuilder sb = new StringBuilder();
- StringTools.padOrTruncateOn(string, length, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testZeroPad() {
- assertEquals("1234", StringTools.zeroPad("1234", 4));
- assertEquals("001234", StringTools.zeroPad("1234", 6));
- boolean exThrown = false;
- try {
- assertEquals("12", StringTools.zeroPad("1234", 2));
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testZeroPadCharArray() {
- assertEquals("1234", new String(StringTools.zeroPad(new char[] { '1', '2', '3', '4' }, 4)));
- assertEquals("001234", new String(StringTools.zeroPad(new char[] { '1', '2', '3', '4' }, 6)));
- boolean exThrown = false;
- try {
- assertEquals("12", new String(StringTools.zeroPad(new char[] { '1', '2', '3', '4' }, 2)));
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testZeroPadOnWriter() {
- Writer writer;
- writer = new StringWriter();
- StringTools.zeroPadOn("1234", 4, writer);
- assertEquals("1234", writer.toString());
-
- writer = new StringWriter();
- StringTools.zeroPadOn("1234", 6, writer);
- assertEquals("001234", writer.toString());
-
- writer = new StringWriter();
- boolean exThrown = false;
- try {
- StringTools.zeroPadOn("1234", 2, writer);
- fail();
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testZeroPadOnStringBuffer() {
- StringBuffer sb;
- sb = new StringBuffer();
- StringTools.zeroPadOn("1234", 4, sb);
- assertEquals("1234", sb.toString());
-
- sb = new StringBuffer();
- StringTools.zeroPadOn("1234", 6, sb);
- assertEquals("001234", sb.toString());
-
- sb = new StringBuffer();
- boolean exThrown = false;
- try {
- StringTools.zeroPadOn("1234", 2, sb);
- fail();
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testZeroPadOnStringBuilder() {
- StringBuilder sb;
- sb = new StringBuilder();
- StringTools.zeroPadOn("1234", 4, sb);
- assertEquals("1234", sb.toString());
-
- sb = new StringBuilder();
- StringTools.zeroPadOn("1234", 6, sb);
- assertEquals("001234", sb.toString());
-
- sb = new StringBuilder();
- boolean exThrown = false;
- try {
- StringTools.zeroPadOn("1234", 2, sb);
- fail();
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testZeroPadOrTruncate() {
- assertEquals("1234", StringTools.zeroPadOrTruncate("1234", 4));
- assertEquals("001234", StringTools.zeroPadOrTruncate("1234", 6));
- assertEquals("34", StringTools.zeroPadOrTruncate("1234", 2));
- }
-
- public void testZeroPadOrTruncateCharArray() {
- assertEquals("1234", new String(StringTools.zeroPadOrTruncate(new char[] { '1', '2', '3', '4' }, 4)));
- assertEquals("001234", new String(StringTools.zeroPadOrTruncate(new char[] { '1', '2', '3', '4' }, 6)));
- assertEquals("34", new String(StringTools.zeroPadOrTruncate(new char[] { '1', '2', '3', '4' }, 2)));
- }
-
- public void testZeroPadOrTruncateOnWriter() {
- this.verifyZeroPadOrTruncateOnWriter("1234", "1234", 4);
- this.verifyZeroPadOrTruncateOnWriter("001234", "1234", 6);
- this.verifyZeroPadOrTruncateOnWriter("34", "1234", 2);
- }
-
- private void verifyZeroPadOrTruncateOnWriter(String expected, String string, int length) {
- Writer writer = new StringWriter();
- StringTools.zeroPadOrTruncateOn(string, length, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testZeroPadOrTruncateOnStringBuffer() {
- this.verifyZeroPadOrTruncateOnStringBuffer("1234", "1234", 4);
- this.verifyZeroPadOrTruncateOnStringBuffer("001234", "1234", 6);
- this.verifyZeroPadOrTruncateOnStringBuffer("34", "1234", 2);
- }
-
- private void verifyZeroPadOrTruncateOnStringBuffer(String expected, String string, int length) {
- StringBuffer sb = new StringBuffer();
- StringTools.zeroPadOrTruncateOn(string, length, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testZeroPadOrTruncateOnStringBuilder() {
- this.verifyZeroPadOrTruncateOnStringBuilder("1234", "1234", 4);
- this.verifyZeroPadOrTruncateOnStringBuilder("001234", "1234", 6);
- this.verifyZeroPadOrTruncateOnStringBuilder("34", "1234", 2);
- }
-
- private void verifyZeroPadOrTruncateOnStringBuilder(String expected, String string, int length) {
- StringBuilder sb = new StringBuilder();
- StringTools.zeroPadOrTruncateOn(string, length, sb);
- assertEquals(expected, sb.toString());
- }
-
- // ********** wrapping **********
-
- public void testWrap() {
- this.verifyWrap("Employee", "123", "123Employee123");
- this.verifyWrap("123", "123", "123123123");
- this.verifyWrap("", "123", "123123");
- }
-
- private void verifyWrap(String string, String wrap, String expectedString) {
- assertEquals(expectedString, StringTools.wrap(string, wrap));
- }
-
- public void testWrapOnWriter() {
- this.verifyWrapOnWriter("Employee", "123", "123Employee123");
- this.verifyWrapOnWriter("123", "123", "123123123");
- this.verifyWrapOnWriter("", "123", "123123");
- }
-
- private void verifyWrapOnWriter(String string, String wrap, String expectedString) {
- Writer writer = new StringWriter();
- StringTools.wrapOn(string, wrap, writer);
- assertEquals(expectedString, writer.toString());
- }
-
- public void testWrapOnStringBuffer() {
- this.verifyWrapOnStringBuffer("Employee", "123", "123Employee123");
- this.verifyWrapOnStringBuffer("123", "123", "123123123");
- this.verifyWrapOnStringBuffer("", "123", "123123");
- }
-
- private void verifyWrapOnStringBuffer(String string, String wrap, String expectedString) {
- StringBuffer sb = new StringBuffer();
- StringTools.wrapOn(string, wrap, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testWrapOnStringBuilder() {
- this.verifyWrapOnStringBuilder("Employee", "123", "123Employee123");
- this.verifyWrapOnStringBuilder("123", "123", "123123123");
- this.verifyWrapOnStringBuilder("", "123", "123123");
- }
-
- private void verifyWrapOnStringBuilder(String string, String wrap, String expectedString) {
- StringBuilder sb = new StringBuilder();
- StringTools.wrapOn(string, wrap, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testQuote() {
- this.verifyQuote("Employee", "\"Employee\"");
- this.verifyQuote("123", "\"123\"");
- this.verifyQuote("", "\"\"");
- }
-
- private void verifyQuote(String string, String expectedString) {
- assertEquals(expectedString, StringTools.quote(string));
- }
-
- public void testQuoteOnWriter() {
- this.verifyQuoteOnWriter("Employee", "\"Employee\"");
- this.verifyQuoteOnWriter("123", "\"123\"");
- this.verifyQuoteOnWriter("", "\"\"");
- }
-
- private void verifyQuoteOnWriter(String string, String expectedString) {
- Writer writer = new StringWriter();
- StringTools.quoteOn(string, writer);
- assertEquals(expectedString, writer.toString());
- }
-
- public void testQuoteOnStringBuffer() {
- this.verifyQuoteOnStringBuffer("Employee", "\"Employee\"");
- this.verifyQuoteOnStringBuffer("123", "\"123\"");
- this.verifyQuoteOnStringBuffer("", "\"\"");
- }
-
- private void verifyQuoteOnStringBuffer(String string, String expectedString) {
- StringBuffer sb = new StringBuffer();
- StringTools.quoteOn(string, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testQuoteOnStringBuilder() {
- this.verifyQuoteOnStringBuilder("Employee", "\"Employee\"");
- this.verifyQuoteOnStringBuilder("123", "\"123\"");
- this.verifyQuoteOnStringBuilder("", "\"\"");
- }
-
- private void verifyQuoteOnStringBuilder(String string, String expectedString) {
- StringBuilder sb = new StringBuilder();
- StringTools.quoteOn(string, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- // ********** removing characters **********
-
- public void testRemoveFirstOccurrence() {
- this.verifyRemoveFirstOccurrence("Emplo&yee", '&', "Employee");
- this.verifyRemoveFirstOccurrence("Emplo&yee&", '&', "Employee&");
- this.verifyRemoveFirstOccurrence("Employee &Foo", '&', "Employee Foo");
- this.verifyRemoveFirstOccurrence("Employee&", '&', "Employee");
- this.verifyRemoveFirstOccurrence("&Employee", '&', "Employee");
- }
-
- private void verifyRemoveFirstOccurrence(String string, char charToRemove, String expectedString) {
- assertEquals(expectedString, StringTools.removeFirstOccurrence(string, charToRemove));
- }
-
- public void testRemoveFirstOccurrenceCharArray() {
- this.verifyRemoveFirstOccurrenceCharArray("Emplo&yee", '&', "Employee");
- this.verifyRemoveFirstOccurrenceCharArray("Emplo&yee&", '&', "Employee&");
- this.verifyRemoveFirstOccurrenceCharArray("Employee &Foo", '&', "Employee Foo");
- this.verifyRemoveFirstOccurrenceCharArray("Employee&", '&', "Employee");
- this.verifyRemoveFirstOccurrenceCharArray("&Employee", '&', "Employee");
- }
-
- private void verifyRemoveFirstOccurrenceCharArray(String string, char charToRemove, String expectedString) {
- assertEquals(expectedString, new String(StringTools.removeFirstOccurrence(string.toCharArray(), charToRemove)));
- }
-
- public void testRemoveFirstOccurrenceOnWriter() {
- this.verifyRemoveFirstOccurrenceOnWriter("Emplo&yee", '&', "Employee");
- this.verifyRemoveFirstOccurrenceOnWriter("Emplo&yee&", '&', "Employee&");
- this.verifyRemoveFirstOccurrenceOnWriter("Employee &Foo", '&', "Employee Foo");
- this.verifyRemoveFirstOccurrenceOnWriter("Employee&", '&', "Employee");
- this.verifyRemoveFirstOccurrenceOnWriter("&Employee", '&', "Employee");
- }
-
- private void verifyRemoveFirstOccurrenceOnWriter(String string, char charToRemove, String expectedString) {
- Writer writer = new StringWriter();
- StringTools.removeFirstOccurrenceOn(string, charToRemove, writer);
- assertEquals(expectedString, writer.toString());
- }
-
- public void testRemoveFirstOccurrenceOnStringBuffer() {
- this.verifyRemoveFirstOccurrenceOnStringBuffer("Emplo&yee", '&', "Employee");
- this.verifyRemoveFirstOccurrenceOnStringBuffer("Emplo&yee&", '&', "Employee&");
- this.verifyRemoveFirstOccurrenceOnStringBuffer("Employee &Foo", '&', "Employee Foo");
- this.verifyRemoveFirstOccurrenceOnStringBuffer("Employee&", '&', "Employee");
- this.verifyRemoveFirstOccurrenceOnStringBuffer("&Employee", '&', "Employee");
- }
-
- private void verifyRemoveFirstOccurrenceOnStringBuffer(String string, char charToRemove, String expectedString) {
- StringBuffer sb = new StringBuffer();
- StringTools.removeFirstOccurrenceOn(string, charToRemove, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testRemoveFirstOccurrenceOnStringBuilder() {
- this.verifyRemoveFirstOccurrenceOnStringBuilder("Emplo&yee", '&', "Employee");
- this.verifyRemoveFirstOccurrenceOnStringBuilder("Emplo&yee&", '&', "Employee&");
- this.verifyRemoveFirstOccurrenceOnStringBuilder("Employee &Foo", '&', "Employee Foo");
- this.verifyRemoveFirstOccurrenceOnStringBuilder("Employee&", '&', "Employee");
- this.verifyRemoveFirstOccurrenceOnStringBuilder("&Employee", '&', "Employee");
- }
-
- private void verifyRemoveFirstOccurrenceOnStringBuilder(String string, char charToRemove, String expectedString) {
- StringBuilder sb = new StringBuilder();
- StringTools.removeFirstOccurrenceOn(string, charToRemove, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testRemoveAllOccurrences() {
- this.verifyRemoveAllOccurrences("Employee Fred", ' ', "EmployeeFred");
- this.verifyRemoveAllOccurrences(" Employee ", ' ', "Employee");
- this.verifyRemoveAllOccurrences("Employee Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllOccurrences(" Emp loyee Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllOccurrences(String string, char charToRemove, String expectedString) {
- assertEquals(expectedString, StringTools.removeAllOccurrences(string, charToRemove));
- }
-
- public void testRemoveAllOccurrencesCharArray() {
- this.verifyRemoveAllOccurrencesCharArray("Employee Fred", ' ', "EmployeeFred");
- this.verifyRemoveAllOccurrencesCharArray(" Employee ", ' ', "Employee");
- this.verifyRemoveAllOccurrencesCharArray("Employee Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllOccurrencesCharArray(" Emp loyee Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllOccurrencesCharArray(String string, char charToRemove, String expectedString) {
- assertEquals(expectedString, new String(StringTools.removeAllOccurrences(string.toCharArray(), charToRemove)));
- }
-
- public void testRemoveAllOccurrencesOnWriter() {
- this.verifyRemoveAllOccurrencesOnWriter("Employee Fred", ' ', "EmployeeFred");
- this.verifyRemoveAllOccurrencesOnWriter(" Employee ", ' ', "Employee");
- this.verifyRemoveAllOccurrencesOnWriter("Employee Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllOccurrencesOnWriter(" Emp loyee Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllOccurrencesOnWriter(String string, char charToRemove, String expectedString) {
- Writer writer = new StringWriter();
- StringTools.removeAllOccurrencesOn(string, charToRemove, writer);
- assertEquals(expectedString, writer.toString());
- }
-
- public void testRemoveAllOccurrencesOnStringBuffer() {
- this.verifyRemoveAllOccurrencesOnStringBuffer("Employee Fred", ' ', "EmployeeFred");
- this.verifyRemoveAllOccurrencesOnStringBuffer(" Employee ", ' ', "Employee");
- this.verifyRemoveAllOccurrencesOnStringBuffer("Employee Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllOccurrencesOnStringBuffer(" Emp loyee Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllOccurrencesOnStringBuffer(String string, char charToRemove, String expectedString) {
- StringBuffer sb = new StringBuffer();
- StringTools.removeAllOccurrencesOn(string, charToRemove, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testRemoveAllOccurrencesOnStringBuilder() {
- this.verifyRemoveAllOccurrencesOnStringBuilder("Employee Fred", ' ', "EmployeeFred");
- this.verifyRemoveAllOccurrencesOnStringBuilder(" Employee ", ' ', "Employee");
- this.verifyRemoveAllOccurrencesOnStringBuilder("Employee Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllOccurrencesOnStringBuilder(" Emp loyee Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllOccurrencesOnStringBuilder(String string, char charToRemove, String expectedString) {
- StringBuilder sb = new StringBuilder();
- StringTools.removeAllOccurrencesOn(string, charToRemove, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testRemoveAllWhitespace() {
- this.verifyRemoveAllWhitespace("Employee Fred\t", ' ', "EmployeeFred");
- this.verifyRemoveAllWhitespace("\tEmployee\n", ' ', "Employee");
- this.verifyRemoveAllWhitespace("Employee \t Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllWhitespace(" Emp\tloyee \n Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllWhitespace(String string, char charToRemove, String expectedString) {
- assertEquals(expectedString, StringTools.removeAllWhitespace(string));
- }
-
- public void testRemoveAllWhitespaceCharArray() {
- this.verifyRemoveAllWhitespaceCharArray("Employee Fred\t", ' ', "EmployeeFred");
- this.verifyRemoveAllWhitespaceCharArray("\tEmployee\n", ' ', "Employee");
- this.verifyRemoveAllWhitespaceCharArray("Employee \t Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllWhitespaceCharArray(" Emp\tloyee \n Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllWhitespaceCharArray(String string, char charToRemove, String expectedString) {
- assertEquals(expectedString, new String(StringTools.removeAllWhitespace(string.toCharArray())));
- }
-
- public void testRemoveAllWhitespaceOnWriter() {
- this.verifyRemoveAllWhitespaceOnWriter("Employee Fred\t", ' ', "EmployeeFred");
- this.verifyRemoveAllWhitespaceOnWriter("\tEmployee\n", ' ', "Employee");
- this.verifyRemoveAllWhitespaceOnWriter("Employee \t Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllWhitespaceOnWriter(" Emp\tloyee \n Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllWhitespaceOnWriter(String string, char charToRemove, String expectedString) {
- Writer writer = new StringWriter();
- StringTools.removeAllWhitespaceOn(string, writer);
- assertEquals(expectedString, writer.toString());
- }
-
- public void testRemoveAllWhitespaceOnStringBuffer() {
- this.verifyRemoveAllWhitespaceOnStringBuffer("Employee Fred\t", ' ', "EmployeeFred");
- this.verifyRemoveAllWhitespaceOnStringBuffer("\tEmployee\n", ' ', "Employee");
- this.verifyRemoveAllWhitespaceOnStringBuffer("Employee \t Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllWhitespaceOnStringBuffer(" Emp\tloyee \n Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllWhitespaceOnStringBuffer(String string, char charToRemove, String expectedString) {
- StringBuffer sb = new StringBuffer();
- StringTools.removeAllWhitespaceOn(string, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testRemoveAllWhitespaceOnStringBuilder() {
- this.verifyRemoveAllWhitespaceOnStringBuilder("Employee Fred\t", ' ', "EmployeeFred");
- this.verifyRemoveAllWhitespaceOnStringBuilder("\tEmployee\n", ' ', "Employee");
- this.verifyRemoveAllWhitespaceOnStringBuilder("Employee \t Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllWhitespaceOnStringBuilder(" Emp\tloyee \n Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllWhitespaceOnStringBuilder(String string, char charToRemove, String expectedString) {
- StringBuilder sb = new StringBuilder();
- StringTools.removeAllWhitespaceOn(string, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- // ********** common prefix **********
-
- public void testCommonPrefixLength() {
- assertEquals(3, StringTools.commonPrefixLength("fooZZZ", "fooBBB"));
- assertEquals(3, StringTools.commonPrefixLength("foo", "fooBBB"));
- assertEquals(3, StringTools.commonPrefixLength("fooZZZ", "foo"));
- assertEquals(3, StringTools.commonPrefixLength("foo", "foo"));
- }
-
- public void testCommonPrefixLengthMax() {
- assertEquals(2, StringTools.commonPrefixLength("fooZZZ", "fooBBB", 2));
- assertEquals(2, StringTools.commonPrefixLength("foo", "fooBBB", 2));
- assertEquals(2, StringTools.commonPrefixLength("fooZZZ", "foo", 2));
- assertEquals(2, StringTools.commonPrefixLength("foo", "foo", 2));
- }
-
- // ********** capitalization **********
-
- public void testCapitalizeCharArray() {
- this.verifyCapitalizeCharArray("Oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeCharArray("Oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeCharArray(" ", new char[] { ' ', ' ', ' ' });
- this.verifyCapitalizeCharArray("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyCapitalizeCharArray("", new char[0]);
- this.verifyCapitalizeCharArray("A", new char[] { 'a' });
- this.verifyCapitalizeCharArray("\u00C9cole", new char[] { '\u00E9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyCapitalizeCharArray(String expected, char[] string) {
- assertEquals(expected, new String(StringTools.capitalize(string)));
- }
-
- public void testCapitalizeString() {
- this.verifyCapitalizeString("Oracle", "Oracle");
- this.verifyCapitalizeString("Oracle", "oracle");
- this.verifyCapitalizeString(" ", " ");
- this.verifyCapitalizeString("ORACLE", "ORACLE");
- this.verifyCapitalizeString("", "");
- this.verifyCapitalizeString("A", "a");
- this.verifyCapitalizeString("\u00C9cole", "\u00E9cole"); // �cole->�COLE
- }
-
- private void verifyCapitalizeString(String expected, String string) {
- assertEquals(expected, StringTools.capitalize(string));
- }
-
- public void testCapitalizeOnCharArrayStringBuffer() {
- this.verifyCapitalizeOnCharArrayStringBuffer("Oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeOnCharArrayStringBuffer("Oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeOnCharArrayStringBuffer(" ", new char[] { ' ', ' ', ' ' });
- this.verifyCapitalizeOnCharArrayStringBuffer("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyCapitalizeOnCharArrayStringBuffer("", new char[0]);
- this.verifyCapitalizeOnCharArrayStringBuffer("A", new char[] { 'a' });
- this.verifyCapitalizeOnCharArrayStringBuffer("\u00C9cole", new char[] { '\u00E9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyCapitalizeOnCharArrayStringBuffer(String expected, char[] string) {
- StringBuffer sb = new StringBuffer();
- StringTools.capitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testCapitalizeOnCharArrayStringBuilder() {
- this.verifyCapitalizeOnCharArrayStringBuilder("Oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeOnCharArrayStringBuilder("Oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeOnCharArrayStringBuilder(" ", new char[] { ' ', ' ', ' ' });
- this.verifyCapitalizeOnCharArrayStringBuilder("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyCapitalizeOnCharArrayStringBuilder("", new char[0]);
- this.verifyCapitalizeOnCharArrayStringBuilder("A", new char[] { 'a' });
- this.verifyCapitalizeOnCharArrayStringBuilder("\u00C9cole", new char[] { '\u00E9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyCapitalizeOnCharArrayStringBuilder(String expected, char[] string) {
- StringBuilder sb = new StringBuilder();
- StringTools.capitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testCapitalizeOnStringStringBuffer() {
- this.verifyCapitalizeOnStringStringBuffer("Oracle", "Oracle");
- this.verifyCapitalizeOnStringStringBuffer("Oracle", "oracle");
- this.verifyCapitalizeOnStringStringBuffer(" ", " ");
- this.verifyCapitalizeOnStringStringBuffer("ORACLE", "ORACLE");
- this.verifyCapitalizeOnStringStringBuffer("", "");
- this.verifyCapitalizeOnStringStringBuffer("A", "a");
- this.verifyCapitalizeOnStringStringBuffer("\u00C9cole", "\u00E9cole"); // �cole->�COLE
- }
-
- private void verifyCapitalizeOnStringStringBuffer(String expected, String string) {
- StringBuffer sb = new StringBuffer();
- StringTools.capitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testCapitalizeOnStringStringBuilder() {
- this.verifyCapitalizeOnStringStringBuilder("Oracle", "Oracle");
- this.verifyCapitalizeOnStringStringBuilder("Oracle", "oracle");
- this.verifyCapitalizeOnStringStringBuilder(" ", " ");
- this.verifyCapitalizeOnStringStringBuilder("ORACLE", "ORACLE");
- this.verifyCapitalizeOnStringStringBuilder("", "");
- this.verifyCapitalizeOnStringStringBuilder("A", "a");
- this.verifyCapitalizeOnStringStringBuilder("\u00C9cole", "\u00E9cole"); // �cole->�COLE
- }
-
- private void verifyCapitalizeOnStringStringBuilder(String expected, String string) {
- StringBuilder sb = new StringBuilder();
- StringTools.capitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testCapitalizeOnCharArrayWriter() {
- this.verifyCapitalizeOnCharArrayWriter("Oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeOnCharArrayWriter("Oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeOnCharArrayWriter(" ", new char[] { ' ', ' ', ' ' });
- this.verifyCapitalizeOnCharArrayWriter("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyCapitalizeOnCharArrayWriter("", new char[0]);
- this.verifyCapitalizeOnCharArrayWriter("A", new char[] { 'a' });
- this.verifyCapitalizeOnCharArrayWriter("\u00C9cole", new char[] { '\u00E9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyCapitalizeOnCharArrayWriter(String expected, char[] string) {
- Writer writer = new StringWriter();
- StringTools.capitalizeOn(string, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testCapitalizeOnStringWriter() {
- this.verifyCapitalizeOnStringWriter("Oracle", "Oracle");
- this.verifyCapitalizeOnStringWriter("Oracle", "oracle");
- this.verifyCapitalizeOnStringWriter(" ", " ");
- this.verifyCapitalizeOnStringWriter("ORACLE", "ORACLE");
- this.verifyCapitalizeOnStringWriter("", "");
- this.verifyCapitalizeOnStringWriter("A", "a");
- this.verifyCapitalizeOnStringWriter("\u00C9cole", "\u00E9cole"); // �cole->�COLE
- }
-
- private void verifyCapitalizeOnStringWriter(String expected, String string) {
- Writer writer = new StringWriter();
- StringTools.capitalizeOn(string, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testUnapitalizeCharArray() {
- this.verifyUncapitalizeCharArray("oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeCharArray("oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeCharArray(" ", new char[] { ' ', ' ', ' ' });
- this.verifyUncapitalizeCharArray("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyUncapitalizeCharArray("", new char[0]);
- this.verifyUncapitalizeCharArray("a", new char[] { 'A' });
- this.verifyUncapitalizeCharArray("\u00E9cole", new char[] { '\u00C9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyUncapitalizeCharArray(String expected, char[] string) {
- assertEquals(expected, new String(StringTools.uncapitalize(string)));
- }
-
- public void testUncapitalizeString() {
- this.verifyUncapitalizeString("oracle", "Oracle");
- this.verifyUncapitalizeString("oracle", "oracle");
- this.verifyUncapitalizeString(" ", " ");
- this.verifyUncapitalizeString("ORACLE", "ORACLE");
- this.verifyUncapitalizeString("", "");
- this.verifyUncapitalizeString("a", "A");
- this.verifyUncapitalizeString("\u00E9cole", "\u00C9cole"); // �cole->�COLE
- }
-
- private void verifyUncapitalizeString(String expected, String string) {
- assertEquals(expected, StringTools.uncapitalize(string));
- }
-
- public void testUncapitalizeOnCharArrayStringBuffer() {
- this.verifyUncapitalizeOnCharArrayStringBuffer("oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeOnCharArrayStringBuffer("oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeOnCharArrayStringBuffer(" ", new char[] { ' ', ' ', ' ' });
- this.verifyUncapitalizeOnCharArrayStringBuffer("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyUncapitalizeOnCharArrayStringBuffer("", new char[0]);
- this.verifyUncapitalizeOnCharArrayStringBuffer("a", new char[] { 'A' });
- this.verifyUncapitalizeOnCharArrayStringBuffer("\u00E9cole", new char[] { '\u00C9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyUncapitalizeOnCharArrayStringBuffer(String expected, char[] string) {
- StringBuffer sb = new StringBuffer();
- StringTools.uncapitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testUncapitalizeOnCharArrayStringBuilder() {
- this.verifyUncapitalizeOnCharArrayStringBuilder("oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeOnCharArrayStringBuilder("oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeOnCharArrayStringBuilder(" ", new char[] { ' ', ' ', ' ' });
- this.verifyUncapitalizeOnCharArrayStringBuilder("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyUncapitalizeOnCharArrayStringBuilder("", new char[0]);
- this.verifyUncapitalizeOnCharArrayStringBuilder("a", new char[] { 'A' });
- this.verifyUncapitalizeOnCharArrayStringBuilder("\u00E9cole", new char[] { '\u00C9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyUncapitalizeOnCharArrayStringBuilder(String expected, char[] string) {
- StringBuilder sb = new StringBuilder();
- StringTools.uncapitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testUncapitalizeOnStringStringBuffer() {
- this.verifyUncapitalizeOnStringStringBuffer("oracle", "Oracle");
- this.verifyUncapitalizeOnStringStringBuffer("oracle", "oracle");
- this.verifyUncapitalizeOnStringStringBuffer(" ", " ");
- this.verifyUncapitalizeOnStringStringBuffer("ORACLE", "ORACLE");
- this.verifyUncapitalizeOnStringStringBuffer("", "");
- this.verifyUncapitalizeOnStringStringBuffer("a", "A");
- this.verifyUncapitalizeOnStringStringBuffer("\u00E9cole", "\u00C9cole"); // �cole->�COLE
- }
-
- private void verifyUncapitalizeOnStringStringBuffer(String expected, String string) {
- StringBuffer sb = new StringBuffer();
- StringTools.uncapitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testUncapitalizeOnStringStringBuilder() {
- this.verifyUncapitalizeOnStringStringBuilder("oracle", "Oracle");
- this.verifyUncapitalizeOnStringStringBuilder("oracle", "oracle");
- this.verifyUncapitalizeOnStringStringBuilder(" ", " ");
- this.verifyUncapitalizeOnStringStringBuilder("ORACLE", "ORACLE");
- this.verifyUncapitalizeOnStringStringBuilder("", "");
- this.verifyUncapitalizeOnStringStringBuilder("a", "A");
- this.verifyUncapitalizeOnStringStringBuilder("\u00E9cole", "\u00C9cole"); // �cole->�COLE
- }
-
- private void verifyUncapitalizeOnStringStringBuilder(String expected, String string) {
- StringBuilder sb = new StringBuilder();
- StringTools.uncapitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testUncapitalizeOnCharArrayWriter() {
- this.verifyUncapitalizeOnCharArrayWriter("oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeOnCharArrayWriter("oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeOnCharArrayWriter(" ", new char[] { ' ', ' ', ' ' });
- this.verifyUncapitalizeOnCharArrayWriter("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyUncapitalizeOnCharArrayWriter("", new char[0]);
- this.verifyUncapitalizeOnCharArrayWriter("a", new char[] { 'A' });
- this.verifyUncapitalizeOnCharArrayWriter("\u00E9cole", new char[] { '\u00C9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyUncapitalizeOnCharArrayWriter(String expected, char[] string) {
- Writer writer = new StringWriter();
- StringTools.uncapitalizeOn(string, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testUncapitalizeOnStringWriter() {
- this.verifyUncapitalizeOnStringWriter("oracle", "Oracle");
- this.verifyUncapitalizeOnStringWriter("oracle", "oracle");
- this.verifyUncapitalizeOnStringWriter(" ", " ");
- this.verifyUncapitalizeOnStringWriter("ORACLE", "ORACLE");
- this.verifyUncapitalizeOnStringWriter("", "");
- this.verifyUncapitalizeOnStringWriter("a", "A");
- this.verifyUncapitalizeOnStringWriter("\u00E9cole", "\u00C9cole"); // �cole->�COLE
- }
-
- private void verifyUncapitalizeOnStringWriter(String expected, String string) {
- Writer writer = new StringWriter();
- StringTools.uncapitalizeOn(string, writer);
- assertEquals(expected, writer.toString());
- }
-
- // ********** queries **********
-
- public void testStringIsEmptyString() {
- assertTrue(StringTools.stringIsEmpty((String) null));
- assertTrue(StringTools.stringIsEmpty(""));
- assertTrue(StringTools.stringIsEmpty(" "));
- assertTrue(StringTools.stringIsEmpty(" \t\t "));
- assertTrue(StringTools.stringIsEmpty(" \t\t " + StringTools.CR));
- }
-
- public void testStringIsEmptyCharArray() {
- assertTrue(StringTools.stringIsEmpty((char[]) null));
- this.verifyStringIsEmptyCharArray("");
- this.verifyStringIsEmptyCharArray(" \t\t ");
- this.verifyStringIsEmptyCharArray(" ");
- this.verifyStringIsEmptyCharArray(" \t\t " + StringTools.CR);
- }
-
- private void verifyStringIsEmptyCharArray(String string) {
- assertTrue(StringTools.stringIsEmpty(string.toCharArray()));
- }
-
- public void testStringsAreEqualIgnoreCaseStringString() {
- assertTrue(StringTools.stringsAreEqualIgnoreCase((String) null, (String) null));
- assertFalse(StringTools.stringsAreEqualIgnoreCase(null, "asdf"));
- assertFalse(StringTools.stringsAreEqualIgnoreCase("asdf", null));
- assertTrue(StringTools.stringsAreEqualIgnoreCase("asdf", "asdf"));
- assertTrue(StringTools.stringsAreEqualIgnoreCase("asdf", "ASDF"));
- }
-
- public void testStringsAreEqualIgnoreCaseCharArrayCharArray() {
- assertTrue(StringTools.stringsAreEqualIgnoreCase((char[]) null, (char[]) null));
- assertFalse(StringTools.stringsAreEqualIgnoreCase((char[]) null, "asdf".toCharArray()));
- assertFalse(StringTools.stringsAreEqualIgnoreCase("asdf".toCharArray(), (char[]) null));
- assertTrue(StringTools.stringsAreEqualIgnoreCase("asdf".toCharArray(), "asdf".toCharArray()));
- assertTrue(StringTools.stringsAreEqualIgnoreCase("asdf".toCharArray(), "ASDF".toCharArray()));
- }
-
- public void testStringStartsWithIgnoreCaseStringString() {
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf", "as"));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf", "aS"));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf", ""));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf", "A"));
-
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf", "bsdf"));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf", "g"));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf", "asdg"));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf", "asdfg"));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf", "asdfgggggg"));
- }
-
- public void testStringStartsWithIgnoreCaseCharArrayCharArray() {
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "as".toCharArray()));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "aS".toCharArray()));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "".toCharArray()));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "A".toCharArray()));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "ASDF".toCharArray()));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "asdf".toCharArray()));
-
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "bsdf".toCharArray()));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "g".toCharArray()));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "asdg".toCharArray()));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "asdfg".toCharArray()));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "asdfgggggg".toCharArray()));
- }
-
- public void testCharactersAreEqualIgnoreCase() {
- assertTrue(StringTools.charactersAreEqualIgnoreCase('a', 'a'));
- assertTrue(StringTools.charactersAreEqualIgnoreCase('a', 'A'));
- assertTrue(StringTools.charactersAreEqualIgnoreCase('A', 'a'));
- assertTrue(StringTools.charactersAreEqualIgnoreCase('A', 'A'));
-
- assertFalse(StringTools.charactersAreEqualIgnoreCase('a', 'b'));
- assertFalse(StringTools.charactersAreEqualIgnoreCase('A', 'b'));
- }
-
- // ********** conversions **********
-
- public void testConvertCamelCaseToAllCaps() {
- assertEquals("TEST", StringTools.convertCamelCaseToAllCaps("test"));
- assertEquals("TEST", StringTools.convertCamelCaseToAllCaps("TEST"));
- assertEquals("TEST_TEST", StringTools.convertCamelCaseToAllCaps("testTest"));
- assertEquals("TEST_TEST", StringTools.convertCamelCaseToAllCaps("TestTest"));
- assertEquals("TEST_TEST_TEST", StringTools.convertCamelCaseToAllCaps("testTESTTest"));
- assertEquals("TEST_TEST_TEST", StringTools.convertCamelCaseToAllCaps("TestTESTTest"));
- assertEquals("TEST_TEST_TEST_T", StringTools.convertCamelCaseToAllCaps("TestTESTTestT"));
- }
-
- public void testConvertCamelCaseToAllCapsOnWriter() {
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST", "test");
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST", "TEST");
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST_TEST", "testTest");
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST_TEST", "TestTest");
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST_TEST_TEST", "testTESTTest");
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST_TEST_TEST", "TestTESTTest");
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST_TEST_TEST_T", "TestTESTTestT");
- }
-
- private void verifyConvertCamelCaseToAllCapsOnWriter(String expected, String string) {
- Writer writer = new StringWriter();
- StringTools.convertCamelCaseToAllCapsOn(string, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testConvertCamelCaseToAllCapsOnStringBuffer() {
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST", "test");
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST", "TEST");
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST_TEST", "testTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST_TEST", "TestTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST_TEST_TEST", "testTESTTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST_TEST_TEST", "TestTESTTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST_TEST_TEST_T", "TestTESTTestT");
- }
-
- private void verifyConvertCamelCaseToAllCapsOnStringBuffer(String expected, String string) {
- StringBuffer sb = new StringBuffer();
- StringTools.convertCamelCaseToAllCapsOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testConvertCamelCaseToAllCapsOnStringBuilder() {
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST", "test");
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST", "TEST");
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST_TEST", "testTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST_TEST", "TestTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST_TEST_TEST", "testTESTTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST_TEST_TEST", "TestTESTTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST_TEST_TEST_T", "TestTESTTestT");
- }
-
- private void verifyConvertCamelCaseToAllCapsOnStringBuilder(String expected, String string) {
- StringBuilder sb = new StringBuilder();
- StringTools.convertCamelCaseToAllCapsOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testConvertCamelCaseToAllCapsMaxLength() {
- assertEquals("TEST", StringTools.convertCamelCaseToAllCaps("test", 44));
- assertEquals("TEST", StringTools.convertCamelCaseToAllCaps("test", 4));
- assertEquals("TES", StringTools.convertCamelCaseToAllCaps("test", 3));
- assertEquals("TEST", StringTools.convertCamelCaseToAllCaps("TEST", 5));
- assertEquals("TE", StringTools.convertCamelCaseToAllCaps("TEST", 2));
- assertEquals("TEST_TEST", StringTools.convertCamelCaseToAllCaps("testTest", 9));
- assertEquals("TEST_TES", StringTools.convertCamelCaseToAllCaps("testTest", 8));
- assertEquals("TEST_T", StringTools.convertCamelCaseToAllCaps("testTest", 6));
- assertEquals("TEST_", StringTools.convertCamelCaseToAllCaps("testTest", 5));
- assertEquals("TEST", StringTools.convertCamelCaseToAllCaps("testTest", 4));
- assertEquals("TEST_TEST", StringTools.convertCamelCaseToAllCaps("TestTest", 9));
- assertEquals("TEST_TEST", StringTools.convertCamelCaseToAllCaps("TestTest", 1100));
- assertEquals("TEST_TEST_", StringTools.convertCamelCaseToAllCaps("testTESTTest", 10));
- assertEquals("TEST_TEST_TEST", StringTools.convertCamelCaseToAllCaps("TestTESTTest", 14));
- assertEquals("TEST_TEST_TEST_T", StringTools.convertCamelCaseToAllCaps("TestTESTTestT", 16));
- assertEquals("TEST_TEST_TEST_", StringTools.convertCamelCaseToAllCaps("TestTESTTestT", 15));
- }
-
- public void testConvertCamelCaseToAllCapsMaxLengthOnWriter() {
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST", "test", 44);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST", "test", 4);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TES", "test", 3);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST", "TEST", 5);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TE", "TEST", 2);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST", "testTest", 9);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TES", "testTest", 8);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_T", "testTest", 6);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_", "testTest", 5);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST", "testTest", 4);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST", "TestTest", 9);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST", "TestTest", 1100);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST_", "testTESTTest", 10);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST_TEST", "TestTESTTest", 14);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST_TEST_T", "TestTESTTestT", 16);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST_TEST_", "TestTESTTestT", 15);
- }
-
- private void verifyConvertCamelCaseToAllCapsMaxLengthOnWriter(String expected, String string, int max) {
- Writer writer = new StringWriter();
- StringTools.convertCamelCaseToAllCapsOn(string, max, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testConvertCamelCaseToAllCapsMaxLengthOnStringBuffer() {
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST", "test", 44);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST", "test", 4);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TES", "test", 3);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST", "TEST", 5);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TE", "TEST", 2);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST", "testTest", 9);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TES", "testTest", 8);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_T", "testTest", 6);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_", "testTest", 5);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST", "testTest", 4);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST", "TestTest", 9);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST", "TestTest", 1100);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST_", "testTESTTest", 10);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST_TEST", "TestTESTTest", 14);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST_TEST_T", "TestTESTTestT", 16);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST_TEST_", "TestTESTTestT", 15);
- }
-
- private void verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer(String expected, String string, int max) {
- StringBuffer sb = new StringBuffer();
- StringTools.convertCamelCaseToAllCapsOn(string, max, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testConvertUnderscoresToCamelCase() {
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("TEST", false));
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("TEST_", false));
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("TEST____", false));
- assertEquals("Test", StringTools.convertUnderscoresToCamelCase("TEST", true));
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("TeST", false));
- assertEquals("testTest", StringTools.convertUnderscoresToCamelCase("TEST_TEST", false));
- assertEquals("testTest", StringTools.convertUnderscoresToCamelCase("TEST___TEST", false));
- assertEquals("TestTest", StringTools.convertUnderscoresToCamelCase("TEST_TEST", true));
- assertEquals("testTestTest", StringTools.convertUnderscoresToCamelCase("TEST_TEST_TEST", false));
- assertEquals("TestTestTest", StringTools.convertUnderscoresToCamelCase("TEST_TEST_TEST", true));
- assertEquals("testTestTestT", StringTools.convertUnderscoresToCamelCase("TEST_TEST_TEST_T", false));
- assertEquals("testTestTestT", StringTools.convertUnderscoresToCamelCase("_TEST_TEST_TEST_T", false));
- assertEquals("testTestTestT", StringTools.convertUnderscoresToCamelCase("__TEST_TEST_TEST_T", false));
- assertEquals("TestTestTestT", StringTools.convertUnderscoresToCamelCase("TEST_TEST_TEST_T", true));
- assertEquals("TestTestTestT", StringTools.convertUnderscoresToCamelCase("_TEST_TEST_TEST_T", true));
- assertEquals("TestTestTestT", StringTools.convertUnderscoresToCamelCase("__TEST_TEST_TEST_T", true));
- }
-
- public void testConvertUnderscoresToCamelCaseLowercase() {
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("test", false));
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("test_", false));
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("test____", false));
- assertEquals("Test", StringTools.convertUnderscoresToCamelCase("test", true));
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("test", false));
- assertEquals("testTest", StringTools.convertUnderscoresToCamelCase("test_test", false));
- assertEquals("testTest", StringTools.convertUnderscoresToCamelCase("test___test", false));
- assertEquals("TestTest", StringTools.convertUnderscoresToCamelCase("test_test", true));
- assertEquals("testTestTest", StringTools.convertUnderscoresToCamelCase("test_test_test", false));
- assertEquals("TestTestTest", StringTools.convertUnderscoresToCamelCase("test_test_test", true));
- assertEquals("testTestTestT", StringTools.convertUnderscoresToCamelCase("test_test_test_t", false));
- assertEquals("testTestTestT", StringTools.convertUnderscoresToCamelCase("_test_test_test_t", false));
- assertEquals("testTestTestT", StringTools.convertUnderscoresToCamelCase("__test_test_test_t", false));
- assertEquals("TestTestTestT", StringTools.convertUnderscoresToCamelCase("test_test_test_t", true));
- assertEquals("TestTestTestT", StringTools.convertUnderscoresToCamelCase("_test_test_test_t", true));
- assertEquals("TestTestTestT", StringTools.convertUnderscoresToCamelCase("__test_test_test_t", true));
- }
-
- public void testConvertUnderscoresToCamelCaseOnWriter() {
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "TEST_", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "TEST____", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("Test", "TEST", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "TeST", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTest", "TEST_TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTest", "TEST___TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTest", "TEST_TEST", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTest", "TEST_TEST_TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTest", "TEST_TEST_TEST", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTestT", "TEST_TEST_TEST_T", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTestT", "_TEST_TEST_TEST_T", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTestT", "__TEST_TEST_TEST_T", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTestT", "TEST_TEST_TEST_T", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTestT", "_TEST_TEST_TEST_T", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTestT", "__TEST_TEST_TEST_T", true);
- }
-
- public void testConvertUnderscoresToCamelCaseOnWriterLowercase() {
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "test", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "test_", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "test____", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("Test", "test", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "test", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTest", "test_test", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTest", "test___test", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTest", "test_test", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTest", "test_test_test", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTest", "test_test_test", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTestT", "test_test_test_t", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTestT", "_test_test_test_t", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTestT", "__test_test_test_t", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTestT", "test_test_test_t", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTestT", "_test_test_test_t", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTestT", "__test_test_test_t", true);
- }
-
- private void verifyConvertUnderscoresToCamelCaseOnWriter(String expected, String string, boolean capitalizeFirstLetter) {
- Writer writer = new StringWriter();
- StringTools.convertUnderscoresToCamelCaseOn(string, capitalizeFirstLetter, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testConvertUnderscoresToCamelCaseOnStringBuffer() {
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "TEST_", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "TEST____", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("Test", "TEST", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "TeST", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTest", "TEST_TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTest", "TEST___TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTest", "TEST_TEST", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTest", "TEST_TEST_TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTest", "TEST_TEST_TEST", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTestT", "TEST_TEST_TEST_T", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTestT", "_TEST_TEST_TEST_T", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTestT", "__TEST_TEST_TEST_T", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTestT", "TEST_TEST_TEST_T", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTestT", "_TEST_TEST_TEST_T", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTestT", "__TEST_TEST_TEST_T", true);
- }
-
- public void testConvertUnderscoresToCamelCaseOnStringBufferLowercase() {
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "test", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "test_", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "test____", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("Test", "test", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "test", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTest", "test_test", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTest", "test___test", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTest", "test_test", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTest", "test_test_test", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTest", "test_test_test", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTestT", "test_test_test_t", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTestT", "_test_test_test_t", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTestT", "__test_test_test_t", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTestT", "test_test_test_t", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTestT", "_test_test_test_t", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTestT", "__test_test_test_t", true);
- }
-
- private void verifyConvertUnderscoresToCamelCaseOnStringBuffer(String expected, String string, boolean capitalizeFirstLetter) {
- StringBuffer sb = new StringBuffer();
- StringTools.convertUnderscoresToCamelCaseOn(string, capitalizeFirstLetter, sb);
- assertEquals(expected, sb.toString());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedBooleanTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedBooleanTests.java
deleted file mode 100644
index 4b42839081..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedBooleanTests.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import org.eclipse.jpt.utility.internal.SynchronizedBoolean;
-
-import junit.framework.TestCase;
-
-public class SynchronizedBooleanTests extends TestCase {
- private volatile SynchronizedBoolean sb;
- private volatile boolean exCaught;
- private volatile boolean timeoutOccurred;
- private volatile long startTime;
- private volatile long endTime;
-
-
- public SynchronizedBooleanTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.sb = new SynchronizedBoolean();
- this.exCaught = false;
- this.timeoutOccurred = false;
- this.startTime = 0;
- this.endTime = 0;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testAccessors() throws Exception {
- this.sb.setValue(false);
- assertFalse(this.sb.value());
- assertFalse(this.sb.isTrue());
- assertTrue(this.sb.isFalse());
-
- this.sb.setValue(true);
- assertTrue(this.sb.value());
- assertTrue(this.sb.isTrue());
- assertFalse(this.sb.isFalse());
-
- this.sb.setFalse();
- assertFalse(this.sb.value());
- assertFalse(this.sb.isTrue());
- assertTrue(this.sb.isFalse());
-
- this.sb.setTrue();
- assertTrue(this.sb.value());
- assertTrue(this.sb.isTrue());
- assertFalse(this.sb.isFalse());
-
- assertSame(this.sb, this.sb.mutex());
- }
-
- public void testEquals() throws Exception {
- this.sb.setValue(false);
- SynchronizedBoolean sb2 = new SynchronizedBoolean(false);
- assertEquals(this.sb, sb2);
-
- this.sb.setValue(true);
- assertFalse(this.sb.equals(sb2));
-
- sb2.setValue(true);
- assertEquals(this.sb, sb2);
- }
-
- public void testHashCode() {
- this.sb.setValue(false);
- assertEquals(0, this.sb.hashCode());
-
- this.sb.setValue(true);
- assertEquals(1, this.sb.hashCode());
- }
-
- public void testWaitUntilTrue() throws Exception {
- this.verifyWaitUntilTrue(0);
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the value should be set to true by t2
- assertTrue(this.sb.value());
- // make a reasonable guess about how long t2 took
- assertTrue(this.elapsedTime() > 150);
- }
-
- public void testWaitUntilTrueTimeout() throws Exception {
- this.verifyWaitUntilTrue(20);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the value will eventually be set to true by t1
- assertTrue(this.sb.value());
- // make a reasonable guess about how long t2 took
- assertTrue(this.elapsedTime() < 150);
- }
-
- private void verifyWaitUntilTrue(long timeout) throws Exception {
- this.sb.setFalse();
- Runnable r1 = this.buildRunnable(this.buildSetTrueCommand(), this.sb, 200);
- Runnable r2 = this.buildRunnable(this.buildWaitUntilTrueCommand(timeout), this.sb, 0);
- Thread t1 = new Thread(r1);
- Thread t2 = new Thread(r2);
- t1.start();
- t2.start();
- while (t1.isAlive() || t2.isAlive()) {
- Thread.sleep(50);
- }
- assertFalse(this.exCaught);
- }
-
- public void testWaitToSetFalse() throws Exception {
- this.verifyWaitToSetFalse(0);
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the value should be set to false by t2
- assertFalse(this.sb.value());
- // make a reasonable guess about how long t2 took
- assertTrue(this.elapsedTime() > 150);
- }
-
- public void testWaitToSetFalseTimeout() throws Exception {
- this.verifyWaitToSetFalse(20);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the value will eventually be set to true by t1
- assertTrue(this.sb.value());
- // make a reasonable guess about how long t2 took
- assertTrue(this.elapsedTime() < 150);
- }
-
- private void verifyWaitToSetFalse(long timeout) throws Exception {
- this.sb.setFalse();
- Runnable r1 = this.buildRunnable(this.buildSetTrueCommand(), this.sb, 200);
- Runnable r2 = this.buildRunnable(this.buildWaitToSetFalseCommand(timeout), this.sb, 0);
- Thread t1 = new Thread(r1);
- Thread t2 = new Thread(r2);
- t1.start();
- t2.start();
- while (t1.isAlive() || t2.isAlive()) {
- Thread.sleep(50);
- }
- assertFalse(this.exCaught);
- }
-
- private Command buildSetTrueCommand() {
- return new Command() {
- public void execute(SynchronizedBoolean syncBool) {
- syncBool.setTrue();
- }
- };
- }
-
- private Command buildWaitUntilTrueCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedBoolean syncBool) throws Exception {
- SynchronizedBooleanTests.this.setStartTime(System.currentTimeMillis());
- SynchronizedBooleanTests.this.setTimeoutOccurred( ! syncBool.waitUntilTrue(timeout));
- SynchronizedBooleanTests.this.setEndTime(System.currentTimeMillis());
- }
- };
- }
-
- private Command buildWaitToSetFalseCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedBoolean syncBool) throws Exception {
- SynchronizedBooleanTests.this.setStartTime(System.currentTimeMillis());
- SynchronizedBooleanTests.this.setTimeoutOccurred( ! syncBool.waitToSetFalse(timeout));
- SynchronizedBooleanTests.this.setEndTime(System.currentTimeMillis());
- }
- };
- }
-
- private Runnable buildRunnable(final Command command, final SynchronizedBoolean syncBool, final long sleep) {
- return new Runnable() {
- public void run() {
- try {
- if (sleep != 0) {
- Thread.sleep(sleep);
- }
- command.execute(syncBool);
- } catch (Exception ex) {
- SynchronizedBooleanTests.this.setExCaught(true);
- }
- }
- };
- }
-
- void setExCaught(boolean exCaught) {
- this.exCaught = exCaught;
- }
-
- void setTimeoutOccurred(boolean timeoutOccurred) {
- this.timeoutOccurred = timeoutOccurred;
- }
-
- void setStartTime(long startTime) {
- this.startTime = startTime;
- }
-
- void setEndTime(long endTime) {
- this.endTime = endTime;
- }
-
- long elapsedTime() {
- return this.endTime - this.startTime;
- }
-
-
- // ********** Command interface **********
-
- private interface Command {
- void execute(SynchronizedBoolean syncBool) throws Exception;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedObjectTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedObjectTests.java
deleted file mode 100644
index e673aa2f42..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedObjectTests.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import org.eclipse.jpt.utility.internal.SynchronizedObject;
-
-import junit.framework.TestCase;
-
-public class SynchronizedObjectTests extends TestCase {
- private volatile SynchronizedObject<Object> so;
- private volatile boolean exCaught;
- private volatile boolean timeoutOccurred;
- volatile Object value = new Object();
- private volatile long startTime;
- private volatile long endTime;
- private volatile Object soValue;
-
-
- public SynchronizedObjectTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.so = new SynchronizedObject<Object>();
- this.exCaught = false;
- this.timeoutOccurred = false;
- this.startTime = 0;
- this.endTime = 0;
- this.soValue = null;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testAccessors() throws Exception {
- this.so.setValue(null);
- assertNull(this.so.value());
- assertFalse(this.so.isNotNull());
- assertTrue(this.so.isNull());
-
- this.so.setValue(this.value);
- assertEquals(this.value, this.so.value());
- assertTrue(this.so.isNotNull());
- assertFalse(this.so.isNull());
-
- this.so.setNull();
- assertNull(this.so.value());
- assertFalse(this.so.isNotNull());
- assertTrue(this.so.isNull());
-
- assertSame(this.so, this.so.mutex());
- }
-
- public void testEquals() throws Exception {
- this.so.setValue(null);
- SynchronizedObject<Object> so2 = new SynchronizedObject<Object>(null);
- assertEquals(this.so, so2);
-
- this.so.setValue(this.value);
- assertFalse(this.so.equals(so2));
-
- so2.setValue(this.value);
- assertEquals(this.so, so2);
- }
-
- public void testHashCode() {
- this.so.setValue(this.value);
- assertEquals(this.value.hashCode(), this.so.hashCode());
-
- this.so.setValue(null);
- assertEquals(0, this.so.hashCode());
- }
-
- /**
- * t2 will wait indefinitely until t1 sets the value to null
- */
- public void testWaitUntilNull() throws Exception {
- this.verifyWaitUntilNull(0);
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the value should be set to null by t2
- assertNull(this.so.value());
- // make a reasonable guess about how long t2 took
- long time = this.elapsedTime();
- assertTrue("t2 finished a bit early (expected value should be > 150): " + time, time > 150);
- }
-
- /**
- * t2 will time out waiting for t1 to set the value to null
- */
- public void testWaitUntilNullTimeout() throws Exception {
- this.verifyWaitUntilNull(20);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the value will eventually be set to null by t1
- assertNull(this.so.value());
- // make a reasonable guess about how long t2 took
- long time = this.elapsedTime();
- assertTrue("t2 finished a bit late (expected value should be < 150): " + time, time < 150);
- }
-
- private void verifyWaitUntilNull(long t2Timeout) throws Exception {
- this.executeThreads(this.buildSetNullCommand(), this.buildWaitUntilNullCommand(t2Timeout));
- }
-
- /**
- * t2 will wait indefinitely until t1 sets the value to null;
- * then t2 will set the value to an object
- */
- public void testWaitToSetValue() throws Exception {
- this.verifyWaitToSetValue(0);
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the value should be set to an object by t2
- assertTrue(this.so.isNotNull());
- // make a reasonable guess about how long t2 took
- long time = this.elapsedTime();
- assertTrue("t2 finished a bit early (expected value should be > 150): " + time, time > 150);
- }
-
- /**
- * t2 will time out waiting for t1 to set the value to null
- */
- public void testWaitToSetValueTimeout() throws Exception {
- this.verifyWaitToSetValue(20);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the value will eventually be set to null by t1
- assertTrue(this.so.isNull());
- // make a reasonable guess about how long t2 took
- long time = this.elapsedTime();
- assertTrue("t2 finished a bit late (expected value should be < 150): " + time, time < 150);
- }
-
- private void verifyWaitToSetValue(long t2Timeout) throws Exception {
- this.executeThreads(this.buildSetNullCommand(), this.buildWaitToSetValueCommand(t2Timeout));
- }
-
- /**
- * t2 will wait until t1 is finished "initializing" the value;
- * then t2 will get the newly-initialized value ("foo")
- */
- public void testExecute() throws Exception {
- this.so.setValue(null);
- Runnable r1 = this.buildRunnable(this.buildInitializeValueCommand(), this.so, 0);
- // give t1 a head start of 100 ms
- Runnable r2 = this.buildRunnable(this.buildGetValueCommand(), this.so, 100);
- Thread t1 = new Thread(r1);
- Thread t2 = new Thread(r2);
- t1.start();
- t2.start();
- while (t1.isAlive() || t2.isAlive()) {
- Thread.sleep(50);
- }
- assertFalse(this.exCaught);
- assertEquals("foo", this.so.value());
- assertEquals("foo", this.soValue);
- // make a reasonable guess about how long t2 took
- long time = this.elapsedTime();
- assertTrue("t2 finished a bit early (expected value should be > 100): " + time, time > 300);
- }
-
- private void executeThreads(Command t1Command, Command t2Command) throws Exception {
- this.so.setValue(this.value);
- Runnable r1 = this.buildRunnable(t1Command, this.so, 200);
- Runnable r2 = this.buildRunnable(t2Command, this.so, 0);
- Thread t1 = new Thread(r1);
- Thread t2 = new Thread(r2);
- t1.start();
- t2.start();
- while (t1.isAlive() || t2.isAlive()) {
- Thread.sleep(50);
- }
- assertFalse(this.exCaught);
- }
-
- private Command buildSetNullCommand() {
- return new Command() {
- public void execute(SynchronizedObject<Object> sObject) {
- sObject.setNull();
- }
- };
- }
-
- private Command buildWaitUntilNullCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedObject<Object> sObject) throws Exception {
- SynchronizedObjectTests.this.setStartTime(System.currentTimeMillis());
- SynchronizedObjectTests.this.setTimeoutOccurred( ! sObject.waitUntilNull(timeout));
- SynchronizedObjectTests.this.setEndTime(System.currentTimeMillis());
- }
- };
- }
-
- private Command buildWaitToSetValueCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedObject<Object> sObject) throws Exception {
- SynchronizedObjectTests.this.setStartTime(System.currentTimeMillis());
- SynchronizedObjectTests.this.setTimeoutOccurred( ! sObject.waitToSetValue(SynchronizedObjectTests.this.value, timeout));
- SynchronizedObjectTests.this.setEndTime(System.currentTimeMillis());
- }
- };
- }
-
- private Command buildInitializeValueCommand() {
- return new Command() {
- public void execute(final SynchronizedObject<Object> sObject) throws Exception {
- sObject.execute(
- new org.eclipse.jpt.utility.Command() {
- public void execute() {
- // pretend to perform some long initialization process
- try {
- Thread.sleep(500);
- } catch (Exception ex) {
- SynchronizedObjectTests.this.setExCaught(true);
- }
- sObject.setValue("foo");
- }
- }
- );
- }
- };
- }
-
- private Command buildGetValueCommand() {
- return new Command() {
- public void execute(SynchronizedObject<Object> sObject) throws Exception {
- SynchronizedObjectTests.this.setStartTime(System.currentTimeMillis());
- SynchronizedObjectTests.this.setSOValue(sObject.value());
- SynchronizedObjectTests.this.setEndTime(System.currentTimeMillis());
- }
- };
- }
-
- private Runnable buildRunnable(final Command command, final SynchronizedObject<Object> sObject, final long sleep) {
- return new Runnable() {
- public void run() {
- try {
- if (sleep != 0) {
- Thread.sleep(sleep);
- }
- command.execute(sObject);
- } catch (Exception ex) {
- SynchronizedObjectTests.this.setExCaught(true);
- }
- }
- };
- }
-
- void setExCaught(boolean exCaught) {
- this.exCaught = exCaught;
- }
-
- void setTimeoutOccurred(boolean timeoutOccurred) {
- this.timeoutOccurred = timeoutOccurred;
- }
-
- void setStartTime(long startTime) {
- this.startTime = startTime;
- }
-
- void setEndTime(long endTime) {
- this.endTime = endTime;
- }
-
- private long elapsedTime() {
- return this.endTime - this.startTime;
- }
-
- void setSOValue(Object soValue) {
- this.soValue = soValue;
- }
-
-
- // ********** Command interface **********
-
- private interface Command {
- void execute(SynchronizedObject<Object> so) throws Exception;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedStackTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedStackTests.java
deleted file mode 100644
index adb83d9f83..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedStackTests.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.util.EmptyStackException;
-
-import org.eclipse.jpt.utility.internal.SimpleStack;
-import org.eclipse.jpt.utility.internal.Stack;
-import org.eclipse.jpt.utility.internal.SynchronizedStack;
-
-public class SynchronizedStackTests extends SimpleStackTests {
- private volatile SynchronizedStack<String> ss;
- private volatile boolean exCaught;
- private volatile boolean timeoutOccurred;
- private volatile long startTime;
- private volatile long endTime;
- private volatile Object poppedObject;
-
- static final String ITEM_1 = new String();
- static final String ITEM_2 = new String();
-
- public SynchronizedStackTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.ss = new SynchronizedStack<String>();
- this.exCaught = false;
- this.timeoutOccurred = false;
- this.startTime = 0;
- this.endTime = 0;
- this.poppedObject = null;
- }
-
- /**
- * test first with an unsynchronized stack,
- * then with a synchronized stack
- */
- public void testConcurrentAccess() throws Exception {
- this.verifyConcurrentAccess(new SlowSimpleStack<String>(), "second");
- this.verifyConcurrentAccess(new SlowSynchronizedStack<String>(), "first");
- }
-
- private void verifyConcurrentAccess(SlowStack<String> slowStack, String expected) throws Exception {
- slowStack.push("first");
- slowStack.push("second");
-
- new Thread(this.buildRunnable(slowStack)).start();
- Thread.sleep(200);
-
- assertEquals(expected, slowStack.pop());
- }
-
- private Runnable buildRunnable(final SlowStack<String> slowStack) {
- return new Runnable() {
- public void run() {
- slowStack.slowPop();
- }
- };
- }
-
-
- private interface SlowStack<E> extends Stack<E> {
- Object slowPop();
- }
-
- private class SlowSimpleStack<E> extends SimpleStack<E> implements SlowStack<E> {
- SlowSimpleStack() {
- super();
- }
- public Object slowPop() {
- try {
- Thread.sleep(500);
- } catch (InterruptedException ex) {
- throw new RuntimeException(ex);
- }
- return this.pop();
- }
-
- }
-
- private class SlowSynchronizedStack<E> extends SynchronizedStack<E> implements SlowStack<E> {
- SlowSynchronizedStack() {
- super();
- }
- public synchronized Object slowPop() {
- try {
- Thread.sleep(100);
- } catch (InterruptedException ex) {
- throw new RuntimeException(ex);
- }
- return this.pop();
- }
-
- }
-
-
- // ********** waits **********
-
- public void testWaitToPop() throws Exception {
- this.verifyWaitToPop(0);
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and an item should have been popped by t2...
- assertSame(ITEM_1, this.poppedObject);
- // ...and the stack should be empty
- assertTrue(this.ss.isEmpty());
- // make a reasonable guess about how long t2 took
- assertTrue(this.elapsedTime() > 150);
- }
-
- public void testWaitToPopTimeout() throws Exception {
- this.verifyWaitToPop(20);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the stack was never popped...
- assertNull(this.poppedObject);
- // ...and it still holds the item
- assertSame(ITEM_1, this.ss.peek());
- // make a reasonable guess about how long t2 took
- assertTrue(this.elapsedTime() < 150);
- }
-
- private void verifyWaitToPop(long timeout) throws Exception {
- Runnable r1 = this.buildRunnable(this.buildPushCommand(), this.ss, 200);
- Runnable r2 = this.buildRunnable(this.buildWaitToPopCommand(timeout), this.ss, 0);
- Thread t1 = new Thread(r1);
- Thread t2 = new Thread(r2);
- t1.start();
- t2.start();
- while (t1.isAlive() || t2.isAlive()) {
- Thread.sleep(50);
- }
- assertFalse(this.exCaught);
- }
-
- public void testWaitToPush() throws Exception {
- this.verifyWaitToPush(0);
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the stack gets popped by t1...
- assertSame(ITEM_1, this.poppedObject);
- // ...and an item is pushed on to the stack by t2
- assertFalse(this.ss.isEmpty());
- assertSame(ITEM_2, this.ss.peek());
- // make a reasonable guess about how long t2 took
- assertTrue(this.elapsedTime() > 150);
- }
-
- public void testWaitToPushTimeout() throws Exception {
- this.verifyWaitToPush(20);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the stack is eventually popped by t1...
- assertSame(ITEM_1, this.poppedObject);
- // ...but nothing is pushed on to the stack by t2
- assertTrue(this.ss.isEmpty());
- // make a reasonable guess about how long t2 took
- assertTrue(this.elapsedTime() < 150);
- }
-
- private void verifyWaitToPush(long timeout) throws Exception {
- this.ss.push(ITEM_1);
- Runnable r1 = this.buildRunnable(this.buildPopCommand(), this.ss, 200);
- Runnable r2 = this.buildRunnable(this.buildWaitToPushCommand(timeout), this.ss, 0);
- Thread t1 = new Thread(r1);
- Thread t2 = new Thread(r2);
- t1.start();
- t2.start();
- while (t1.isAlive() || t2.isAlive()) {
- Thread.sleep(50);
- }
- assertFalse(this.exCaught);
- }
-
- private Command buildPushCommand() {
- return new Command() {
- public void execute(SynchronizedStack<String> synchronizedStack) {
- synchronizedStack.push(ITEM_1);
- }
- };
- }
-
- private Command buildWaitToPopCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedStack<String> synchronizedStack) throws Exception {
- SynchronizedStackTests.this.setStartTime(System.currentTimeMillis());
- try {
- SynchronizedStackTests.this.setPoppedObject(synchronizedStack.waitToPop(timeout));
- } catch (EmptyStackException ex) {
- SynchronizedStackTests.this.setTimeoutOccurred(true);
- }
- SynchronizedStackTests.this.setEndTime(System.currentTimeMillis());
- }
- };
- }
-
- private Command buildPopCommand() {
- return new Command() {
- public void execute(SynchronizedStack<String> synchronizedStack) {
- SynchronizedStackTests.this.setPoppedObject(synchronizedStack.pop());
- }
- };
- }
-
- private Command buildWaitToPushCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedStack<String> synchronizedStack) throws Exception {
- SynchronizedStackTests.this.setStartTime(System.currentTimeMillis());
- SynchronizedStackTests.this.setTimeoutOccurred( ! synchronizedStack.waitToPush(ITEM_2, timeout));
- SynchronizedStackTests.this.setEndTime(System.currentTimeMillis());
- }
- };
- }
-
- private Runnable buildRunnable(final Command command, final SynchronizedStack<String> synchronizedStack, final long sleep) {
- return new Runnable() {
- public void run() {
- try {
- if (sleep != 0) {
- Thread.sleep(sleep);
- }
- command.execute(synchronizedStack);
- } catch (Exception ex) {
- SynchronizedStackTests.this.setExCaught(true);
- }
- }
- };
- }
-
- void setExCaught(boolean exCaught) {
- this.exCaught = exCaught;
- }
-
- void setTimeoutOccurred(boolean timeoutOccurred) {
- this.timeoutOccurred = timeoutOccurred;
- }
-
- void setStartTime(long startTime) {
- this.startTime = startTime;
- }
-
- void setEndTime(long endTime) {
- this.endTime = endTime;
- }
-
- void setPoppedObject(Object poppedObject) {
- this.poppedObject = poppedObject;
- }
-
- long elapsedTime() {
- return this.endTime - this.startTime;
- }
-
-
- // ********** Command interface **********
-
- private interface Command {
- void execute(SynchronizedStack<String> synchronizedStack) throws Exception;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java
deleted file mode 100644
index 57fe19877c..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import junit.framework.TestCase;
-import junit.framework.TestFailure;
-import junit.framework.TestResult;
-
-/**
- * various tools that can be used by test cases
- */
-public final class TestTools {
-
- /**
- * test an object's implementation of Serializable by serializing the
- * specified object to a byte array; then de-serializing the byte array and
- * returning the resultant object
- */
- public static <T> T serialize(T o) throws IOException, ClassNotFoundException {
- ByteArrayOutputStream baOutStream = new ByteArrayOutputStream(2000);
- ObjectOutputStream outStream = new ObjectOutputStream(baOutStream);
- outStream.writeObject(o);
- outStream.close();
-
- ByteArrayInputStream baInStream = new ByteArrayInputStream(baOutStream.toByteArray());
- ObjectInputStream inStream = new ObjectInputStream(baInStream);
- T o2 = readObject(inStream);
- inStream.close();
-
- return o2;
- }
-
- @SuppressWarnings("unchecked")
- private static <T> T readObject(ObjectInput objectInput) throws IOException, ClassNotFoundException {
- return (T) objectInput.readObject();
- }
-
- /**
- * redirect std out and std err to the specified stream
- */
- public static void redirectSystemStreamsTo(OutputStream outputStream) {
- redirectSystemStreamsTo(new PrintStream(outputStream));
- }
-
- /**
- * redirect std out and std err to the specified stream
- */
- public static void redirectSystemStreamsTo(PrintStream printStream) {
- System.setOut(printStream);
- System.setErr(printStream);
- }
-
- /**
- * execute the specified test and dump the results to the console
- */
- public static String execute(TestCase testCase) {
- long start = System.currentTimeMillis();
- TestResult result = testCase.run();
- long end = System.currentTimeMillis();
-
- StringWriter stringWriter = new StringWriter();
- PrintWriter writer = new PrintWriter(stringWriter);
- writer.print(testCase.getName());
- writer.print(": ");
- if (result.wasSuccessful()) {
- writer.println("OK");
- } else {
- TestFailure failure = null;
- if (result.failures().hasMoreElements()) {
- failure = (TestFailure) result.failures().nextElement();
- } else {
- failure = (TestFailure) result.errors().nextElement();
- }
- failure.thrownException().printStackTrace(writer);
- }
- writer.print("elapsed time: ");
- long elapsed = end - start;
- writer.print(elapsed / 1000L);
- writer.println(" sec.");
- return stringWriter.toString();
- }
-
- private static final Class<TestCase> TestCase_class = TestCase.class;
-
- /**
- * Clear out all the instance variable of the specified test case, allowing
- * the various test fixtures to be garbage-collected. Typically this is
- * called in the #tearDown() method.
- */
- public static void clear(TestCase testCase) throws IllegalAccessException {
- for (Class<?> tempClass = testCase.getClass(); tempClass != TestCase_class; tempClass = tempClass.getSuperclass()) {
- Field[] fields = tempClass.getDeclaredFields();
- for (int i = fields.length; i-- > 0;) {
- Field field = fields[i];
- // leave primitives alone - they don't get garbage-collected, and we can't set them to null...
- if (field.getType().isPrimitive()) {
- continue;
- }
- // leave static fields alone (?)
- if (Modifier.isStatic(field.getModifiers())) {
- continue;
- }
- field.setAccessible(true);
- field.set(testCase, null);
- }
- }
- }
-
- /**
- * Workaround for a JUnit bug: JUnit does not configure the testing Thread
- * with a context class loader. This should probably happen in
- * TestRunner.doRunTest(Test), just before starting the thread.
- */
- public static void setUpJUnitThreadContextClassLoader() {
- Thread.currentThread().setContextClassLoader(TestTools.class.getClassLoader());
- }
-
- private TestTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java
deleted file mode 100644
index 3b104b9b89..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.FileTools;
-import org.eclipse.jpt.utility.internal.XMLStringEncoder;
-
-public class XMLStringEncoderTests extends TestCase {
-
- public XMLStringEncoderTests(String name) {
- super(name);
- }
-
- public void testEncodeNoCharacterSequences() {
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
-
- String s = "foo";
- assertEquals(s, encoder.encode(s));
-
- s = "123foo123";
- assertEquals(s, encoder.encode(s));
- }
-
- public void testEncodeCharacterSequences() {
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
-
- String s = "?foo?";
- String expected = "&#x3f;foo&#x3f;";
- assertEquals(expected, encoder.encode(s));
-
- s = "?foo&123";
- expected = "&#x3f;foo&#x26;123";
- assertEquals(expected, encoder.encode(s));
- }
-
- public void testDenormalizeValidFileName() {
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
-
- String s = "foo";
- assertEquals(s, encoder.decode(s));
-
- s = "123foo123";
- assertEquals(s, encoder.decode(s));
- }
-
- public void testDenormalizeInvalidFileName() {
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
-
- String s = "&#x3f;foo&#x3f;";
- String expected = "?foo?";
- assertEquals(expected, encoder.decode(s));
-
- s = "&#x3f;foo&#x26;123";
- expected = "?foo&123";
- assertEquals(expected, encoder.decode(s));
- }
-
- public void testRoundTripNoCharacterSequences() {
- this.verifyRoundTrip("foo");
- this.verifyRoundTrip("123foo456");
- }
-
- public void testRoundTripCharacterSequences() {
- this.verifyRoundTrip("?foo?");
- this.verifyRoundTrip("?foo&123&&&&&&>>>>");
- }
-
- private void verifyRoundTrip(String s) {
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
- String actual = encoder.encode(s);
- assertEquals(s, encoder.decode(actual));
- }
-
- public void testInvalidCharacterSequence1() {
- this.verifyIllegalStateException("foo&");
- }
-
- public void testInvalidCharacterSequence2() {
- this.verifyIllegalStateException("foo&#");
- }
-
- public void testInvalidCharacterSequence3() {
- this.verifyIllegalStateException("foo&#x");
- }
-
- public void testInvalidCharacterSequence4() {
- this.verifyIllegalStateException("foo&#x3");
- }
-
- public void testInvalidCharacterSequence5() {
- this.verifyIllegalStateException("foo&#x;");
- }
-
- public void testInvalidCharacterSequence6() {
- this.verifyIllegalStateException("foo&A");
- }
-
- public void testInvalidCharacterSequence7() {
- this.verifyIllegalStateException("foo&#A");
- }
-
- private void verifyIllegalStateException(String s) {
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
- boolean exCaught = false;
- try {
- s = encoder.decode(s);
- fail(s);
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidCharacterSequence8() {
- String s = "foo&#xZZZZ;";
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
- boolean exCaught = false;
- try {
- s = encoder.decode(s);
- fail(s);
- } catch (NumberFormatException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayIteratorTests.java
deleted file mode 100644
index d2309c351c..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayIteratorTests.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-
-public class ArrayIteratorTests extends TestCase {
-
- public ArrayIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(this.buildArray().length, i);
- }
-
- public void testNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildIterator(); stream.hasNext();) {
- assertEquals("bogus element", ++i, Integer.parseInt(stream.next()));
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildIterator(); stream.hasNext();) {
- if (stream.next().equals("3")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testIllegalArgumentException() {
- this.triggerIllegalArgumentException(-1, 1);
- this.triggerIllegalArgumentException(8, 1);
- this.triggerIllegalArgumentException(0, -1);
- this.triggerIllegalArgumentException(0, 9);
- }
-
- public void testGenerics() {
- Integer[] integers = new Integer[3];
- integers[0] = new Integer(0);
- integers[1] = new Integer(1);
- integers[2] = new Integer(2);
- int i = 0;
- for (Iterator<Number> stream = new ArrayIterator<Number>(integers); stream.hasNext();) {
- assertEquals(i++, stream.next().intValue());
- }
- assertEquals(integers.length, i);
- }
-
- public void testVarargs() {
- int i = 0;
- for (Iterator<Number> stream = new ArrayIterator<Number>(new Integer(0), new Integer(1), new Integer(2)); stream.hasNext();) {
- assertEquals(i++, stream.next().intValue());
- }
- assertEquals(3, i);
- }
-
- public void triggerIllegalArgumentException(int start, int length) {
- boolean exCaught = false;
- Iterator<String> stream = null;
- try {
- stream = this.buildIterator(start, length);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue("IllegalArgumentException not thrown: " + stream, exCaught);
- }
-
- Iterator<String> buildIterator() {
- return this.buildIterator(this.buildArray());
- }
-
- Iterator<String> buildIterator(String[] array) {
- return new ArrayIterator<String>(array);
- }
-
- Iterator<String> buildIterator(int start, int length) {
- return this.buildIterator(this.buildArray(), start, length);
- }
-
- Iterator<String> buildIterator(String[] array, int start, int length) {
- return new ArrayIterator<String>(array, start, length);
- }
-
- String[] buildArray() {
- return new String[] { "1", "2", "3", "4", "5", "6", "7", "8" };
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayListIteratorTests.java
deleted file mode 100644
index 44f8e86a94..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayListIteratorTests.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.utility.internal.iterators.ArrayListIterator;
-
-public class ArrayListIteratorTests extends ArrayIteratorTests {
-
- public ArrayListIteratorTests(String name) {
- super(name);
- }
-
- public void testHasPrevious() {
- ListIterator<String> stream = this.buildListIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- int i = 0;
- while (stream.hasPrevious()) {
- stream.previous();
- i++;
- }
- assertEquals(this.buildArray().length, i);
- }
-
- public void testPrevious() {
- ListIterator<String> stream = this.buildListIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- int i = this.buildArray().length;
- while (stream.hasPrevious()) {
- assertEquals("bogus element", i--, Integer.parseInt(stream.previous()));
- }
- }
-
- public void testNextIndex() {
- int i = 0;
- ListIterator<String> stream = this.buildListIterator();
- while (stream.hasNext()) {
- assertEquals(i, stream.nextIndex());
- stream.next();
- i++;
- }
- assertEquals(i, stream.nextIndex());
- }
-
- public void testPreviousIndex() {
- int i = 0;
- ListIterator<String> stream = this.buildListIterator();
- while (stream.hasNext()) {
- assertEquals(i - 1, stream.previousIndex());
- stream.next();
- i++;
- }
- assertEquals(i - 1, stream.previousIndex());
- }
-
- @Override
- public void testNoSuchElementException() {
- boolean exCaught = false;
- ListIterator<String> stream = this.buildListIterator();
- String string = null;
- try {
- string = stream.previous();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testUnsupportedOperationExceptionAdd() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildListIterator(); stream.hasNext();) {
- if (stream.next().equals("3")) {
- try {
- stream.add("3.5");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testUnsupportedOperationExceptionSet() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildListIterator(); stream.hasNext();) {
- if (stream.next().equals("3")) {
- try {
- stream.set("three");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- @Override
- public void testGenerics() {
- Integer[] integers = new Integer[3];
- integers[0] = new Integer(0);
- integers[1] = new Integer(1);
- integers[2] = new Integer(2);
- int i = 0;
- for (Iterator<Number> stream = new ArrayListIterator<Number>(integers); stream.hasNext();) {
- assertEquals(i++, stream.next().intValue());
- }
- assertEquals(integers.length, i);
- }
-
- @Override
- public void testVarargs() {
- int i = 0;
- for (Iterator<Number> stream = new ArrayListIterator<Number>(new Integer(0), new Integer(1), new Integer(2)); stream.hasNext();) {
- assertEquals(i++, stream.next().intValue());
- }
- assertEquals(3, i);
- }
-
- private ListIterator<String> buildListIterator() {
- return this.buildListIterator(this.buildArray());
- }
-
- private ListIterator<String> buildListIterator(String[] array) {
- return new ArrayListIterator<String>(array);
- }
-
- @Override
- Iterator<String> buildIterator(String[] array) {
- return new ArrayListIterator<String>(array);
- }
-
- @Override
- Iterator<String> buildIterator(String[] array, int start, int length) {
- return new ArrayListIterator<String>(array, start, length);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ChainIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ChainIteratorTests.java
deleted file mode 100644
index 18b3db2669..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ChainIteratorTests.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.AbstractCollection;
-import java.util.AbstractList;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Vector;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.ChainIterator;
-
-public class ChainIteratorTests extends TestCase {
- private final static Class<?>[] VECTOR_HIERARCHY = { Vector.class, AbstractList.class, AbstractCollection.class, Object.class };
-
- public ChainIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<Class<?>> stream = this.buildIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(VECTOR_HIERARCHY.length, i);
- }
-
- public void testInnerHasNext() {
- int i = 0;
- for (Iterator<Class<?>> stream = this.buildInnerIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(VECTOR_HIERARCHY.length, i);
- }
-
- public void testNext() {
- int i = 0;
- for (Iterator<Class<?>> stream = this.buildIterator(); stream.hasNext(); i++) {
- assertEquals("bogus link", VECTOR_HIERARCHY[i], stream.next());
- }
- }
-
- public void testInnerNext() {
- int i = 0;
- for (Iterator<Class<?>> stream = this.buildInnerIterator(); stream.hasNext(); i++) {
- assertEquals("bogus link", VECTOR_HIERARCHY[i], stream.next());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<Class<?>> stream = this.buildIterator();
- Class<?> javaClass = null;
- while (stream.hasNext()) {
- javaClass = stream.next();
- }
- try {
- javaClass = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + javaClass, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<Class<?>> stream = this.buildIterator(); stream.hasNext();) {
- if (stream.next() == AbstractCollection.class) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- private Iterator<Class<?>> buildIterator() {
- return this.buildChainIterator(Vector.class, this.buildLinker());
- }
-
- private Iterator<Class<?>> buildInnerIterator() {
- return this.buildInnerChainIterator(Vector.class);
- }
-
- private Iterator<Class<?>> buildChainIterator(Class<?> startLink, ChainIterator.Linker<Class<?>> linker) {
- return new ChainIterator<Class<?>>(startLink, linker);
- }
-
- private ChainIterator.Linker<Class<?>> buildLinker() {
- // chain up the class's hierarchy
- return new ChainIterator.Linker<Class<?>>() {
- public Class<?> nextLink(Class<?> currentLink) {
- return currentLink.getSuperclass();
- }
- };
- }
-
- private Iterator<Class<?>> buildInnerChainIterator(Class<?> startLink) {
- // chain up the class's hierarchy
- return new ChainIterator<Class<?>>(startLink) {
- @Override
- protected Class<?> nextLink(Class<?> currentLink) {
- return currentLink.getSuperclass();
- }
- };
- }
-
- public void testInvalidChainIterator() {
- // missing method override
- Iterator<Class<?>> iterator = new ChainIterator<Class<?>>(Vector.class);
- boolean exCaught = false;
- try {
- Class<?> c = iterator.next();
- fail("invalid class: " + c.getName());
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneIteratorTests.java
deleted file mode 100644
index e3afdb585f..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneIteratorTests.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-public class CloneIteratorTests extends TestCase {
- Collection<String> originalCollection;
-
- private boolean concurrentProblem;
- private Collection<String> concurrentCollection;
-
- public CloneIteratorTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.originalCollection = this.buildCollection();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testHasNext() {
- int originalSize = this.originalCollection.size();
- int i = 0;
- for (Iterator<String> stream = this.buildCloneIterator(); stream.hasNext();) {
- stream.next();
- // should allow concurrent modification
- this.originalCollection.add("foo");
- i++;
- }
- assertTrue(originalSize != this.originalCollection.size());
- assertEquals(originalSize, i);
- }
-
- public void testNext() {
- Iterator<String> nestedIterator = this.originalCollection.iterator();
- for (Iterator<String> stream = this.buildCloneIterator(); stream.hasNext();) {
- assertEquals("bogus element", nestedIterator.next(), stream.next());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildCloneIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testRemoveDefault() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildCloneIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testRemoveEliminator() {
- CloneIterator.Mutator<String> eliminator = new CloneIterator.Mutator<String>() {
- public void remove(String current) {
- CloneIteratorTests.this.originalCollection.remove(current);
- }
- };
- this.verifyRemove(new CloneIterator<String>(this.originalCollection, eliminator));
- }
-
- public void testRemoveSubclass() {
- this.verifyRemove(new CloneIterator<String>(this.originalCollection) {
- @Override
- protected void remove(String current) {
- CloneIteratorTests.this.originalCollection.remove(current);
- }
- });
- }
-
- /**
- * Test concurrent access: First build a clone iterator in a separate thread
- * that hangs momentarily during its construction; then modify the shared
- * collection in this thread. This would cause a
- * ConcurrentModificationException in the other thread if the clone iterator
- * were not synchronized on the original collection.
- */
- public void testConcurrentAccess() throws Exception {
- SlowCollection<String> slow = new SlowCollection<String>();
- this.populateCollection(slow);
- // using the unsynchronized collection will cause the test to fail
- // this.originalCollection = slow;
- this.originalCollection = Collections.synchronizedCollection(slow);
-
- this.concurrentProblem = false;
- this.concurrentCollection = new ArrayList<String>();
- Thread thread = new Thread(this.buildRunnable());
- thread.start();
- while (!slow.hasStartedClone()) {
- // wait for the other thread to start the clone...
- Thread.yield();
- }
- // ...then sneak in an extra element
- this.originalCollection.add("seventeen");
- while (thread.isAlive()) {
- // wait for the other thread to finish
- Thread.yield();
- }
- assertFalse(this.concurrentProblem);
- Collection<String> expected = new ArrayList<String>();
- this.populateCollection(expected);
- assertEquals(expected, this.concurrentCollection);
- }
-
- private Runnable buildRunnable() {
- return new Runnable() {
- public void run() {
- CloneIteratorTests.this.loopWithCloneIterator();
- }
- };
- }
-
- /**
- * use a clone iterator to loop over the "slow" collection and copy its
- * contents to the concurrent collection
- */
- void loopWithCloneIterator() {
- try {
- for (Iterator<String> stream = this.buildCloneIterator(); stream.hasNext();) {
- this.concurrentCollection.add(stream.next());
- }
- } catch (Throwable t) {
- this.concurrentProblem = true;
- }
- }
-
- private void verifyRemove(Iterator<String> iterator) {
- Object removed = "three";
- assertTrue(this.originalCollection.contains(removed));
- // try to remove before calling #next()
- boolean exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- while (iterator.hasNext()) {
- if (iterator.next().equals(removed)) {
- iterator.remove();
- // try to remove twice
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
- }
- assertFalse(this.originalCollection.contains(removed));
- }
-
- private Iterator<String> buildCloneIterator() {
- return this.buildCloneIterator(this.originalCollection);
- }
-
- private Iterator<String> buildCloneIterator(Collection<String> c) {
- return new CloneIterator<String>(c);
- }
-
- private Collection<String> buildCollection() {
- Collection<String> c = this.buildEmptyCollection();
- this.populateCollection(c);
- return c;
- }
-
- protected Collection<String> buildEmptyCollection() {
- return new ArrayList<String>();
- }
-
- private void populateCollection(Collection<String> c) {
- c.add("one");
- c.add("two");
- c.add("three");
- c.add("four");
- c.add("five");
- c.add("six");
- c.add("seven");
- c.add("eight");
- }
-
- // ********** custom collection **********
- static class SlowCollection<E> extends ArrayList<E> {
- private static final long serialVersionUID = 1L;
- private boolean hasStartedClone = false;
-
- public SlowCollection() {
- super();
- }
-
- @Override
- public Object[] toArray() {
- this.setHasStartedClone(true);
- // take a little snooze before returning the array
- try {
- Thread.sleep(100);
- } catch (InterruptedException ex) {
- throw new RuntimeException(ex);
- }
- return super.toArray();
- }
-
- synchronized void setHasStartedClone(boolean hasStartedClone) {
- this.hasStartedClone = hasStartedClone;
- }
-
- synchronized boolean hasStartedClone() {
- return this.hasStartedClone;
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneListIteratorTests.java
deleted file mode 100644
index c6045a9f12..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneListIteratorTests.java
+++ /dev/null
@@ -1,408 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-public class CloneListIteratorTests extends TestCase {
- List<String> originalList;
-
- private boolean concurrentProblem;
- private List<String> concurrentList;
-
- public CloneListIteratorTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.originalList = this.buildList();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testHasNext() {
- int originalSize = this.originalList.size();
- int i = 0;
- for (ListIterator<String> stream = this.buildCloneListIterator(); stream.hasNext();) {
- stream.next();
- // should allow concurrent modification
- this.originalList.add("foo");
- i++;
- }
- assertTrue(originalSize != this.originalList.size());
- assertEquals(originalSize, i);
- }
-
- public void testNext() {
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- for (ListIterator<String> stream = this.buildCloneListIterator(); stream.hasNext();) {
- assertEquals("bogus element", nestedListIterator.next(), stream.next());
- }
- }
-
- public void testIndex() {
- ListIterator<String> cloneListIterator = this.buildCloneListIterator();
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- for (int i = 0; i < 7; i++) {
- nestedListIterator.next();
- cloneListIterator.next();
- assertEquals("bogus index", nestedListIterator.nextIndex(), cloneListIterator.nextIndex());
- assertEquals("bogus index", nestedListIterator.previousIndex(), cloneListIterator.previousIndex());
- }
-
- for (int i = 0; i < 3; i++) {
- nestedListIterator.previous();
- cloneListIterator.previous();
- assertEquals("bogus index", nestedListIterator.nextIndex(), cloneListIterator.nextIndex());
- assertEquals("bogus index", nestedListIterator.previousIndex(), cloneListIterator.previousIndex());
- }
-
- while (nestedListIterator.hasNext()) {
- nestedListIterator.next();
- cloneListIterator.next();
- assertEquals("bogus index", nestedListIterator.nextIndex(), cloneListIterator.nextIndex());
- assertEquals("bogus index", nestedListIterator.previousIndex(), cloneListIterator.previousIndex());
- }
- }
-
- public void testHasPrevious() {
- int originalSize = this.originalList.size();
- int i = 0;
- ListIterator<String> stream = this.buildCloneListIterator();
- while (stream.hasNext()) {
- stream.next();
- this.originalList.add("foo");
- i++;
- }
- assertTrue(originalSize != this.originalList.size());
- originalSize = this.originalList.size();
- while (stream.hasPrevious()) {
- stream.previous();
- // should allow concurrent modification
- this.originalList.add("bar");
- i--;
- }
- assertTrue(originalSize != this.originalList.size());
- assertEquals(0, i);
- }
-
- public void testPrevious() {
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- ListIterator<String> stream = this.buildCloneListIterator();
- while (stream.hasNext()) {
- nestedListIterator.next();
- stream.next();
- }
- while (stream.hasPrevious()) {
- assertEquals("bogus element", nestedListIterator.previous(), stream.previous());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- ListIterator<String> stream = this.buildCloneListIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
-
- exCaught = false;
- while (stream.hasPrevious()) {
- string = stream.previous();
- }
- try {
- string = stream.previous();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testModifyDefault() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildCloneListIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
-
- exCaught = false;
- for (ListIterator<String> stream = this.buildCloneListIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.add("three and a half");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
-
- exCaught = false;
- for (ListIterator<String> stream = this.buildCloneListIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.set("another three");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testModifyMutatorNext() {
- this.verifyModifyNext(new CloneListIterator<String>(this.originalList, this.buildMutator()));
- }
-
- public void testModifyMutatorPrevious() {
- this.verifyModifyPrevious(new CloneListIterator<String>(this.originalList, this.buildMutator()));
- }
-
- private CloneListIterator.Mutator<String> buildMutator() {
- return new CloneListIterator.Mutator<String>() {
- public void add(int index, String o) {
- CloneListIteratorTests.this.originalList.add(index, o);
- }
-
- public void remove(int index) {
- CloneListIteratorTests.this.originalList.remove(index);
- }
-
- public void set(int index, String o) {
- CloneListIteratorTests.this.originalList.set(index, o);
- }
- };
- }
-
- public void testModifySubclassNext() {
- this.verifyModifyNext(this.buildSubclass());
- }
-
- public void testModifySubclassPrevious() {
- this.verifyModifyPrevious(this.buildSubclass());
- }
-
- private ListIterator<String> buildSubclass() {
- return new CloneListIterator<String>(this.originalList) {
- @Override
- protected void add(int currentIndex, String o) {
- CloneListIteratorTests.this.originalList.add(currentIndex, o);
- }
-
- @Override
- protected void remove(int currentIndex) {
- CloneListIteratorTests.this.originalList.remove(currentIndex);
- }
-
- @Override
- protected void set(int currentIndex, String o) {
- CloneListIteratorTests.this.originalList.set(currentIndex, o);
- }
- };
- }
-
- private void verifyModifyNext(ListIterator<String> iterator) {
- String removed = "three";
- String addedAfter = "five";
- String added = "five and a half";
- String replaced = "seven";
- String replacement = "another seven";
- assertTrue(this.originalList.contains(removed));
- assertTrue(this.originalList.contains(addedAfter));
- assertTrue(this.originalList.contains(replaced));
- // try to remove before calling #next()
- boolean exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- while (iterator.hasNext()) {
- String next = iterator.next();
- if (next.equals(addedAfter)) {
- iterator.add(added);
- }
- if (next.equals(removed)) {
- iterator.remove();
- // try to remove twice
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
- if (next.equals(replaced)) {
- iterator.set(replacement);
- }
- }
- assertTrue(this.originalList.contains(added));
- assertFalse(this.originalList.contains(removed));
- assertFalse(this.originalList.contains(replaced));
- assertTrue(this.originalList.contains(replacement));
- }
-
- private void verifyModifyPrevious(ListIterator<String> iterator) {
- String removed = "three";
- String addedBefore = "five";
- String added = "four and a half";
- String replaced = "seven";
- String replacement = "another seven";
- assertTrue(this.originalList.contains(removed));
- assertTrue(this.originalList.contains(addedBefore));
- assertTrue(this.originalList.contains(replaced));
- while (iterator.hasNext()) {
- iterator.next();
- }
- while (iterator.hasPrevious()) {
- Object previous = iterator.previous();
- if (previous.equals(addedBefore)) {
- iterator.add(added);
- }
- if (previous.equals(removed)) {
- iterator.remove();
- // try to remove twice
- boolean exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
- if (previous.equals(replaced)) {
- iterator.set(replacement);
- }
- }
- assertTrue(this.originalList.contains(added));
- assertFalse(this.originalList.contains(removed));
- assertFalse(this.originalList.contains(replaced));
- assertTrue(this.originalList.contains(replacement));
- }
-
- private ListIterator<String> buildCloneListIterator() {
- return this.buildCloneListIterator(this.originalList);
- }
-
- private ListIterator<String> buildCloneListIterator(List<String> list) {
- return new CloneListIterator<String>(list);
- }
-
- private ListIterator<String> buildNestedListIterator() {
- return this.originalList.listIterator();
- }
-
- private List<String> buildList() {
- List<String> list = this.buildEmptyList();
- this.populateList(list);
- return list;
- }
-
- private void populateList(List<String> list) {
- list.add("zero");
- list.add("one");
- list.add("two");
- list.add("three");
- list.add("four");
- list.add("five");
- list.add("six");
- list.add("seven");
- list.add("eight");
- list.add("nine");
- }
-
- protected List<String> buildEmptyList() {
- return new ArrayList<String>();
- }
-
- /**
- * Test concurrent access: First build a clone iterator in a separate thread
- * that hangs momentarily during its construction; then modify the shared
- * collection in this thread. This would cause a
- * ConcurrentModificationException in the other thread if the clone iterator
- * were not synchronized on the original collection.
- */
- public void testConcurrentAccess() throws Exception {
- CloneIteratorTests.SlowCollection<String> slow = new CloneIteratorTests.SlowCollection<String>();
- this.populateList(slow);
- // using the unsynchronized list will cause the test to fail
- // this.originalList = slow;
- this.originalList = Collections.synchronizedList(slow);
-
- this.concurrentProblem = false;
- this.concurrentList = new ArrayList<String>();
- Thread thread = new Thread(this.buildRunnable());
- thread.start();
- while (!slow.hasStartedClone()) {
- // wait for the other thread to start the clone...
- Thread.yield();
- }
- // ...then sneak in an extra element
- this.originalList.add("seventeen");
- while (thread.isAlive()) {
- // wait for the other thread to finish
- Thread.yield();
- }
- assertFalse(this.concurrentProblem);
- List<String> expected = new ArrayList<String>();
- this.populateList(expected);
- assertEquals(expected, this.concurrentList);
- }
-
- private Runnable buildRunnable() {
- return new Runnable() {
- public void run() {
- CloneListIteratorTests.this.loopWithCloneListIterator();
- }
- };
- }
-
- /**
- * use a clone iterator to loop over the "slow" collection and copy its
- * contents to the concurrent collection
- */
- void loopWithCloneListIterator() {
- try {
- for (ListIterator<String> stream = this.buildCloneListIterator(); stream.hasNext();) {
- this.concurrentList.add(stream.next());
- }
- } catch (Throwable t) {
- this.concurrentProblem = true;
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeIteratorTests.java
deleted file mode 100644
index 58c3976076..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeIteratorTests.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-
-public class CompositeIteratorTests extends TestCase {
-
- public CompositeIteratorTests(String name) {
- super(name);
- }
-
- public void testHasAnother() {
- this.verifyHasAnother(this.buildCompositeIterator());
- }
-
- public void testHasAnother2() {
- this.verifyHasAnother(this.buildCompositeIterator2());
- }
-
- public void testHasAnother3() {
- this.verifyHasAnother(this.buildCompositeIterator3());
- }
-
- void verifyHasAnother(Iterator<String> stream) {
- this.verifyHasAnother(8, stream);
- }
-
- void verifyHasAnother(int expected, Iterator<String> stream) {
- int i = 0;
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(expected, i);
- }
-
- public void testAnother() {
- this.verifyAnother(this.buildCompositeIterator());
- }
-
- public void testAnother2() {
- this.verifyAnother(this.buildCompositeIterator2());
- }
-
- public void testAnother3() {
- this.verifyAnother(this.buildCompositeIterator3());
- }
-
- void verifyAnother(Iterator<String> stream) {
- this.verifyAnother(1, stream);
- }
-
- void verifyAnother(int start, Iterator<String> stream) {
- int index = start;
- while (stream.hasNext()) {
- assertEquals("bogus element", String.valueOf(index++), stream.next().substring(0, 1));
- }
- }
-
- public void testRemove() {
- this.verifyRemove();
- }
-
- protected void verifyRemove() {
- List<String> list1 = this.buildList1();
- Object lastElement1 = list1.get(list1.size() - 1);
- List<String> list2 = this.buildList2();
- List<String> list3 = this.buildList3();
-
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(list1.listIterator());
- list.add(list2.listIterator());
- list.add(list3.listIterator());
-
- Iterator<String> stream = this.buildCompositeIterator(list.listIterator());
- while (stream.hasNext()) {
- Object next = stream.next();
- if (next.equals("333")) {
- stream.remove();
- }
- // test special case - where we are between iterators
- if (next.equals(lastElement1)) {
- // this will trigger the next iterator to be loaded
- stream.hasNext();
- // now try to remove from the previous iterator
- stream.remove();
- }
- }
- stream.remove();
-
- assertEquals("nothing removed from collection 1", this.buildList1().size() - 2, list1.size());
- assertFalse("element still in collection 1", list1.contains("333"));
- assertFalse("last element still in collection 1", list1.contains(lastElement1));
- assertTrue("wrong element removed from collection 1", list1.contains("22"));
-
- assertEquals("nothing removed from collection 3", this.buildList3().size() - 1, list3.size());
- assertFalse("element still in collection 3", list3.contains("88888888"));
- assertTrue("wrong element removed from collection 3", list3.contains("666666"));
- }
-
- public void testSingleElement() {
- String item = "0";
- this.verifyHasAnother(9, this.buildCompositeIterator(item, this.buildCompositeIterator()));
- this.verifyAnother(0, this.buildCompositeIterator(item, this.buildCompositeIterator()));
- }
-
- public void testNoSuchElementException() {
- this.verifyNoSuchElementException(this.buildCompositeIterator());
- }
-
- void verifyNoSuchElementException(Iterator<String> stream) {
- boolean exCaught = false;
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- this.verifyUnsupportedOperationException(this.buildUnmodifiableCompositeIterator());
- }
-
- void verifyUnsupportedOperationException(Iterator<String> stream) {
- boolean exCaught = false;
- while (stream.hasNext()) {
- Object string = stream.next();
- if (string.equals("333")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testIllegalStateException() {
- this.verifyIllegalStateException();
- }
-
- void verifyIllegalStateException() {
- this.verifyIllegalStateException(this.buildCompositeIterator());
- }
-
- void verifyIllegalStateException(Iterator<String> stream) {
- boolean exCaught = false;
- try {
- stream.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
-
- public void testEmptyHasAnother1() {
- this.verifyEmptyHasAnother(this.buildEmptyCompositeIterator1());
- }
-
- void verifyEmptyHasAnother(Iterator<String> stream) {
- int i = 0;
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(0, i);
- }
-
- public void testEmptyNoSuchElementException1() {
- this.verifyNoSuchElementException(this.buildEmptyCompositeIterator1());
- }
-
- public void testEmptyIllegalStateException1() {
- this.verifyEmptyIllegalStateException1();
- }
-
- void verifyEmptyIllegalStateException1() {
- this.verifyIllegalStateException(this.buildEmptyCompositeIterator1());
- }
-
- public void testEmptyHasAnother2() {
- this.verifyEmptyHasAnother(this.buildEmptyCompositeIterator2());
- }
-
- public void testEmptyNoSuchElementException2() {
- this.verifyNoSuchElementException(this.buildEmptyCompositeIterator2());
- }
-
- public void testEmptyIllegalStateException2() {
- this.verifyEmptyIllegalStateException2();
- }
-
- void verifyEmptyIllegalStateException2() {
- this.verifyIllegalStateException(this.buildEmptyCompositeIterator2());
- }
-
- Iterator<String> buildCompositeIterator() {
- return this.buildCompositeIterator(this.buildIterators());
- }
-
- Iterator<String> buildEmptyCompositeIterator1() {
- return this.buildCompositeIterator(this.buildEmptyIterators1());
- }
-
- Iterator<String> buildEmptyCompositeIterator2() {
- return this.buildCompositeIterator(this.buildEmptyIterators2());
- }
-
- Iterator<String> buildUnmodifiableCompositeIterator() {
- return this.buildCompositeIterator(this.buildUnmodifiableIterators());
- }
-
- // leave unchecked so we can override in subclass
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator(Iterator iterators) {
- return new CompositeIterator<String>(iterators);
- }
-
- // use vararg constructor
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator2() {
- return new CompositeIterator<String>(this.buildIterator1(), this.buildIterator2(), this.buildIterator3());
- }
-
- // use vararg constructor
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator3() {
- return new CompositeIterator<String>(new Iterator[] { this.buildIterator1(), this.buildIterator2(), this.buildIterator3() });
- }
-
- Iterator<String> buildCompositeIterator(String string, Iterator<String> iterator) {
- return new CompositeIterator<String>(string, iterator);
- }
-
- ListIterator<Iterator<String>> buildIterators() {
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(this.buildIterator1());
- list.add(this.buildIterator2());
- list.add(this.buildIterator3());
- return list.listIterator();
- }
-
- ListIterator<Iterator<String>> buildEmptyIterators1() {
- return this.buildEmptyIteratorIterator();
- }
-
- ListIterator<Iterator<String>> buildEmptyIterators2() {
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(this.buildEmptyStringIterator());
- list.add(this.buildEmptyStringIterator());
- list.add(this.buildEmptyStringIterator());
- return list.listIterator();
- }
-
- ListIterator<Iterator<String>> buildUnmodifiableIterators() {
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(this.buildUnmodifiableIterator1());
- list.add(this.buildUnmodifiableIterator2());
- list.add(this.buildUnmodifiableIterator3());
- return list.listIterator();
- }
-
- ListIterator<String> buildIterator1() {
- return this.buildList1().listIterator();
- }
-
- ListIterator<String> buildIterator2() {
- return this.buildList2().listIterator();
- }
-
- ListIterator<String> buildIterator3() {
- return this.buildList3().listIterator();
- }
-
- ListIterator<String> buildUnmodifiableIterator1() {
- return this.buildUnmodifiableList1().listIterator();
- }
-
- ListIterator<String> buildUnmodifiableIterator2() {
- return this.buildUnmodifiableList2().listIterator();
- }
-
- ListIterator<String> buildUnmodifiableIterator3() {
- return this.buildUnmodifiableList3().listIterator();
- }
-
- ListIterator<Iterator<String>> buildEmptyIteratorIterator() {
- return (new ArrayList<Iterator<String>>()).listIterator();
- }
-
- ListIterator<String> buildEmptyStringIterator() {
- return (new ArrayList<String>()).listIterator();
- }
-
- List<String> buildList1() {
- List<String> list = new ArrayList<String>();
- list.add("1");
- list.add("22");
- list.add("333");
- list.add("4444");
- return list;
- }
-
- List<String> buildList2() {
- return new ArrayList<String>();
- }
-
- List<String> buildList3() {
- List<String> list = new ArrayList<String>();
- list.add("55555");
- list.add("666666");
- list.add("7777777");
- list.add("88888888");
- return list;
- }
-
- List<String> buildUnmodifiableList1() {
- return Collections.unmodifiableList(this.buildList1());
- }
-
- List<String> buildUnmodifiableList2() {
- return Collections.unmodifiableList(this.buildList2());
- }
-
- List<String> buildUnmodifiableList3() {
- return Collections.unmodifiableList(this.buildList3());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeListIteratorTests.java
deleted file mode 100644
index 2d2bdbec7a..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeListIteratorTests.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.iterators.CompositeListIterator;
-
-public class CompositeListIteratorTests extends ReadOnlyCompositeListIteratorTests {
-
- public CompositeListIteratorTests(String name) {
- super(name);
- }
-
- @Override
- public void testRemove() {
- super.testRemove();
- List<String> list1 = this.buildList1();
- List<String> list2 = this.buildList2();
- List<String> list3 = this.buildList3();
- Object firstElement3 = list3.get(0);
-
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(list1.listIterator());
- list.add(list2.listIterator());
- list.add(list3.listIterator());
-
- ListIterator<String> stream = (ListIterator<String>) this.buildCompositeIterator(list.listIterator());
- // position to end of stream
- while (stream.hasNext()) {
- stream.next();
- }
- while (stream.hasPrevious()) {
- Object previous = stream.previous();
- if (previous.equals("333")) {
- stream.remove();
- }
- // test special case - where we are between iterators
- if (previous.equals(firstElement3)) {
- // this will trigger the next iterator to be loaded
- stream.hasPrevious();
- // now try to remove from the previous iterator
- stream.remove();
- }
- }
- stream.remove();
-
- assertEquals("nothing removed from collection 1", this.buildList1().size() - 2, list1.size());
- assertFalse("element still in collection 1", list1.contains("1"));
- assertFalse("element still in collection 1", list1.contains("333"));
-
- assertEquals("nothing removed from collection 3", this.buildList3().size() - 1, list3.size());
- assertFalse("first element still in collection 3", list3.contains(firstElement3));
- assertTrue("wrong element removed from collection 3", list3.contains("666666"));
- }
-
- public void testAdd() {
- List<String> list1 = this.buildList1();
- Object lastElement1 = list1.get(list1.size() - 1);
- List<String> list2 = this.buildList2();
- List<String> list3 = this.buildList3();
- Object firstElement3 = list3.get(0);
-
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(list1.listIterator());
- list.add(list2.listIterator());
- list.add(list3.listIterator());
-
- ListIterator<String> stream = (ListIterator<String>) this.buildCompositeIterator(list.listIterator());
- while (stream.hasNext()) {
- Object next = stream.next();
- if (next.equals("333")) {
- stream.add("3.5");
- }
- // test special case - where we are between iterators
- if (next.equals(lastElement1)) {
- // this will trigger the next iterator to be loaded
- stream.hasNext();
- // now try to add to the iterator
- stream.add("something in 3");
- }
- }
- stream.add("finale");
- boolean checkForFinale = true;
- while (stream.hasPrevious()) {
- Object previous = stream.previous();
- if (checkForFinale) {
- checkForFinale = false;
- assertEquals("added element dropped", "finale", previous);
- }
- if (previous.equals("333")) {
- stream.add("2.5");
- }
- // test special case - where we are between iterators
- if (previous.equals(firstElement3)) {
- // this will trigger the next iterator to be loaded
- stream.hasPrevious();
- // now try to remove from the previous iterator
- stream.add("old start of 3");
- }
- }
- stream.add("prelude");
- assertEquals("added element dropped", "prelude", stream.previous());
-
- assertEquals("elements not added to collection 1", this.buildList1().size() + 3, list1.size());
- assertEquals("element not added to collection 1", "prelude", list1.get(0));
- assertEquals("element not added to collection 1", "2.5", list1.get(3));
- assertEquals("element not added to collection 1", "3.5", list1.get(5));
-
- assertEquals("elements not added to collection 3", this.buildList3().size() + 3, list3.size());
- assertEquals("element not added to collection 3", "something in 3", list3.get(0));
- assertEquals("element not added to collection 3", "old start of 3", list3.get(1));
- assertEquals("element not added to collection 3", "finale", list3.get(list3.size() - 1));
-
- // add to the front
- stream = (ListIterator<String>) this.buildCompositeIterator();
- stream.add("blah");
- assertFalse("added element should be placed BEFORE the \"cursor\"", stream.next().equals("blah"));
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- stream.add("blah");
- assertTrue("added element should be placed BEFORE the \"cursor\"", stream.previous().equals("blah"));
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- while (stream.hasPrevious()) {
- stream.previous();
- }
- stream.add("blah");
- assertFalse("added element should be placed BEFORE the \"cursor\"", stream.next().equals("blah"));
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- while (stream.hasPrevious()) {
- stream.previous();
- }
- stream.add("blah");
- assertTrue("added element should be placed BEFORE the \"cursor\"", stream.previous().equals("blah"));
-
- // add to the middle
- stream = (ListIterator<String>) this.buildCompositeIterator();
- stream.next();
- stream.add("blah");
- assertFalse("added element should be placed BEFORE the \"cursor\"", stream.next().equals("blah"));
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- stream.next();
- stream.add("blah");
- assertTrue("added element should be placed BEFORE the \"cursor\"", stream.previous().equals("blah"));
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- stream.previous();
- stream.add("blah");
- assertFalse("added element should be placed BEFORE the \"cursor\"", stream.next().equals("blah"));
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- stream.previous();
- stream.add("blah");
- assertTrue("added element should be placed BEFORE the \"cursor\"", stream.previous().equals("blah"));
-
- // add to the end
- stream = (ListIterator<String>) this.buildCompositeIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- stream.add("blah");
- assertFalse("added element should be placed BEFORE the \"cursor\"", stream.hasNext());
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- stream.add("blah");
- assertTrue("added element should be placed BEFORE the \"cursor\"", stream.previous().equals("blah"));
- }
-
- public void testSet() {
- List<String> list1 = this.buildList1();
- Object lastElement1 = list1.get(list1.size() - 1);
- List<String> list2 = this.buildList2();
- List<String> list3 = this.buildList3();
- Object firstElement3 = list3.get(0);
-
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(list1.listIterator());
- list.add(list2.listIterator());
- list.add(list3.listIterator());
-
- ListIterator<String> stream = (ListIterator<String>) this.buildCompositeIterator(list.listIterator());
- // position to end of stream
- while (stream.hasNext()) {
- Object next = stream.next();
- if (next.equals("333")) {
- stream.set("333a");
- }
- // test special case - where we are between iterators
- if (next.equals(lastElement1)) {
- // this will trigger the next iterator to be loaded
- stream.hasNext();
- // now try to remove from the previous iterator
- stream.set("end of 1");
- }
- }
- while (stream.hasPrevious()) {
- Object previous = stream.previous();
- if (previous.equals("22")) {
- stream.set("22a");
- }
- // test special case - where we are between iterators
- if (previous.equals(firstElement3)) {
- // this will trigger the next iterator to be loaded
- stream.hasPrevious();
- // now try to remove from the previous iterator
- stream.set("start of 3");
- }
- }
-
- assertEquals("element(s) added to collection 1", this.buildList1().size(), list1.size());
- assertEquals("element not set in collection 1", "22a", list1.get(1));
- assertFalse("element not set in collection 1", list1.contains("22"));
- assertEquals("element not set in collection 1", "333a", list1.get(2));
- assertFalse("element not set in collection 1", list1.contains("333"));
- assertEquals("element not set in collection 1", "end of 1", list1.get(list1.size() - 1));
- assertFalse("element not set in collection 1", list1.contains(lastElement1));
-
- assertEquals("element(s) added to collection 3", this.buildList3().size(), list3.size());
- assertEquals("element not set in collection 3", "start of 3", list3.get(0));
- assertFalse("element not set in collection 3", list3.contains(firstElement3));
- }
-
- @Override
- public void testNextIndexPreviousIndex() {
- int i = 0;
- ListIterator<String> stream = (ListIterator<String>) this.buildCompositeIterator();
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- while (stream.hasNext()) {
- Object next = stream.next();
- i++;
- if (next.equals("333")) {
- stream.remove();
- i--;
- }
- if (next.equals("7777777")) {
- stream.add("7.5");
- i++;
- }
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- }
- assertEquals("index is corrupt", 8, i);
-
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- while (stream.hasPrevious()) {
- Object previous = stream.previous();
- i--;
- if (previous.equals("666666")) {
- stream.remove();
- // removing a previous element, does not change the cursor
- }
- if (previous.equals("22")) {
- stream.add("1.5");
- i++;
- }
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- }
- assertEquals("index is corrupt", 0, i);
- }
-
- @Override
- public void testIllegalStateException() {
- this.verifyIllegalStateException();
- }
-
- @Override
- public void testEmptyIllegalStateException1() {
- this.verifyEmptyIllegalStateException1();
- }
-
- @Override
- public void testEmptyIllegalStateException2() {
- this.verifyEmptyIllegalStateException2();
- }
-
- // unchecked so we can override the unchecked method in superclass
- @Override
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator(Iterator iterators) {
- return new CompositeListIterator<String>((ListIterator<ListIterator<String>>) iterators);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator2() {
- return new CompositeListIterator<String>(this.buildIterator1(), this.buildIterator2(), this.buildIterator3());
- }
-
- @Override
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator3() {
- return new CompositeListIterator<String>(new ListIterator[] { this.buildIterator1(), this.buildIterator2(), this.buildIterator3() });
- }
-
- @Override
- ListIterator<String> buildCompositeListIterator(String string, ListIterator<String> iterator) {
- return new CompositeListIterator<String>(string, iterator);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyEnumerationTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyEnumerationTests.java
deleted file mode 100644
index 98697897b7..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyEnumerationTests.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.EmptyEnumeration;
-
-public class EmptyEnumerationTests extends TestCase {
-
- public EmptyEnumerationTests(String name) {
- super(name);
- }
-
- public void testHasMoreElements() {
- int i = 0;
- for (Enumeration<Object> stream = EmptyEnumeration.instance(); stream.hasMoreElements();) {
- stream.nextElement();
- i++;
- }
- assertEquals(0, i);
- }
-
- public void testNextElement() {
- for (Enumeration<Object> stream = EmptyEnumeration.instance(); stream.hasMoreElements();) {
- fail("bogus element: " + stream.nextElement());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Enumeration<Object> stream = EmptyEnumeration.instance();
- Object element = null;
- while (stream.hasMoreElements()) {
- element = stream.nextElement();
- }
- try {
- element = stream.nextElement();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + element, exCaught);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyIteratorTests.java
deleted file mode 100644
index 6985ad4ffa..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyIteratorTests.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-
-public class EmptyIteratorTests extends TestCase {
-
- public EmptyIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<Object> stream = EmptyIterator.instance(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(0, i);
- }
-
- public void testNext() {
- for (Iterator<String> stream = EmptyIterator.instance(); stream.hasNext();) {
- fail("bogus element: " + stream.next());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<Number> stream = EmptyIterator.instance();
- Object element = null;
- while (stream.hasNext()) {
- element = stream.next();
- }
- try {
- element = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + element, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- try {
- EmptyIterator.instance().remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyListIteratorTests.java
deleted file mode 100644
index 35c8efc011..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyListIteratorTests.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-
-public class EmptyListIteratorTests extends TestCase {
-
- public EmptyListIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (ListIterator<Object> stream = EmptyListIterator.instance(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(0, i);
- }
-
- public void testNext() {
- for (ListIterator<Object> stream = EmptyListIterator.instance(); stream.hasNext();) {
- fail("bogus element: " + stream.next());
- }
- }
-
- public void testNextIndex() {
- ListIterator<Object> stream = EmptyListIterator.instance();
- assertEquals(0, stream.nextIndex());
- }
-
- public void testHasPrevious() {
- ListIterator<Object> stream = EmptyListIterator.instance();
- int i = 0;
- while (stream.hasPrevious()) {
- stream.previous();
- i++;
- }
- assertEquals(0, i);
-
- while (stream.hasNext()) {
- stream.next();
- }
- i = 0;
- while (stream.hasPrevious()) {
- stream.previous();
- i++;
- }
- assertEquals(0, i);
- }
-
- public void testPrevious() {
- ListIterator<Object> stream = EmptyListIterator.instance();
- while (stream.hasPrevious()) {
- fail("bogus element: " + stream.previous());
- }
- while (stream.hasNext()) {
- stream.next();
- }
- while (stream.hasPrevious()) {
- fail("bogus element: " + stream.previous());
- }
- }
-
- public void testPreviousIndex() {
- ListIterator<Object> stream = EmptyListIterator.instance();
- assertEquals(-1, stream.previousIndex());
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- ListIterator<Object> stream = EmptyListIterator.instance();
- Object element = null;
- while (stream.hasNext()) {
- element = stream.next();
- }
- try {
- element = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown (next): " + element, exCaught);
- while (stream.hasPrevious()) {
- element = stream.previous();
- }
- try {
- element = stream.previous();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown (previous): " + element, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- try {
- EmptyListIterator.instance().remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("UnsupportedOperationException not thrown (remove)", exCaught);
- try {
- EmptyListIterator.instance().set(new Object());
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("UnsupportedOperationException not thrown (set)", exCaught);
- try {
- EmptyListIterator.instance().add(new Object());
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("UnsupportedOperationException not thrown (add)", exCaught);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EnumerationIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EnumerationIteratorTests.java
deleted file mode 100644
index 528f101110..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EnumerationIteratorTests.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Vector;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.EnumerationIterator;
-
-public class EnumerationIteratorTests extends TestCase {
-
- public EnumerationIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(this.buildVector().size(), i);
- }
-
- public void testHasNextUpcast() {
- int i = 0;
- for (Iterator<Object> stream = this.buildIteratorUpcast(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(this.buildVector().size(), i);
- }
-
- public void testNext() {
- Enumeration<String> enumeration = this.buildEnumeration();
- for (Iterator<String> stream = this.buildIterator(); stream.hasNext();) {
- assertEquals("bogus element", enumeration.nextElement(), stream.next());
- }
- }
-
- public void testNextUpcast() {
- Enumeration<String> enumeration = this.buildEnumeration();
- for (Iterator<Object> stream = this.buildIteratorUpcast(); stream.hasNext();) {
- assertEquals("bogus element", enumeration.nextElement(), stream.next());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- private Iterator<String> buildIterator() {
- return this.buildIterator(this.buildEnumeration());
- }
-
- private Iterator<String> buildIterator(Enumeration<String> enumeration) {
- return new EnumerationIterator<String>(enumeration);
- }
-
- private Enumeration<String> buildEnumeration() {
- return this.buildVector().elements();
- }
-
- private Vector<String> buildVector() {
- Vector<String> v = new Vector<String>();
- v.addElement("one");
- v.addElement("two");
- v.addElement("three");
- v.addElement("four");
- v.addElement("five");
- v.addElement("six");
- v.addElement("seven");
- v.addElement("eight");
- return v;
- }
-
- private Iterator<Object> buildIteratorUpcast() {
- return this.buildIteratorUpcast(this.buildEnumeration());
- }
-
- private Iterator<Object> buildIteratorUpcast(Enumeration<String> enumeration) {
- return new EnumerationIterator<Object>(enumeration);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java
deleted file mode 100644
index fe498aab9f..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.SimpleFilter;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-
-public class FilteringIteratorTests extends TestCase {
-
- private static final String PREFIX = "prefix";
-
- public FilteringIteratorTests(String name) {
- super(name);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildAcceptIterator(); stream.hasNext();) {
- String string = stream.next();
- if (string.equals(PREFIX + "3")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildAcceptIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testAcceptHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildAcceptIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testAcceptNext() {
- for (Iterator<String> stream = this.buildAcceptIterator(); stream.hasNext();) {
- assertTrue("bogus accept", stream.next().startsWith(PREFIX));
- }
- }
-
- public void testInnerHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildInnerIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testInnerNext() {
- for (Iterator<String> stream = this.buildInnerIterator(); stream.hasNext();) {
- assertTrue("bogus accept", stream.next().startsWith(PREFIX));
- }
- }
-
- public void testRejectHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildRejectIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(2, i);
- }
-
- public void testRejectNext() {
- for (Iterator<String> stream = this.buildRejectIterator(); stream.hasNext();) {
- assertFalse("bogus reject", stream.next().startsWith(PREFIX));
- }
- }
-
- public void testBothHasNext() {
- // if both accept() and reject() are overridden, accept() is used
- int i = 0;
- for (Iterator<String> stream = this.buildBothIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testLoadNext() {
- // loadNext() used to cause a NPE when executing during the
- // constructor because the "outer" class is not bound until completion
- // of the constructor
- for (Iterator<String> stream = this.buildInnerIterator2(); stream.hasNext();) {
- assertTrue("bogus accept", stream.next().startsWith(PREFIX));
- }
- }
-
- // test a filtered iterator with a nested iterator of a sub-type (Number vs. Integer)
- public void testGenerics1() {
- List<Integer> integers = new ArrayList<Integer>();
- integers.add(new Integer(0));
- integers.add(new Integer(1));
- integers.add(new Integer(2));
- integers.add(new Integer(3));
- Iterator<Number> stream = new FilteringIterator<Integer, Number>(integers.iterator()) {
- @Override
- protected boolean accept(Integer o) {
- return o.intValue() > 1;
- }
- };
- assertEquals(2, CollectionTools.size(stream));
- }
-
- // test a filtered iterator with a nested iterator of a super-type (Integer vs. Number)
- // i.e. trust that Filter will only return the appropriate sub-type objects
- public void testGenerics2() {
- List<Number> numbers = new ArrayList<Number>();
- numbers.add(new Integer(0));
- numbers.add(new Long(1));
- numbers.add(new Integer(2));
- numbers.add(new Float(3));
- Iterator<Integer> stream = new FilteringIterator<Number, Integer>(numbers.iterator()) {
- @Override
- protected boolean accept(Number o) {
- return o instanceof Integer;
- }
- };
- assertEquals(2, CollectionTools.size(stream));
- }
-
- public void testFilterHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildFilterIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testFilterNext() {
- for (Iterator<String> stream = this.buildFilterIterator(); stream.hasNext();) {
- assertTrue("bogus accept", stream.next().startsWith(PREFIX));
- }
- }
-
- private Iterator<String> buildFilteredIterator(Iterator<String> nestedIterator, Filter<String> filter) {
- return new FilteringIterator<String, String>(nestedIterator, filter);
- }
-
- private Iterator<String> buildInnerFilteredIterator(Iterator<String> nestedIterator) {
- return new FilteringIterator<String, String>(nestedIterator) {
- @Override
- protected boolean accept(String s) {
- return s.startsWith(PREFIX);
- }
- };
- }
-
- String getPrefix() {
- return PREFIX;
- }
-
- // this inner iterator will call the "outer" object
- private Iterator<String> buildInnerFilteredIterator2(Iterator<String> nestedIterator) {
- return new FilteringIterator<String, String>(nestedIterator) {
- @Override
- protected boolean accept(String s) {
- return s.startsWith(FilteringIteratorTests.this.getPrefix());
- }
- };
- }
-
- private Iterator<String> buildNestedIterator() {
- Collection<String> c = new ArrayList<String>();
- c.add(PREFIX + "1");
- c.add(PREFIX + "2");
- c.add(PREFIX + "3");
- c.add("4");
- c.add(PREFIX + "5");
- c.add(PREFIX + "6");
- c.add(PREFIX + "7");
- c.add("8");
- return c.iterator();
- }
-
- private Iterator<String> buildAcceptIterator() {
- return this.buildFilteredIterator(this.buildNestedIterator(), this.buildAcceptFilter(PREFIX));
- }
-
- private Iterator<String> buildInnerIterator() {
- return this.buildInnerFilteredIterator(this.buildNestedIterator());
- }
-
- // this inner iterator will call the "outer" object
- private Iterator<String> buildInnerIterator2() {
- return this.buildInnerFilteredIterator2(this.buildNestedIterator());
- }
-
- private Iterator<String> buildFilterIterator() {
- return this.buildFilteredIterator(this.buildNestedIterator(), this.buildFilterFilter(PREFIX));
- }
-
- private Filter<String> buildAcceptFilter(String prefix) {
- return new SimpleFilter<String, String>(prefix) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public boolean accept(String s) {
- return s.startsWith(this.criterion);
- }
- };
- }
-
- private Iterator<String> buildRejectIterator() {
- return this.buildFilteredIterator(this.buildNestedIterator(), this.buildRejectFilter(PREFIX));
- }
-
- private Filter<String> buildRejectFilter(String prefix) {
- return new SimpleFilter<String, String>(prefix) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public boolean reject(String s) {
- return s.startsWith(this.criterion);
- }
- };
- }
-
- // use anonymous inner Filter
- private Filter<String> buildFilterFilter(final String prefix) {
- return new Filter<String>() {
- public boolean accept(String s) {
- return s.startsWith(prefix);
- }
- };
- }
-
- private Iterator<String> buildBothIterator() {
- return this.buildFilteredIterator(this.buildNestedIterator(), this.buildBothFilter(PREFIX));
- }
-
- private Filter<String> buildBothFilter(String prefix) {
- return new SimpleFilter<String, String>(prefix) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public boolean reject(String s) {
- return s.startsWith(this.criterion);
- }
-
- @Override
- public boolean accept(String s) {
- return s.startsWith(this.criterion);
- }
- };
- }
-
- public void testInvalidFilteringIterator() {
- boolean exCaught = false;
- try {
- // missing method override
- Iterator<String> iterator = new FilteringIterator<String, String>(this.buildNestedIterator());
- String s = iterator.next();
- fail("invalid string: " + s);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/GraphIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/GraphIteratorTests.java
deleted file mode 100644
index 8048a2f10c..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/GraphIteratorTests.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.GraphIterator;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-public class GraphIteratorTests extends TestCase {
- /** this will be populated with all the nodes created for the test */
- Collection<GraphNode> nodes = new ArrayList<GraphNode>();
-
- public GraphIteratorTests(String name) {
- super(name);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testHasNext1() {
- this.verifyHasNext(this.buildGraphIterator1());
- }
-
- public void testHasNext2() {
- this.verifyHasNext(this.buildGraphIterator2());
- }
-
- private void verifyHasNext(Iterator<GraphNode> iterator) {
- int i = 0;
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(this.nodes.size(), i);
- }
-
- public void testNext1() {
- this.verifyNext(this.buildGraphIterator1());
- }
-
- public void testNext2() {
- this.verifyNext(this.buildGraphIterator2());
- }
-
- private void verifyNext(Iterator<GraphNode> iterator) {
- while (iterator.hasNext()) {
- assertTrue("bogus element", this.nodes.contains(iterator.next()));
- }
- }
-
- public void testNoSuchElementException1() {
- this.verifyNoSuchElementException(this.buildGraphIterator1());
- }
-
- public void testNoSuchElementException2() {
- this.verifyNoSuchElementException(this.buildGraphIterator2());
- }
-
- private void verifyNoSuchElementException(Iterator<GraphNode> iterator) {
- boolean exCaught = false;
- while (iterator.hasNext()) {
- iterator.next();
- }
- try {
- iterator.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
- public void testSize1() {
- this.verifySize(this.buildGraphIterator1());
- }
-
- public void testSize2() {
- this.verifySize(this.buildGraphIterator2());
- }
-
- private void verifySize(Iterator<GraphNode> iterator) {
- int iteratorSize = CollectionTools.size(iterator);
- int actualSize = this.nodes.size();
- assertTrue("Too few items in iterator.", iteratorSize >= actualSize);
- assertTrue("Too many items in iterator.", iteratorSize <= actualSize);
- }
-
- public void testInvalidGraphIterator() {
- boolean exCaught = false;
- try {
- // missing method override
- Iterator<GraphNode> iterator = new GraphIterator<GraphNode>(this.buildGraphRoot());
- GraphNode gn = iterator.next();
- fail("invalid graph node: " + gn);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
- /**
- * build a graph iterator with an explicit misterRogers
- */
- private Iterator<GraphNode> buildGraphIterator1() {
- return new GraphIterator<GraphNode>(this.buildGraphRoot(), this.buildMisterRogers());
- }
-
- private GraphIterator.MisterRogers<GraphNode> buildMisterRogers() {
- return new GraphIterator.MisterRogers<GraphNode>() {
- public Iterator<GraphNode> neighbors(GraphNode next) {
- return next.neighbors();
- }
- };
- }
-
- /**
- * build a graph iterator with an override
- */
- private Iterator<GraphNode> buildGraphIterator2() {
- return new GraphIterator<GraphNode>(this.buildGraphRoot()) {
- @Override
- public Iterator<GraphNode> neighbors(GraphNode next) {
- return next.neighbors();
- }
- };
- }
-
- private GraphNode buildGraphRoot() {
- GraphNode ncNode = new GraphNode("North Carolina");
- GraphNode vaNode = new GraphNode("Virginia");
- GraphNode scNode = new GraphNode("South Carolina");
- GraphNode gaNode = new GraphNode("Georgia");
- GraphNode flNode = new GraphNode("Florida");
- GraphNode alNode = new GraphNode("Alabama");
- GraphNode msNode = new GraphNode("Mississippi");
- GraphNode tnNode = new GraphNode("Tennessee");
-
- ncNode.setNeighbors(new GraphNode[] { vaNode, scNode, gaNode, tnNode });
- vaNode.setNeighbors(new GraphNode[] { ncNode, tnNode });
- scNode.setNeighbors(new GraphNode[] { ncNode, gaNode });
- gaNode.setNeighbors(new GraphNode[] { ncNode, scNode, flNode, alNode, tnNode });
- flNode.setNeighbors(new GraphNode[] { gaNode });
- alNode.setNeighbors(new GraphNode[] { gaNode, msNode, tnNode });
- msNode.setNeighbors(new GraphNode[] { alNode, tnNode });
- tnNode.setNeighbors(new GraphNode[] { vaNode, ncNode, gaNode, alNode, msNode });
-
- return ncNode;
- }
-
- private class GraphNode {
- private String name;
-
- private Collection<GraphNode> neighbors = new ArrayList<GraphNode>();
-
- public GraphNode(String name) {
- super();
- GraphIteratorTests.this.nodes.add(this); // log node
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- void setNeighbors(GraphNode[] neighbors) {
- this.neighbors = CollectionTools.list(neighbors);
- }
-
- public Iterator<GraphNode> neighbors() {
- return this.neighbors.iterator();
- }
-
- public int neighborsSize() {
- return this.neighbors.size();
- }
-
- @Override
- public String toString() {
- return "GraphNode(" + this.name + ")";
- }
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/IteratorEnumerationTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/IteratorEnumerationTests.java
deleted file mode 100644
index 42d8eb459e..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/IteratorEnumerationTests.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Vector;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.IteratorEnumeration;
-
-public class IteratorEnumerationTests extends TestCase {
-
- public IteratorEnumerationTests(String name) {
- super(name);
- }
-
- public void testHasMoreElements() {
- int i = 0;
- for (Enumeration<String> stream = this.buildEnumeration(); stream.hasMoreElements();) {
- stream.nextElement();
- i++;
- }
- assertEquals(this.buildVector().size(), i);
- }
-
- public void testHasMoreElementsUpcast() {
- int i = 0;
- for (Enumeration<Object> stream = this.buildEnumerationUpcast(); stream.hasMoreElements();) {
- stream.nextElement();
- i++;
- }
- assertEquals(this.buildVector().size(), i);
- }
-
- public void testNextElement() {
- Iterator<String> iterator = this.buildIterator();
- for (Enumeration<String> stream = this.buildEnumeration(); stream.hasMoreElements();) {
- assertEquals("bogus element", iterator.next(), stream.nextElement());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Enumeration<String> stream = this.buildEnumeration();
- String string = null;
- while (stream.hasMoreElements()) {
- string = stream.nextElement();
- }
- try {
- string = stream.nextElement();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- private Enumeration<String> buildEnumeration() {
- return this.buildEnumeration(this.buildIterator());
- }
-
- private Enumeration<Object> buildEnumerationUpcast() {
- return this.buildEnumerationUpcast(this.buildIterator());
- }
-
- private Enumeration<String> buildEnumeration(Iterator<String> iterator) {
- return new IteratorEnumeration<String>(iterator);
- }
-
- private Enumeration<Object> buildEnumerationUpcast(Iterator<String> iterator) {
- return new IteratorEnumeration<Object>(iterator);
- }
-
- private Iterator<String> buildIterator() {
- return this.buildVector().iterator();
- }
-
- private Vector<String> buildVector() {
- Vector<String> v = new Vector<String>();
- v.addElement("one");
- v.addElement("two");
- v.addElement("three");
- v.addElement("four");
- v.addElement("five");
- v.addElement("six");
- v.addElement("seven");
- v.addElement("eight");
- return v;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java
deleted file mode 100644
index 8d9d3f7270..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptUtilityIteratorsTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityIteratorsTests.class.getPackage().getName());
-
- suite.addTestSuite(ArrayIteratorTests.class);
- suite.addTestSuite(ArrayListIteratorTests.class);
- suite.addTestSuite(ChainIteratorTests.class);
- suite.addTestSuite(CloneIteratorTests.class);
- suite.addTestSuite(CloneListIteratorTests.class);
- suite.addTestSuite(CompositeIteratorTests.class);
- suite.addTestSuite(CompositeListIteratorTests.class);
- suite.addTestSuite(EmptyEnumerationTests.class);
- suite.addTestSuite(EmptyIteratorTests.class);
- suite.addTestSuite(EmptyListIteratorTests.class);
- suite.addTestSuite(EnumerationIteratorTests.class);
- suite.addTestSuite(FilteringIteratorTests.class);
- suite.addTestSuite(GraphIteratorTests.class);
- suite.addTestSuite(IteratorEnumerationTests.class);
- suite.addTestSuite(PeekableIteratorTests.class);
- suite.addTestSuite(ReadOnlyCompositeListIteratorTests.class);
- suite.addTestSuite(ReadOnlyIteratorTests.class);
- suite.addTestSuite(ReadOnlyListIteratorTests.class);
- suite.addTestSuite(SingleElementIteratorTests.class);
- suite.addTestSuite(SingleElementListIteratorTests.class);
- suite.addTestSuite(TransformationIteratorTests.class);
- suite.addTestSuite(TransformationListIteratorTests.class);
- suite.addTestSuite(TreeIteratorTests.class);
-
- return suite;
- }
-
- private JptUtilityIteratorsTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/PeekableIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/PeekableIteratorTests.java
deleted file mode 100644
index 1a3b47b78f..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/PeekableIteratorTests.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.PeekableIterator;
-
-public class PeekableIteratorTests extends TestCase {
-
- public PeekableIteratorTests(String name) {
- super(name);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildPeekableIterator(); stream.hasNext();) {
- String string = stream.next();
- if (string.equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildPeekableIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildPeekableIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testHasNextUpcast() {
- int i = 0;
- for (Iterator<Object> stream = this.buildPeekableIteratorUpcast(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testNext() {
- Iterator<String> stream = this.buildPeekableIterator();
- assertEquals("zero", stream.next());
- assertEquals("one", stream.next());
- assertEquals("two", stream.next());
- assertEquals("three", stream.next());
- assertEquals("four", stream.next());
- assertEquals("five", stream.next());
- }
-
- public void testNextUpcast() {
- Iterator<Object> stream = this.buildPeekableIteratorUpcast();
- assertEquals("zero", stream.next());
- assertEquals("one", stream.next());
- assertEquals("two", stream.next());
- assertEquals("three", stream.next());
- assertEquals("four", stream.next());
- assertEquals("five", stream.next());
- }
-
- public void testPeek() {
- Object next = null;
- for (PeekableIterator<String> stream = this.buildPeekableIterator(); stream.hasNext();) {
- Object peek = stream.peek();
- assertTrue("peek and next are prematurely identical", peek != next);
- next = stream.next();
- assertTrue("peek and next are not identical", peek == next);
- }
- }
-
- public void testPeekUpcast() {
- Object next = null;
- for (PeekableIterator<Object> stream = this.buildPeekableIteratorUpcast(); stream.hasNext();) {
- Object peek = stream.peek();
- assertTrue("peek and next are prematurely identical", peek != next);
- next = stream.next();
- assertTrue("peek and next are not identical", peek == next);
- }
- }
-
- private PeekableIterator<String> buildPeekableIterator() {
- return this.buildPeekableIterator(this.buildNestedIterator());
- }
-
- private PeekableIterator<Object> buildPeekableIteratorUpcast() {
- return this.buildPeekableIteratorUpcast(this.buildNestedIterator());
- }
-
- private PeekableIterator<String> buildPeekableIterator(Iterator<String> nestedIterator) {
- return new PeekableIterator<String>(nestedIterator);
- }
-
- private PeekableIterator<Object> buildPeekableIteratorUpcast(Iterator<String> nestedIterator) {
- return new PeekableIterator<Object>(nestedIterator);
- }
-
- private Iterator<String> buildNestedIterator() {
- Collection<String> c = new ArrayList<String>();
- c.add("zero");
- c.add("one");
- c.add("two");
- c.add("three");
- c.add("four");
- c.add("five");
- return c.iterator();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyCompositeListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyCompositeListIteratorTests.java
deleted file mode 100644
index 8d92c03656..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyCompositeListIteratorTests.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyCompositeListIterator;
-
-public class ReadOnlyCompositeListIteratorTests extends CompositeIteratorTests {
-
- public ReadOnlyCompositeListIteratorTests(String name) {
- super(name);
- }
-
- @Override
- void verifyHasAnother(Iterator<String> stream) {
- super.verifyHasAnother(stream);
- ListIterator<String> stream2 = (ListIterator<String>) stream;
- int i = 0;
- while (stream2.hasPrevious()) {
- stream2.previous();
- i++;
- }
- assertEquals(8, i);
- }
-
- @Override
- void verifyAnother(Iterator<String> stream) {
- super.verifyAnother(stream);
- int i = 8;
- ListIterator<String> stream2 = (ListIterator<String>) stream;
- while (stream2.hasPrevious()) {
- assertEquals("bogus element", String.valueOf(i--), stream2.previous().substring(0, 1));
- }
- }
-
- public void testNextIndexPreviousIndex() {
- int i = 0;
- ListIterator<String> stream = (ListIterator<String>) this.buildCompositeIterator();
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- while (stream.hasNext()) {
- stream.next();
- i++;
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- }
- assertEquals("index is corrupt", 8, i);
-
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- while (stream.hasPrevious()) {
- stream.previous();
- i--;
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- }
- assertEquals("index is corrupt", 0, i);
- }
-
- public void testPreviousIndex() {
- // TODO
- }
-
- @Override
- public void testRemove() {
- // #remove() is not supported
- }
-
- @Override
- public void testIllegalStateException() {
- // #remove() is not supported
- }
-
- @Override
- public void testEmptyIllegalStateException1() {
- // #remove() is not supported
- }
-
- @Override
- public void testEmptyIllegalStateException2() {
- // #remove() is not supported
- }
-
- @Override
- void verifyNoSuchElementException(Iterator<String> stream) {
- super.verifyNoSuchElementException(stream);
- ListIterator<String> stream2 = (ListIterator<String>) stream;
- boolean exCaught = false;
- String string = null;
- while (stream2.hasPrevious()) {
- string = stream2.previous();
- }
- try {
- string = stream2.previous();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- @Override
- void verifyUnsupportedOperationException(Iterator<String> stream) {
- super.verifyUnsupportedOperationException(stream);
- boolean exCaught = false;
- ListIterator<String> stream2 = (ListIterator<String>) stream;
- while (stream2.hasPrevious()) {
- Object string = stream2.previous();
- if (string.equals("333")) {
- try {
- stream2.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- @Override
- void verifyIllegalStateException(Iterator<String> stream) {
- super.verifyIllegalStateException(stream);
- ListIterator<String> stream2 = (ListIterator<String>) stream;
- boolean exCaught = false;
- try {
- stream2.set("junk");
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
-
- @Override
- void verifyEmptyHasAnother(Iterator<String> stream) {
- super.verifyEmptyHasAnother(stream);
- ListIterator<String> stream2 = (ListIterator<String>) stream;
- int i = 0;
- while (stream2.hasPrevious()) {
- stream2.previous();
- i++;
- }
- assertEquals(0, i);
- }
-
- // unchecked so we can override the unchecked method in superclass
- @Override
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator(Iterator iterators) {
- return new ReadOnlyCompositeListIterator<String>((ListIterator<ListIterator<String>>) iterators);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator2() {
- return new ReadOnlyCompositeListIterator<String>(this.buildIterator1(), this.buildIterator2(), this.buildIterator3());
- }
-
- @Override
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator3() {
- return new ReadOnlyCompositeListIterator<String>(new ListIterator[] { this.buildIterator1(), this.buildIterator2(), this.buildIterator3() });
- }
-
- Iterator<String> buildCompositeIterator(String string, ListIterator<String> iterator) {
- return this.buildCompositeListIterator(string, iterator);
- }
-
- ListIterator<String> buildCompositeListIterator(String string, ListIterator<String> iterator) {
- return new ReadOnlyCompositeListIterator<String>(string, iterator);
- }
-
- public void testVariedNestedIterators() {
- List<Integer> integerList = new ArrayList<Integer>();
- integerList.add(new Integer(42));
- integerList.add(new Integer(42));
- integerList.add(new Integer(111));
- integerList.add(new Integer(77));
-
- List<Float> floatList = new ArrayList<Float>();
- floatList.add(new Float(42.42f));
- floatList.add(new Float(22.22f));
- floatList.add(new Float(111.111f));
- floatList.add(new Float(77.77f));
-
- List<ListIterator<? extends Number>> list = new ArrayList<ListIterator<? extends Number>>();
- list.add(integerList.listIterator());
- list.add(floatList.listIterator());
- ListIterator<Number> li = new ReadOnlyCompositeListIterator<Number>(list);
- while (li.hasNext()) {
- assertTrue(li.next().intValue() > 0);
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyIteratorTests.java
deleted file mode 100644
index 4defa2e414..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyIteratorTests.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Vector;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyIterator;
-
-public class ReadOnlyIteratorTests extends TestCase {
-
- public ReadOnlyIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildReadOnlyIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(this.buildVector().size(), i);
- }
-
- public void testHasNextUpcast() {
- int i = 0;
- for (Iterator<Object> stream = this.buildReadOnlyIteratorUpcast(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(this.buildVector().size(), i);
- }
-
- public void testNext() {
- Iterator<String> nestedIterator = this.buildNestedIterator();
- for (Iterator<String> stream = this.buildReadOnlyIterator(); stream.hasNext();) {
- assertEquals("bogus element", nestedIterator.next(), stream.next());
- }
- }
-
- public void testNextUpcast() {
- Iterator<String> nestedIterator = this.buildNestedIterator();
- for (Iterator<Object> stream = this.buildReadOnlyIteratorUpcast(); stream.hasNext();) {
- assertEquals("bogus element", nestedIterator.next(), stream.next());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildReadOnlyIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testRemove() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildReadOnlyIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- private Iterator<String> buildReadOnlyIterator() {
- return this.buildReadOnlyIterator(this.buildNestedIterator());
- }
-
- private Iterator<Object> buildReadOnlyIteratorUpcast() {
- return this.buildReadOnlyIteratorUpcast(this.buildNestedIterator());
- }
-
- private Iterator<String> buildReadOnlyIterator(Iterator<String> nestedIterator) {
- return new ReadOnlyIterator<String>(nestedIterator);
- }
-
- private Iterator<Object> buildReadOnlyIteratorUpcast(Iterator<String> nestedIterator) {
- return new ReadOnlyIterator<Object>(nestedIterator);
- }
-
- private Iterator<String> buildNestedIterator() {
- return this.buildVector().iterator();
- }
-
- private Vector<String> buildVector() {
- Vector<String> v = new Vector<String>();
- v.addElement("one");
- v.addElement("two");
- v.addElement("three");
- v.addElement("four");
- v.addElement("five");
- v.addElement("six");
- v.addElement("seven");
- v.addElement("eight");
- return v;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java
deleted file mode 100644
index 4db72f6754..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyListIterator;
-
-public class ReadOnlyListIteratorTests extends TestCase {
-
- public ReadOnlyListIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNextAndHasPrevious() {
- int i = 0;
- ListIterator<String> stream = this.buildReadOnlyListIterator();
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(this.buildList().size(), i);
-
- while (stream.hasPrevious()) {
- stream.previous();
- i--;
- }
- assertEquals(0, i);
- }
-
- public void testHasNextAndHasPreviousUpcast() {
- int i = 0;
- ListIterator<Object> stream = this.buildReadOnlyListIteratorUpcast();
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(this.buildList().size(), i);
-
- while (stream.hasPrevious()) {
- stream.previous();
- i--;
- }
- assertEquals(0, i);
- }
-
- public void testNextAndPrevious() {
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- ListIterator<String> stream = this.buildReadOnlyListIterator();
- while (stream.hasNext()) {
- assertEquals("bogus element", nestedListIterator.next(), stream.next());
- }
- while (stream.hasPrevious()) {
- assertEquals("bogus element", nestedListIterator.previous(), stream.previous());
- }
- }
-
- public void testNextAndPreviousUpcast() {
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- ListIterator<Object> stream = this.buildReadOnlyListIteratorUpcast();
- while (stream.hasNext()) {
- assertEquals("bogus element", nestedListIterator.next(), stream.next());
- }
- while (stream.hasPrevious()) {
- assertEquals("bogus element", nestedListIterator.previous(), stream.previous());
- }
- }
-
- public void testNextIndexAndPreviousIndex() {
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- ListIterator<String> stream = this.buildReadOnlyListIterator();
- while (stream.hasNext()) {
- assertEquals("bogus index", nestedListIterator.nextIndex(), stream.nextIndex());
- nestedListIterator.next();
- stream.next();
- }
- assertEquals("bogus index", this.buildList().size(), stream.nextIndex());
- while (stream.hasPrevious()) {
- assertEquals("bogus element", nestedListIterator.previousIndex(), stream.previousIndex());
- nestedListIterator.previous();
- stream.previous();
- }
- assertEquals("bogus index", -1, stream.previousIndex());
- }
-
- public void testNextIndexAndPreviousIndexUpcast() {
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- ListIterator<Object> stream = this.buildReadOnlyListIteratorUpcast();
- while (stream.hasNext()) {
- assertEquals("bogus index", nestedListIterator.nextIndex(), stream.nextIndex());
- nestedListIterator.next();
- stream.next();
- }
- assertEquals("bogus index", this.buildList().size(), stream.nextIndex());
- while (stream.hasPrevious()) {
- assertEquals("bogus element", nestedListIterator.previousIndex(), stream.previousIndex());
- nestedListIterator.previous();
- stream.previous();
- }
- assertEquals("bogus index", -1, stream.previousIndex());
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- ListIterator<String> stream = this.buildReadOnlyListIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testRemove() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildReadOnlyListIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testSet() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildReadOnlyListIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.set("bogus");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testAdd() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildReadOnlyListIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.add("bogus");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- private ListIterator<String> buildReadOnlyListIterator() {
- return this.buildReadOnlyListIterator(this.buildNestedListIterator());
- }
-
- private ListIterator<Object> buildReadOnlyListIteratorUpcast() {
- return this.buildReadOnlyListIteratorUpcast(this.buildNestedListIterator());
- }
-
- private ListIterator<String> buildReadOnlyListIterator(ListIterator<String> nestedListIterator) {
- return new ReadOnlyListIterator<String>(nestedListIterator);
- }
-
- private ListIterator<Object> buildReadOnlyListIteratorUpcast(ListIterator<String> nestedListIterator) {
- return new ReadOnlyListIterator<Object>(nestedListIterator);
- }
-
- private ListIterator<String> buildNestedListIterator() {
- return this.buildList().listIterator();
- }
-
- private List<String> buildList() {
- List<String> l = new ArrayList<String>();
- l.add("one");
- l.add("two");
- l.add("three");
- l.add("four");
- l.add("five");
- l.add("six");
- l.add("seven");
- l.add("eight");
- return l;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementIteratorTests.java
deleted file mode 100644
index e84657c93d..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementIteratorTests.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
-
-public class SingleElementIteratorTests extends TestCase {
-
- public SingleElementIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildSingleElementIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(1, i);
- }
-
- public void testNext() {
- for (Iterator<String> stream = this.buildSingleElementIterator(); stream.hasNext();) {
- assertEquals("bogus element", this.singleElement(), stream.next());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildSingleElementIterator();
- String string = stream.next();
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testRemove() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildSingleElementIterator(); stream.hasNext();) {
- if (stream.next().equals(this.singleElement())) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- protected Iterator<String> buildSingleElementIterator() {
- return new SingleElementIterator<String>(this.singleElement());
- }
-
- protected String singleElement() {
- return "single element";
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementListIteratorTests.java
deleted file mode 100644
index e3e4197c7d..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementListIteratorTests.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
-
-public class SingleElementListIteratorTests extends SingleElementIteratorTests {
-
- public SingleElementListIteratorTests(String name) {
- super(name);
- }
-
- public void testNextIndex() {
- ListIterator<String> stream = this.buildSingleElementListIterator();
- while (stream.hasNext()) {
- assertEquals("bogus index", 0, stream.nextIndex());
- stream.next();
- }
- assertEquals("bogus index", 1, stream.nextIndex());
- }
-
- public void testHasPrevious() {
- int i = 0;
- ListIterator<String> stream = this.buildSingleElementListIterator();
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(1, i);
-
- while (stream.hasPrevious()) {
- stream.previous();
- i++;
- }
- assertEquals(2, i);
- }
-
- public void testPrevious() {
- ListIterator<String> stream = this.buildSingleElementListIterator();
-
- while (stream.hasNext()) {
- assertEquals("bogus element", this.singleElement(), stream.next());
- }
-
- while (stream.hasPrevious()) {
- assertEquals("bogus element", this.singleElement(), stream.previous());
- }
- }
-
- public void testPreviousIndex() {
- ListIterator<String> stream = this.buildSingleElementListIterator();
-
- while (stream.hasNext()) {
- assertEquals("bogus index", 0, stream.nextIndex());
- stream.next();
- }
-
- while (stream.hasPrevious()) {
- assertEquals("bogus index", 0, stream.previousIndex());
- stream.previous();
- }
-
- assertEquals("bogus index", -1, stream.previousIndex());
- }
-
- public void testAdd() {
- boolean exCaught = false;
- ListIterator<String> stream = this.buildSingleElementListIterator();
-
- try {
- stream.add("foo");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
-
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testSet() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildSingleElementListIterator(); stream.hasNext();) {
- if (stream.next().equals(this.singleElement())) {
- try {
- stream.set("foo");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- @Override
- protected Iterator<String> buildSingleElementIterator() {
- return new SingleElementListIterator<String>(this.singleElement());
- }
-
- protected ListIterator<String> buildSingleElementListIterator() {
- return (ListIterator<String>) this.buildSingleElementIterator();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationIteratorTests.java
deleted file mode 100644
index bef2552570..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationIteratorTests.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.Transformer;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-public class TransformationIteratorTests extends TestCase {
-
- public TransformationIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<Integer> stream = this.buildIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(8, i);
- }
-
- public void testHasNextUpcast() {
- int i = 0;
- for (Iterator<Object> stream = this.buildIteratorUpcast(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(8, i);
- }
-
- public void testInnerHasNext() {
- int i = 0;
- for (Iterator<Integer> stream = this.buildInnerIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(8, i);
- }
-
- public void testNext() {
- int i = 0;
- for (Iterator<Integer> stream = this.buildIterator(); stream.hasNext();) {
- assertEquals("bogus transformation", ++i, stream.next().intValue());
- }
- }
-
- public void testNextUpcast() {
- int i = 0;
- for (Iterator<Object> stream = this.buildIteratorUpcast(); stream.hasNext();) {
- assertEquals("bogus transformation", ++i, ((Integer) stream.next()).intValue());
- }
- }
-
- public void testInnerNext() {
- int i = 0;
- for (Iterator<Integer> stream = this.buildInnerIterator(); stream.hasNext();) {
- assertEquals("bogus transformation", ++i, stream.next().intValue());
- }
- }
-
- public void testRemove() {
- Collection<String> c = this.buildCollection();
- for (Iterator<Integer> stream = this.buildInnerTransformationIterator(c.iterator()); stream.hasNext();) {
- if (stream.next().intValue() == 3) {
- stream.remove();
- }
- }
- assertEquals("nothing removed", this.buildCollection().size() - 1, c.size());
- assertFalse("element still in collection", c.contains("333"));
- assertTrue("wrong element removed", c.contains("22"));
- }
-
- public void testInnerRemove() {
- Collection<String> c = this.buildCollection();
- for (Iterator<Integer> stream = this.buildTransformationIterator(c.iterator(), this.buildTransformer()); stream.hasNext();) {
- if (stream.next().intValue() == 3) {
- stream.remove();
- }
- }
- assertEquals("nothing removed", this.buildCollection().size() - 1, c.size());
- assertFalse("element still in collection", c.contains("333"));
- assertTrue("wrong element removed", c.contains("22"));
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<Integer> stream = this.buildIterator();
- Integer integer = null;
- while (stream.hasNext()) {
- integer = stream.next();
- }
- try {
- integer = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + integer, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<Integer> stream = this.buildUnmodifiableIterator(); stream.hasNext();) {
- int i = stream.next().intValue();
- if (i == 3) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testIllegalStateException() {
- boolean exCaught = false;
- try {
- this.buildIterator().remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
-
- private Iterator<Integer> buildIterator() {
- return this.buildTransformationIterator(this.buildNestedIterator(), this.buildTransformer());
- }
-
- private Iterator<Object> buildIteratorUpcast() {
- return this.buildTransformationIteratorUpcast(this.buildNestedIterator(), this.buildTransformerUpcast());
- }
-
- private Iterator<Integer> buildInnerIterator() {
- return this.buildInnerTransformationIterator(this.buildNestedIterator());
- }
-
- private Iterator<Integer> buildUnmodifiableIterator() {
- return this.buildTransformationIterator(this.buildUnmodifiableNestedIterator(), this.buildTransformer());
- }
-
- private Iterator<Integer> buildTransformationIterator(Iterator<String> nestedIterator, Transformer<String, Integer> transformer) {
- return new TransformationIterator<String, Integer>(nestedIterator, transformer);
- }
-
- private Iterator<Object> buildTransformationIteratorUpcast(Iterator<String> nestedIterator, Transformer<Object, Integer> transformer) {
- return new TransformationIterator<Object, Object>(nestedIterator, transformer);
- }
-
- private Transformer<String, Integer> buildTransformer() {
- // transform each string into an integer with a value of the string's length
- return new Transformer<String, Integer>() {
- public Integer transform(String next) {
- return new Integer(next.length());
- }
- };
- }
-
- private Transformer<Object, Integer> buildTransformerUpcast() {
- // transform each string into an integer with a value of the string's length
- return new Transformer<Object, Integer>() {
- public Integer transform(Object next) {
- return new Integer(((String) next).length());
- }
- };
- }
-
- private Iterator<Integer> buildInnerTransformationIterator(Iterator<String> nestedIterator) {
- // transform each string into an integer with a value of the string's length
- return new TransformationIterator<String, Integer>(nestedIterator) {
- @Override
- protected Integer transform(String next) {
- return new Integer(next.length());
- }
- };
- }
-
- private Iterator<String> buildNestedIterator() {
- return this.buildCollection().iterator();
- }
-
- private Iterator<String> buildUnmodifiableNestedIterator() {
- return this.buildUnmodifiableCollection().iterator();
- }
-
- private Collection<String> buildCollection() {
- Collection<String> c = new ArrayList<String>();
- c.add("1");
- c.add("22");
- c.add("333");
- c.add("4444");
- c.add("55555");
- c.add("666666");
- c.add("7777777");
- c.add("88888888");
- return c;
- }
-
- private Collection<String> buildUnmodifiableCollection() {
- return Collections.unmodifiableCollection(this.buildCollection());
- }
-
- public void testInvalidTransformationIterator() {
- // missing method override
- Iterator<Integer> iterator = new TransformationIterator<String, Integer>(this.buildCollection().iterator());
- boolean exCaught = false;
- try {
- Integer integer = iterator.next();
- fail("invalid integer: " + integer);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationListIteratorTests.java
deleted file mode 100644
index dc8a2e02c7..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationListIteratorTests.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.Transformer;
-import org.eclipse.jpt.utility.internal.iterators.TransformationListIterator;
-
-public class TransformationListIteratorTests extends TestCase {
-
- public TransformationListIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNextAndHasPrevious() {
- int i = 0;
- ListIterator<Integer> stream = this.buildIterator();
-
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(8, i);
-
- while (stream.hasPrevious()) {
- stream.previous();
- i--;
- }
- assertEquals(0, i);
- }
-
- public void testHasNextAndHasPreviousUpcast() {
- int i = 0;
- ListIterator<Object> stream = this.buildIteratorUpcast();
-
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(8, i);
-
- while (stream.hasPrevious()) {
- stream.previous();
- i--;
- }
- assertEquals(0, i);
- }
-
- public void testInnerHasNextAndHasPrevious() {
- int i = 0;
- ListIterator<Integer> stream = this.buildInnerIterator();
-
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(8, i);
-
- while (stream.hasPrevious()) {
- stream.previous();
- i--;
- }
- assertEquals(0, i);
- }
-
- public void testNextAndPrevious() {
- int i = 0;
- ListIterator<Integer> stream = this.buildIterator();
-
- while (stream.hasNext()) {
- assertEquals(++i, stream.next().intValue());
- }
-
- ++i;
-
- while (stream.hasPrevious()) {
- assertEquals(--i, stream.previous().intValue());
- }
- }
-
- public void testInnerNextAndPrevious() {
- int i = 0;
- ListIterator<Integer> stream = this.buildInnerIterator();
-
- while (stream.hasNext()) {
- assertEquals(++i, stream.next().intValue());
- }
-
- ++i;
-
- while (stream.hasPrevious()) {
- assertEquals(--i, stream.previous().intValue());
- }
- }
-
- public void testNextIndexAndPreviousIndex() {
- int i = -1;
- ListIterator<Integer> stream = this.buildIterator();
-
- while (stream.hasNext()) {
- assertEquals(++i, stream.nextIndex());
- stream.next();
- }
-
- ++i;
-
- while (stream.hasPrevious()) {
- assertEquals(--i, stream.previousIndex());
- stream.previous();
- }
- }
-
- public void testInnerNextIndexAndPreviousIndex() {
- int i = -1;
- ListIterator<Integer> stream = this.buildInnerIterator();
-
- while (stream.hasNext()) {
- assertEquals(++i, stream.nextIndex());
- stream.next();
- }
-
- ++i;
-
- while (stream.hasPrevious()) {
- assertEquals(--i, stream.previousIndex());
- stream.previous();
- }
- }
-
- public void testRemove() {
- List<String> l = this.buildList();
- for (ListIterator<Integer> stream = this.buildInnerTransformationListIterator(l.listIterator()); stream.hasNext();) {
- if (stream.next().intValue() == 3) {
- stream.remove();
- }
- }
- assertEquals("nothing removed", this.buildList().size() - 1, l.size());
- assertFalse("element still in list", l.contains("333"));
- assertTrue("wrong element removed", l.contains("22"));
- }
-
- public void testInnerRemove() {
- List<String> l = this.buildList();
- for (ListIterator<Integer> stream = this.buildTransformationListIterator(l.listIterator(), this.buildTransformer()); stream.hasNext();) {
- if (stream.next().intValue() == 3) {
- stream.remove();
- }
- }
- assertEquals("nothing removed", this.buildList().size() - 1, l.size());
- assertFalse("element still in list", l.contains("333"));
- assertTrue("wrong element removed", l.contains("22"));
- }
-
- public void testUnsupportedOperationExceptionOnAdd() {
- ListIterator<Integer> stream = this.buildIterator();
- boolean exCaught = false;
- try {
- stream.add(new Integer(0));
- fail("exception not thrown");
- } catch (UnsupportedOperationException e) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testUnsupportedOperationExceptionOnSet() {
- ListIterator<Integer> stream = this.buildIterator();
- boolean exCaught = false;
- try {
- stream.set(new Integer(0));
- fail("exception not thrown");
- } catch (UnsupportedOperationException e) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- ListIterator<Integer> stream = this.buildIterator();
- Integer integer = null;
- while (stream.hasNext()) {
- integer = stream.next();
- }
- try {
- integer = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + integer, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<Integer> stream = this.buildUnmodifiableIterator(); stream.hasNext();) {
- int i = stream.next().intValue();
- if (i == 3) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testIllegalStateException() {
- boolean exCaught = false;
- try {
- this.buildIterator().remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
-
- private ListIterator<Integer> buildIterator() {
- return this.buildTransformationListIterator(this.buildNestedIterator(), this.buildTransformer());
- }
-
- private ListIterator<Object> buildIteratorUpcast() {
- return this.buildTransformationListIteratorUpcast(this.buildNestedIterator(), this.buildTransformerUpcast());
- }
-
- private ListIterator<Integer> buildInnerIterator() {
- return this.buildInnerTransformationListIterator(this.buildNestedIterator());
- }
-
- private ListIterator<Integer> buildUnmodifiableIterator() {
- return this.buildTransformationListIterator(this.buildUnmodifiableNestedIterator(), this.buildTransformer());
- }
-
- private ListIterator<Integer> buildTransformationListIterator(ListIterator<String> nestedIterator, Transformer<String, Integer> transformer) {
- return new TransformationListIterator<String, Integer>(nestedIterator, transformer);
- }
-
- private ListIterator<Object> buildTransformationListIteratorUpcast(ListIterator<String> nestedIterator, Transformer<Object, Integer> transformer) {
- return new TransformationListIterator<Object, Object>(nestedIterator, transformer);
- }
-
- private Transformer<String, Integer> buildTransformer() {
- // transform each string into an integer with a value of the string's length
- return new Transformer<String, Integer>() {
- public Integer transform(String next) {
- return new Integer(next.length());
- }
- };
- }
-
- private Transformer<Object, Integer> buildTransformerUpcast() {
- // transform each string into an integer with a value of the string's length
- return new Transformer<Object, Integer>() {
- public Integer transform(Object next) {
- return new Integer(((String) next).length());
- }
- };
- }
-
- private ListIterator<Integer> buildInnerTransformationListIterator(ListIterator<String> nestedIterator) {
- // transform each string into an integer with a value of the string's length
- return new TransformationListIterator<String, Integer>(nestedIterator) {
- @Override
- protected Integer transform(String next) {
- return new Integer(next.length());
- }
- };
- }
-
- private ListIterator<String> buildNestedIterator() {
- return this.buildList().listIterator();
- }
-
- private ListIterator<String> buildUnmodifiableNestedIterator() {
- return this.buildUnmodifiableList().listIterator();
- }
-
- private List<String> buildList() {
- List<String> l = new ArrayList<String>();
- l.add("1");
- l.add("22");
- l.add("333");
- l.add("4444");
- l.add("55555");
- l.add("666666");
- l.add("7777777");
- l.add("88888888");
- return l;
- }
-
- private List<String> buildUnmodifiableList() {
- return Collections.unmodifiableList(this.buildList());
- }
-
- public void testInvalidTransformationListIterator() {
- // missing method override
- Iterator<Integer> iterator = new TransformationListIterator<String, Integer>(this.buildList().listIterator());
- boolean exCaught = false;
- try {
- Integer integer = iterator.next();
- fail("invalid integer: " + integer);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TreeIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TreeIteratorTests.java
deleted file mode 100644
index e15f1a8d50..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TreeIteratorTests.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.TreeIterator;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-public class TreeIteratorTests extends TestCase {
- /** this will be populated with all the nodes created for the test */
- Collection<TreeNode> nodes = new ArrayList<TreeNode>();
-
- public TreeIteratorTests(String name) {
- super(name);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testHasNext1() {
- this.verifyHasNext(this.buildTreeIterator1());
- }
-
- public void testHasNext2() {
- this.verifyHasNext(this.buildTreeIterator2());
- }
-
- private void verifyHasNext(Iterator<TreeNode> iterator) {
- int i = 0;
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(this.nodes.size(), i);
- }
-
- public void testNext1() {
- this.verifyNext(this.buildTreeIterator1());
- }
-
- public void testNext2() {
- this.verifyNext(this.buildTreeIterator2());
- }
-
- private void verifyNext(Iterator<TreeNode> iterator) {
- while (iterator.hasNext()) {
- assertTrue("bogus element", this.nodes.contains(iterator.next()));
- }
- }
-
- public void testNoSuchElementException1() {
- this.verifyNoSuchElementException(this.buildTreeIterator1());
- }
-
- public void testNoSuchElementException2() {
- this.verifyNoSuchElementException(this.buildTreeIterator2());
- }
-
- private void verifyNoSuchElementException(Iterator<TreeNode> iterator) {
- boolean exCaught = false;
- while (iterator.hasNext()) {
- iterator.next();
- }
- try {
- iterator.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
- public void testRemove1() {
- this.verifyRemove(this.buildTreeIterator1());
- }
-
- public void testRemove2() {
- this.verifyRemove(this.buildTreeIterator2());
- }
-
- private void verifyRemove(Iterator<TreeNode> iterator) {
- String parentName = "child 2";
- String childName = "grandchild 2A";
- int startSize = this.childrenSize(parentName);
- while (iterator.hasNext()) {
- TreeNode node = iterator.next();
- if (node.getName().equals(childName)) {
- iterator.remove();
- }
- }
- int endSize = this.childrenSize(parentName);
- assertEquals(startSize - 1, endSize);
- }
-
- private int childrenSize(String nodeName) {
- for (Iterator<TreeNode> stream = this.nodes.iterator(); stream.hasNext();) {
- TreeNode node = stream.next();
- if (node.getName().equals(nodeName)) {
- return node.childrenSize();
- }
- }
- throw new IllegalArgumentException(nodeName);
- }
-
- /**
- * build a tree iterator with an explicit midwife
- */
- private Iterator<TreeNode> buildTreeIterator1() {
- return new TreeIterator<TreeNode>(this.buildTree(), this.buildMidwife());
- }
-
- private TreeIterator.Midwife<TreeNode> buildMidwife() {
- return new TreeIterator.Midwife<TreeNode>() {
- public Iterator<TreeNode> children(TreeNode next) {
- return next.children();
- }
- };
- }
-
- /**
- * build a tree iterator with an override
- */
- private Iterator<TreeNode> buildTreeIterator2() {
- return new TreeIterator<TreeNode>(this.buildTree()) {
- @Override
- public Iterator<TreeNode> children(TreeNode next) {
- return next.children();
- }
- };
- }
-
- public void testInvalidTreeIterator() {
- // missing method override
- Iterator<TreeNode> iterator = new TreeIterator<TreeNode>(this.buildTree());
- boolean exCaught = false;
- try {
- TreeNode tn = iterator.next();
- fail("invalid tree node: " + tn);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
- private TreeNode buildTree() {
- TreeNode root = new TreeNode("root");
- TreeNode child1 = new TreeNode(root, "child 1");
- new TreeNode(child1, "grandchild 1A");
- TreeNode child2 = new TreeNode(root, "child 2");
- new TreeNode(child2, "grandchild 2A");
- TreeNode grandchild2B = new TreeNode(child2, "grandchild 2B");
- new TreeNode(grandchild2B, "great-grandchild 2B1");
- new TreeNode(grandchild2B, "great-grandchild 2B2");
- TreeNode grandchild2C = new TreeNode(child2, "grandchild 2C");
- new TreeNode(grandchild2C, "great-grandchild 2C1");
- new TreeNode(root, "child 3");
- return root;
- }
-
- private class TreeNode {
- private String name;
- private Collection<TreeNode> children = new ArrayList<TreeNode>();
-
- public TreeNode(String name) {
- super();
- TreeIteratorTests.this.nodes.add(this); // log node
- this.name = name;
- }
-
- public TreeNode(TreeNode parent, String name) {
- this(name);
- parent.addChild(this);
- }
-
- public String getName() {
- return this.name;
- }
-
- private void addChild(TreeNode child) {
- this.children.add(child);
- }
-
- public Iterator<TreeNode> children() {
- return this.children.iterator();
- }
-
- public int childrenSize() {
- return this.children.size();
- }
-
- @Override
- public String toString() {
- return "TreeNode(" + this.name + ")";
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/AbstractModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/AbstractModelTests.java
deleted file mode 100644
index eb394a98fe..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/AbstractModelTests.java
+++ /dev/null
@@ -1,1686 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.listener.ListChangeAdapter;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-public class AbstractModelTests
- extends TestCase
- implements StateChangeListener, PropertyChangeListener, CollectionChangeListener, ListChangeListener, TreeChangeListener
-{
- private TestModel testModel;
- private static final String TEST_TO_STRING = "this is a test";
-
- private StateChangeEvent stateChangeEvent;
- private boolean stateChangedCalled = false;
-
- private PropertyChangeEvent propertyChangeEvent;
- private boolean propertyChangeCalled = false;
- private static final String PROPERTY_NAME = "propertyName";
- static final Object OLD_OBJECT_VALUE = new Object();
- static final Object NEW_OBJECT_VALUE = new Object();
- static final Integer OLD_INT_VALUE = new Integer(27);
- static final Integer NEW_INT_VALUE = new Integer(42);
- static final Boolean OLD_BOOLEAN_VALUE = Boolean.TRUE;
- static final Boolean NEW_BOOLEAN_VALUE = Boolean.FALSE;
-
- private CollectionChangeEvent collectionChangeEvent;
- private boolean itemsAddedCollectionCalled = false;
- private boolean itemsRemovedCollectionCalled = false;
- private boolean collectionChangedCalled = false;
- private boolean collectionClearedCalled = false;
- private static final String COLLECTION_NAME = "collectionName";
- static final Object ADDED_OBJECT_VALUE = new Object();
- static final Object REMOVED_OBJECT_VALUE = new Object();
- static final int TARGET_INDEX = 7;
- static final int SOURCE_INDEX = 22;
-
- private ListChangeEvent listChangeEvent;
- private boolean itemsAddedListCalled = false;
- private boolean itemsRemovedListCalled = false;
- private boolean itemsReplacedListCalled = false;
- private boolean itemsMovedListCalled = false;
- private boolean listChangedCalled = false;
- private boolean listClearedCalled = false;
- private static final String LIST_NAME = "listName";
- private static final int ADD_INDEX = 3;
- private static final int REMOVE_INDEX = 5;
- private static final int REPLACE_INDEX = 2;
-
- private TreeChangeEvent treeChangeEvent;
- private boolean nodeAddedCalled = false;
- private boolean nodeRemovedCalled = false;
- private boolean treeChangedCalled = false;
- private boolean treeClearedCalled = false;
- private static final String TREE_NAME = "treeName";
- static final Object[] OBJECT_ARRAY_PATH = {new Object(), new Object(), new String()};
- static final Object[] EMPTY_PATH = {};
-
- public AbstractModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.testModel = new TestModel();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testFireStateChange() {
- this.stateChangeEvent = null;
- this.stateChangedCalled = false;
- this.testModel.addStateChangeListener(this);
- this.testModel.testFireStateChange();
- assertNotNull(this.stateChangeEvent);
- assertEquals(this.testModel, this.stateChangeEvent.getSource());
- assertTrue(this.stateChangedCalled);
- }
-
- public void testFirePropertyChangeObjectObject() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(this);
- this.testModel.testFirePropertyChangeObjectObject();
- this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(this);
- this.testModel.testFirePropertyChangeObjectObject();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this);
- this.testModel.testFirePropertyChangeObjectObject();
- this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this);
- this.testModel.testFirePropertyChangeObjectObject();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFirePropertyChangeObject() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(this);
- this.testModel.testFirePropertyChangeObject();
- this.verifyPropertyChangeEvent(null, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(this);
- this.testModel.testFirePropertyChangeObject();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this);
- this.testModel.testFirePropertyChangeObject();
- this.verifyPropertyChangeEvent(null, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this);
- this.testModel.testFirePropertyChangeObject();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFirePropertyChangeIntInt() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(this);
- this.testModel.testFirePropertyChangeIntInt();
- this.verifyPropertyChangeEvent(OLD_INT_VALUE, NEW_INT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(this);
- this.testModel.testFirePropertyChangeIntInt();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this);
- this.testModel.testFirePropertyChangeIntInt();
- this.verifyPropertyChangeEvent(OLD_INT_VALUE, NEW_INT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this);
- this.testModel.testFirePropertyChangeIntInt();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFirePropertyChangeBooleanBoolean() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(this);
- this.testModel.testFirePropertyChangeBooleanBoolean();
- this.verifyPropertyChangeEvent(OLD_BOOLEAN_VALUE, NEW_BOOLEAN_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(this);
- this.testModel.testFirePropertyChangeBooleanBoolean();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this);
- this.testModel.testFirePropertyChangeBooleanBoolean();
- this.verifyPropertyChangeEvent(OLD_BOOLEAN_VALUE, NEW_BOOLEAN_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this);
- this.testModel.testFirePropertyChangeBooleanBoolean();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFireItemAddedCollection() {
- this.collectionChangeEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(this);
- this.testModel.testFireItemAddedCollection();
- this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionChangeEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(this);
- this.testModel.testFireItemAddedCollection();
- assertNull(this.collectionChangeEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionChangeEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this);
- this.testModel.testFireItemAddedCollection();
- this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionChangeEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this);
- this.testModel.testFireItemAddedCollection();
- assertNull(this.collectionChangeEvent);
- assertFalse(this.itemsAddedCollectionCalled);
- }
-
- public void testFireItemRemovedCollection() {
- this.collectionChangeEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(this);
- this.testModel.testFireItemRemovedCollection();
- this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionChangeEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(this);
- this.testModel.testFireItemRemovedCollection();
- assertNull(this.collectionChangeEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionChangeEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this);
- this.testModel.testFireItemRemovedCollection();
- this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionChangeEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this);
- this.testModel.testFireItemRemovedCollection();
- assertNull(this.collectionChangeEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testFireCollectionCleared() {
- this.collectionChangeEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.addCollectionChangeListener(this);
- this.testModel.testFireCollectionCleared();
- this.verifyCollectionChangeEvent(null);
- assertTrue(this.collectionClearedCalled);
-
- this.collectionChangeEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.removeCollectionChangeListener(this);
- this.testModel.testFireCollectionCleared();
- assertNull(this.collectionChangeEvent);
- assertFalse(this.collectionClearedCalled);
-
- this.collectionChangeEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this);
- this.testModel.testFireCollectionCleared();
- this.verifyCollectionChangeEvent(null);
- assertTrue(this.collectionClearedCalled);
-
- this.collectionChangeEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this);
- this.testModel.testFireCollectionCleared();
- assertNull(this.collectionChangeEvent);
- assertFalse(this.collectionClearedCalled);
- }
-
- public void testFireCollectionChanged() {
- this.collectionChangeEvent = null;
- this.collectionChangedCalled = false;
- this.testModel.addCollectionChangeListener(this);
- this.testModel.testFireCollectionChanged();
- this.verifyCollectionChangeEvent(null);
- assertTrue(this.collectionChangedCalled);
-
- this.collectionChangeEvent = null;
- this.collectionChangedCalled = false;
- this.testModel.removeCollectionChangeListener(this);
- this.testModel.testFireCollectionChanged();
- assertNull(this.collectionChangeEvent);
- assertFalse(this.collectionChangedCalled);
-
- this.collectionChangeEvent = null;
- this.collectionChangedCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this);
- this.testModel.testFireCollectionChanged();
- this.verifyCollectionChangeEvent(null);
- assertTrue(this.collectionChangedCalled);
-
- this.collectionChangeEvent = null;
- this.collectionChangedCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this);
- this.testModel.testFireCollectionChanged();
- assertNull(this.collectionChangeEvent);
- assertFalse(this.collectionChangedCalled);
- }
-
- public void testFireItemAddedList() {
- this.listChangeEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(this);
- this.testModel.testFireItemAddedList();
- this.verifyListChangeEvent(ADD_INDEX, ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedListCalled);
-
- this.listChangeEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(this);
- this.testModel.testFireItemAddedList();
- assertNull(this.listChangeEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listChangeEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this);
- this.testModel.testFireItemAddedList();
- this.verifyListChangeEvent(ADD_INDEX, ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedListCalled);
-
- this.listChangeEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this);
- this.testModel.testFireItemAddedList();
- assertNull(this.listChangeEvent);
- assertFalse(this.itemsAddedListCalled);
- }
-
- public void testFireItemRemovedList() {
- this.listChangeEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(this);
- this.testModel.testFireItemRemovedList();
- this.verifyListChangeEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedListCalled);
-
- this.listChangeEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(this);
- this.testModel.testFireItemRemovedList();
- assertNull(this.listChangeEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listChangeEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this);
- this.testModel.testFireItemRemovedList();
- this.verifyListChangeEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedListCalled);
-
- this.listChangeEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this);
- this.testModel.testFireItemRemovedList();
- assertNull(this.listChangeEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testFireItemReplacedList() {
- this.listChangeEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addListChangeListener(this);
- this.testModel.testFireItemReplacedList();
- this.verifyListChangeEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsReplacedListCalled);
-
- this.listChangeEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeListChangeListener(this);
- this.testModel.testFireItemReplacedList();
- assertNull(this.listChangeEvent);
- assertFalse(this.itemsReplacedListCalled);
-
- this.listChangeEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this);
- this.testModel.testFireItemReplacedList();
- this.verifyListChangeEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsReplacedListCalled);
-
- this.listChangeEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this);
- this.testModel.testFireItemReplacedList();
- assertNull(this.listChangeEvent);
- assertFalse(this.itemsReplacedListCalled);
- }
-
- public void testFireItemMovedList() {
- this.listChangeEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addListChangeListener(this);
- this.testModel.testFireItemMovedList();
- this.verifyListChangeEvent(TARGET_INDEX, SOURCE_INDEX);
- assertTrue(this.itemsMovedListCalled);
-
- this.listChangeEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeListChangeListener(this);
- this.testModel.testFireItemMovedList();
- assertNull(this.listChangeEvent);
- assertFalse(this.itemsMovedListCalled);
-
- this.listChangeEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this);
- this.testModel.testFireItemMovedList();
- this.verifyListChangeEvent(TARGET_INDEX, SOURCE_INDEX);
- assertTrue(this.itemsMovedListCalled);
-
- this.listChangeEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this);
- this.testModel.testFireItemMovedList();
- assertNull(this.listChangeEvent);
- assertFalse(this.itemsMovedListCalled);
- }
-
- public void testFireListCleared() {
- this.listChangeEvent = null;
- this.listClearedCalled = false;
- this.testModel.addListChangeListener(this);
- this.testModel.testFireListCleared();
- this.verifyListChangeEvent(-1, null);
- assertTrue(this.listClearedCalled);
-
- this.listChangeEvent = null;
- this.listClearedCalled = false;
- this.testModel.removeListChangeListener(this);
- this.testModel.testFireListCleared();
- assertNull(this.listChangeEvent);
- assertFalse(this.listClearedCalled);
-
- this.listChangeEvent = null;
- this.listClearedCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this);
- this.testModel.testFireListCleared();
- this.verifyListChangeEvent(-1, null);
- assertTrue(this.listClearedCalled);
-
- this.listChangeEvent = null;
- this.listClearedCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this);
- this.testModel.testFireListCleared();
- assertNull(this.listChangeEvent);
- assertFalse(this.listClearedCalled);
- }
-
- public void testFireListChanged() {
- this.listChangeEvent = null;
- this.listChangedCalled = false;
- this.testModel.addListChangeListener(this);
- this.testModel.testFireListChanged();
- this.verifyListChangeEvent(-1, null);
- assertTrue(this.listChangedCalled);
-
- this.listChangeEvent = null;
- this.listChangedCalled = false;
- this.testModel.removeListChangeListener(this);
- this.testModel.testFireListChanged();
- assertNull(this.listChangeEvent);
- assertFalse(this.listChangedCalled);
-
- this.listChangeEvent = null;
- this.listChangedCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this);
- this.testModel.testFireListChanged();
- this.verifyListChangeEvent(-1, null);
- assertTrue(this.listChangedCalled);
-
- this.listChangeEvent = null;
- this.listChangedCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this);
- this.testModel.testFireListChanged();
- assertNull(this.listChangeEvent);
- assertFalse(this.listChangedCalled);
- }
-
- public void testFireNodeAddedObjectArrayPath() {
- this.treeChangeEvent = null;
- this.nodeAddedCalled = false;
- this.testModel.addTreeChangeListener(this);
- this.testModel.testFireNodeAddedObjectArrayPath();
- this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH);
- assertTrue(this.nodeAddedCalled);
-
- this.treeChangeEvent = null;
- this.nodeAddedCalled = false;
- this.testModel.removeTreeChangeListener(this);
- this.testModel.testFireNodeAddedObjectArrayPath();
- assertNull(this.treeChangeEvent);
- assertFalse(this.nodeAddedCalled);
-
- this.treeChangeEvent = null;
- this.nodeAddedCalled = false;
- this.testModel.addTreeChangeListener(TREE_NAME, this);
- this.testModel.testFireNodeAddedObjectArrayPath();
- this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH);
- assertTrue(this.nodeAddedCalled);
-
- this.treeChangeEvent = null;
- this.nodeAddedCalled = false;
- this.testModel.removeTreeChangeListener(TREE_NAME, this);
- this.testModel.testFireNodeAddedObjectArrayPath();
- assertNull(this.treeChangeEvent);
- assertFalse(this.nodeAddedCalled);
- }
-
- public void testFireNodeRemovedObjectArrayPath() {
- this.treeChangeEvent = null;
- this.nodeRemovedCalled = false;
- this.testModel.addTreeChangeListener(this);
- this.testModel.testFireNodeRemovedObjectArrayPath();
- this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH);
- assertTrue(this.nodeRemovedCalled);
-
- this.treeChangeEvent = null;
- this.nodeRemovedCalled = false;
- this.testModel.removeTreeChangeListener(this);
- this.testModel.testFireNodeRemovedObjectArrayPath();
- assertNull(this.treeChangeEvent);
- assertFalse(this.nodeRemovedCalled);
-
- this.treeChangeEvent = null;
- this.nodeRemovedCalled = false;
- this.testModel.addTreeChangeListener(TREE_NAME, this);
- this.testModel.testFireNodeRemovedObjectArrayPath();
- this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH);
- assertTrue(this.nodeRemovedCalled);
-
- this.treeChangeEvent = null;
- this.nodeRemovedCalled = false;
- this.testModel.removeTreeChangeListener(TREE_NAME, this);
- this.testModel.testFireNodeRemovedObjectArrayPath();
- assertNull(this.treeChangeEvent);
- assertFalse(this.nodeRemovedCalled);
- }
-
- public void testFireTreeCleared() {
- this.treeChangeEvent = null;
- this.treeClearedCalled = false;
- this.testModel.addTreeChangeListener(this);
- this.testModel.testFireTreeCleared();
- this.verifyTreeChangeEvent(EMPTY_PATH);
- assertTrue(this.treeClearedCalled);
-
- this.treeChangeEvent = null;
- this.treeClearedCalled = false;
- this.testModel.removeTreeChangeListener(this);
- this.testModel.testFireTreeCleared();
- assertNull(this.treeChangeEvent);
- assertFalse(this.treeClearedCalled);
-
- this.treeChangeEvent = null;
- this.treeClearedCalled = false;
- this.testModel.addTreeChangeListener(TREE_NAME, this);
- this.testModel.testFireTreeCleared();
- this.verifyTreeChangeEvent(EMPTY_PATH);
- assertTrue(this.treeClearedCalled);
-
- this.treeChangeEvent = null;
- this.treeClearedCalled = false;
- this.testModel.removeTreeChangeListener(TREE_NAME, this);
- this.testModel.testFireTreeCleared();
- assertNull(this.treeChangeEvent);
- assertFalse(this.treeClearedCalled);
- }
-
- public void testFireTreeChangedObjectArrayPath() {
- this.treeChangeEvent = null;
- this.treeChangedCalled = false;
- this.testModel.addTreeChangeListener(this);
- this.testModel.testFireTreeChangedObjectArrayPath();
- this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH);
- assertTrue(this.treeChangedCalled);
-
- this.treeChangeEvent = null;
- this.treeChangedCalled = false;
- this.testModel.removeTreeChangeListener(this);
- this.testModel.testFireTreeChangedObjectArrayPath();
- assertNull(this.treeChangeEvent);
- assertFalse(this.treeChangedCalled);
-
- this.treeChangeEvent = null;
- this.treeChangedCalled = false;
- this.testModel.addTreeChangeListener(TREE_NAME, this);
- this.testModel.testFireTreeChangedObjectArrayPath();
- this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH);
- assertTrue(this.treeChangedCalled);
-
- this.treeChangeEvent = null;
- this.treeChangedCalled = false;
- this.testModel.removeTreeChangeListener(TREE_NAME, this);
- this.testModel.testFireTreeChangedObjectArrayPath();
- assertNull(this.treeChangeEvent);
- assertFalse(this.treeChangedCalled);
- }
-
- public void testHasAnyChangeListeners() {
- assertFalse(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME));
- this.testModel.addPropertyChangeListener(this);
- assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME));
- this.testModel.removePropertyChangeListener(this);
-
- assertFalse(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME));
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this);
- assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME));
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this);
-
- assertFalse(this.testModel.hasAnyCollectionChangeListeners(COLLECTION_NAME));
- this.testModel.addCollectionChangeListener(this);
- assertTrue(this.testModel.hasAnyCollectionChangeListeners(COLLECTION_NAME));
- this.testModel.removeCollectionChangeListener(this);
-
- assertFalse(this.testModel.hasAnyCollectionChangeListeners(COLLECTION_NAME));
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this);
- assertTrue(this.testModel.hasAnyCollectionChangeListeners(COLLECTION_NAME));
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this);
-
- assertFalse(this.testModel.hasAnyListChangeListeners(LIST_NAME));
- this.testModel.addListChangeListener(this);
- assertTrue(this.testModel.hasAnyListChangeListeners(LIST_NAME));
- this.testModel.removeListChangeListener(this);
-
- assertFalse(this.testModel.hasAnyListChangeListeners(LIST_NAME));
- this.testModel.addListChangeListener(LIST_NAME, this);
- assertTrue(this.testModel.hasAnyListChangeListeners(LIST_NAME));
- this.testModel.removeListChangeListener(LIST_NAME, this);
-
- assertFalse(this.testModel.hasAnyTreeChangeListeners(TREE_NAME));
- this.testModel.addTreeChangeListener(this);
- assertTrue(this.testModel.hasAnyTreeChangeListeners(TREE_NAME));
- this.testModel.removeTreeChangeListener(this);
-
- assertFalse(this.testModel.hasAnyTreeChangeListeners(TREE_NAME));
- this.testModel.addTreeChangeListener(TREE_NAME, this);
- assertTrue(this.testModel.hasAnyTreeChangeListeners(TREE_NAME));
- this.testModel.removeTreeChangeListener(TREE_NAME, this);
- }
-
- public void testAttributeValueHasChanged() {
- this.testModel.testAttributeValueHasChanged();
- }
-
- public void testClone() {
- assertFalse(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME));
- this.testModel.addPropertyChangeListener(this);
- assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME));
-
- // verify that the clone does not have any listeners
- TestModel clone = this.testModel.clone();
- assertFalse(clone.hasAnyPropertyChangeListeners(PROPERTY_NAME));
- clone.addPropertyChangeListener(this);
- assertTrue(clone.hasAnyPropertyChangeListeners(PROPERTY_NAME));
- // check original
- assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME));
-
- // now test events fired by original
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.testFirePropertyChangeObjectObject();
- this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- // now test events fired by clone
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- clone.testFirePropertyChangeObjectObject();
- this.verifyPropertyChangeEvent(clone, OLD_OBJECT_VALUE, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
- }
-
- public void testAddNullStateListener() {
- boolean exCaught = false;
- try {
- this.testModel.addStateChangeListener(null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddNullPropertyListener() {
- boolean exCaught = false;
- try {
- this.testModel.addPropertyChangeListener(null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddNullCollectionListener() {
- boolean exCaught = false;
- try {
- this.testModel.addCollectionChangeListener(null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddNullListListener() {
- boolean exCaught = false;
- try {
- this.testModel.addListChangeListener(null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddNullTreeListener() {
- boolean exCaught = false;
- try {
- this.testModel.addTreeChangeListener(null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddNullPropertyListenerName() {
- boolean exCaught = false;
- try {
- this.testModel.addPropertyChangeListener("foo", null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddNullCollectionListenerName() {
- boolean exCaught = false;
- try {
- this.testModel.addCollectionChangeListener("foo", null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddNullListListenerName() {
- boolean exCaught = false;
- try {
- this.testModel.addListChangeListener("foo", null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddNullTreeListenerName() {
- boolean exCaught = false;
- try {
- this.testModel.addTreeChangeListener("foo", null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusStateListener() {
- boolean exCaught = false;
- try {
- this.testModel.removeStateChangeListener(this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener(this);
- exCaught = false;
- try {
- this.testModel.removeStateChangeListener(this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addStateChangeListener(this);
- exCaught = false;
- try {
- this.testModel.removeStateChangeListener(new AbstractModelTests("dummy"));
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusPropertyListener() {
- boolean exCaught = false;
- try {
- this.testModel.removePropertyChangeListener(this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addCollectionChangeListener(this);
- exCaught = false;
- try {
- this.testModel.removePropertyChangeListener(this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener(this);
- exCaught = false;
- try {
- this.testModel.removePropertyChangeListener(new AbstractModelTests("dummy"));
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusCollectionListener() {
- boolean exCaught = false;
- try {
- this.testModel.removeCollectionChangeListener(this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener(this);
- exCaught = false;
- try {
- this.testModel.removeCollectionChangeListener(this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addCollectionChangeListener(this);
- exCaught = false;
- try {
- this.testModel.removeCollectionChangeListener(new AbstractModelTests("dummy"));
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusListListener() {
- boolean exCaught = false;
- try {
- this.testModel.removeListChangeListener(this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener(this);
- exCaught = false;
- try {
- this.testModel.removeListChangeListener(this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addListChangeListener(this);
- exCaught = false;
- try {
- this.testModel.removeListChangeListener(new AbstractModelTests("dummy"));
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusTreeListener() {
- boolean exCaught = false;
- try {
- this.testModel.removeTreeChangeListener(this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener(this);
- exCaught = false;
- try {
- this.testModel.removeTreeChangeListener(this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addTreeChangeListener(this);
- exCaught = false;
- try {
- this.testModel.removeTreeChangeListener(new AbstractModelTests("dummy"));
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusPropertyListenerName() {
- boolean exCaught = false;
- try {
- this.testModel.removePropertyChangeListener("foo", this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addCollectionChangeListener("foo", this);
- exCaught = false;
- try {
- this.testModel.removePropertyChangeListener("foo", this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener("foo", this);
- exCaught = false;
- try {
- this.testModel.removePropertyChangeListener("foo", new AbstractModelTests("dummy"));
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusCollectionListenerName() {
- boolean exCaught = false;
- try {
- this.testModel.removeCollectionChangeListener("foo", this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener("foo", this);
- exCaught = false;
- try {
- this.testModel.removeCollectionChangeListener("foo", this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addCollectionChangeListener("foo", this);
- exCaught = false;
- try {
- this.testModel.removeCollectionChangeListener("foo", new AbstractModelTests("dummy"));
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusListListenerName() {
- boolean exCaught = false;
- try {
- this.testModel.removeListChangeListener("foo", this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener("foo", this);
- exCaught = false;
- try {
- this.testModel.removeListChangeListener("foo", this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addListChangeListener("foo", this);
- exCaught = false;
- try {
- this.testModel.removeListChangeListener("foo", new AbstractModelTests("dummy"));
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusTreeListenerName() {
- boolean exCaught = false;
- try {
- this.testModel.removeTreeChangeListener("foo", this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener("foo", this);
- exCaught = false;
- try {
- this.testModel.removeTreeChangeListener("foo", this);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addTreeChangeListener("foo", this);
- exCaught = false;
- try {
- this.testModel.removeTreeChangeListener("foo", new AbstractModelTests("dummy"));
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testToString() {
- assertTrue(this.testModel.toString().indexOf(TEST_TO_STRING) != -1);
- }
-
-// ********** internal methods **********
-
- private void verifyPropertyChangeEvent(Object oldValue, Object newValue) {
- this.verifyPropertyChangeEvent(this.testModel, oldValue, newValue);
- }
-
- private void verifyPropertyChangeEvent(Object source, Object oldValue, Object newValue) {
- assertNotNull(this.propertyChangeEvent);
- assertEquals(source, this.propertyChangeEvent.getSource());
- assertEquals(PROPERTY_NAME, this.propertyChangeEvent.getPropertyName());
- assertEquals(oldValue, this.propertyChangeEvent.getOldValue());
- assertEquals(newValue, this.propertyChangeEvent.getNewValue());
- }
-
- private void verifyCollectionChangeEvent(Object item) {
- assertNotNull(this.collectionChangeEvent);
- assertEquals(this.testModel, this.collectionChangeEvent.getSource());
- assertEquals(COLLECTION_NAME, this.collectionChangeEvent.getCollectionName());
- if (item == null) {
- assertFalse(this.collectionChangeEvent.items().hasNext());
- } else {
- assertEquals(item, this.collectionChangeEvent.items().next());
- }
- }
-
- private void verifyListChangeEvent(int index, Object item) {
- this.verifyListChangeEvent(index, item, null);
- }
-
- private void verifyListChangeEvent(int targetIndex, int sourceIndex) {
- assertNotNull(this.listChangeEvent);
- assertEquals(this.testModel, this.listChangeEvent.getSource());
- assertEquals(LIST_NAME, this.listChangeEvent.getListName());
- assertEquals(targetIndex, this.listChangeEvent.getTargetIndex());
- assertEquals(sourceIndex, this.listChangeEvent.getSourceIndex());
- }
-
- private void verifyListChangeEvent(int index, Object item, Object replacedItem) {
- assertNotNull(this.listChangeEvent);
- assertEquals(this.testModel, this.listChangeEvent.getSource());
- assertEquals(LIST_NAME, this.listChangeEvent.getListName());
- assertEquals(index, this.listChangeEvent.getIndex());
- if (item == null) {
- assertFalse(this.listChangeEvent.items().hasNext());
- } else {
- assertEquals(item, this.listChangeEvent.items().next());
- }
- if (replacedItem == null) {
- assertFalse(this.listChangeEvent.replacedItems().hasNext());
- } else {
- assertEquals(replacedItem, this.listChangeEvent.replacedItems().next());
- }
- }
-
- private void verifyTreeChangeEvent(Object[] path) {
- assertNotNull(this.treeChangeEvent);
- assertEquals(this.testModel, this.treeChangeEvent.getSource());
- assertEquals(TREE_NAME, this.treeChangeEvent.getTreeName());
- assertTrue(Arrays.equals(path, this.treeChangeEvent.getPath()));
- }
-
-// ********** listener implementations **********
-
- public void stateChanged(StateChangeEvent e) {
- this.stateChangedCalled = true;
- this.stateChangeEvent = e;
- }
-
- public void propertyChanged(PropertyChangeEvent e) {
- this.propertyChangeCalled = true;
- this.propertyChangeEvent = e;
- }
-
- public void itemsAdded(CollectionChangeEvent e) {
- this.itemsAddedCollectionCalled = true;
- this.collectionChangeEvent = e;
- }
- public void itemsRemoved(CollectionChangeEvent e) {
- this.itemsRemovedCollectionCalled = true;
- this.collectionChangeEvent = e;
- }
- public void collectionCleared(CollectionChangeEvent e) {
- this.collectionClearedCalled = true;
- this.collectionChangeEvent = e;
- }
- public void collectionChanged(CollectionChangeEvent e) {
- this.collectionChangedCalled = true;
- this.collectionChangeEvent = e;
- }
-
- public void itemsAdded(ListChangeEvent e) {
- this.itemsAddedListCalled = true;
- this.listChangeEvent = e;
- }
- public void itemsRemoved(ListChangeEvent e) {
- this.itemsRemovedListCalled = true;
- this.listChangeEvent = e;
- }
- public void itemsReplaced(ListChangeEvent e) {
- this.itemsReplacedListCalled = true;
- this.listChangeEvent = e;
- }
- public void itemsMoved(ListChangeEvent e) {
- this.itemsMovedListCalled = true;
- this.listChangeEvent = e;
- }
- public void listCleared(ListChangeEvent e) {
- this.listClearedCalled = true;
- this.listChangeEvent = e;
- }
- public void listChanged(ListChangeEvent e) {
- this.listChangedCalled = true;
- this.listChangeEvent = e;
- }
-
- public void nodeAdded(TreeChangeEvent e) {
- this.nodeAddedCalled = true;
- this.treeChangeEvent = e;
- }
- public void nodeRemoved(TreeChangeEvent e) {
- this.nodeRemovedCalled = true;
- this.treeChangeEvent = e;
- }
- public void treeCleared(TreeChangeEvent e) {
- this.treeClearedCalled = true;
- this.treeChangeEvent = e;
- }
- public void treeChanged(TreeChangeEvent e) {
- this.treeChangedCalled = true;
- this.treeChangeEvent = e;
- }
-
- // ********** inner class **********
-
- private static class TestModel extends AbstractModel implements Cloneable {
- TestModel() {
- super();
- }
-
- public void testFireStateChange() {
- this.fireStateChanged();
- }
-
- public void testFirePropertyChangeObjectObject() {
- this.firePropertyChanged(PROPERTY_NAME, OLD_OBJECT_VALUE, NEW_OBJECT_VALUE);
- }
-
- public void testFirePropertyChangeObject() {
- this.firePropertyChanged(PROPERTY_NAME, NEW_OBJECT_VALUE);
- }
-
- public void testFirePropertyChangeIntInt() {
- this.firePropertyChanged(PROPERTY_NAME, OLD_INT_VALUE.intValue(), NEW_INT_VALUE.intValue());
- }
-
- public void testFirePropertyChangeBooleanBoolean() {
- this.firePropertyChanged(PROPERTY_NAME, OLD_BOOLEAN_VALUE.booleanValue(), NEW_BOOLEAN_VALUE.booleanValue());
- }
-
- public void testFireItemAddedCollection() {
- this.fireItemAdded(COLLECTION_NAME, ADDED_OBJECT_VALUE);
- }
-
- public void testFireItemRemovedCollection() {
- this.fireItemRemoved(COLLECTION_NAME, REMOVED_OBJECT_VALUE);
- }
-
- public void testFireCollectionCleared() {
- this.fireCollectionCleared(COLLECTION_NAME);
- }
-
- public void testFireCollectionChanged() {
- this.fireCollectionChanged(COLLECTION_NAME);
- }
-
- public void testFireItemAddedList() {
- this.fireItemAdded(LIST_NAME, ADD_INDEX, ADDED_OBJECT_VALUE);
- }
-
- public void testFireItemRemovedList() {
- this.fireItemRemoved(LIST_NAME, REMOVE_INDEX, REMOVED_OBJECT_VALUE);
- }
-
- public void testFireItemReplacedList() {
- this.fireItemReplaced(LIST_NAME, REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE);
- }
-
- public void testFireItemMovedList() {
- this.fireItemMoved(LIST_NAME, TARGET_INDEX, SOURCE_INDEX);
- }
-
- public void testFireListCleared() {
- this.fireListCleared(LIST_NAME);
- }
-
- public void testFireListChanged() {
- this.fireListChanged(LIST_NAME);
- }
-
- public void testFireNodeAddedObjectArrayPath() {
- this.fireNodeAdded(TREE_NAME, OBJECT_ARRAY_PATH);
- }
-
- public void testFireNodeRemovedObjectArrayPath() {
- this.fireNodeRemoved(TREE_NAME, OBJECT_ARRAY_PATH);
- }
-
- public void testFireTreeCleared() {
- this.fireTreeCleared(TREE_NAME);
- }
-
- public void testFireTreeChangedObjectArrayPath() {
- this.fireTreeChanged(TREE_NAME, OBJECT_ARRAY_PATH);
- }
-
- public void testAttributeValueHasChanged() {
- assertTrue(this.attributeValueHasChanged(null, new Object()));
- assertTrue(this.attributeValueHasChanged(new Object(), null));
- assertTrue(this.attributeValueHasChanged(new Object(), new Object()));
-
- Object same = new Object();
- assertFalse(this.attributeValueHasChanged(same, same));
- assertFalse(this.attributeValueHasChanged(null, null));
- }
-
- @Override
- public TestModel clone() {
- try {
- return (TestModel) super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(TEST_TO_STRING);
- }
-
- }
-
-
- // ********** serialization test **********
-
-//TODO - This test doesn't pass in the Eclipse build environment (Linux) for some reason
-// public void testSerialization() throws IOException, ClassNotFoundException {
-// LocalModel model1 = new LocalModel();
-// Foo foo1 = new Foo();
-// Bar bar1 = new Bar();
-// Joo joo1 = new Joo();
-// Jar jar1 = new Jar();
-// model1.addStateChangeListener(foo1);
-// model1.addStateChangeListener(bar1);
-// model1.addListChangeListener(joo1);
-// model1.addListChangeListener(jar1);
-//
-// ChangeListener[] listeners1 = this.listeners(model1, StateChangeListener.class);
-// assertEquals(2, listeners1.length);
-// // the order of these could change...
-// assertEquals(Foo.class, listeners1[0].getClass());
-// assertEquals(Bar.class, listeners1[1].getClass());
-//
-// listeners1 = this.listeners(model1, ListChangeListener.class);
-// assertEquals(2, listeners1.length);
-// // the order of these could change...
-// assertEquals(Joo.class, listeners1[0].getClass());
-// assertEquals(Jar.class, listeners1[1].getClass());
-//
-// LocalModel model2 = TestTools.serialize(model1);
-//
-// ChangeListener[] listeners2 = this.listeners(model2, StateChangeListener.class);
-// assertEquals(1, listeners2.length);
-// assertEquals(Foo.class, listeners2[0].getClass());
-//
-// listeners2 = this.listeners(model2, ListChangeListener.class);
-// assertEquals(1, listeners2.length);
-// assertEquals(Joo.class, listeners2[0].getClass());
-// }
-
-// >>>>>>>>>>>>>>>>> these methods are called by #testSerialization(), commented out above...
- private ChangeListener[] listeners(LocalModel model, Class<? extends ChangeListener> listenerClass) {
- ChangeSupport changeSupport = (ChangeSupport) ClassTools.fieldValue(model, "changeSupport");
- return (ChangeListener[]) ClassTools.executeMethod(changeSupport, "listeners", Class.class, listenerClass);
- }
-
- private static class LocalModel extends AbstractModel implements Serializable {
- LocalModel() {
- super();
- }
- }
-
- private static class Foo implements Serializable, StateChangeListener {
- Foo() {
- super();
- }
- public void stateChanged(StateChangeEvent event) {
- // do nothing
- }
- }
-
- private static class Bar implements StateChangeListener {
- Bar() {
- super();
- }
- public void stateChanged(StateChangeEvent event) {
- // do nothing
- }
- }
-
- private static class Joo extends ListChangeAdapter implements Serializable {
-// private static final ObjectStreamField[] serialPersistentFields = {new ObjectStreamField("changeSupport", ChangeSupport.class)};
- Joo() {
- super();
- }
- }
-
- private static class Jar extends ListChangeAdapter {
- Jar() {
- super();
- }
- }
-
-
- // ********** bug(?) test **********
-
- private static final String ISE_MESSAGE = "this object is no longer listening to localA";
-
- /**
- * Test the following situation:
- * - both B and C are listening to A
- * - C is also listening to B
- * - when B receives an event from A, it will fire an event to C
- * - when C receives an event from B, it will STOP listening to A
- * - the event from B to C may be preceded or followed (depending on
- * the hash positions of listeners) by an event from A to C:
- * - if the A to C event comes first, no problem
- * - but if the A to B event comes first, the A to C event should NOT happen
- */
- public void testIndirectRemoveStateListener() {
- this.verifyIndirectRemoveListener(
- new NotifyCommand() {
- public void notifyListeners(LocalA localA) {
- localA.notifyStateListeners();
- }
- }
- );
- }
-
- public void testIndirectRemovePropertyListener() {
- this.verifyIndirectRemoveListener(
- new NotifyCommand() {
- public void notifyListeners(LocalA localA) {
- localA.notifyPropertyListeners();
- }
- }
- );
- }
-
- public void testIndirectRemoveCollectionListener() {
- this.verifyIndirectRemoveListener(
- new NotifyCommand() {
- public void notifyListeners(LocalA localA) {
- localA.notifyCollectionListeners();
- }
- }
- );
- }
-
- public void testIndirectRemoveListListener() {
- this.verifyIndirectRemoveListener(
- new NotifyCommand() {
- public void notifyListeners(LocalA localA) {
- localA.notifyListListeners();
- }
- }
- );
- }
-
- public void testIndirectRemoveTreeListener() {
- this.verifyIndirectRemoveListener(
- new NotifyCommand() {
- public void notifyListeners(LocalA localA) {
- localA.notifyTreeListeners();
- }
- }
- );
- }
-
- public void verifyIndirectRemoveListener(NotifyCommand command) {
- LocalA localA = new LocalA();
- LocalB localB = new LocalB(localA);
-
- // build a bunch of LocalCs so at least one of them is notified AFTER the LocalB;
- // using 1000 seemed to fail very consistently before ChangeSupport was fixed
- LocalC[] localCs = new LocalC[1000];
- for (int i = localCs.length; i-- > 0; ) {
- localCs[i] = new LocalC(localA, localB);
- }
-
- boolean exCaught = false;
- try {
- command.notifyListeners(localA);
- } catch (IllegalStateException ex) {
- if (ex.getMessage() == ISE_MESSAGE) {
- exCaught = true;
- } else {
- throw ex;
- }
- }
- assertFalse(exCaught);
-
- for (int i = localCs.length; i-- > 0; ) {
- assertFalse(localCs[i].isListeningToLocalA());
- }
- }
-
- private interface NotifyCommand {
- void notifyListeners(LocalA localA);
- }
-
- /**
- * This object simply fires a state change event. Both LocalB and LocalC
- * will be listeners.
- */
- private static class LocalA extends AbstractModel {
- LocalA() {
- super();
- }
- void notifyStateListeners() {
- this.fireStateChanged();
- }
- void notifyPropertyListeners() {
- this.firePropertyChanged("foo", 1, 2);
- }
- void notifyCollectionListeners() {
- this.fireCollectionChanged("foo");
- }
- void notifyListListeners() {
- this.fireListChanged("foo");
- }
- void notifyTreeListeners() {
- this.fireTreeChanged("foo");
- }
- }
-
- /**
- * This object will fire state change events whenever it receives
- * a state change event from localA.
- */
- private static class LocalB
- extends AbstractModel
- implements StateChangeListener, PropertyChangeListener, CollectionChangeListener, ListChangeListener, TreeChangeListener
- {
- LocalB(LocalA localA) {
- super();
- localA.addStateChangeListener(this);
- localA.addPropertyChangeListener(this);
- localA.addCollectionChangeListener(this);
- localA.addListChangeListener(this);
- localA.addTreeChangeListener(this);
- }
-
- public void stateChanged(StateChangeEvent e) {
- this.fireStateChanged();
- }
-
- public void propertyChanged(PropertyChangeEvent evt) {
- this.firePropertyChanged("bar", 1, 2);
- }
-
- public void collectionChanged(CollectionChangeEvent e) {
- this.fireCollectionChanged("bar");
- }
- public void collectionCleared(CollectionChangeEvent e) {/*ignore*/}
- public void itemsAdded(CollectionChangeEvent e) {/*ignore*/}
- public void itemsRemoved(CollectionChangeEvent e) {/*ignore*/}
-
- public void listChanged(ListChangeEvent e) {
- this.fireListChanged("bar");
- }
- public void listCleared(ListChangeEvent e) {/*ignore*/}
- public void itemsAdded(ListChangeEvent e) {/*ignore*/}
- public void itemsRemoved(ListChangeEvent e) {/*ignore*/}
- public void itemsReplaced(ListChangeEvent e) {/*ignore*/}
- public void itemsMoved(ListChangeEvent e) {/*ignore*/}
-
- public void treeChanged(TreeChangeEvent e) {
- this.fireTreeChanged("bar");
- }
- public void treeCleared(TreeChangeEvent e) {/*ignore*/}
- public void nodeAdded(TreeChangeEvent e) {/*ignore*/}
- public void nodeRemoved(TreeChangeEvent e) {/*ignore*/}
-
- }
-
- /**
- * This object will listen to two other objects, localA and localB.
- * If this object receives notification from localB, it will stop listening to
- * localA. If this object receives notification from localA, it will check to
- * see whether it still listening to localA. If this object is no longer
- * listening to localA, it will complain about receiving the event and
- * throw an exception.
- */
- private static class LocalC
- extends AbstractModel
- implements StateChangeListener, PropertyChangeListener, CollectionChangeListener, ListChangeListener, TreeChangeListener
- {
- private LocalA localA;
- private LocalB localB;
- private boolean listeningToLocalA;
-
- LocalC(LocalA localA, LocalB localB) {
- super();
- this.localA = localA;
- this.localB = localB;
-
- localA.addStateChangeListener(this);
- localA.addPropertyChangeListener(this);
- localA.addCollectionChangeListener(this);
- localA.addListChangeListener(this);
- localA.addTreeChangeListener(this);
- this.listeningToLocalA = true;
-
- localB.addStateChangeListener(this);
- localB.addPropertyChangeListener(this);
- localB.addCollectionChangeListener(this);
- localB.addListChangeListener(this);
- localB.addTreeChangeListener(this);
- }
- boolean isListeningToLocalA() {
- return this.listeningToLocalA;
- }
-
- public void stateChanged(StateChangeEvent e) {
- Object source = e.getSource();
- if (source == this.localA) {
- if ( ! this.listeningToLocalA) {
- throw new IllegalStateException(ISE_MESSAGE);
- }
- } else if (source == this.localB) {
- this.localA.removeStateChangeListener(this);
- this.listeningToLocalA = false;
- } else {
- throw new IllegalStateException("bogus event source: " + source);
- }
- }
-
- public void propertyChanged(PropertyChangeEvent e) {
- Object source = e.getSource();
- if (source == this.localA) {
- if ( ! this.listeningToLocalA) {
- throw new IllegalStateException(ISE_MESSAGE);
- }
- } else if (source == this.localB) {
- this.localA.removePropertyChangeListener(this);
- this.listeningToLocalA = false;
- } else {
- throw new IllegalStateException("bogus event source: " + source);
- }
- }
-
- public void collectionChanged(CollectionChangeEvent e) {
- Object source = e.getSource();
- if (source == this.localA) {
- if ( ! this.listeningToLocalA) {
- throw new IllegalStateException(ISE_MESSAGE);
- }
- } else if (source == this.localB) {
- this.localA.removeCollectionChangeListener(this);
- this.listeningToLocalA = false;
- } else {
- throw new IllegalStateException("bogus event source: " + source);
- }
- }
- public void collectionCleared(CollectionChangeEvent e) {/*ignore*/}
- public void itemsAdded(CollectionChangeEvent e) {/*ignore*/}
- public void itemsRemoved(CollectionChangeEvent e) {/*ignore*/}
-
- public void listChanged(ListChangeEvent e) {
- Object source = e.getSource();
- if (source == this.localA) {
- if ( ! this.listeningToLocalA) {
- throw new IllegalStateException(ISE_MESSAGE);
- }
- } else if (source == this.localB) {
- this.localA.removeListChangeListener(this);
- this.listeningToLocalA = false;
- } else {
- throw new IllegalStateException("bogus event source: " + source);
- }
- }
- public void listCleared(ListChangeEvent e) {/*ignore*/}
- public void itemsAdded(ListChangeEvent e) {/*ignore*/}
- public void itemsRemoved(ListChangeEvent e) {/*ignore*/}
- public void itemsReplaced(ListChangeEvent e) {/*ignore*/}
- public void itemsMoved(ListChangeEvent e) {/*ignore*/}
-
- public void treeChanged(TreeChangeEvent e) {
- Object source = e.getSource();
- if (source == this.localA) {
- if ( ! this.listeningToLocalA) {
- throw new IllegalStateException(ISE_MESSAGE);
- }
- } else if (source == this.localB) {
- this.localA.removeTreeChangeListener(this);
- this.listeningToLocalA = false;
- } else {
- throw new IllegalStateException("bogus event source: " + source);
- }
- }
- public void treeCleared(TreeChangeEvent e) {/*ignore*/}
- public void nodeAdded(TreeChangeEvent e) {/*ignore*/}
- public void nodeRemoved(TreeChangeEvent e) {/*ignore*/}
-
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/JptUtilityModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/JptUtilityModelTests.java
deleted file mode 100644
index d77ba7e2e1..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/JptUtilityModelTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model;
-
-import org.eclipse.jpt.utility.tests.internal.model.listener.JptUtilityModelListenerTests;
-import org.eclipse.jpt.utility.tests.internal.model.value.JptUtilityModelValueTests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptUtilityModelTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityModelTests.class.getPackage().getName());
-
- suite.addTest(JptUtilityModelListenerTests.suite());
- suite.addTest(JptUtilityModelValueTests.suite());
-
- suite.addTestSuite(AbstractModelTests.class);
- suite.addTestSuite(NewEventTests.class);
-
- return suite;
- }
-
- private JptUtilityModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java
deleted file mode 100644
index d50e13ec0e..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.ChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-/**
- * test what it takes to add a new type of event to
- * model and change support
- */
-public class NewEventTests extends TestCase {
- private Foo foo;
-
- public NewEventTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.foo = new Foo();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testHasNoFooChangeListeners() {
- assertTrue(this.foo.hasNoFooChangeListeners());
- LocalListener listener = new LocalListener();
- this.foo.addFooChangeListener(listener);
- assertFalse(this.foo.hasNoFooChangeListeners());
- this.foo.removeFooChangeListener(listener);
- assertTrue(this.foo.hasNoFooChangeListeners());
- }
-
- public void testHasAnyFooChangeListeners() {
- assertFalse(this.foo.hasAnyFooChangeListeners());
- LocalListener listener = new LocalListener();
- this.foo.addFooChangeListener(listener);
- assertTrue(this.foo.hasAnyFooChangeListeners());
- this.foo.removeFooChangeListener(listener);
- assertFalse(this.foo.hasAnyFooChangeListeners());
- }
-
- public void testFireFooChangeEvent() {
- LocalListener listener = new LocalListener();
- assertFalse(listener.receivedFooEvent);
- this.foo.addFooChangeListener(listener);
- this.foo.foo();
- assertTrue(listener.receivedFooEvent);
- }
-
-
- // ********** harness classes **********
-
- class Foo extends AbstractFooModel {
- Foo() {
- super();
- }
- void foo() {
- this.fireFooChangeEvent();
- }
- }
-
- class LocalListener implements FooChangeListener {
- boolean receivedFooEvent = false;
- LocalListener() {
- super();
- }
- public void fooChanged(FooChangeEvent event) {
- this.receivedFooEvent = true;
- }
- }
-
- interface FooModel extends Model {
- void addFooChangeListener(FooChangeListener listener);
- void removeFooChangeListener(FooChangeListener listener);
- }
-
- interface FooChangeListener extends ChangeListener {
- void fooChanged(FooChangeEvent event);
- }
-
- static class FooChangeEvent extends ChangeEvent {
- private static final long serialVersionUID = 1L;
- public FooChangeEvent(FooModel source) {
- super(source);
- }
- @Override
- public String getAspectName() {
- return null; // the point of the event is that the name is unknown...
- }
- @Override
- public FooChangeEvent cloneWithSource(Model newSource) {
- return new FooChangeEvent((FooModel) newSource);
- }
- }
-
- static class AbstractFooModel extends AbstractModel implements FooModel {
- @Override
- protected synchronized FooChangeSupport getChangeSupport() {
- return (FooChangeSupport) super.getChangeSupport();
- }
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new FooChangeSupport(this);
- }
- public void addFooChangeListener(FooChangeListener listener) {
- this.getChangeSupport().addFooChangeListener(listener);
- }
- public void removeFooChangeListener(FooChangeListener listener) {
- this.getChangeSupport().removeFooChangeListener(listener);
- }
- protected void fireFooChangeEvent() {
- this.getChangeSupport().fireFooChanged();
- }
- public boolean hasAnyFooChangeListeners() {
- return this.getChangeSupport().hasAnyFooChangeListeners();
- }
- public boolean hasNoFooChangeListeners() {
- return ! this.hasAnyFooChangeListeners();
- }
- }
-
- static class FooChangeSupport extends ChangeSupport {
- FooChangeSupport(FooModel source) {
- super(source);
- }
- protected static final Class<FooChangeListener> FOO_CHANGE_LISTENER_CLASS = FooChangeListener.class;
- void addFooChangeListener(FooChangeListener listener) {
- this.addListener(FOO_CHANGE_LISTENER_CLASS, listener);
- }
- void removeFooChangeListener(FooChangeListener listener) {
- this.removeListener(FOO_CHANGE_LISTENER_CLASS, listener);
- }
- public boolean hasAnyFooChangeListeners() {
- return this.hasAnyListeners(FOO_CHANGE_LISTENER_CLASS);
- }
- private FooChangeListener[] fooChangeListeners() {
- return (FooChangeListener[]) this.listeners(FOO_CHANGE_LISTENER_CLASS);
- }
- public void fireFooChanged() {
- FooChangeListener[] targets = null;
- synchronized (this) {
- FooChangeListener[] fooChangeListeners = this.fooChangeListeners();
- if (fooChangeListeners != null) {
- targets = fooChangeListeners.clone();
- }
- }
- if (targets != null) {
- FooChangeEvent event = null;
- for (FooChangeListener target : targets) {
- boolean stillListening;
- synchronized (this) {
- stillListening = CollectionTools.contains(this.fooChangeListeners(), target);
- }
- if (stillListening) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new FooChangeEvent((FooModel) this.source);
- }
- target.fooChanged(event);
- }
- }
- }
- this.sourceChanged(null);
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/JptUtilityModelListenerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/JptUtilityModelListenerTests.java
deleted file mode 100644
index 084a9b8ab3..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/JptUtilityModelListenerTests.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.listener;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptUtilityModelListenerTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityModelListenerTests.class.getPackage().getName());
-
- suite.addTestSuite(ReflectiveCollectionChangeListenerTests.class);
- suite.addTestSuite(ReflectiveListChangeListenerTests.class);
- suite.addTestSuite(ReflectivePropertyChangeListenerTests.class);
- suite.addTestSuite(ReflectiveStateChangeListenerTests.class);
- suite.addTestSuite(ReflectiveTreeChangeListenerTests.class);
-
- return suite;
- }
-
- private JptUtilityModelListenerTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java
deleted file mode 100644
index ddd0bab630..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java
+++ /dev/null
@@ -1,455 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.listener;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.ReflectiveChangeListener;
-
-import junit.framework.TestCase;
-
-public class ReflectiveCollectionChangeListenerTests extends TestCase {
-
- public ReflectiveCollectionChangeListenerTests(String name) {
- super(name);
- }
-
- private CollectionChangeListener buildZeroArgumentListener(Object target) {
- return ReflectiveChangeListener.buildCollectionChangeListener(target, "itemAddedZeroArgument", "itemRemovedZeroArgument", "collectionClearedZeroArgument", "collectionChangedZeroArgument");
- }
-
- private CollectionChangeListener buildSingleArgumentListener(Object target) {
- return ReflectiveChangeListener.buildCollectionChangeListener(target, "itemAddedSingleArgument", "itemRemovedSingleArgument", "collectionClearedSingleArgument", "collectionChangedSingleArgument");
- }
-
- public void testItemAddedZeroArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(this.buildZeroArgumentListener(target));
- testModel.addString(string);
- assertTrue(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testItemAddedZeroArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildZeroArgumentListener(target));
- testModel.addString(string);
- assertTrue(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testItemAddedSingleArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(this.buildSingleArgumentListener(target));
- testModel.addString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertTrue(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testItemAddedSingleArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildSingleArgumentListener(target));
- testModel.addString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertTrue(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testItemRemovedZeroArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(this.buildZeroArgumentListener(target));
- testModel.removeString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertTrue(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testItemRemovedZeroArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildZeroArgumentListener(target));
- testModel.removeString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertTrue(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testItemRemovedSingleArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(this.buildSingleArgumentListener(target));
- testModel.removeString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertTrue(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testItemRemovedSingleArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildSingleArgumentListener(target));
- testModel.removeString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertTrue(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testCollectionClearedZeroArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(this.buildZeroArgumentListener(target));
- testModel.clearStrings();
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertTrue(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testCollectionClearedZeroArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildZeroArgumentListener(target));
- testModel.clearStrings();
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertTrue(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testCollectionClearedSingleArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(this.buildSingleArgumentListener(target));
- testModel.clearStrings();
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertTrue(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testCollectionClearedSingleArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildSingleArgumentListener(target));
- testModel.clearStrings();
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertTrue(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testCollectionChangedZeroArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(this.buildZeroArgumentListener(target));
- testModel.replaceStrings(new String[] {"bar", "baz"});
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertTrue(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testCollectionChangedZeroArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildZeroArgumentListener(target));
- testModel.replaceStrings(new String[] {"bar", "baz"});
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertTrue(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testCollectionChangedSingleArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(this.buildSingleArgumentListener(target));
- testModel.replaceStrings(new String[] {"bar", "baz"});
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertTrue(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testCollectionChangedSingleArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildSingleArgumentListener(target));
- testModel.replaceStrings(new String[] {"bar", "baz"});
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertTrue(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testBogusDoubleArgument1() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- boolean exCaught = false;
- try {
- CollectionChangeListener listener = ReflectiveChangeListener.buildCollectionChangeListener(target, "collectionChangedDoubleArgument");
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getCause().getClass() == NoSuchMethodException.class) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument2() throws Exception {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- Method method = ClassTools.method(target, "collectionChangedDoubleArgument", new Class[] {CollectionChangeEvent.class, Object.class});
- boolean exCaught = false;
- try {
- CollectionChangeListener listener = ReflectiveChangeListener.buildCollectionChangeListener(target, method);
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getMessage().equals(method.toString())) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testListenerMismatch() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- // build a COLLECTION change listener and hack it so we
- // can add it as a LIST change listener
- Object listener = ReflectiveChangeListener.buildCollectionChangeListener(target, "itemAddedSingleArgument");
- testModel.addListChangeListener((ListChangeListener) listener);
-
- boolean exCaught = false;
- try {
- testModel.changeList();
- fail("listener mismatch: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- private class TestModel extends AbstractModel {
- private Collection<String> strings = new ArrayList<String>();
- public static final String STRINGS_COLLECTION = "strings";
- TestModel() {
- super();
- }
- Iterator<String> strings() {
- return new CloneIterator<String>(this.strings) {
- @Override
- protected void remove(String s) {
- TestModel.this.removeString(s);
- }
- };
- }
- void addString(String string) {
- this.addItemToCollection(string, this.strings, STRINGS_COLLECTION);
- }
- void removeString(String string) {
- this.removeItemFromCollection(string, this.strings, STRINGS_COLLECTION);
- }
- void clearStrings() {
- this.clearCollection(this.strings, STRINGS_COLLECTION);
- }
- void replaceStrings(String[] newStrings) {
- this.strings.clear();
- CollectionTools.addAll(this.strings, newStrings);
- this.fireCollectionChanged(STRINGS_COLLECTION);
- }
- void changeList() {
- this.fireListChanged("bogus list");
- }
- }
-
- private class Target {
- TestModel testModel;
- String collectionName;
- String string;
- boolean itemAddedZeroArgumentFlag = false;
- boolean itemAddedSingleArgumentFlag = false;
- boolean itemRemovedZeroArgumentFlag = false;
- boolean itemRemovedSingleArgumentFlag = false;
- boolean collectionClearedZeroArgumentFlag = false;
- boolean collectionClearedSingleArgumentFlag = false;
- boolean collectionChangedZeroArgumentFlag = false;
- boolean collectionChangedSingleArgumentFlag = false;
- Target(TestModel testModel, String collectionName, String string) {
- super();
- this.testModel = testModel;
- this.collectionName = collectionName;
- this.string = string;
- }
- void itemAddedZeroArgument() {
- this.itemAddedZeroArgumentFlag = true;
- }
- void itemAddedSingleArgument(CollectionChangeEvent e) {
- this.itemAddedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.collectionName, e.getCollectionName());
- assertEquals(this.string, e.items().next());
- }
- void itemRemovedZeroArgument() {
- this.itemRemovedZeroArgumentFlag = true;
- }
- void itemRemovedSingleArgument(CollectionChangeEvent e) {
- this.itemRemovedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.collectionName, e.getCollectionName());
- assertEquals(this.string, e.items().next());
- }
- void collectionClearedZeroArgument() {
- this.collectionClearedZeroArgumentFlag = true;
- }
- void collectionClearedSingleArgument(CollectionChangeEvent e) {
- this.collectionClearedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.collectionName, e.getCollectionName());
- assertFalse(e.items().hasNext());
- }
- void collectionChangedZeroArgument() {
- this.collectionChangedZeroArgumentFlag = true;
- }
- void collectionChangedSingleArgument(CollectionChangeEvent e) {
- this.collectionChangedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.collectionName, e.getCollectionName());
- assertFalse(e.items().hasNext());
- }
- void collectionChangedDoubleArgument(CollectionChangeEvent e, Object o) {
- fail("bogus event: " + e);
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java
deleted file mode 100644
index f836aa76fa..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.listener;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.ReflectiveChangeListener;
-
-import junit.framework.TestCase;
-
-public class ReflectiveListChangeListenerTests extends TestCase {
-
- public ReflectiveListChangeListenerTests(String name) {
- super(name);
- }
-
- private ListChangeListener buildZeroArgumentListener(Object target) {
- return ReflectiveChangeListener.buildListChangeListener(target, "itemAddedZeroArgument", "itemRemovedZeroArgument", "itemReplacedZeroArgument", "itemMovedZeroArgument", "listClearedZeroArgument", "listChangedZeroArgument");
- }
-
- private ListChangeListener buildSingleArgumentListener(Object target) {
- return ReflectiveChangeListener.buildListChangeListener(target, "itemAddedSingleArgument", "itemRemovedSingleArgument", "itemReplacedSingleArgument", "itemMovedSingleArgument", "listClearedSingleArgument", "listChangedSingleArgument");
- }
-
- public void testItemAddedZeroArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- testModel.addListChangeListener(this.buildZeroArgumentListener(target));
- testModel.addString(string);
- assertTrue(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemAddedZeroArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildZeroArgumentListener(target));
- testModel.addString(string);
- assertTrue(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemAddedSingleArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- testModel.addListChangeListener(this.buildSingleArgumentListener(target));
- testModel.addString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertTrue(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemAddedSingleArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildSingleArgumentListener(target));
- testModel.addString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertTrue(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemRemovedZeroArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- testModel.addListChangeListener(this.buildZeroArgumentListener(target));
- testModel.removeString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertTrue(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemRemovedZeroArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildZeroArgumentListener(target));
- testModel.removeString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertTrue(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemRemovedSingleArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- testModel.addListChangeListener(this.buildSingleArgumentListener(target));
- testModel.removeString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertTrue(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemRemovedSingleArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildSingleArgumentListener(target));
- testModel.removeString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertTrue(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemReplacedZeroArgument() {
- TestModel testModel = new TestModel();
- String oldString = "foo";
- String newString = "bar";
- testModel.addString(oldString);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, newString, 0, oldString);
- testModel.addListChangeListener(this.buildZeroArgumentListener(target));
- testModel.replaceString(oldString, newString);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertTrue(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemReplacedZeroArgumentNamedList() {
- TestModel testModel = new TestModel();
- String oldString = "foo";
- String newString = "bar";
- testModel.addString(oldString);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, newString, 0, oldString);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildZeroArgumentListener(target));
- testModel.replaceString(oldString, newString);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertTrue(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemReplacedSingleArgument() {
- TestModel testModel = new TestModel();
- String oldString = "foo";
- String newString = "bar";
- testModel.addString(oldString);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, newString, 0, oldString);
- testModel.addListChangeListener(this.buildSingleArgumentListener(target));
- testModel.replaceString(oldString, newString);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertTrue(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemReplacedSingleArgumentNamedList() {
- TestModel testModel = new TestModel();
- String oldString = "foo";
- String newString = "bar";
- testModel.addString(oldString);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, newString, 0, oldString);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildSingleArgumentListener(target));
- testModel.replaceString(oldString, newString);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertTrue(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemMovedZeroArgument() {
- TestModel testModel = new TestModel();
- testModel.addString("zero");
- testModel.addString("one");
- testModel.addString("two");
- testModel.addString("three");
- Target target = new Target(testModel, TestModel.STRINGS_LIST, 0, 2);
- testModel.addListChangeListener(this.buildZeroArgumentListener(target));
- testModel.moveString(0, 2);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertTrue(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemMovedZeroArgumentNamedList() {
- TestModel testModel = new TestModel();
- testModel.addString("zero");
- testModel.addString("one");
- testModel.addString("two");
- testModel.addString("three");
- Target target = new Target(testModel, TestModel.STRINGS_LIST, 0, 2);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildZeroArgumentListener(target));
- testModel.moveString(0, 2);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertTrue(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemMovedSingleArgument() {
- TestModel testModel = new TestModel();
- testModel.addString("zero");
- testModel.addString("one");
- testModel.addString("two");
- testModel.addString("three");
- Target target = new Target(testModel, TestModel.STRINGS_LIST, 0, 2);
- testModel.addListChangeListener(this.buildSingleArgumentListener(target));
- testModel.moveString(0, 2);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertTrue(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemMovedSingleArgumentNamedList() {
- TestModel testModel = new TestModel();
- testModel.addString("zero");
- testModel.addString("one");
- testModel.addString("two");
- testModel.addString("three");
- Target target = new Target(testModel, TestModel.STRINGS_LIST, 0, 2);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildSingleArgumentListener(target));
- testModel.moveString(0, 2);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertTrue(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testListClearedZeroArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, null, -1);
- testModel.addListChangeListener(this.buildZeroArgumentListener(target));
- testModel.clearStrings();
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertTrue(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testListClearedZeroArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, null, -1);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildZeroArgumentListener(target));
- testModel.clearStrings();
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertTrue(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testListClearedSingleArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, null, -1);
- testModel.addListChangeListener(this.buildSingleArgumentListener(target));
- testModel.clearStrings();
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertTrue(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testListClearedSingleArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, null, -1);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildSingleArgumentListener(target));
- testModel.clearStrings();
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertTrue(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testListChangedZeroArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, null, -1);
- testModel.addListChangeListener(this.buildZeroArgumentListener(target));
- testModel.replaceAllStrings(new String[] {"bar", "baz"});
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertTrue(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testListChangedZeroArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, null, -1);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildZeroArgumentListener(target));
- testModel.replaceAllStrings(new String[] {"bar", "baz"});
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertTrue(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testListChangedSingleArgument() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, null, -1);
- testModel.addListChangeListener(this.buildSingleArgumentListener(target));
- testModel.replaceAllStrings(new String[] {"bar", "baz"});
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertTrue(target.listChangedSingleArgumentFlag);
- }
-
- public void testListChangedSingleArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, null, -1);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildSingleArgumentListener(target));
- testModel.replaceAllStrings(new String[] {"bar", "baz"});
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertTrue(target.listChangedSingleArgumentFlag);
- }
-
- public void testBogusDoubleArgument1() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- boolean exCaught = false;
- try {
- ListChangeListener listener = ReflectiveChangeListener.buildListChangeListener(target, "listChangedDoubleArgument");
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getCause().getClass() == NoSuchMethodException.class) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument2() throws Exception {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- Method method = ClassTools.method(target, "listChangedDoubleArgument", new Class[] {ListChangeEvent.class, Object.class});
- boolean exCaught = false;
- try {
- ListChangeListener listener = ReflectiveChangeListener.buildListChangeListener(target, method);
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getMessage().equals(method.toString())) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testListenerMismatch() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- // build a LIST change listener and hack it so we
- // can add it as a COLLECTION change listener
- Object listener = ReflectiveChangeListener.buildListChangeListener(target, "itemAddedSingleArgument");
- testModel.addCollectionChangeListener((CollectionChangeListener) listener);
-
- boolean exCaught = false;
- try {
- testModel.changeCollection();
- fail("listener mismatch: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- private class TestModel extends AbstractModel {
- private List<String> strings = new ArrayList<String>();
- public static final String STRINGS_LIST = "strings";
- TestModel() {
- super();
- }
- ListIterator<String> strings() {
- return new CloneListIterator<String>(this.strings);
- }
- void addString(String string) {
- this.addItemToList(string, this.strings, STRINGS_LIST);
- }
- void removeString(String string) {
- this.removeItemFromList(this.strings.indexOf(string), this.strings, STRINGS_LIST);
- }
- void replaceString(String oldString, String newString) {
- this.setItemInList(this.strings.indexOf(oldString), newString, this.strings, STRINGS_LIST);
- }
- void moveString(int targetIndex, int sourceIndex) {
- this.moveItemInList(targetIndex, sourceIndex, this.strings, STRINGS_LIST);
- }
- void clearStrings() {
- this.clearList(this.strings, STRINGS_LIST);
- }
- void replaceAllStrings(String[] newStrings) {
- this.strings.clear();
- CollectionTools.addAll(this.strings, newStrings);
- this.fireListChanged(STRINGS_LIST);
- }
- void changeCollection() {
- this.fireCollectionChanged("bogus collection");
- }
- }
-
- private class Target {
- TestModel testModel;
- String listName;
- String string;
- int index;
- String replacedString;
- int sourceIndex;
- boolean itemAddedZeroArgumentFlag = false;
- boolean itemAddedSingleArgumentFlag = false;
- boolean itemRemovedZeroArgumentFlag = false;
- boolean itemRemovedSingleArgumentFlag = false;
- boolean itemReplacedZeroArgumentFlag = false;
- boolean itemReplacedSingleArgumentFlag = false;
- boolean itemMovedZeroArgumentFlag = false;
- boolean itemMovedSingleArgumentFlag = false;
- boolean listClearedZeroArgumentFlag = false;
- boolean listClearedSingleArgumentFlag = false;
- boolean listChangedZeroArgumentFlag = false;
- boolean listChangedSingleArgumentFlag = false;
- Target(TestModel testModel, String listName, String string, int index) {
- super();
- this.testModel = testModel;
- this.listName = listName;
- this.string = string;
- this.index = index;
- }
- Target(TestModel testModel, String listName, String string, int index, String replacedString) {
- this(testModel, listName, string, index);
- this.replacedString = replacedString;
- }
- Target(TestModel testModel, String listName, int targetIndex, int sourceIndex) {
- super();
- this.testModel = testModel;
- this.listName = listName;
- this.index = targetIndex;
- this.sourceIndex = sourceIndex;
- }
- void itemAddedZeroArgument() {
- this.itemAddedZeroArgumentFlag = true;
- }
- void itemAddedSingleArgument(ListChangeEvent e) {
- this.itemAddedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- assertEquals(this.string, e.items().next());
- assertEquals(this.index, e.getIndex());
- }
- void itemRemovedZeroArgument() {
- this.itemRemovedZeroArgumentFlag = true;
- }
- void itemRemovedSingleArgument(ListChangeEvent e) {
- this.itemRemovedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- assertEquals(this.string, e.items().next());
- assertEquals(this.index, e.getIndex());
- }
- void itemReplacedZeroArgument() {
- this.itemReplacedZeroArgumentFlag = true;
- }
- void itemReplacedSingleArgument(ListChangeEvent e) {
- this.itemReplacedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- assertEquals(this.string, e.items().next());
- assertEquals(this.replacedString, e.replacedItems().next());
- assertEquals(this.index, e.getIndex());
- }
- void itemMovedZeroArgument() {
- this.itemMovedZeroArgumentFlag = true;
- }
- void itemMovedSingleArgument(ListChangeEvent e) {
- this.itemMovedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- assertEquals(this.index, e.getTargetIndex());
- assertEquals(this.sourceIndex, e.getSourceIndex());
- }
- void listChangedZeroArgument() {
- this.listChangedZeroArgumentFlag = true;
- }
- void listClearedSingleArgument(ListChangeEvent e) {
- this.listClearedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- assertFalse(e.items().hasNext());
- assertEquals(this.index, e.getIndex());
- }
- void listClearedZeroArgument() {
- this.listClearedZeroArgumentFlag = true;
- }
- void listChangedSingleArgument(ListChangeEvent e) {
- this.listChangedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- assertFalse(e.items().hasNext());
- assertEquals(this.index, e.getIndex());
- }
- void listChangedDoubleArgument(ListChangeEvent e, Object o) {
- fail("bogus event: " + e);
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java
deleted file mode 100644
index 2286225afa..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.listener;
-
-import java.lang.reflect.Method;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.ReflectiveChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-
-import junit.framework.TestCase;
-
-public class ReflectivePropertyChangeListenerTests extends TestCase {
-
- public ReflectivePropertyChangeListenerTests(String name) {
- super(name);
- }
-
- public void testZeroArgument() {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- testModel.addPropertyChangeListener(ReflectiveChangeListener.buildPropertyChangeListener(target, "propertyChangedZeroArgument"));
- testModel.setValue(99);
- assertTrue(target.zeroArgumentFlag);
- assertFalse(target.singleArgumentFlag);
- }
-
- public void testZeroArgumentNamedProperty() {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- testModel.addPropertyChangeListener(TestModel.VALUE_PROPERTY, ReflectiveChangeListener.buildPropertyChangeListener(target, "propertyChangedZeroArgument"));
- testModel.setValue(99);
- assertTrue(target.zeroArgumentFlag);
- assertFalse(target.singleArgumentFlag);
- }
-
- public void testSingleArgument() {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- testModel.addPropertyChangeListener(ReflectiveChangeListener.buildPropertyChangeListener(target, "propertyChangedSingleArgument"));
- testModel.setValue(99);
- assertFalse(target.zeroArgumentFlag);
- assertTrue(target.singleArgumentFlag);
- }
-
- /**
- * test method that has more general method parameter type
- */
- public void testSingleArgument2() throws Exception {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- Method method = ClassTools.method(target, "propertyChangedSingleArgument2", new Class[] {Object.class});
- testModel.addPropertyChangeListener(ReflectiveChangeListener.buildPropertyChangeListener(target, method));
- testModel.setValue(99);
- assertFalse(target.zeroArgumentFlag);
- assertTrue(target.singleArgumentFlag);
- }
-
- public void testSingleArgumentNamedProperty() {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- testModel.addPropertyChangeListener(TestModel.VALUE_PROPERTY, ReflectiveChangeListener.buildPropertyChangeListener(target, "propertyChangedSingleArgument"));
- testModel.setValue(99);
- assertFalse(target.zeroArgumentFlag);
- assertTrue(target.singleArgumentFlag);
- }
-
- /**
- * test method that has more general method parameter type
- */
- public void testSingleArgumentNamedProperty2() throws Exception {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- Method method = ClassTools.method(target, "propertyChangedSingleArgument2", new Class[] {Object.class});
- testModel.addPropertyChangeListener(TestModel.VALUE_PROPERTY, ReflectiveChangeListener.buildPropertyChangeListener(target, method));
- testModel.setValue(99);
- assertFalse(target.zeroArgumentFlag);
- assertTrue(target.singleArgumentFlag);
- }
-
- public void testListenerMismatch() {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- // build a PROPERTY change listener and hack it so we
- // can add it as a STATE change listener
- Object listener = ReflectiveChangeListener.buildPropertyChangeListener(target, "propertyChangedSingleArgument");
- testModel.addStateChangeListener((StateChangeListener) listener);
-
- boolean exCaught = false;
- try {
- testModel.setValue(99);
- fail("listener mismatch: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument1() {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- boolean exCaught = false;
- try {
- PropertyChangeListener listener = ReflectiveChangeListener.buildPropertyChangeListener(target, "stateChangedDoubleArgument");
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getCause().getClass() == NoSuchMethodException.class) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument2() throws Exception {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- Method method = ClassTools.method(target, "propertyChangedDoubleArgument", new Class[] {PropertyChangeEvent.class, Object.class});
- boolean exCaught = false;
- try {
- PropertyChangeListener listener = ReflectiveChangeListener.buildPropertyChangeListener(target, method);
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getMessage().equals(method.toString())) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
-
- private class TestModel extends AbstractModel {
- private int value = 0;
- public static final String VALUE_PROPERTY = "value";
- TestModel(int value) {
- super();
- this.value = value;
- }
- void setValue(int value) {
- int old = this.value;
- this.value = value;
- this.firePropertyChanged(VALUE_PROPERTY, old, value);
- if (old != value) {
- this.fireStateChanged();
- }
- }
- }
-
- private class Target {
- TestModel testModel;
- String propertyName;
- Object oldValue;
- Object newValue;
- boolean zeroArgumentFlag = false;
- boolean singleArgumentFlag = false;
- Target(TestModel testModel, String propertyName, int oldValue, int newValue) {
- super();
- this.testModel = testModel;
- this.propertyName = propertyName;
- this.oldValue = new Integer(oldValue);
- this.newValue = new Integer(newValue);
- }
- void propertyChangedZeroArgument() {
- this.zeroArgumentFlag = true;
- }
- void propertyChangedSingleArgument(PropertyChangeEvent e) {
- this.singleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.propertyName, e.getPropertyName());
- assertEquals(this.oldValue, e.getOldValue());
- assertEquals(this.newValue, e.getNewValue());
- }
- void propertyChangedSingleArgument2(Object o) {
- PropertyChangeEvent e = (PropertyChangeEvent) o;
- this.singleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.propertyName, e.getPropertyName());
- assertEquals(this.oldValue, e.getOldValue());
- assertEquals(this.newValue, e.getNewValue());
- }
- void propertyChangedDoubleArgument(PropertyChangeEvent e, Object o) {
- fail("bogus event: " + e);
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java
deleted file mode 100644
index 6230b1c644..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.listener;
-
-import java.lang.reflect.Method;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.ReflectiveChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-
-import junit.framework.TestCase;
-
-public class ReflectiveStateChangeListenerTests extends TestCase {
-
- public ReflectiveStateChangeListenerTests(String name) {
- super(name);
- }
-
- public void testZeroArgument() {
- TestModel testModel = new TestModel();
- Target target = new Target(testModel);
- testModel.addStateChangeListener(ReflectiveChangeListener.buildStateChangeListener(target, "stateChangedZeroArgument"));
- testModel.changeState();
- assertTrue(target.zeroArgumentFlag);
- assertFalse(target.singleArgumentFlag);
- }
-
- public void testSingleArgument() {
- TestModel testModel = new TestModel();
- Target target = new Target(testModel);
- testModel.addStateChangeListener(ReflectiveChangeListener.buildStateChangeListener(target, "stateChangedSingleArgument"));
- testModel.changeState();
- assertFalse(target.zeroArgumentFlag);
- assertTrue(target.singleArgumentFlag);
- }
-
- /**
- * test method that has more general method parameter type
- */
- public void testSingleArgument2() throws Exception {
- TestModel testModel = new TestModel();
- Target target = new Target(testModel);
- Method method = ClassTools.method(target, "stateChangedSingleArgument2", new Class[] {Object.class});
- testModel.addStateChangeListener(ReflectiveChangeListener.buildStateChangeListener(target, method));
- testModel.changeState();
- assertFalse(target.zeroArgumentFlag);
- assertTrue(target.singleArgumentFlag);
- }
-
- public void testListenerMismatch() {
- TestModel testModel = new TestModel();
- Target target = new Target(testModel);
- // build a STATE change listener and hack it so we
- // can add it as a PROPERTY change listener
- Object listener = ReflectiveChangeListener.buildStateChangeListener(target, "stateChangedSingleArgument");
- testModel.addPropertyChangeListener((PropertyChangeListener) listener);
-
- boolean exCaught = false;
- try {
- testModel.changeProperty();
- fail("listener mismatch: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument1() {
- TestModel testModel = new TestModel();
- Target target = new Target(testModel);
- boolean exCaught = false;
- try {
- StateChangeListener listener = ReflectiveChangeListener.buildStateChangeListener(target, "stateChangedDoubleArgument");
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getCause().getClass() == NoSuchMethodException.class) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument2() throws Exception {
- TestModel testModel = new TestModel();
- Target target = new Target(testModel);
- Method method = ClassTools.method(target, "stateChangedDoubleArgument", new Class[] {StateChangeEvent.class, Object.class});
- boolean exCaught = false;
- try {
- StateChangeListener listener = ReflectiveChangeListener.buildStateChangeListener(target, method);
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getMessage().equals(method.toString())) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
-
- private class TestModel extends AbstractModel {
- TestModel() {
- super();
- }
- void changeState() {
- this.fireStateChanged();
- }
- void changeProperty() {
- this.firePropertyChanged("value", 55, 42);
- }
- }
-
- private class Target {
- TestModel testModel;
- boolean zeroArgumentFlag = false;
- boolean singleArgumentFlag = false;
- Target(TestModel testModel) {
- super();
- this.testModel = testModel;
- }
- void stateChangedZeroArgument() {
- this.zeroArgumentFlag = true;
- }
- void stateChangedSingleArgument(StateChangeEvent e) {
- this.singleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- }
- void stateChangedSingleArgument2(Object e) {
- this.singleArgumentFlag = true;
- assertSame(this.testModel, ((StateChangeEvent) e).getSource());
- }
- void stateChangedDoubleArgument(StateChangeEvent e, Object o) {
- fail("bogus event: " + e);
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveTreeChangeListenerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveTreeChangeListenerTests.java
deleted file mode 100644
index b97c785ea8..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveTreeChangeListenerTests.java
+++ /dev/null
@@ -1,515 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.listener;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.listener.ReflectiveChangeListener;
-import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
-
-import junit.framework.TestCase;
-
-public class ReflectiveTreeChangeListenerTests extends TestCase {
-
- public ReflectiveTreeChangeListenerTests(String name) {
- super(name);
- }
-
- private TreeChangeListener buildZeroArgumentListener(Object target) {
- return ReflectiveChangeListener.buildTreeChangeListener(target, "nodeAddedZeroArgument", "nodeRemovedZeroArgument", "treeClearedZeroArgument", "treeChangedZeroArgument");
- }
-
- private TreeChangeListener buildSingleArgumentListener(Object target) {
- return ReflectiveChangeListener.buildTreeChangeListener(target, "nodeAddedSingleArgument", "nodeRemovedSingleArgument", "treeClearedSingleArgument", "treeChangedSingleArgument");
- }
-
- public void testNodeAddedZeroArgument() {
- TestModel testModel = new TestModel("root");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- testModel.addTreeChangeListener(this.buildZeroArgumentListener(target));
- testModel.addNode("root", "child");
- assertTrue(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testNodeAddedZeroArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildZeroArgumentListener(target));
- testModel.addNode("root", "child");
- assertTrue(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testNodeAddedSingleArgument() {
- TestModel testModel = new TestModel("root");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- testModel.addTreeChangeListener(this.buildSingleArgumentListener(target));
- testModel.addNode("root", "child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertTrue(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testNodeAddedSingleArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildSingleArgumentListener(target));
- testModel.addNode("root", "child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertTrue(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testNodeRemovedZeroArgument() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- testModel.addTreeChangeListener(this.buildZeroArgumentListener(target));
- testModel.removeNode("child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertTrue(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testNodeRemovedZeroArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildZeroArgumentListener(target));
- testModel.removeNode("child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertTrue(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testNodeRemovedSingleArgument() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- testModel.addTreeChangeListener(this.buildSingleArgumentListener(target));
- testModel.removeNode("child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertTrue(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testNodeRemovedSingleArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildSingleArgumentListener(target));
- testModel.removeNode("child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertTrue(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testTreeClearedZeroArgument() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- testModel.addNode("child", "grandchild");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[0]);
- testModel.addTreeChangeListener(this.buildZeroArgumentListener(target));
- testModel.clearTree();
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertTrue(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testTreeClearedZeroArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- testModel.addNode("child", "grandchild");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[0]);
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildZeroArgumentListener(target));
- testModel.clearTree();
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertTrue(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testTreeClearedSingleArgument() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- testModel.addNode("child", "grandchild");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[0]);
- testModel.addTreeChangeListener(this.buildSingleArgumentListener(target));
- testModel.clearTree();
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertTrue(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testTreeClearedSingleArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- testModel.addNode("child", "grandchild");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[0]);
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildSingleArgumentListener(target));
- testModel.clearTree();
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertTrue(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testTreeChangedZeroArgument() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "another child"});
- testModel.addTreeChangeListener(this.buildZeroArgumentListener(target));
- testModel.replaceNode("child", "another child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertTrue(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testTreeChangedZeroArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "another child"});
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildZeroArgumentListener(target));
- testModel.replaceNode("child", "another child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertTrue(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testTreeChangedSingleArgument() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "another child"});
- testModel.addTreeChangeListener(this.buildSingleArgumentListener(target));
- testModel.replaceNode("child", "another child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertTrue(target.treeChangedSingleArgumentFlag);
- }
-
- public void testTreeChangedSingleArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "another child"});
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildSingleArgumentListener(target));
- testModel.replaceNode("child", "another child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertTrue(target.treeChangedSingleArgumentFlag);
- }
-
- public void testBogusDoubleArgument1() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- boolean exCaught = false;
- try {
- TreeChangeListener listener = ReflectiveChangeListener.buildTreeChangeListener(target, "collectionChangedDoubleArgument");
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getCause().getClass() == NoSuchMethodException.class) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument2() throws Exception {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- Method method = ClassTools.method(target, "collectionChangedDoubleArgument", new Class[] {TreeChangeEvent.class, Object.class});
- boolean exCaught = false;
- try {
- TreeChangeListener listener = ReflectiveChangeListener.buildTreeChangeListener(target, method);
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getMessage().equals(method.toString())) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testListenerMismatch() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- // build a TREE change listener and hack it so we
- // can add it as a COLLECTION change listener
- Object listener = ReflectiveChangeListener.buildTreeChangeListener(target, "nodeAddedSingleArgument");
- testModel.addCollectionChangeListener((CollectionChangeListener) listener);
-
- boolean exCaught = false;
- try {
- testModel.changeCollection();
- fail("listener mismatch: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- private class TestModel extends AbstractModel {
- private final String root;
- private Map<String, Collection<String>> childrenLists = new HashMap<String, Collection<String>>();
- private Map<String, String> parents = new HashMap<String, String>();
- public static final String STRINGS_TREE = "strings";
- TestModel(String root) {
- super();
- if (root == null) {
- throw new NullPointerException();
- }
- this.root = root;
- this.childrenLists.put(root, new ArrayList<String>());
- this.parents.put(root, null);
- }
- String getRoot() {
- return this.root;
- }
- private String[] path(String node) {
- String temp = node;
- List<String> reversePath = new ArrayList<String>();
- do {
- reversePath.add(temp);
- temp = this.parents.get(temp);
- } while (temp != null);
- return CollectionTools.reverse(reversePath).toArray(new String[reversePath.size()]);
- }
- Iterator<String> strings() {
- return new CloneIterator<String>(this.childrenLists.keySet()) {
- @Override
- protected void remove(String s) {
- TestModel.this.removeNode(s);
- }
- };
- }
- void addNode(String parent, String child) {
- if ((parent == null) || (child == null)) {
- throw new NullPointerException();
- }
-
- Collection<String> children = this.childrenLists.get(parent);
- if (children == null) {
- throw new IllegalStateException("cannot add a child to a non-existent parent");
- }
-
- if (this.childrenLists.get(child) != null) {
- throw new IllegalStateException("cannot add a child that is already in the tree");
- }
-
- children.add(child);
- this.childrenLists.put(child, new ArrayList<String>());
- this.parents.put(child, parent);
- this.fireNodeAdded(STRINGS_TREE, this.path(child));
- }
- void removeNode(String node) {
- if (node == null) {
- throw new NullPointerException();
- }
-
- Collection<String> children = this.childrenLists.get(node);
- if (children == null) {
- throw new IllegalStateException("node is not in tree");
- }
- Object[] path = this.path(node);
- for (String s : children) {
- this.removeNode(s);
- }
- this.childrenLists.remove(node);
- this.parents.remove(node);
- this.fireNodeRemoved(STRINGS_TREE, path);
- }
- void replaceNode(String oldNode, String newNode) {
- if ((oldNode == null) || (newNode == null)) {
- throw new NullPointerException();
- }
-
- Collection<String> children = this.childrenLists.remove(oldNode);
- if (children == null) {
- throw new IllegalStateException("old node is not in tree");
- }
- this.childrenLists.put(newNode, children);
- for (String child : children) {
- this.parents.put(child, newNode);
- }
-
- String parent = this.parents.remove(oldNode);
- this.parents.put(newNode, parent);
-
- this.fireTreeChanged(STRINGS_TREE, this.path(newNode));
- }
- void clearTree() {
- this.childrenLists.clear();
- this.childrenLists.put(root, new ArrayList<String>());
- this.parents.clear();
- this.parents.put(root, null);
- this.fireTreeCleared(STRINGS_TREE);
- }
- void changeCollection() {
- this.fireCollectionChanged("bogus collection");
- }
- }
-
- private class Target {
- TestModel testModel;
- String treeName;
- String[] path;
- boolean nodeAddedZeroArgumentFlag = false;
- boolean nodeAddedSingleArgumentFlag = false;
- boolean nodeRemovedZeroArgumentFlag = false;
- boolean nodeRemovedSingleArgumentFlag = false;
- boolean treeClearedZeroArgumentFlag = false;
- boolean treeClearedSingleArgumentFlag = false;
- boolean treeChangedZeroArgumentFlag = false;
- boolean treeChangedSingleArgumentFlag = false;
- Target(TestModel testModel, String treeName, String[] path) {
- super();
- this.testModel = testModel;
- this.treeName = treeName;
- this.path = path;
- }
- void nodeAddedZeroArgument() {
- this.nodeAddedZeroArgumentFlag = true;
- }
- void nodeAddedSingleArgument(TreeChangeEvent e) {
- this.nodeAddedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.treeName, e.getTreeName());
- assertTrue(Arrays.equals(this.path, e.getPath()));
- }
- void nodeRemovedZeroArgument() {
- this.nodeRemovedZeroArgumentFlag = true;
- }
- void nodeRemovedSingleArgument(TreeChangeEvent e) {
- this.nodeRemovedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.treeName, e.getTreeName());
- assertTrue(Arrays.equals(this.path, e.getPath()));
- }
- void treeClearedZeroArgument() {
- this.treeClearedZeroArgumentFlag = true;
- }
- void treeClearedSingleArgument(TreeChangeEvent e) {
- this.treeClearedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.treeName, e.getTreeName());
- assertTrue(Arrays.equals(this.path, e.getPath()));
- }
- void treeChangedZeroArgument() {
- this.treeChangedZeroArgumentFlag = true;
- }
- void treeChangedSingleArgument(TreeChangeEvent e) {
- this.treeChangedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.treeName, e.getTreeName());
- assertTrue(Arrays.equals(this.path, e.getPath()));
- }
- void collectionChangedDoubleArgument(TreeChangeEvent e, Object o) {
- fail("bogus event: " + e);
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/BufferedWritablePropertyValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/BufferedWritablePropertyValueModelTests.java
deleted file mode 100644
index 43cf94fdac..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/BufferedWritablePropertyValueModelTests.java
+++ /dev/null
@@ -1,410 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.Date;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.BufferedWritablePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class BufferedWritablePropertyValueModelTests extends TestCase {
- private Employee employee;
- private WritablePropertyValueModel<Employee> employeeHolder;
- PropertyChangeEvent employeeEvent;
-
- private WritablePropertyValueModel<Integer> idAdapter;
- private WritablePropertyValueModel<String> nameAdapter;
- private WritablePropertyValueModel<Date> hireDateAdapter;
- PropertyChangeEvent adapterEvent;
-
- private BufferedWritablePropertyValueModel.Trigger trigger;
- private WritablePropertyValueModel<Integer> bufferedIDHolder;
- private WritablePropertyValueModel<String> bufferedNameHolder;
- private WritablePropertyValueModel<Date> bufferedHireDateHolder;
- PropertyChangeEvent bufferedEvent;
-
- public BufferedWritablePropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- this.employee = new Employee(17, "Freddy", new Date());
- this.employeeHolder = new SimplePropertyValueModel<Employee>(this.employee);
-
- this.trigger = new BufferedWritablePropertyValueModel.Trigger();
-
- this.idAdapter = this.buildIDAdapter(this.employeeHolder);
- this.bufferedIDHolder = new BufferedWritablePropertyValueModel<Integer>(this.idAdapter, this.trigger);
-
- this.nameAdapter = this.buildNameAdapter(this.employeeHolder);
- this.bufferedNameHolder = new BufferedWritablePropertyValueModel<String>(this.nameAdapter, this.trigger);
-
- this.hireDateAdapter = this.buildHireDateAdapter(this.employeeHolder);
- this.bufferedHireDateHolder = new BufferedWritablePropertyValueModel<Date>(this.hireDateAdapter, this.trigger);
- }
-
- private WritablePropertyValueModel<Integer> buildIDAdapter(PropertyValueModel<Employee> eHolder) {
- return new PropertyAspectAdapter<Employee, Integer>(eHolder, Employee.ID_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return new Integer(this.subject.getID());
- }
- @Override
- protected void setValue_(Integer value) {
- this.subject.setID(value.intValue());
- }
- };
- }
-
- private WritablePropertyValueModel<String> buildNameAdapter(PropertyValueModel<Employee> eHolder) {
- return new PropertyAspectAdapter<Employee, String>(eHolder, Employee.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getName();
- }
- @Override
- protected void setValue_(String value) {
- this.subject.setName(value);
- }
- };
- }
-
- private WritablePropertyValueModel<Date> buildHireDateAdapter(PropertyValueModel<Employee> eHolder) {
- return new PropertyAspectAdapter<Employee, Date>(eHolder, Employee.HIRE_DATE_PROPERTY) {
- @Override
- protected Date buildValue_() {
- return this.subject.getHireDate();
- }
- @Override
- protected void setValue_(Date value) {
- this.subject.setHireDate(value);
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedIDHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedHireDateHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- assertEquals(new Integer(17), this.idAdapter.getValue());
- assertEquals(new Integer(17), this.bufferedIDHolder.getValue());
-
- assertEquals("Freddy", this.employee.getName());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Freddy", this.bufferedNameHolder.getValue());
-
- Date temp = this.employee.getHireDate();
- assertEquals(temp, this.employee.getHireDate());
- assertEquals(temp, this.hireDateAdapter.getValue());
- assertEquals(temp, this.bufferedHireDateHolder.getValue());
-
- this.bufferedIDHolder.setValue(new Integer(323));
- assertEquals(17, this.employee.getID());
- assertEquals(new Integer(17), this.idAdapter.getValue());
- assertEquals(new Integer(323), this.bufferedIDHolder.getValue());
-
- this.bufferedNameHolder.setValue("Ripley");
- assertEquals("Freddy", this.employee.getName());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
-
- this.bufferedHireDateHolder.setValue(null);
- assertEquals(temp, this.employee.getHireDate());
- assertEquals(temp, this.hireDateAdapter.getValue());
- assertEquals(null, this.bufferedHireDateHolder.getValue());
- }
-
- public void testAccept() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedIDHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedHireDateHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- this.bufferedIDHolder.setValue(new Integer(323));
- assertEquals(17, this.employee.getID());
- assertEquals(new Integer(17), this.idAdapter.getValue());
- assertEquals(new Integer(323), this.bufferedIDHolder.getValue());
-
- this.bufferedNameHolder.setValue("Ripley");
- assertEquals("Freddy", this.employee.getName());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
-
- Date temp = this.employee.getHireDate();
- this.bufferedHireDateHolder.setValue(null);
- assertEquals(temp, this.employee.getHireDate());
- assertEquals(temp, this.hireDateAdapter.getValue());
- assertEquals(null, this.bufferedHireDateHolder.getValue());
-
- this.trigger.accept();
-
- assertEquals(323, this.employee.getID());
- assertEquals(new Integer(323), this.idAdapter.getValue());
- assertEquals(new Integer(323), this.bufferedIDHolder.getValue());
-
- assertEquals("Ripley", this.employee.getName());
- assertEquals("Ripley", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
-
- assertEquals(null, this.employee.getHireDate());
- assertEquals(null, this.hireDateAdapter.getValue());
- assertEquals(null, this.bufferedHireDateHolder.getValue());
- }
-
- public void testReset() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedIDHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedHireDateHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- this.bufferedIDHolder.setValue(new Integer(323));
- assertEquals(17, this.employee.getID());
- assertEquals(new Integer(17), this.idAdapter.getValue());
- assertEquals(new Integer(323), this.bufferedIDHolder.getValue());
-
- this.bufferedNameHolder.setValue("Ripley");
- assertEquals("Freddy", this.employee.getName());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
-
- Date temp = this.employee.getHireDate();
- this.bufferedHireDateHolder.setValue(null);
- assertEquals(temp, this.employee.getHireDate());
- assertEquals(temp, this.hireDateAdapter.getValue());
- assertEquals(null, this.bufferedHireDateHolder.getValue());
-
- this.trigger.reset();
-
- assertEquals(17, this.employee.getID());
- assertEquals(new Integer(17), this.idAdapter.getValue());
- assertEquals(new Integer(17), this.bufferedIDHolder.getValue());
-
- assertEquals("Freddy", this.employee.getName());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Freddy", this.bufferedNameHolder.getValue());
-
- assertEquals(temp, this.employee.getHireDate());
- assertEquals(temp, this.hireDateAdapter.getValue());
- assertEquals(temp, this.bufferedHireDateHolder.getValue());
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.bufferedIDHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.bufferedNameHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.bufferedHireDateHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- assertTrue(((AbstractModel) this.idAdapter).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.nameAdapter).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.hireDateAdapter).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- assertTrue(this.employee.hasNoPropertyChangeListeners(Employee.ID_PROPERTY));
- assertTrue(this.employee.hasNoPropertyChangeListeners(Employee.NAME_PROPERTY));
- assertTrue(this.employee.hasNoPropertyChangeListeners(Employee.HIRE_DATE_PROPERTY));
-
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedIDHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedHireDateHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- assertTrue(((AbstractModel) this.bufferedIDHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.bufferedNameHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.bufferedHireDateHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- assertTrue(((AbstractModel) this.idAdapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.nameAdapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.hireDateAdapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- assertTrue(this.employee.hasAnyPropertyChangeListeners(Employee.ID_PROPERTY));
- assertTrue(this.employee.hasAnyPropertyChangeListeners(Employee.NAME_PROPERTY));
- assertTrue(this.employee.hasAnyPropertyChangeListeners(Employee.HIRE_DATE_PROPERTY));
-
- this.bufferedIDHolder.removePropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedNameHolder.removePropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedHireDateHolder.removePropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- assertTrue(((AbstractModel) this.bufferedIDHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.bufferedNameHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.bufferedHireDateHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- assertTrue(((AbstractModel) this.idAdapter).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.nameAdapter).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.hireDateAdapter).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- assertTrue(this.employee.hasNoPropertyChangeListeners(Employee.ID_PROPERTY));
- assertTrue(this.employee.hasNoPropertyChangeListeners(Employee.NAME_PROPERTY));
- assertTrue(this.employee.hasNoPropertyChangeListeners(Employee.HIRE_DATE_PROPERTY));
- }
-
- public void testPropertyChange1() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- PropertyChangeListener adapterListener = this.buildAdapterListener();
- this.nameAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, adapterListener);
-
- PropertyChangeListener employeeListener = this.buildEmployeeListener();
- this.employee.addPropertyChangeListener(Employee.NAME_PROPERTY, employeeListener);
-
- this.verifyPropertyChanges();
- }
-
- public void testPropertyChange2() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedNameHolder.addPropertyChangeListener(bufferedListener);
-
- PropertyChangeListener adapterListener = this.buildAdapterListener();
- this.nameAdapter.addPropertyChangeListener(adapterListener);
-
- PropertyChangeListener employeeListener = this.buildEmployeeListener();
- this.employee.addPropertyChangeListener(employeeListener);
-
- this.verifyPropertyChanges();
- }
-
- private void verifyPropertyChanges() {
- this.bufferedEvent = null;
- this.adapterEvent = null;
- this.employeeEvent = null;
- this.bufferedNameHolder.setValue("Ripley");
- this.verifyEvent(this.bufferedEvent, this.bufferedNameHolder, PropertyValueModel.VALUE, "Freddy", "Ripley");
- assertNull(this.adapterEvent);
- assertNull(this.employeeEvent);
-
- this.bufferedEvent = null;
- this.adapterEvent = null;
- this.employeeEvent = null;
- this.bufferedNameHolder.setValue("Charlie");
- this.verifyEvent(this.bufferedEvent, this.bufferedNameHolder, PropertyValueModel.VALUE, "Ripley", "Charlie");
- assertNull(this.adapterEvent);
- assertNull(this.employeeEvent);
-
- this.bufferedEvent = null;
- this.adapterEvent = null;
- this.employeeEvent = null;
- this.trigger.accept();
- assertNull(this.bufferedEvent);
- this.verifyEvent(this.adapterEvent, this.nameAdapter, PropertyValueModel.VALUE, "Freddy", "Charlie");
- this.verifyEvent(this.employeeEvent, this.employee, Employee.NAME_PROPERTY, "Freddy", "Charlie");
-
- this.bufferedEvent = null;
- this.adapterEvent = null;
- this.employeeEvent = null;
- this.bufferedNameHolder.setValue("Jason");
- this.verifyEvent(this.bufferedEvent, this.bufferedNameHolder, PropertyValueModel.VALUE, "Charlie", "Jason");
- assertNull(this.adapterEvent);
- assertNull(this.employeeEvent);
-
- this.bufferedEvent = null;
- this.adapterEvent = null;
- this.employeeEvent = null;
- this.trigger.reset();
- this.verifyEvent(this.bufferedEvent, this.bufferedNameHolder, PropertyValueModel.VALUE, "Jason", "Charlie");
- assertNull(this.adapterEvent);
- assertNull(this.employeeEvent);
- }
-
- private PropertyChangeListener buildBufferedListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- BufferedWritablePropertyValueModelTests.this.bufferedEvent = e;
- }
- };
- }
-
- private PropertyChangeListener buildAdapterListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- BufferedWritablePropertyValueModelTests.this.adapterEvent = e;
- }
- };
- }
-
- private PropertyChangeListener buildEmployeeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- BufferedWritablePropertyValueModelTests.this.employeeEvent = e;
- }
- };
- }
-
- private void verifyEvent(PropertyChangeEvent event, Object source, String propertyName, Object oldValue, Object newValue) {
- assertEquals(source, event.getSource());
- assertEquals(propertyName, event.getPropertyName());
- assertEquals(oldValue, event.getOldValue());
- assertEquals(newValue, event.getNewValue());
- }
-
-
- // ********** inner class **********
-
- private class Employee extends AbstractModel {
- private int id;
- public static final String ID_PROPERTY = "id";
- private String name;
- public static final String NAME_PROPERTY = "name";
- private Date hireDate;
- public static final String HIRE_DATE_PROPERTY = "hireDate";
-
- Employee(int id, String name, Date hireDate) {
- super();
- this.id = id;
- this.name = name;
- this.hireDate = hireDate;
- }
- int getID() {
- return this.id;
- }
- void setID(int id) {
- int old = this.id;
- this.id = id;
- this.firePropertyChanged(ID_PROPERTY, old, id);
- }
- String getName() {
- return this.name;
- }
- void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
- Date getHireDate() {
- return this.hireDate;
- }
- void setHireDate(Date hireDate) {
- Object old = this.hireDate;
- this.hireDate = hireDate;
- this.firePropertyChanged(HIRE_DATE_PROPERTY, old, hireDate);
- }
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionAspectAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionAspectAdapterTests.java
deleted file mode 100644
index 430d71c603..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionAspectAdapterTests.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.CollectionAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class CollectionAspectAdapterTests extends TestCase {
- private TestSubject subject1;
- private WritablePropertyValueModel<TestSubject> subjectHolder1;
- private LocalCollectionAspectAdapter aa1;
- private CollectionChangeEvent event1;
- private CollectionChangeListener listener1;
- private String event1Type;
-
- private static final String ADD = "add";
- private static final String REMOVE = "remove";
- private static final String CHANGE = "change";
- private static final String CLEAR = "clear";
-
- private TestSubject subject2;
-
- public CollectionAspectAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.subject1 = new TestSubject();
- this.subject1.addNames(this.subject1Names());
- this.subject1.addDescriptions(this.subject1Descriptions());
- this.subjectHolder1 = new SimplePropertyValueModel<TestSubject>(this.subject1);
- this.aa1 = this.buildAspectAdapter(this.subjectHolder1);
- this.listener1 = this.buildValueChangeListener1();
- this.aa1.addCollectionChangeListener(CollectionValueModel.VALUES, this.listener1);
- this.event1 = null;
- this.event1Type = null;
-
- this.subject2 = new TestSubject();
- this.subject2.addNames(this.subject2Names());
- this.subject2.addDescriptions(this.subject2Descriptions());
- }
-
- private Collection<String> subject1Names() {
- Collection<String> result = new HashBag<String>();
- result.add("foo");
- result.add("bar");
- return result;
- }
-
- private Collection<String> subject1Descriptions() {
- Collection<String> result = new HashBag<String>();
- result.add("this.subject1 description1");
- result.add("this.subject1 description2");
- return result;
- }
-
- private Collection<String> subject2Names() {
- Collection<String> result = new HashBag<String>();
- result.add("baz");
- result.add("bam");
- return result;
- }
-
- private Collection<String> subject2Descriptions() {
- Collection<String> result = new HashBag<String>();
- result.add("this.subject2 description1");
- result.add("this.subject2 description2");
- return result;
- }
-
- private LocalCollectionAspectAdapter buildAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- return new LocalCollectionAspectAdapter(subjectHolder);
- }
-
- private CollectionChangeListener buildValueChangeListener1() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent e) {
- CollectionAspectAdapterTests.this.value1Changed(e, ADD);
- }
- public void itemsRemoved(CollectionChangeEvent e) {
- CollectionAspectAdapterTests.this.value1Changed(e, REMOVE);
- }
- public void collectionCleared(CollectionChangeEvent e) {
- CollectionAspectAdapterTests.this.value1Changed(e, CLEAR);
- }
- public void collectionChanged(CollectionChangeEvent e) {
- CollectionAspectAdapterTests.this.value1Changed(e, CHANGE);
- }
- };
- }
-
- void value1Changed(CollectionChangeEvent e, String eventType) {
- this.event1 = e;
- this.event1Type = eventType;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSubjectHolder() {
- assertEquals(this.subject1Names(), CollectionTools.bag(this.aa1.iterator()));
- assertNull(this.event1);
-
- this.subjectHolder1.setValue(this.subject2);
- assertNotNull(this.event1);
- assertEquals(this.event1Type, CHANGE);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertFalse(this.event1.items().hasNext());
- assertEquals(this.subject2Names(), CollectionTools.bag(this.aa1.iterator()));
-
- this.event1 = null;
- this.event1Type = null;
- this.subjectHolder1.setValue(null);
- assertNotNull(this.event1);
- assertEquals(this.event1Type, CHANGE);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertFalse(this.event1.items().hasNext());
- assertFalse((this.aa1.iterator()).hasNext());
-
- this.event1 = null;
- this.event1Type = null;
- this.subjectHolder1.setValue(this.subject1);
- assertNotNull(this.event1);
- assertEquals(this.event1Type, CHANGE);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertFalse(this.event1.items().hasNext());
- assertEquals(this.subject1Names(), CollectionTools.bag(this.aa1.iterator()));
- }
-
- public void testAdd() {
- assertEquals(this.subject1Names(), CollectionTools.bag(this.aa1.iterator()));
- assertNull(this.event1);
-
- this.subject1.addName("jam");
- assertNotNull(this.event1);
- assertEquals(this.event1Type, ADD);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertEquals("jam", this.event1.items().next());
- Collection<String> namesPlus = this.subject1Names();
- namesPlus.add("jam");
- assertEquals(namesPlus, CollectionTools.bag(this.aa1.iterator()));
-
- this.event1 = null;
- this.event1Type = null;
- this.aa1.addAll(Collections.singleton("jaz"));
- assertNotNull(this.event1);
- assertEquals(this.event1Type, ADD);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertEquals("jaz", this.event1.items().next());
- namesPlus.add("jaz");
- assertEquals(namesPlus, CollectionTools.bag(this.aa1.iterator()));
- }
-
- public void testRemove() {
- assertEquals(this.subject1Names(), CollectionTools.bag(this.aa1.iterator()));
- assertNull(this.event1);
-
- this.subject1.removeName("foo");
- assertNotNull(this.event1);
- assertEquals(this.event1Type, REMOVE);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertEquals("foo", this.event1.items().next());
- Collection<String> namesMinus = this.subject1Names();
- namesMinus.remove("foo");
- assertEquals(namesMinus, CollectionTools.bag(this.aa1.iterator()));
-
- this.event1 = null;
- this.event1Type = null;
- this.aa1.removeAll(Collections.singleton("bar"));
- assertNotNull(this.event1);
- assertEquals(this.event1Type, REMOVE);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertEquals("bar", this.event1.items().next());
- namesMinus.remove("bar");
- assertEquals(namesMinus, CollectionTools.bag(this.aa1.iterator()));
- }
-
- public void testCollectionChange() {
- assertEquals(this.subject1Names(), CollectionTools.bag(this.aa1.iterator()));
- assertNull(this.event1);
-
- this.subject1.addTwoNames("jam", "jaz");
- assertNotNull(this.event1);
- assertEquals(this.event1Type, CHANGE);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertFalse(this.event1.items().hasNext());
- Collection<String> namesPlus2 = this.subject1Names();
- namesPlus2.add("jam");
- namesPlus2.add("jaz");
- assertEquals(namesPlus2, CollectionTools.bag(this.aa1.iterator()));
- }
-
- public void testIterator() {
- assertEquals(this.subject1Names(), CollectionTools.bag(this.subject1.names()));
- assertEquals(this.subject1Names(), CollectionTools.bag(this.aa1.iterator()));
- }
-
- public void testSize() {
- assertEquals(this.subject1Names().size(), CollectionTools.size(this.subject1.names()));
- assertEquals(this.subject1Names().size(), CollectionTools.size(this.aa1.iterator()));
- }
-
- public void testHasListeners() {
- assertTrue(this.aa1.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertTrue(this.subject1.hasAnyCollectionChangeListeners(TestSubject.NAMES_COLLECTION));
- this.aa1.removeCollectionChangeListener(CollectionValueModel.VALUES, this.listener1);
- assertFalse(this.subject1.hasAnyCollectionChangeListeners(TestSubject.NAMES_COLLECTION));
- assertFalse(this.aa1.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- CollectionChangeListener listener2 = this.buildValueChangeListener1();
- this.aa1.addCollectionChangeListener(listener2);
- assertTrue(this.aa1.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertTrue(this.subject1.hasAnyCollectionChangeListeners(TestSubject.NAMES_COLLECTION));
- this.aa1.removeCollectionChangeListener(listener2);
- assertFalse(this.subject1.hasAnyCollectionChangeListeners(TestSubject.NAMES_COLLECTION));
- assertFalse(this.aa1.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
-
- // ********** inner class **********
-
- private class TestSubject extends AbstractModel {
- private Collection<String> names;
- public static final String NAMES_COLLECTION = "names";
- private Collection<String> descriptions;
- public static final String DESCRIPTIONS_COLLECTION = "descriptions";
-
- public TestSubject() {
- this.names = new HashBag<String>();
- this.descriptions = new HashBag<String>();
- }
- public Iterator<String> names() {
- return new ReadOnlyIterator<String>(this.names);
- }
- public void addName(String name) {
- if (this.names.add(name)) {
- this.fireItemAdded(NAMES_COLLECTION, name);
- }
- }
- public void addNames(Iterator<String> newNames) {
- while (newNames.hasNext()) {
- this.addName(newNames.next());
- }
- }
- public void addNames(Collection<String> newNames) {
- this.addNames(newNames.iterator());
- }
- public void addTwoNames(String name1, String name2) {
- if (this.names.add(name1) | this.names.add(name2)) {
- this.fireCollectionChanged(NAMES_COLLECTION);
- }
- }
- public void removeName(String name) {
- if (this.names.remove(name)) {
- this.fireItemRemoved(NAMES_COLLECTION, name);
- }
- }
- public Iterator<String> descriptions() {
- return new ReadOnlyIterator<String>(this.descriptions);
- }
- public void addDescription(String description) {
- if (this.descriptions.add(description)) {
- this.fireItemAdded(DESCRIPTIONS_COLLECTION, description);
- }
- }
- public void addDescriptions(Iterator<String> newDescriptions) {
- while (newDescriptions.hasNext()) {
- this.addDescription(newDescriptions.next());
- }
- }
- public void addDescriptions(Collection<String> newDescriptions) {
- this.addDescriptions(newDescriptions.iterator());
- }
- public void removeDescription(String description) {
- if (this.descriptions.remove(description)) {
- this.fireItemRemoved(DESCRIPTIONS_COLLECTION, description);
- }
- }
- }
-
- // this is not a typical aspect adapter - the value is determined by the aspect name
- private class LocalCollectionAspectAdapter extends CollectionAspectAdapter<TestSubject, String> {
-
- LocalCollectionAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- super(subjectHolder, TestSubject.NAMES_COLLECTION);
- }
-
- @Override
- protected Iterator<String> iterator_() {
- if (this.collectionNames[0] == TestSubject.NAMES_COLLECTION) {
- return this.subject.names();
- }
- if (this.collectionNames[0] == TestSubject.DESCRIPTIONS_COLLECTION) {
- return this.subject.descriptions();
- }
- throw new IllegalStateException("invalid aspect name: " + this.collectionNames[0]);
- }
-
- public void add(String item) {
- if (this.collectionNames[0] == TestSubject.NAMES_COLLECTION) {
- this.subject.addName(item);
- } else if (this.collectionNames[0] == TestSubject.DESCRIPTIONS_COLLECTION) {
- this.subject.addDescription(item);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.collectionNames[0]);
- }
- }
-
- public void addAll(Collection<String> items) {
- for (Iterator<String> stream = items.iterator(); stream.hasNext(); ) {
- this.add(stream.next());
- }
- }
-
- public void remove(Object item) {
- if (this.collectionNames[0] == TestSubject.NAMES_COLLECTION) {
- this.subject.removeName((String) item);
- } else if (this.collectionNames[0] == TestSubject.DESCRIPTIONS_COLLECTION) {
- this.subject.removeDescription((String) item);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.collectionNames[0]);
- }
- }
-
- public void removeAll(Collection<String> items) {
- for (Iterator<String> stream = items.iterator(); stream.hasNext(); ) {
- this.remove(stream.next());
- }
- }
-
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java
deleted file mode 100644
index a4c4e23918..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.Collection;
-import java.util.List;
-
-import javax.swing.JList;
-
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.CollectionListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class CollectionListValueModelAdapterTests extends TestCase {
- private ListValueModel<String> adapter;
- private SimpleCollectionValueModel<String> wrappedCollectionHolder;
- private Collection<String> wrappedCollection;
-
- public CollectionListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.wrappedCollection = new HashBag<String>();
- this.wrappedCollectionHolder = new SimpleCollectionValueModel<String>(this.wrappedCollection);
- this.adapter = new CollectionListValueModelAdapter<String>(this.wrappedCollectionHolder);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListChangeEvent e) {/* OK */}
- });
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- Collection<String> adapterCollection = this.adapterCollection();
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection, adapterCollection);
- }
-
- private Collection<String> adapterCollection() {
- return CollectionTools.collection(this.adapter.iterator());
- }
-
- public void testStaleValue() {
- ListChangeListener listener = new TestListChangeListener() {
- @Override
- public void itemsAdded(ListChangeEvent e) {/* OK */}
- };
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- Collection<String> adapterCollection = this.adapterCollection();
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection, adapterCollection);
-
- this.adapter.removeListChangeListener(ListValueModel.LIST_VALUES, listener);
- adapterCollection = this.adapterCollection();
- assertEquals(0, adapterCollection.size());
- assertEquals(new HashBag<String>(), adapterCollection);
-
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- adapterCollection = this.adapterCollection();
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection, adapterCollection);
- }
-
- public void testAdd() {
- List<String> synchList = new CoordinatedList<String>(this.adapter);
- Bag<String> synchCollection = new CoordinatedBag<String>(this.wrappedCollectionHolder);
- this.wrappedCollectionHolder.add("foo");
- assertTrue(this.wrappedCollection.contains("foo"));
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- assertEquals(6, this.wrappedCollection.size());
-
- Collection<String> adapterCollection = this.adapterCollection();
- assertEquals(this.wrappedCollection, adapterCollection);
- assertEquals(this.wrappedCollection, CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection, synchCollection);
- }
-
- public void testRemove() {
- List<String> synchList = new CoordinatedList<String>(this.adapter);
- Bag<String> synchCollection = new CoordinatedBag<String>(this.wrappedCollectionHolder);
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- assertTrue(this.wrappedCollection.contains("jaz"));
- this.wrappedCollectionHolder.remove("jaz");
- assertFalse(this.wrappedCollection.contains("jaz"));
- this.wrappedCollectionHolder.remove("foo");
- assertFalse(this.wrappedCollection.contains("foo"));
- assertEquals(4, this.wrappedCollection.size());
-
- Collection<String> adapterCollection = this.adapterCollection();
- assertEquals(this.wrappedCollection, adapterCollection);
- assertEquals(this.wrappedCollection, CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection, synchCollection);
- }
-
- public void testListSynch() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListChangeEvent e) {/* OK */}
- @Override
- public void itemsRemoved(ListChangeEvent e) {/* OK */}
- });
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- this.wrappedCollectionHolder.remove("jaz");
- assertFalse(this.wrappedCollection.contains("jaz"));
- this.wrappedCollectionHolder.remove("foo");
- assertFalse(this.wrappedCollection.contains("foo"));
- assertEquals(4, this.wrappedCollection.size());
-
- Collection<String> adapterCollection = this.adapterCollection();
- assertEquals(this.wrappedCollection, adapterCollection);
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- CoordinatedList<String> synchList = new CoordinatedList<String>(this.adapter);
- assertTrue(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.addListChangeListener(synchList);
- assertTrue(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.removeListChangeListener(synchList);
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- public void testCollectionChangedToEmpty() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListChangeEvent e) {/* OK */}
- @Override
- public void itemsRemoved(ListChangeEvent e) {/* OK */}
- });
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- JList jList = new JList(new ListModelAdapter(this.adapter));
- this.wrappedCollectionHolder.setCollection(new HashBag<String>());
- assertEquals(0, jList.getModel().getSize());
- }
-
- public void testCollectionChangedFromEmpty() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListChangeEvent e) {/* OK */}
- @Override
- public void itemsRemoved(ListChangeEvent e) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- HashBag<String> bag = new HashBag<String>();
- bag.add("foo");
- bag.add("bar");
- this.wrappedCollectionHolder.setCollection(bag);
- assertEquals(2, jList.getModel().getSize());
- }
-
- public void testCollectionChangedFromEmptyToEmpty() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListChangeEvent e) {/* OK */}
- @Override
- public void itemsRemoved(ListChangeEvent e) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- HashBag<String> bag = new HashBag<String>();
- this.wrappedCollectionHolder.setCollection(bag);
- assertEquals(0, jList.getModel().getSize());
- }
-
-
- class TestListChangeListener implements ListChangeListener {
- public void itemsAdded(ListChangeEvent e) {
- fail("unexpected event");
- }
- public void itemsRemoved(ListChangeEvent e) {
- fail("unexpected event");
- }
- public void itemsReplaced(ListChangeEvent e) {
- fail("unexpected event");
- }
- public void itemsMoved(ListChangeEvent e) {
- fail("unexpected event");
- }
- public void listCleared(ListChangeEvent e) {
- fail("unexpected event");
- }
- public void listChanged(ListChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java
deleted file mode 100644
index 80f4626dec..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.CollectionPropertyValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class CollectionPropertyValueModelAdapterTests extends TestCase {
- private WritablePropertyValueModel<Boolean> adapter;
- private SimpleCollectionValueModel<String> wrappedCollectionHolder;
- PropertyChangeEvent event;
-
- public CollectionPropertyValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.wrappedCollectionHolder = new SimpleCollectionValueModel<String>();
- this.adapter = new LocalAdapter(this.wrappedCollectionHolder, "666");
- this.event = null;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- private boolean booleanValue() {
- return this.adapter.getValue().booleanValue();
- }
-
- private Collection<String> wrappedCollection() {
- return CollectionTools.collection(this.wrappedCollectionHolder.iterator());
- }
-
- public void testValue() {
- this.adapter.addPropertyChangeListener(PropertyValueModel.VALUE, new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {/* OK */}
- });
- assertFalse(this.booleanValue());
- assertFalse(this.wrappedCollection().contains("666"));
-
- this.wrappedCollectionHolder.add("111");
- assertFalse(this.booleanValue());
-
- this.wrappedCollectionHolder.add("222");
- assertFalse(this.booleanValue());
-
- this.wrappedCollectionHolder.add("666");
- assertTrue(this.booleanValue());
- assertTrue(this.wrappedCollection().contains("666"));
-
- this.wrappedCollectionHolder.remove("666");
- assertFalse(this.booleanValue());
- assertFalse(this.wrappedCollection().contains("666"));
-
- this.wrappedCollectionHolder.add("666");
- assertTrue(this.booleanValue());
- assertTrue(this.wrappedCollection().contains("666"));
-
- this.wrappedCollectionHolder.clear();
- assertFalse(this.booleanValue());
- assertFalse(this.wrappedCollection().contains("666"));
- }
-
- public void testSetValue() {
- this.adapter.addPropertyChangeListener(PropertyValueModel.VALUE, new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {/* OK */}
- });
- assertFalse(this.booleanValue());
- assertFalse(this.wrappedCollection().contains("666"));
-
- this.adapter.setValue(Boolean.TRUE);
- assertTrue(this.booleanValue());
- assertTrue(this.wrappedCollection().contains("666"));
-
- this.adapter.setValue(Boolean.FALSE);
- assertFalse(this.booleanValue());
- assertFalse(this.wrappedCollection().contains("666"));
- }
-
- public void testEventFiring() {
- this.adapter.addPropertyChangeListener(PropertyValueModel.VALUE, new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CollectionPropertyValueModelAdapterTests.this.event = e;
- }
- });
- assertNull(this.event);
-
- this.wrappedCollectionHolder.add("111");
- assertNull(this.event);
-
- this.wrappedCollectionHolder.add("222");
- assertNull(this.event);
-
- this.wrappedCollectionHolder.add("666");
- this.verifyEvent(false, true);
-
- this.wrappedCollectionHolder.remove("666");
- this.verifyEvent(true, false);
-
- this.wrappedCollectionHolder.add("666");
- this.verifyEvent(false, true);
-
- this.wrappedCollectionHolder.clear();
- this.verifyEvent(true, false);
- }
-
- private void verifyEvent(boolean oldValue, boolean newValue) {
- assertEquals(this.adapter, this.event.getSource());
- assertEquals(Boolean.valueOf(oldValue), this.event.getOldValue());
- assertEquals(Boolean.valueOf(newValue), this.event.getNewValue());
- this.event = null;
- }
-
- public void testStaleValue() {
- PropertyChangeListener listener = new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {/* OK */}
- };
- this.adapter.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- this.wrappedCollectionHolder.add("666");
- assertTrue(this.booleanValue());
- assertTrue(this.wrappedCollection().contains("666"));
-
- this.adapter.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertFalse(this.booleanValue());
- assertTrue(this.wrappedCollection().contains("666"));
-
- this.adapter.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(this.booleanValue());
- assertTrue(this.wrappedCollection().contains("666"));
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.adapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(((AbstractModel) this.wrappedCollectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- PropertyChangeListener listener = new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {/* OK */}
- };
- this.adapter.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.adapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.wrappedCollectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- this.adapter.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertFalse(((AbstractModel) this.adapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(((AbstractModel) this.wrappedCollectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- this.adapter.addPropertyChangeListener(listener);
- assertTrue(((AbstractModel) this.adapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.wrappedCollectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- this.adapter.removePropertyChangeListener(listener);
- assertFalse(((AbstractModel) this.adapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(((AbstractModel) this.wrappedCollectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
-
- // ********** member class **********
-
- /**
- * the value is true if the wrapped collection contains the specified item,
- * otherwise the value is false
- */
- private static class LocalAdapter
- extends CollectionPropertyValueModelAdapter<Boolean>
- implements WritablePropertyValueModel<Boolean>
- {
- private String item;
-
- LocalAdapter(CollectionValueModel<String> collectionHolder, String item) {
- super(collectionHolder);
- this.item = item;
- }
-
- // ********** CollectionPropertyValueModelAdapter implementation **********
- /**
- * always return a Boolean
- */
- @Override
- public Boolean getValue() {
- Boolean result = super.getValue();
- return (result == null) ? Boolean.FALSE : result;
- }
- @SuppressWarnings("unchecked")
- public void setValue(Boolean value) {
- if (this.booleanValue()) {
- if ( ! this.booleanValueOf(value)) {
- // the value is changing from true to false
- ((SimpleCollectionValueModel<String>) this.collectionHolder).remove(this.item);
- }
- } else {
- if (this.booleanValueOf(value)) {
- // the value is changing from false to true
- ((SimpleCollectionValueModel<String>) this.collectionHolder).add(this.item);
- }
- }
- }
- @Override
- protected Boolean buildValue() {
- return Boolean.valueOf(CollectionTools.contains(this.collectionHolder.iterator(), this.item));
- }
-
- // ********** internal methods **********
- private boolean booleanValue() {
- return this.booleanValueOf(this.value);
- }
- private boolean booleanValueOf(Object b) {
- return (b == null) ? false : ((Boolean) b).booleanValue();
- }
-
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java
deleted file mode 100644
index 90f4b6ff0b..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java
+++ /dev/null
@@ -1,416 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.Transformer;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.CollectionAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.CompositeCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class CompositeCollectionValueModelTests extends TestCase {
- private Neighborhood neighborhood;
- private WritablePropertyValueModel<Neighborhood> neighborhoodHolder;
-
- public CompositeCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.neighborhood = new Neighborhood("Hanna-Barbera");
- this.neighborhoodHolder = new SimplePropertyValueModel<Neighborhood>(this.neighborhood);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSynch1() {
- this.verifySynch(this.buildAllMembersComposite(this.neighborhoodHolder));
- }
-
- public void testSynch2() {
- this.verifySynch(this.buildAllMembersComposite2(this.neighborhoodHolder));
- }
-
- private void verifySynch(CollectionValueModel<Member> compositeCVM) {
- assertEquals(0, CollectionTools.size(compositeCVM.iterator()));
- Bag<Family> familiesSynch = new CoordinatedBag<Family>(this.buildFamiliesAspectAdapter(this.neighborhoodHolder));
- Bag<Member> membersSynch = new CoordinatedBag<Member>(compositeCVM);
- this.populateNeighborhood(this.neighborhood);
-
- Family jetsons = this.neighborhood.familyNamed("Jetson");
-
- assertEquals(3, familiesSynch.size());
- assertEquals(12, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(12, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- jetsons.removeMember(jetsons.memberNamed("Astro"));
- assertEquals(3, familiesSynch.size());
- assertEquals(11, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(11, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- jetsons.removeMember(jetsons.memberNamed("Judy"));
- assertEquals(3, familiesSynch.size());
- assertEquals(10, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(10, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- jetsons.addMember("Fido");
- assertEquals(3, familiesSynch.size());
- assertEquals(11, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(11, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- this.neighborhood.removeFamily(jetsons);
- assertEquals(2, familiesSynch.size());
- assertEquals(7, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(7, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- Family bears = this.neighborhood.addFamily("Bear");
- bears.addMember("Yogi");
- assertEquals(3, familiesSynch.size());
- assertEquals(8, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(8, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- bears.addMember("Boo-Boo");
- assertEquals(3, familiesSynch.size());
- assertEquals(9, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(9, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- Neighborhood n2 = new Neighborhood("Hanna-Barbera 2");
- this.neighborhoodHolder.setValue(n2);
- this.populateNeighborhood(n2);
- assertEquals(3, familiesSynch.size());
- assertEquals(12, CollectionTools.size(n2.allMembers()));
- assertEquals(12, membersSynch.size());
- assertEquals(CollectionTools.bag(n2.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
- }
-
- public void testNoTransformer() {
- SimpleCollectionValueModel<String> subCVM1 = new SimpleCollectionValueModel<String>();
- SimpleCollectionValueModel<String> subCVM2 = new SimpleCollectionValueModel<String>();
- Collection<CollectionValueModel<String>> collection = new ArrayList<CollectionValueModel<String>>();
- collection.add(subCVM1);
- collection.add(subCVM2);
- Bag<String> synchBag = new CoordinatedBag<String>(new CompositeCollectionValueModel<CollectionValueModel<String>, String>(collection));
-
- assertEquals(0, synchBag.size());
-
- subCVM1.add("foo");
- subCVM1.add("bar");
- subCVM1.add("baz");
- assertEquals(3, synchBag.size());
- assertTrue(synchBag.contains("foo"));
-
- subCVM2.add("joo");
- subCVM2.add("jar");
- subCVM2.add("jaz");
- assertEquals(6, synchBag.size());
- assertTrue(synchBag.contains("foo"));
- assertTrue(synchBag.contains("jaz"));
-
- subCVM1.remove("baz");
- assertEquals(5, synchBag.size());
- assertFalse(synchBag.contains("baz"));
- }
-
- public void testDuplicateItem() {
- Bag<Member> synchBag = new CoordinatedBag<Member>(this.buildAllMembersComposite(this.neighborhoodHolder));
- this.populateNeighborhood(this.neighborhood);
- boolean exCaught = false;
- try {
- this.neighborhood.addFamily(this.neighborhood.familyNamed("Jetson"));
- } catch (IllegalStateException ex) {
- if (ex.getMessage().indexOf("duplicate component") != -1) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- assertEquals(12, synchBag.size());
- }
-
- public void testHasListeners() {
- CompositeCollectionValueModel<Family, Member> compositeCVM = this.buildAllMembersComposite(this.neighborhoodHolder);
- CoordinatedBag<Member> synchBag = new CoordinatedBag<Member>(compositeCVM);
- this.populateNeighborhood(this.neighborhood);
- Family jetsons = this.neighborhood.familyNamed("Jetson");
-
- assertTrue(compositeCVM.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertTrue(jetsons.hasAnyCollectionChangeListeners(Family.MEMBERS_COLLECTION));
-
- compositeCVM.removeCollectionChangeListener(CollectionValueModel.VALUES, synchBag);
- assertFalse(compositeCVM.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertFalse(jetsons.hasAnyCollectionChangeListeners(Family.MEMBERS_COLLECTION));
-
- compositeCVM.addCollectionChangeListener(CollectionValueModel.VALUES, synchBag);
- assertTrue(compositeCVM.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertTrue(jetsons.hasAnyCollectionChangeListeners(Family.MEMBERS_COLLECTION));
- }
-
- private void populateNeighborhood(Neighborhood n) {
- Family family1 = n.addFamily("Flintstone");
- family1.addMember("Fred");
- family1.addMember("Wilma");
- family1.addMember("Pebbles");
- family1.addMember("Dino");
- Family family2 = n.addFamily("Rubble");
- family2.addMember("Barney");
- family2.addMember("Betty");
- family2.addMember("Bamm-Bamm");
- Family family3 = n.addFamily("Jetson");
- family3.addMember("George");
- family3.addMember("Jane");
- family3.addMember("Judy");
- family3.addMember("Elroy");
- family3.addMember("Astro");
- }
-
- private CollectionValueModel<Family> buildFamiliesAspectAdapter(PropertyValueModel<Neighborhood> communeHolder) {
- return new CollectionAspectAdapter<Neighborhood, Family>(communeHolder, Neighborhood.FAMILIES_COLLECTION) {
- @Override
- protected Iterator<Family> iterator_() {
- return this.subject.families();
- }
- };
- }
-
- CollectionValueModel<Member> buildMembersAdapter(Family family) {
- return new CollectionAspectAdapter<Family, Member>(Family.MEMBERS_COLLECTION, family) {
- @Override
- protected Iterator<Member> iterator_() {
- return this.subject.members();
- }
- };
- }
-
- private CompositeCollectionValueModel<Family, Member> buildAllMembersComposite(PropertyValueModel<Neighborhood> communeHolder) {
- // override #transform(Object)
- return new CompositeCollectionValueModel<Family, Member>(this.buildFamiliesAspectAdapter(communeHolder)) {
- @Override
- protected CollectionValueModel<Member> transform(Family family) {
- return CompositeCollectionValueModelTests.this.buildMembersAdapter(family);
- }
- };
- }
-
- private CollectionValueModel<Member> buildAllMembersComposite2(PropertyValueModel<Neighborhood> communeHolder) {
- // build a custom Transformer
- return new CompositeCollectionValueModel<Family, Member>(this.buildFamiliesAspectAdapter(communeHolder), this.buildTransformer());
- }
-
- private Transformer<Family, CollectionValueModel<Member>> buildTransformer() {
- return new Transformer<Family, CollectionValueModel<Member>>() {
- public CollectionValueModel<Member> transform(Family family) {
- return CompositeCollectionValueModelTests.this.buildMembersAdapter(family);
- }
- @Override
- public String toString() {
- return "Local Transformer";
- }
- };
- }
-
-
-// ********** inner classes **********
-
- /**
- * inner class
- */
- private class Neighborhood extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
- private Collection<Family> families = new ArrayList<Family>();
- public static final String FAMILIES_COLLECTION = "families";
-
- public Neighborhood(String name) {
- super();
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- public Iterator<Family> families() {
- return this.families.iterator();
- }
-
- public Family addFamily(String familyName) {
- return this.addFamily(new Family(familyName));
- }
-
- // backdoor to allow duplicates
- public Family addFamily(Family family) {
- this.addItemToCollection(family, this.families, FAMILIES_COLLECTION);
- return family;
- }
-
- public void removeFamily(Family family) {
- this.removeItemFromCollection(family, this.families, FAMILIES_COLLECTION);
- }
-
- public Family familyNamed(String familyName) {
- for (Family family : this.families) {
- if (family.getName().equals(familyName)) {
- return family;
- }
- }
- throw new IllegalArgumentException(familyName);
- }
-
- public Iterator<Member> allMembers() {
- return new CompositeIterator<Member>(this.membersIterators());
- }
-
- private Iterator<Iterator<Member>> membersIterators() {
- return new TransformationIterator<Family, Iterator<Member>>(this.families()) {
- @Override
- protected Iterator<Member> transform(Family family) {
- return family.members();
- }
- };
- }
-
- public Member memberNamed(String familyName, String memberName) {
- return this.familyNamed(familyName).memberNamed(memberName);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
- }
-
-
- /**
- * inner class
- */
- private class Family extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
- private Collection<Member> members = new ArrayList<Member>();
- public static final String MEMBERS_COLLECTION = "members";
-
- public Family(String name) {
- super();
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- public Iterator<Member> members() {
- return this.members.iterator();
- }
-
- public Member addMember(String memberName) {
- Member member = new Member(memberName);
- this.addItemToCollection(member, this.members, MEMBERS_COLLECTION);
- return member;
- }
-
- public void removeMember(Member member) {
- this.removeItemFromCollection(member, this.members, MEMBERS_COLLECTION);
- }
-
- public Member memberNamed(String memberName) {
- for (Member member : this.members) {
- if (member.getName().equals(memberName)) {
- return member;
- }
- }
- throw new IllegalArgumentException(memberName);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
- }
-
-
- /**
- * inner class
- */
- private class Member extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- public Member(String name) {
- super();
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeListValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeListValueModelTests.java
deleted file mode 100644
index 5ff07daaf0..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeListValueModelTests.java
+++ /dev/null
@@ -1,849 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class CompositeListValueModelTests extends TestCase {
- private SimpleListValueModel<String> lvm0;
- private SimpleListValueModel<String> lvm1;
- private SimpleListValueModel<String> lvm2;
- private SimpleListValueModel<String> lvm3;
- private SimpleListValueModel<SimpleListValueModel<String>> uberLVM;
- private CompositeListValueModel<SimpleListValueModel<String>, String> compositeLVM;
-
- public CompositeListValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- this.lvm0 = new SimpleListValueModel<String>();
- this.lvm0.add("aaa");
- this.lvm0.add("bbb");
- this.lvm0.add("ccc");
-
- this.lvm1 = new SimpleListValueModel<String>();
- this.lvm1.add("ddd");
- this.lvm1.add("eee");
-
- this.lvm2 = new SimpleListValueModel<String>();
- this.lvm2.add("fff");
-
- this.lvm3 = new SimpleListValueModel<String>();
- this.lvm3.add("ggg");
- this.lvm3.add("hhh");
- this.lvm3.add("iii");
- this.lvm3.add("jjj");
- this.lvm3.add("kkk");
-
- this.uberLVM = new SimpleListValueModel<SimpleListValueModel<String>>();
- this.uberLVM.add(this.lvm0);
- this.uberLVM.add(this.lvm1);
- this.uberLVM.add(this.lvm2);
- this.uberLVM.add(this.lvm3);
-
- this.compositeLVM = new CompositeListValueModel<SimpleListValueModel<String>, String>((ListValueModel<SimpleListValueModel<String>>) this.uberLVM);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGetInt() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
- assertEquals("aaa", this.compositeLVM.get(0));
- assertEquals("aaa", coordList.get(0));
- assertEquals("bbb", this.compositeLVM.get(1));
- assertEquals("bbb", coordList.get(1));
- assertEquals("ccc", this.compositeLVM.get(2));
- assertEquals("ccc", coordList.get(2));
-
- assertEquals("ddd", this.compositeLVM.get(3));
- assertEquals("ddd", coordList.get(3));
- assertEquals("eee", this.compositeLVM.get(4));
- assertEquals("eee", coordList.get(4));
-
- assertEquals("fff", this.compositeLVM.get(5));
- assertEquals("fff", coordList.get(5));
-
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testIterator() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
- assertEquals("aaa", this.compositeLVM.iterator().next());
- assertEquals("aaa", coordList.iterator().next());
- Iterator<String> stream1 = coordList.iterator();
- for (Iterator<String> stream2 = this.compositeLVM.iterator(); stream2.hasNext(); ) {
- assertEquals(stream1.next(), stream2.next());
- }
- assertFalse(stream1.hasNext());
- }
-
- public void testSize() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
- assertEquals(11, this.compositeLVM.size());
- assertEquals(11, coordList.size());
- }
-
- public void testToArray() {
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- }
-
- public void testHasListeners() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- assertTrue(this.compositeLVM.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.lvm0.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.compositeLVM.removeListChangeListener(ListValueModel.LIST_VALUES, coordList);
- assertFalse(this.compositeLVM.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.lvm0.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, coordList);
- assertTrue(this.compositeLVM.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.lvm0.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- public void testAddSource_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- SimpleListValueModel<String> lvm = new SimpleListValueModel<String>();
- lvm.add("xxx");
- lvm.add("yyy");
- lvm.add("zzz");
- this.uberLVM.add(0, lvm);
-
- Object[] expected = new Object[] { "xxx", "yyy", "zzz", "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(9));
- assertEquals("ggg", coordList.get(9));
- }
-
- public void testAddSource_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- SimpleListValueModel<String> lvm = new SimpleListValueModel<String>();
- lvm.add("xxx");
- lvm.add("yyy");
- lvm.add("zzz");
- this.uberLVM.add(2, lvm);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "xxx", "yyy", "zzz", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(9));
- assertEquals("ggg", coordList.get(9));
- }
-
- public void testAddSource_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- SimpleListValueModel<String> lvm = new SimpleListValueModel<String>();
- lvm.add("xxx");
- lvm.add("yyy");
- lvm.add("zzz");
- this.uberLVM.add(lvm);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk", "xxx", "yyy", "zzz" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testAddSources() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- SimpleListValueModel<String> lvmA = new SimpleListValueModel<String>();
- lvmA.add("xxx");
- lvmA.add("yyy");
- lvmA.add("zzz");
- SimpleListValueModel<String> lvmB = new SimpleListValueModel<String>();
- lvmB.add("ppp");
- lvmB.add("qqq");
- lvmB.add("rrr");
- Collection<SimpleListValueModel<String>> c = new ArrayList<SimpleListValueModel<String>>();
- c.add(lvmA);
- c.add(lvmB);
- this.uberLVM.addAll(2, c);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "xxx", "yyy", "zzz", "ppp", "qqq", "rrr", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(12));
- assertEquals("ggg", coordList.get(12));
- }
-
- public void testRemoveSource_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.remove(0);
-
- Object[] expected = new Object[] { "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(3));
- assertEquals("ggg", coordList.get(3));
- }
-
- public void testRemoveSource_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.remove(2);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(5));
- assertEquals("ggg", coordList.get(5));
- }
-
- public void testRemoveSource_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.remove(3);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("fff", this.compositeLVM.get(5));
- assertEquals("fff", coordList.get(5));
- }
-
- public void testRemoveSources() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.remove(2, 2);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("eee", this.compositeLVM.get(4));
- assertEquals("eee", coordList.get(4));
- }
-
- public void testReplaceSources() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- SimpleListValueModel<String> lvmA = new SimpleListValueModel<String>();
- lvmA.add("xxx");
- lvmA.add("yyy");
- lvmA.add("zzz");
- SimpleListValueModel<String> lvmB = new SimpleListValueModel<String>();
- lvmB.add("ppp");
- lvmB.add("qqq");
- lvmB.add("rrr");
- List<SimpleListValueModel<String>> list = new ArrayList<SimpleListValueModel<String>>();
- list.add(lvmA);
- list.add(lvmB);
- this.uberLVM.set(2, list);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "xxx", "yyy", "zzz", "ppp", "qqq", "rrr" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("qqq", this.compositeLVM.get(9));
- assertEquals("qqq", coordList.get(9));
- }
-
- public void testMoveSources_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.move(0, 2, 2);
-
- Object[] expected = new Object[] { "fff", "ggg", "hhh", "iii", "jjj", "kkk", "aaa", "bbb", "ccc", "ddd", "eee" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(1));
- assertEquals("ggg", coordList.get(1));
- }
-
- public void testMoveSources_Middle() {
- SimpleListValueModel<String> lvm4 = new SimpleListValueModel<String>();
- lvm4.add("lll");
- lvm4.add("mmm");
- this.uberLVM.add(lvm4);
-
- SimpleListValueModel<String> lvm5 = new SimpleListValueModel<String>();
- lvm5.add("nnn");
- lvm5.add("ooo");
- lvm5.add("ppp");
- lvm5.add("qqq");
- this.uberLVM.add(lvm5);
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.move(1, 3, 2);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ggg", "hhh", "iii", "jjj", "kkk", "lll", "mmm", "ddd", "eee", "fff", "nnn", "ooo", "ppp", "qqq" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(3));
- assertEquals("ggg", coordList.get(3));
- }
-
- public void testMoveSources_End() {
- SimpleListValueModel<String> lvm4 = new SimpleListValueModel<String>();
- lvm4.add("lll");
- lvm4.add("mmm");
- this.uberLVM.add(lvm4);
-
- SimpleListValueModel<String> lvm5 = new SimpleListValueModel<String>();
- lvm5.add("nnn");
- lvm5.add("ooo");
- lvm5.add("ppp");
- lvm5.add("qqq");
- this.uberLVM.add(lvm5);
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.move(3, 0, 3);
-
- Object[] expected = new Object[] { "ggg", "hhh", "iii", "jjj", "kkk", "lll", "mmm", "nnn", "ooo", "ppp", "qqq", "aaa", "bbb", "ccc", "ddd", "eee", "fff" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(0));
- assertEquals("ggg", coordList.get(0));
- }
-
- public void testMoveSource() {
- SimpleListValueModel<String> lvm4 = new SimpleListValueModel<String>();
- lvm4.add("lll");
- lvm4.add("mmm");
- this.uberLVM.add(lvm4);
-
- SimpleListValueModel<String> lvm5 = new SimpleListValueModel<String>();
- lvm5.add("nnn");
- lvm5.add("ooo");
- lvm5.add("ppp");
- lvm5.add("qqq");
- this.uberLVM.add(lvm5);
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.move(3, 1);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "fff", "ggg", "hhh", "iii", "jjj", "kkk", "ddd", "eee", "lll", "mmm", "nnn", "ooo", "ppp", "qqq" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ooo", this.compositeLVM.get(14));
- assertEquals("ooo", coordList.get(14));
- }
-
- public void testClearSources() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.clear();
-
- Object[] expected = new Object[0];
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- }
-
- public void testChangeSources() {
- List<SimpleListValueModel<String>> newList = new ArrayList<SimpleListValueModel<String>>();
- SimpleListValueModel<String> lvm4 = new SimpleListValueModel<String>();
- lvm4.add("lll");
- lvm4.add("mmm");
- newList.add(lvm4);
-
- SimpleListValueModel<String> lvm5 = new SimpleListValueModel<String>();
- lvm5.add("nnn");
- lvm5.add("ooo");
- lvm5.add("ppp");
- lvm5.add("qqq");
- newList.add(lvm5);
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.setList(newList);
-
- Object[] expected = new Object[] { "lll", "mmm", "nnn", "ooo", "ppp", "qqq" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ooo", this.compositeLVM.get(3));
- assertEquals("ooo", coordList.get(3));
- }
-
- public void testAddItem_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.add(0, "xxx");
-
- Object[] expected = new Object[] { "xxx", "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(7));
- assertEquals("ggg", coordList.get(7));
- }
-
- public void testAddItem_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm2.add(1, "xxx");
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "xxx", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(7));
- assertEquals("ggg", coordList.get(7));
- }
-
- public void testAddItem_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.add(5, "xxx");
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk", "xxx" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testAddItems_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.addAll(0, Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "xxx", "yyy", "zzz", "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(9));
- assertEquals("ggg", coordList.get(9));
- }
-
- public void testAddItems_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm2.addAll(1, Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "xxx", "yyy", "zzz", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(9));
- assertEquals("ggg", coordList.get(9));
- }
-
- public void testAddItems_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.addAll(5, Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk", "xxx", "yyy", "zzz" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testRemoveItem_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.remove(0);
-
- Object[] expected = new Object[] { "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(5));
- assertEquals("ggg", coordList.get(5));
- }
-
- public void testRemoveItem_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm2.remove(0);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(5));
- assertEquals("ggg", coordList.get(5));
- }
-
- public void testRemoveItem_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.remove(4);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testRemoveItems_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.remove(0, 3);
-
- Object[] expected = new Object[] { "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(3));
- assertEquals("ggg", coordList.get(3));
- }
-
- public void testRemoveItems_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.remove(1, 3);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("kkk", this.compositeLVM.get(7));
- assertEquals("kkk", coordList.get(7));
- }
-
- public void testRemoveItems_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.remove(3, 2);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testReplaceItem_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.set(0, "xxx");
-
- Object[] expected = new Object[] { "xxx", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testReplaceItem_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm2.set(0, "xxx");
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "xxx", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testReplaceItem_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.set(4, "xxx");
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "xxx" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testReplaceItems_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.set(0, Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "xxx", "yyy", "zzz", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testReplaceItems_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.set(1, Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "xxx", "yyy", "zzz", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("kkk", this.compositeLVM.get(10));
- assertEquals("kkk", coordList.get(10));
- }
-
- public void testReplaceItems_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.set(3, Arrays.asList(new String[] { "xxx", "yyy" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "xxx", "yyy" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testMoveItem_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.move(2, 0);
-
- Object[] expected = new Object[] { "bbb", "ccc", "aaa", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testMoveItem_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm1.move(0, 1);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "eee", "ddd", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testMoveItem_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.move(0, 4);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "kkk", "ggg", "hhh", "iii", "jjj" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(7));
- assertEquals("ggg", coordList.get(7));
- }
-
- public void testMoveItems_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.move(1, 0, 2);
-
- Object[] expected = new Object[] { "ccc", "aaa", "bbb", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testMoveItems_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm1.add("eee.1");
- this.lvm1.add("eee.2");
- this.lvm1.add("eee.3");
- this.lvm1.move(1, 2, 3);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee.1", "eee.2", "eee.3", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(9));
- assertEquals("ggg", coordList.get(9));
- }
-
- public void testMoveItems_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.move(0, 2, 3);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "iii", "jjj", "kkk", "ggg", "hhh" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(9));
- assertEquals("ggg", coordList.get(9));
- }
-
- public void testClearItems_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.clear();
-
- Object[] expected = new Object[] { "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(3));
- assertEquals("ggg", coordList.get(3));
- }
-
- public void testClearItems_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm1.clear();
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(4));
- assertEquals("ggg", coordList.get(4));
- }
-
- public void testClearItems_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.clear();
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("fff", this.compositeLVM.get(5));
- assertEquals("fff", coordList.get(5));
- }
-
- public void testChangeItems_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.setList(Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "xxx", "yyy", "zzz", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testChangeItems_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm1.setList(Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "xxx", "yyy", "zzz", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(7));
- assertEquals("ggg", coordList.get(7));
- }
-
- public void testChangeItems_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.setList(Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "xxx", "yyy", "zzz" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("fff", this.compositeLVM.get(5));
- assertEquals("fff", coordList.get(5));
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CoordinatedBag.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CoordinatedBag.java
deleted file mode 100644
index e05ec8543c..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CoordinatedBag.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.Collection;
-import java.util.Iterator;
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-
-/**
- * Helper class that keeps an internal collection in synch with the
- * collection held by a collection value model.
- */
-class CoordinatedBag<E> implements Bag<E>, CollectionChangeListener {
-
- private Bag<E> bag = new HashBag<E>();
-
- CoordinatedBag(CollectionValueModel<E> cvm) {
- cvm.addCollectionChangeListener(CollectionValueModel.VALUES, this);
- }
-
-
- // ********** Collection implementation **********
-
- public boolean add(E o) {
- return this.bag.add(o);
- }
-
- public boolean addAll(Collection<? extends E> c) {
- return this.bag.addAll(c);
- }
-
- public void clear() {
- this.bag.clear();
- }
-
- public boolean contains(Object o) {
- return this.bag.contains(o);
- }
-
- public boolean containsAll(Collection<?> c) {
- return this.bag.containsAll(c);
- }
-
- public boolean isEmpty() {
- return this.bag.isEmpty();
- }
-
- public Iterator<E> iterator() {
- return this.bag.iterator();
- }
-
- public boolean remove(Object o) {
- return this.bag.remove(o);
- }
-
- public boolean removeAll(Collection<?> c) {
- return this.bag.removeAll(c);
- }
-
- public boolean retainAll(Collection<?> c) {
- return this.bag.retainAll(c);
- }
-
- public int size() {
- return this.bag.size();
- }
-
- public Object[] toArray() {
- return this.bag.toArray();
- }
-
- public <T> T[] toArray(T[] a) {
- return this.bag.toArray(a);
- }
-
-
- // ********** Bag implementation **********
-
- public int count(Object o) {
- return this.bag.count(o);
- }
-
- public boolean add(E o, int count) {
- return this.bag.add(o, count);
- }
-
- public boolean remove(Object o, int count) {
- return this.bag.remove(o, count);
- }
-
- public Iterator<E> uniqueIterator() {
- return this.bag.uniqueIterator();
- }
-
- // ********** CollectionChangeListener implementation **********
-
- public void itemsAdded(CollectionChangeEvent e) {
- for (@SuppressWarnings("unchecked") Iterator<E> stream = (Iterator<E>) e.items(); stream.hasNext(); ) {
- this.bag.add(stream.next());
- }
- }
-
- public void itemsRemoved(CollectionChangeEvent e) {
- for (@SuppressWarnings("unchecked") Iterator<E> stream = (Iterator<E>) e.items(); stream.hasNext(); ) {
- this.bag.remove(stream.next());
- }
- }
-
- public void collectionCleared(CollectionChangeEvent e) {
- this.bag.clear();
- }
-
- @SuppressWarnings("unchecked")
- public void collectionChanged(CollectionChangeEvent e) {
- this.bag.clear();
- CollectionTools.addAll(this.bag, ((CollectionValueModel<E>) e.getSource()).iterator());
- }
-
-
- // ********** standard methods **********
-
- @Override
- public boolean equals(Object o) {
- return this.bag.equals(o);
- }
-
- @Override
- public int hashCode() {
- return this.bag.hashCode();
- }
-
- @Override
- public String toString() {
- return this.bag.toString();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CoordinatedList.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CoordinatedList.java
deleted file mode 100644
index 7bf7b88c6f..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CoordinatedList.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import javax.swing.ListModel;
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- * Helper class that keeps an internal list in synch with the
- * list held by a list value model.
- */
-public class CoordinatedList<E> implements List<E>, ListChangeListener, ListDataListener {
- private List<E> list = new ArrayList<E>();
-
- public CoordinatedList(ListValueModel<E> listValueModel) {
- listValueModel.addListChangeListener(ListValueModel.LIST_VALUES, this);
- for (Iterator<E> stream = listValueModel.iterator(); stream.hasNext(); ) {
- this.add(stream.next());
- }
- }
-
- public CoordinatedList(ListModel listModel) {
- listModel.addListDataListener(this);
- for (int i = 0; i < listModel.getSize(); i++) {
- this.add(i, this.getElementAt(listModel, i));
- }
- }
-
-
- // ********** List implementation **********
-
- public void add(int index, E element) {
- this.list.add(index, element);
- }
-
- public boolean add(E o) {
- return this.list.add(o);
- }
-
- public boolean addAll(Collection<? extends E> c) {
- return this.list.addAll(c);
- }
-
- public boolean addAll(int index, Collection<? extends E> c) {
- return this.list.addAll(index, c);
- }
-
- public void clear() {
- this.list.clear();
- }
-
- public boolean contains(Object o) {
- return this.list.contains(o);
- }
-
- public boolean containsAll(Collection<?> c) {
- return this.list.containsAll(c);
- }
-
- public E get(int index) {
- return this.list.get(index);
- }
-
- public int indexOf(Object o) {
- return this.list.indexOf(o);
- }
-
- public boolean isEmpty() {
- return this.list.isEmpty();
- }
-
- public Iterator<E> iterator() {
- return this.list.iterator();
- }
-
- public int lastIndexOf(Object o) {
- return this.list.lastIndexOf(o);
- }
-
- public ListIterator<E> listIterator() {
- return this.list.listIterator();
- }
-
- public ListIterator<E> listIterator(int index) {
- return this.list.listIterator(index);
- }
-
- public E remove(int index) {
- return this.list.remove(index);
- }
-
- public boolean remove(Object o) {
- return this.list.remove(o);
- }
-
- public boolean removeAll(Collection<?> c) {
- return this.list.removeAll(c);
- }
-
- public boolean retainAll(Collection<?> c) {
- return this.list.retainAll(c);
- }
-
- public E set(int index, E element) {
- return this.list.set(index, element);
- }
-
- public int size() {
- return this.list.size();
- }
-
- public List<E> subList(int fromIndex, int toIndex) {
- return this.list.subList(fromIndex, toIndex);
- }
-
- public Object[] toArray() {
- return this.list.toArray();
- }
-
- public <T> T[] toArray(T[] a) {
- return this.list.toArray(a);
- }
-
-
- // ********** ListChangeListener implementation **********
-
- public void itemsAdded(ListChangeEvent e) {
- int i = e.getIndex();
- for (Iterator<E> stream = this.items(e); stream.hasNext(); ) {
- this.list.add(i++, stream.next());
- }
- }
-
- public void itemsRemoved(ListChangeEvent e) {
- int i = e.getIndex();
- for (Iterator<E> stream = this.items(e); stream.hasNext(); ) {
- stream.next();
- this.list.remove(i);
- }
- }
-
- public void itemsReplaced(ListChangeEvent e) {
- int i = e.getIndex();
- for (Iterator<E> stream = this.items(e); stream.hasNext(); ) {
- this.list.set(i++, stream.next());
- }
- }
-
- public void itemsMoved(ListChangeEvent e) {
- CollectionTools.move(this.list, e.getTargetIndex(), e.getSourceIndex(), e.getMoveLength());
- }
-
- public void listCleared(ListChangeEvent e) {
- this.list.clear();
- }
-
- public void listChanged(ListChangeEvent e) {
- this.list.clear();
- CollectionTools.addAll(this.list, this.getSource(e).iterator());
- }
-
-
- // ********** ListDataListener implementation **********
-
- public void contentsChanged(ListDataEvent e) {
- this.list.clear();
- ListModel lm = (ListModel) e.getSource();
- int size = lm.getSize();
- for (int i = 0; i < size; i++) {
- this.list.add(i, this.getElementAt(lm, i));
- }
- }
-
- public void intervalAdded(ListDataEvent e) {
- ListModel lm = (ListModel) e.getSource();
- int start = Math.min(e.getIndex0(), e.getIndex1());
- int end = Math.max(e.getIndex0(), e.getIndex1());
- for (int i = start; i <= end; i++) {
- this.list.add(i, this.getElementAt(lm, i));
- }
- }
-
- public void intervalRemoved(ListDataEvent e) {
- int start = Math.min(e.getIndex0(), e.getIndex1());
- int end = Math.max(e.getIndex0(), e.getIndex1());
- int length = end - start + 1;
- for (int i = 1; i <= length; i++) {
- this.list.remove(start);
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public boolean equals(Object o) {
- return this.list.equals(o);
- }
-
- @Override
- public int hashCode() {
- return this.list.hashCode();
- }
-
- @Override
- public String toString() {
- return this.list.toString();
- }
-
-
- // ********** internal methods **********
-
- /**
- * minimize the scope of the suppressed warnings.=
- */
- @SuppressWarnings("unchecked")
- private E getElementAt(ListModel listModel, int index) {
- return (E) listModel.getElementAt(index);
- }
-
- /**
- * minimize the scope of the suppressed warnings.=
- */
- @SuppressWarnings("unchecked")
- private Iterator<E> items(ListChangeEvent event) {
- return (Iterator<E>) event.items();
- }
-
- /**
- * minimize the scope of the suppressed warnings.=
- */
- @SuppressWarnings("unchecked")
- private ListValueModel<E> getSource(ListChangeEvent event) {
- return (ListValueModel<E>) event.getSource();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ExtendedListValueModelWrapperTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ExtendedListValueModelWrapperTests.java
deleted file mode 100644
index 9ecba890a7..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ExtendedListValueModelWrapperTests.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.ExtendedListValueModelWrapper;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ExtendedListValueModelWrapperTests extends TestCase {
- private SimpleListValueModel<String> listHolder;
- private ListValueModel<String> extendedListHolder;
- ListChangeEvent event;
- String eventType;
-
- private static final String ADD = "add";
- private static final String REMOVE = "remove";
- private static final String REPLACE = "replace";
- private static final String MOVE = "move";
- private static final String CLEAR = "clear";
- private static final String CHANGE = "change";
-
- public ExtendedListValueModelWrapperTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.listHolder = new SimpleListValueModel<String>(this.buildList());
- this.extendedListHolder = this.buildExtendedListHolder(this.listHolder);
- }
-
- private List<String> buildList() {
- List<String> result = new ArrayList<String>();
- result.add("A");
- result.add("B");
- result.add("C");
- result.add("D");
- return result;
- }
-
- private List<String> buildExtendedList() {
- List<String> extendedList = new ArrayList<String>();
- extendedList.addAll(this.buildPrefix());
- extendedList.addAll(this.buildList());
- extendedList.addAll(this.buildSuffix());
- return extendedList;
- }
-
- private List<String> buildPrefix() {
- List<String> prefix = new ArrayList<String>();
- prefix.add("x");
- prefix.add("y");
- prefix.add("z");
- return prefix;
- }
-
- private List<String> buildSuffix() {
- List<String> suffix = new ArrayList<String>();
- suffix.add("i");
- suffix.add("j");
- return suffix;
- }
-
- private ListValueModel<String> buildExtendedListHolder(ListValueModel<String> lvm) {
- return new ExtendedListValueModelWrapper<String>(this.buildPrefix(), lvm, this.buildSuffix());
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- assertEquals(this.buildExtendedList(), CollectionTools.list(this.extendedListHolder.iterator()));
- }
-
- public void testSize() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- assertEquals(this.buildExtendedList().size(), CollectionTools.size(this.extendedListHolder.iterator()));
- assertEquals(this.buildExtendedList().size(), this.extendedListHolder.size());
- }
-
- private boolean extendedListContains(Object item) {
- return CollectionTools.contains(this.extendedListHolder.iterator(), item);
- }
-
- private boolean extendedListContainsAll(Collection<String> items) {
- return CollectionTools.containsAll(this.extendedListHolder.iterator(), items);
- }
-
- private boolean extendedListContainsAny(Collection<String> items) {
- List<String> extendedList = CollectionTools.list(this.extendedListHolder.iterator());
- for (Iterator<String> stream = items.iterator(); stream.hasNext(); ) {
- if (extendedList.contains(stream.next())) {
- return true;
- }
- }
- return false;
- }
-
- private boolean listContains(Object item) {
- return CollectionTools.contains(this.listHolder.iterator(), item);
- }
-
- private boolean listContainsAll(Collection<String> items) {
- return CollectionTools.containsAll(this.listHolder.iterator(), items);
- }
-
-// private boolean listContainsAny(Collection<String> items) {
-// List<String> extendedList = CollectionTools.list(this.listHolder.iterator());
-// for (Iterator<String> stream = items.iterator(); stream.hasNext(); ) {
-// if (extendedList.contains(stream.next())) {
-// return true;
-// }
-// }
-// return false;
-// }
-//
- public void testAdd1() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertFalse(this.extendedListContains("E"));
- this.listHolder.add(4, "E");
- assertTrue(this.extendedListContains("E"));
- assertTrue(this.listContains("E"));
- }
-
- public void testAdd2() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertFalse(this.extendedListContains(null));
- this.listHolder.add(4, null);
- assertTrue(this.extendedListContains(null));
- assertTrue(this.listContains(null));
- }
-
- private List<String> buildAddList() {
- List<String> addList = new ArrayList<String>();
- addList.add("E");
- addList.add("F");
- return addList;
- }
-
- public void testAddAll1() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertFalse(this.extendedListContainsAny(this.buildAddList()));
- this.listHolder.addAll(4, this.buildAddList());
- assertTrue(this.extendedListContainsAll(this.buildAddList()));
- assertTrue(this.listContainsAll(this.buildAddList()));
- }
-
- public void testRemove1() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertTrue(this.extendedListContains("B"));
- this.listHolder.remove(this.buildList().indexOf("B"));
- assertFalse(this.extendedListContains("B"));
- assertFalse(this.listContains("B"));
- }
-
- public void testListChangeGeneric() {
- this.extendedListHolder.addListChangeListener(this.buildListener());
- this.verifyListChange();
- }
-
- public void testListChangeNamed() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- this.verifyListChange();
- }
-
- private void verifyListChange() {
- this.event = null;
- this.eventType = null;
- this.listHolder.add(4, "E");
- this.verifyEvent(ADD, 7, "E");
-
- this.event = null;
- this.eventType = null;
- this.listHolder.add(5, null);
- this.verifyEvent(ADD, 8, null);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.remove(5);
- this.verifyEvent(REMOVE, 8, null);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.remove(4);
- this.verifyEvent(REMOVE, 7, "E");
-
- this.event = null;
- this.eventType = null;
- this.listHolder.addAll(0, this.buildList());
- this.verifyEvent(ADD);
- assertEquals(this.buildList(), CollectionTools.list(this.event.items()));
-
- this.event = null;
- this.eventType = null;
- this.listHolder.set(0, "AA");
- this.verifyEvent(REPLACE);
- assertFalse(CollectionTools.contains(this.event.items(), "A"));
- assertTrue(CollectionTools.contains(this.event.items(), "AA"));
- }
-
- private ListChangeListener buildListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent e) {
- ExtendedListValueModelWrapperTests.this.eventType = ADD;
- ExtendedListValueModelWrapperTests.this.event = e;
- }
- public void itemsRemoved(ListChangeEvent e) {
- ExtendedListValueModelWrapperTests.this.eventType = REMOVE;
- ExtendedListValueModelWrapperTests.this.event = e;
- }
- public void itemsReplaced(ListChangeEvent e) {
- ExtendedListValueModelWrapperTests.this.eventType = REPLACE;
- ExtendedListValueModelWrapperTests.this.event = e;
- }
- public void itemsMoved(ListChangeEvent e) {
- ExtendedListValueModelWrapperTests.this.eventType = MOVE;
- ExtendedListValueModelWrapperTests.this.event = e;
- }
- public void listCleared(ListChangeEvent e) {
- ExtendedListValueModelWrapperTests.this.eventType = CLEAR;
- ExtendedListValueModelWrapperTests.this.event = e;
- }
- public void listChanged(ListChangeEvent e) {
- ExtendedListValueModelWrapperTests.this.eventType = CHANGE;
- ExtendedListValueModelWrapperTests.this.event = e;
- }
- };
- }
-
- private void verifyEvent(String type) {
- assertEquals(type, this.eventType);
- assertEquals(this.extendedListHolder, this.event.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event.getListName());
- }
-
- private void verifyEvent(String type, int index, Object item) {
- this.verifyEvent(type);
- assertEquals(index, this.event.getIndex());
- assertEquals(item, this.event.items().next());
- }
-
- public void testHasListeners() {
- /*
- * adding listeners to the extended list will cause listeners
- * to be added to the wrapped list;
- * likewise, removing listeners from the extended list will
- * cause listeners to be removed from the wrapped list
- */
- assertFalse(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ListChangeListener listener = this.buildListener();
-
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- assertTrue(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.extendedListHolder.removeListChangeListener(ListValueModel.LIST_VALUES, listener);
- assertFalse(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.extendedListHolder.addListChangeListener(listener);
- assertTrue(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.extendedListHolder.removeListChangeListener(listener);
- assertFalse(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java
deleted file mode 100644
index 69f6e797fd..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Vector;
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.FilteringCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-public class FilteringCollectionValueModelTests extends TestCase {
- private SimpleCollectionValueModel<String> collectionHolder;
- CollectionChangeEvent addEvent;
- CollectionChangeEvent removeEvent;
- CollectionChangeEvent collectionClearedEvent;
- CollectionChangeEvent collectionChangedEvent;
-
- private CollectionValueModel<String> filteredCollectionHolder;
- CollectionChangeEvent filteredAddEvent;
- CollectionChangeEvent filteredRemoveEvent;
- CollectionChangeEvent filteredCollectionClearedEvent;
- CollectionChangeEvent filteredCollectionChangedEvent;
-
- public FilteringCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.collectionHolder = new SimpleCollectionValueModel<String>(buildCollection());
- this.filteredCollectionHolder = new FilteringCollectionValueModel<String>(this.collectionHolder, this.buildFilter());
- }
-
- private Collection<String> buildCollection() {
- Collection<String> collection = new Vector<String>();
- collection.add("foo");
- return collection;
- }
-
- private Filter<String> buildFilter() {
- return new Filter<String>() {
- public boolean accept(String s) {
- return s.startsWith("b");
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- // add a listener to "activate" the wrapper
- this.filteredCollectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildFilteredListener());
-
- assertEquals("foo", this.collectionHolder.iterator().next());
- assertFalse(this.filteredCollectionHolder.iterator().hasNext());
-
- this.collectionHolder.add("bar");
- Iterator<String> collectionHolderValue = this.collectionHolder.iterator();
- assertEquals("foo", collectionHolderValue.next());
- assertEquals("bar", collectionHolderValue.next());
- assertTrue(this.filteredCollectionHolder.iterator().hasNext());
- assertEquals("bar", this.filteredCollectionHolder.iterator().next());
-
- this.collectionHolder.remove("bar");
- assertEquals("foo", this.collectionHolder.iterator().next());
- assertFalse(this.filteredCollectionHolder.iterator().hasNext());
-
- this.collectionHolder.remove("foo");
- assertFalse(this.collectionHolder.iterator().hasNext());
- assertFalse(this.filteredCollectionHolder.iterator().hasNext());
-
- this.collectionHolder.add("foo");
- assertEquals("foo", this.collectionHolder.iterator().next());
- assertFalse(this.filteredCollectionHolder.iterator().hasNext());
- }
-
- public void testSetValue() {
- // add a listener to "activate" the wrapper
- this.filteredCollectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildFilteredListener());
-
- Collection<String> newCollection = new Vector<String>();
- newCollection.add("fox");
- newCollection.add("baz");
-
- this.collectionHolder.setCollection(newCollection);
-
- Iterator<String> collectionValues = this.collectionHolder.iterator();
- assertEquals("fox", collectionValues.next());
- assertEquals("baz", collectionValues.next());
- Iterator<String> filteredCollectionValues = this.filteredCollectionHolder.iterator();
- assertEquals("baz", filteredCollectionValues.next());
- assertFalse(filteredCollectionValues.hasNext());
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.collectionHolder).hasNoCollectionChangeListeners(CollectionValueModel.VALUES));
- CollectionChangeListener listener = this.buildFilteredListener();
- this.filteredCollectionHolder.addCollectionChangeListener(listener);
- assertTrue(((AbstractModel) this.collectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.filteredCollectionHolder.removeCollectionChangeListener(listener);
- assertTrue(((AbstractModel) this.collectionHolder).hasNoCollectionChangeListeners(CollectionValueModel.VALUES));
-
- this.filteredCollectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- assertTrue(((AbstractModel) this.collectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.filteredCollectionHolder.removeCollectionChangeListener(CollectionValueModel.VALUES, listener);
- assertTrue(((AbstractModel) this.collectionHolder).hasNoCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
- public void testCollectionChange1() {
- this.collectionHolder.addCollectionChangeListener(this.buildListener());
- this.filteredCollectionHolder.addCollectionChangeListener(this.buildFilteredListener());
- this.verifyCollectionChanges();
- }
-
- public void testCollectionChange2() {
- this.collectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildListener());
- this.filteredCollectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildFilteredListener());
- this.verifyCollectionChanges();
- }
-
- private void clearEvents() {
- this.addEvent = null;
- this.removeEvent = null;
- this.collectionClearedEvent = null;
- this.collectionChangedEvent = null;
- this.filteredAddEvent = null;
- this.filteredRemoveEvent = null;
- this.filteredCollectionClearedEvent = null;
- this.filteredCollectionChangedEvent = null;
- }
-
- private void verifyCollectionChanges() {
- clearEvents();
- this.collectionHolder.add("bar");
- Collection<String> tempCollection = new Vector<String>();
- tempCollection.add("bar");
- this.verifyEvent(this.addEvent, this.collectionHolder, tempCollection);
- this.verifyEvent(this.filteredAddEvent, this.filteredCollectionHolder, tempCollection);
-
- clearEvents();
- this.collectionHolder.remove("foo");
- tempCollection.remove("bar");
- tempCollection.add("foo");
- this.verifyEvent(this.removeEvent, this.collectionHolder, tempCollection);
- assertNull(this.filteredRemoveEvent);
-
-
- clearEvents();
- this.collectionHolder.remove("bar");
- tempCollection.add("bar");
- tempCollection.remove("foo");
- this.verifyEvent(this.removeEvent, this.collectionHolder, tempCollection);
- this.verifyEvent(this.filteredRemoveEvent, this.filteredCollectionHolder, tempCollection);
-
-
- clearEvents();
- this.collectionHolder.add("foo");
- tempCollection.remove("bar");
- tempCollection.add("foo");
- this.verifyEvent(this.addEvent, this.collectionHolder, tempCollection);
- assertNull(this.filteredAddEvent);
-
-
- clearEvents();
- Collection<String> newCollection = new Vector<String>();
- newCollection.add("fox");
- newCollection.add("baz");
-
- this.collectionHolder.setCollection(newCollection);
-
- this.verifyEvent(this.collectionChangedEvent, this.collectionHolder, new Vector<String>());
-
- tempCollection.remove("foo");
- tempCollection.add("baz");
- this.verifyEvent(this.filteredCollectionChangedEvent, this.filteredCollectionHolder, new Vector<String>());
-
- }
-
- private CollectionChangeListener buildListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent e) {
- FilteringCollectionValueModelTests.this.addEvent = e;
- }
- public void itemsRemoved(CollectionChangeEvent e) {
- FilteringCollectionValueModelTests.this.removeEvent = e;
- }
- public void collectionCleared(CollectionChangeEvent e) {
- FilteringCollectionValueModelTests.this.collectionClearedEvent = e;
- }
- public void collectionChanged(CollectionChangeEvent e) {
- FilteringCollectionValueModelTests.this.collectionChangedEvent = e;
- }
- };
- }
-
- private CollectionChangeListener buildFilteredListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent e) {
- FilteringCollectionValueModelTests.this.filteredAddEvent = e;
- }
- public void itemsRemoved(CollectionChangeEvent e) {
- FilteringCollectionValueModelTests.this.filteredRemoveEvent = e;
- }
- public void collectionCleared(CollectionChangeEvent e) {
- FilteringCollectionValueModelTests.this.filteredCollectionClearedEvent = e;
- }
- public void collectionChanged(CollectionChangeEvent e) {
- FilteringCollectionValueModelTests.this.filteredCollectionChangedEvent = e;
- }
- };
- }
-
- private void verifyEvent(CollectionChangeEvent event, Object source, Object items) {
- assertEquals(source, event.getSource());
- assertEquals(CollectionValueModel.VALUES, event.getCollectionName());
- assertEquals(items, CollectionTools.vector(event.items()));
- }
-
- public void testRemoveFilteredItem() {
- // build collection with TestItems
- SimpleCollectionValueModel<TestItem> tiHolder = new SimpleCollectionValueModel<TestItem>(this.buildCollection2());
- CollectionValueModel<TestItem> filteredTIHolder = new FilteringCollectionValueModel<TestItem>(tiHolder, this.buildFilter2());
- // add a listener to "activate" the wrapper
- filteredTIHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildFilteredListener());
-
- assertEquals(0, filteredTIHolder.size());
-
- tiHolder.add(new TestItem("bar"));
- assertEquals(1, filteredTIHolder.size());
-
- TestItem baz = new TestItem("baz");
- tiHolder.add(baz);
- assertEquals(2, filteredTIHolder.size());
- // before removing it, change the item so that it is filtered
- baz.name = "jaz";
- tiHolder.remove(baz);
- // this would fail because the item was not removed from
- // the filtered collection cache... but we've fixed it now
- assertEquals(1, filteredTIHolder.size());
- }
-
- private Collection<TestItem> buildCollection2() {
- Collection<TestItem> collection = new Vector<TestItem>();
- collection.add(new TestItem("foo"));
- return collection;
- }
-
- private Filter<TestItem> buildFilter2() {
- return new Filter<TestItem>() {
- public boolean accept(TestItem ti) {
- return ti.name.startsWith("b");
- }
- };
- }
-
-
- // ********** TestItem inner class **********
-
- private class TestItem {
- String name;
- TestItem(String name) {
- super();
- this.name = name;
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringPropertyValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringPropertyValueModelTests.java
deleted file mode 100644
index 81912fd3f2..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringPropertyValueModelTests.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.BidiFilter;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.FilteringWritablePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class FilteringPropertyValueModelTests extends TestCase {
- private WritablePropertyValueModel<String> objectHolder;
- PropertyChangeEvent event;
-
- private WritablePropertyValueModel<String> filteredObjectHolder;
- PropertyChangeEvent filteredEvent;
-
- public FilteringPropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.objectHolder = new SimplePropertyValueModel<String>("foo");
- this.filteredObjectHolder = new FilteringWritablePropertyValueModel<String>(this.objectHolder, this.buildFilter());
- }
-
- private BidiFilter<String> buildFilter() {
- return new BidiFilter<String>() {
- public boolean accept(String s) {
- return (s != null) && s.startsWith("b");
- }
- public boolean reverseAccept(String s) {
- return (s != null) && s.startsWith("b");
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- assertEquals("foo", this.objectHolder.getValue());
- assertNull(this.filteredObjectHolder.getValue());
-
- this.objectHolder.setValue("bar");
- assertEquals("bar", this.objectHolder.getValue());
- assertNotNull(this.filteredObjectHolder.getValue());
- assertEquals("bar", this.filteredObjectHolder.getValue());
-
- this.objectHolder.setValue("baz");
- assertEquals("baz", this.objectHolder.getValue());
- assertNotNull(this.filteredObjectHolder.getValue());
- assertEquals("baz", this.filteredObjectHolder.getValue());
-
- this.objectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.filteredObjectHolder.getValue());
-
- this.objectHolder.setValue("foo");
- assertEquals("foo", this.objectHolder.getValue());
- assertNull(this.filteredObjectHolder.getValue());
- }
-
- public void testSetValue() {
- this.filteredObjectHolder.setValue("bar");
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("bar", this.filteredObjectHolder.getValue());
-
- this.filteredObjectHolder.setValue("foo");
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("bar", this.filteredObjectHolder.getValue());
-
- this.filteredObjectHolder.setValue(null);
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("bar", this.filteredObjectHolder.getValue());
-
- this.filteredObjectHolder.setValue("baz");
- assertEquals("baz", this.objectHolder.getValue());
- assertEquals("baz", this.filteredObjectHolder.getValue());
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- PropertyChangeListener listener = this.buildFilteredListener();
- this.filteredObjectHolder.addPropertyChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.filteredObjectHolder.removePropertyChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.filteredObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.filteredObjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testPropertyChange1() {
- this.objectHolder.addPropertyChangeListener(this.buildListener());
- this.filteredObjectHolder.addPropertyChangeListener(this.buildFilteredListener());
- this.verifyPropertyChanges();
- }
-
- public void testPropertyChange2() {
- this.objectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.filteredObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildFilteredListener());
- this.verifyPropertyChanges();
- }
-
- private void verifyPropertyChanges() {
- this.event = null;
- this.filteredEvent = null;
- this.objectHolder.setValue("bar");
- this.verifyEvent(this.event, this.objectHolder, "foo", "bar");
- this.verifyEvent(this.filteredEvent, this.filteredObjectHolder, null, "bar");
-
- this.event = null;
- this.filteredEvent = null;
- this.objectHolder.setValue("baz");
- this.verifyEvent(this.event, this.objectHolder, "bar", "baz");
- this.verifyEvent(this.filteredEvent, this.filteredObjectHolder, "bar", "baz");
-
- this.event = null;
- this.filteredEvent = null;
- this.objectHolder.setValue("foo");
- this.verifyEvent(this.event, this.objectHolder, "baz", "foo");
- this.verifyEvent(this.filteredEvent, this.filteredObjectHolder, "baz", null);
-
- this.event = null;
- this.filteredEvent = null;
- this.objectHolder.setValue("fop");
- this.verifyEvent(this.event, this.objectHolder, "foo", "fop");
- assertNull(this.filteredEvent);
-
- this.event = null;
- this.filteredEvent = null;
- this.objectHolder.setValue(null);
- this.verifyEvent(this.event, this.objectHolder, "fop", null);
- assertNull(this.filteredEvent);
-
- this.event = null;
- this.filteredEvent = null;
- this.objectHolder.setValue("bar");
- this.verifyEvent(this.event, this.objectHolder, null, "bar");
- this.verifyEvent(this.filteredEvent, this.filteredObjectHolder, null, "bar");
- }
-
- private PropertyChangeListener buildListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- FilteringPropertyValueModelTests.this.event = e;
- }
- };
- }
-
- private PropertyChangeListener buildFilteredListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- FilteringPropertyValueModelTests.this.filteredEvent = e;
- }
- };
- }
-
- private void verifyEvent(PropertyChangeEvent e, Object source, Object oldValue, Object newValue) {
- assertEquals(source, e.getSource());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- assertEquals(oldValue, e.getOldValue());
- assertEquals(newValue, e.getNewValue());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java
deleted file mode 100644
index 347bbed778..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.swing.Icon;
-
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.ItemCollectionListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.swing.Displayable;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ItemCollectionListValueModelAdapterTests extends TestCase {
- private Junk foo;
- private Junk bar;
- private Junk baz;
- private Junk joo;
- private Junk jar;
- private Junk jaz;
-
- private Junk tom;
- private Junk dick;
- private Junk harry;
-
- public ItemCollectionListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.foo = new Junk("foo");
- this.bar = new Junk("bar");
- this.baz = new Junk("baz");
- this.joo = new Junk("joo");
- this.jar = new Junk("jar");
- this.jaz = new Junk("jaz");
-
- this.tom = new Junk("tom");
- this.dick = new Junk("dick");
- this.harry = new Junk("harry");
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testCollectionSynchronization() {
- SimpleCollectionValueModel<Junk> collectionHolder = this.buildCollectionHolder();
- ListValueModel<Junk> listValueModel = new ItemCollectionListValueModelAdapter<Junk>(collectionHolder, Junk.STUFF_COLLECTION);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.add(this.tom);
- collectionHolder.add(this.dick);
- collectionHolder.add(this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.remove(this.foo);
- collectionHolder.remove(this.jar);
- collectionHolder.remove(this.harry);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- public void testListSynchronization() {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemCollectionListValueModelAdapter<Junk>(listHolder, Junk.STUFF_COLLECTION);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.add(6, this.tom);
- listHolder.add(7, this.dick);
- listHolder.add(8, this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.remove(8);
- listHolder.remove(0);
- listHolder.remove(4);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- private void compare(ListValueModel<Junk> listValueModel, List<Junk> list) {
- assertEquals(listValueModel.size(), list.size());
- for (int i = 0; i < listValueModel.size(); i++) {
- assertEquals(listValueModel.get(i), list.get(i));
- }
- }
-
-
- public void testHasListeners() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyListChangeListeners(Junk.STUFF_COLLECTION));
- assertFalse(this.jaz.hasAnyListChangeListeners(Junk.STUFF_COLLECTION));
-
- ListValueModel<Junk> listValueModel = new ItemCollectionListValueModelAdapter<Junk>(listHolder, Junk.STUFF_COLLECTION);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- assertFalse(this.jaz.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- this.verifyHasNoListeners(listValueModel);
-
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.foo.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- assertTrue(this.jaz.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- this.verifyHasListeners(listValueModel);
-
- listValueModel.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- assertFalse(this.jaz.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- this.verifyHasNoListeners(listValueModel);
- }
-
- public void testGetSize() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemCollectionListValueModelAdapter<Junk>(listHolder, Junk.STUFF_COLLECTION);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(6, listValueModel.size());
- assertEquals(6, synchList.size());
- }
-
- public void testGet() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new SortedListValueModelAdapter<Junk>(new ItemCollectionListValueModelAdapter<Junk>(listHolder, Junk.STUFF_COLLECTION));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(this.bar, listValueModel.get(0));
- assertEquals(this.bar, synchList.get(0));
- this.bar.removeStuff("bar");
- this.bar.addStuff("zzz");
- this.bar.addStuff("bar");
- assertEquals(this.bar, listValueModel.get(5));
- assertEquals(this.bar, synchList.get(5));
- this.bar.removeStuff("zzz");
- }
-
- private void verifyHasNoListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private void verifyHasListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private SimpleCollectionValueModel<Junk> buildCollectionHolder() {
- return new SimpleCollectionValueModel<Junk>(this.buildCollection());
- }
-
- private Collection<Junk> buildCollection() {
- Bag<Junk> bag = new HashBag<Junk>();
- this.populateCollection(bag);
- return bag;
- }
-
- private SimpleListValueModel<Junk> buildListHolder() {
- return new SimpleListValueModel<Junk>(this.buildList());
- }
-
- private List<Junk> buildList() {
- List<Junk> list = new ArrayList<Junk>();
- this.populateCollection(list);
- return list;
- }
-
- private void populateCollection(Collection<Junk> c) {
- c.add(this.foo);
- c.add(this.bar);
- c.add(this.baz);
- c.add(this.joo);
- c.add(this.jar);
- c.add(this.jaz);
- }
-
-
- // ********** Junk class **********
-
- private class Junk extends AbstractModel implements Displayable {
- private Collection<String> stuff;
- public static final String STUFF_COLLECTION = "stuff";
-
-
- public Junk(String stuffItem) {
- this.stuff = new ArrayList<String>();
- this.stuff.add(stuffItem);
- }
-
- public void addStuff(String stuffItem) {
- this.addItemToCollection(stuffItem, this.stuff, STUFF_COLLECTION);
- }
-
- public void removeStuff(String stuffItem) {
- this.removeItemFromCollection(stuffItem, this.stuff, STUFF_COLLECTION);
- }
-
- public String displayString() {
- return toString();
- }
-
- public Icon icon() {
- return null;
- }
-
- public int compareTo(Displayable o) {
- return DEFAULT_COMPARATOR.compare(this, o);
- }
-
- @Override
- public String toString() {
- return "Junk(" + this.stuff + ")";
- }
-
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java
deleted file mode 100644
index bfc8169e55..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.swing.Icon;
-
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.ItemListListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.swing.Displayable;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ItemListListValueModelAdapterTests extends TestCase {
- private Junk foo;
- private Junk bar;
- private Junk baz;
- private Junk joo;
- private Junk jar;
- private Junk jaz;
-
- private Junk tom;
- private Junk dick;
- private Junk harry;
-
- public ItemListListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.foo = new Junk("foo");
- this.bar = new Junk("bar");
- this.baz = new Junk("baz");
- this.joo = new Junk("joo");
- this.jar = new Junk("jar");
- this.jaz = new Junk("jaz");
-
- this.tom = new Junk("tom");
- this.dick = new Junk("dick");
- this.harry = new Junk("harry");
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testCollectionSynchronization() {
- SimpleCollectionValueModel<Junk> collectionHolder = this.buildCollectionHolder();
- ListValueModel<Junk> listValueModel = new ItemListListValueModelAdapter<Junk>(collectionHolder, Junk.STUFF_LIST);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.add(this.tom);
- collectionHolder.add(this.dick);
- collectionHolder.add(this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.remove(this.foo);
- collectionHolder.remove(this.jar);
- collectionHolder.remove(this.harry);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- public void testListSynchronization() {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemListListValueModelAdapter<Junk>(listHolder, Junk.STUFF_LIST);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.add(6, this.tom);
- listHolder.add(7, this.dick);
- listHolder.add(8, this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.remove(8);
- listHolder.remove(0);
- listHolder.remove(4);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- private void compare(ListValueModel<Junk> listValueModel, List<Junk> list) {
- assertEquals(listValueModel.size(), list.size());
- for (int i = 0; i < listValueModel.size(); i++) {
- assertEquals(listValueModel.get(i), list.get(i));
- }
- }
-
-
- public void testHasListeners() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertFalse(this.jaz.hasAnyListChangeListeners(Junk.STUFF_LIST));
-
- ListValueModel<Junk> listValueModel = new ItemListListValueModelAdapter<Junk>(listHolder, Junk.STUFF_LIST);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertFalse(this.jaz.hasAnyListChangeListeners(Junk.STUFF_LIST));
- this.verifyHasNoListeners(listValueModel);
-
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.foo.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertTrue(this.jaz.hasAnyListChangeListeners(Junk.STUFF_LIST));
- this.verifyHasListeners(listValueModel);
-
- listValueModel.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertFalse(this.jaz.hasAnyListChangeListeners(Junk.STUFF_LIST));
- this.verifyHasNoListeners(listValueModel);
- }
-
- public void testGetSize() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemListListValueModelAdapter<Junk>(listHolder, Junk.STUFF_LIST);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(6, listValueModel.size());
- assertEquals(6, synchList.size());
- }
-
- public void testGet() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new SortedListValueModelAdapter<Junk>(new ItemListListValueModelAdapter<Junk>(listHolder, Junk.STUFF_LIST));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(this.bar, listValueModel.get(0));
- assertEquals(this.bar, synchList.get(0));
- this.bar.removeStuff("bar");
- this.bar.addStuff("zzz");
- this.bar.addStuff("bar");
- assertEquals(this.bar, listValueModel.get(5));
- assertEquals(this.bar, synchList.get(5));
- this.bar.removeStuff("zzz");
- }
-
- private void verifyHasNoListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private void verifyHasListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private SimpleCollectionValueModel<Junk> buildCollectionHolder() {
- return new SimpleCollectionValueModel<Junk>(this.buildCollection());
- }
-
- private Collection<Junk> buildCollection() {
- Bag<Junk> bag = new HashBag<Junk>();
- this.populateCollection(bag);
- return bag;
- }
-
- private SimpleListValueModel<Junk> buildListHolder() {
- return new SimpleListValueModel<Junk>(this.buildList());
- }
-
- private List<Junk> buildList() {
- List<Junk> list = new ArrayList<Junk>();
- this.populateCollection(list);
- return list;
- }
-
- private void populateCollection(Collection<Junk> c) {
- c.add(this.foo);
- c.add(this.bar);
- c.add(this.baz);
- c.add(this.joo);
- c.add(this.jar);
- c.add(this.jaz);
- }
-
-
- // ********** Junk class **********
-
- private class Junk extends AbstractModel implements Displayable {
- private List<String> stuff;
- public static final String STUFF_LIST = "stuff";
-
-
- public Junk(String stuffItem) {
- this.stuff = new ArrayList<String>();
- this.stuff.add(stuffItem);
- }
- public void addStuff(String stuffItem) {
- this.stuff.add(stuffItem);
- fireItemAdded(STUFF_LIST, this.stuff.indexOf(stuffItem), stuffItem);
- }
-
- public void removeStuff(String stuffItem) {
- int index = this.stuff.indexOf(stuffItem);
- this.stuff.remove(stuffItem);
- fireItemRemoved(STUFF_LIST, index, stuffItem);
- }
-
- public String displayString() {
- return toString();
- }
-
- public Icon icon() {
- return null;
- }
-
- public int compareTo(Displayable o) {
- return DEFAULT_COMPARATOR.compare(this, o);
- }
-
- @Override
- public String toString() {
- return "Junk(" + this.stuff + ")";
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java
deleted file mode 100644
index 3860703216..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.swing.Icon;
-
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.swing.Displayable;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ItemPropertyListValueModelAdapterTests extends TestCase {
- private Junk foo;
- private Junk bar;
- private Junk baz;
- private Junk joo;
- private Junk jar;
- private Junk jaz;
-
- private Junk tom;
- private Junk dick;
- private Junk harry;
-
- public ItemPropertyListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.foo = new Junk("this.foo");
- this.bar = new Junk("this.bar");
- this.baz = new Junk("this.baz");
- this.joo = new Junk("this.joo");
- this.jar = new Junk("this.jar");
- this.jaz = new Junk("this.jaz");
-
- this.tom = new Junk("this.tom");
- this.dick = new Junk("this.dick");
- this.harry = new Junk("this.harry");
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testCollectionSynchronization() {
- SimpleCollectionValueModel<Junk> collectionHolder = this.buildCollectionHolder();
- ListValueModel<Junk> listValueModel = new ItemPropertyListValueModelAdapter<Junk>(collectionHolder, Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.add(this.tom);
- collectionHolder.add(this.dick);
- collectionHolder.add(this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.remove(this.foo);
- collectionHolder.remove(this.jar);
- collectionHolder.remove(this.harry);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.setCollection(this.buildCollection());
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- public void testListSynchronization() {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemPropertyListValueModelAdapter<Junk>(listHolder, Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.add(6, this.tom);
- listHolder.add(7, this.dick);
- listHolder.add(8, this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.remove(8);
- listHolder.remove(0);
- listHolder.remove(4);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- // test concurrent modification exception
- listHolder.setList(this.buildList());
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- private void compare(ListValueModel<Junk> listValueModel, List<Junk> list) {
- assertEquals(listValueModel.size(), list.size());
- for (int i = 0; i < listValueModel.size(); i++) {
- assertEquals(listValueModel.get(i), list.get(i));
- }
- }
-
- public void testCollectionSort() {
- this.verifyCollectionSort(null);
- }
-
- public void testListSort() {
- this.verifyListSort(null);
- }
-
- public void testCustomCollectionSort() {
- this.verifyCollectionSort(this.buildCustomComparator());
- }
-
- public void testCustomListSort() {
- this.verifyListSort(this.buildCustomComparator());
- }
-
- private Comparator<Junk> buildCustomComparator() {
- // sort with reverse order
- return new Comparator<Junk>() {
- public int compare(Junk o1, Junk o2) {
- return o2.compareTo(o1);
- }
- };
- }
-
- private void verifyCollectionSort(Comparator<Junk> comparator) {
- SimpleCollectionValueModel<Junk> collectionHolder = this.buildCollectionHolder();
- ListValueModel<Junk> listValueModel = new ItemPropertyListValueModelAdapter<Junk>(new SortedListValueModelAdapter<Junk>(collectionHolder, comparator), Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- collectionHolder.add(this.tom);
- collectionHolder.add(this.dick);
- collectionHolder.add(this.harry);
- assertEquals(9, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- collectionHolder.remove(this.foo);
- collectionHolder.remove(this.jar);
- collectionHolder.remove(this.harry);
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- collectionHolder.setCollection(this.buildCollection());
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
- }
-
- private void verifyListSort(Comparator<Junk> comparator) {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemPropertyListValueModelAdapter<Junk>(new SortedListValueModelAdapter<Junk>(listHolder, comparator), Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- listHolder.add(0, this.tom);
- listHolder.add(0, this.dick);
- listHolder.add(0, this.harry);
- assertEquals(9, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- listHolder.remove(8);
- listHolder.remove(4);
- listHolder.remove(0);
- listHolder.remove(5);
- assertEquals(5, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- listHolder.setList(this.buildList());
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
- }
-
- private void compareSort(ListValueModel<Junk> listValueModel, List<Junk> list, Comparator<Junk> comparator) {
- SortedSet<Junk> ss = new TreeSet<Junk>(comparator);
- for (int i = 0; i < listValueModel.size(); i++) {
- ss.add(listValueModel.get(i));
- }
- assertEquals(ss.size(), list.size());
- for (Iterator<Junk> stream1 = ss.iterator(), stream2 = list.iterator(); stream1.hasNext(); ) {
- assertEquals(stream1.next(), stream2.next());
- }
- }
-
- public void testHasListeners() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertFalse(this.foo.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- assertFalse(this.jaz.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertFalse(this.jaz.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
-
- ListValueModel<Junk> listValueModel = new ItemPropertyListValueModelAdapter<Junk>(new SortedListValueModelAdapter<Junk>(listHolder), Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertFalse(this.foo.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- assertFalse(this.jaz.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertFalse(this.jaz.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- this.verifyHasNoListeners(listValueModel);
-
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.foo.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertTrue(this.foo.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- assertTrue(this.jaz.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertTrue(this.jaz.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- this.verifyHasListeners(listValueModel);
-
- listValueModel.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertFalse(this.foo.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- assertFalse(this.jaz.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertFalse(this.jaz.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- this.verifyHasNoListeners(listValueModel);
- }
-
- public void testGetSize() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemPropertyListValueModelAdapter<Junk>(new SortedListValueModelAdapter<Junk>(listHolder), Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(6, listValueModel.size());
- assertEquals(6, synchList.size());
- }
-
- public void testGet() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new SortedListValueModelAdapter<Junk>(new ItemPropertyListValueModelAdapter<Junk>(listHolder, Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(this.bar, listValueModel.get(0));
- assertEquals(this.bar, synchList.get(0));
- this.bar.setName("zzz");
- assertEquals(this.bar, listValueModel.get(5));
- assertEquals(this.bar, synchList.get(5));
- this.bar.setName("this.bar");
- }
-
- private void verifyHasNoListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private void verifyHasListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private SimpleCollectionValueModel<Junk> buildCollectionHolder() {
- return new SimpleCollectionValueModel<Junk>(this.buildCollection());
- }
-
- private Collection<Junk> buildCollection() {
- Bag<Junk> bag = new HashBag<Junk>();
- this.populateCollection(bag);
- return bag;
- }
-
- private SimpleListValueModel<Junk> buildListHolder() {
- return new SimpleListValueModel<Junk>(this.buildList());
- }
-
- private List<Junk> buildList() {
- List<Junk> list = new ArrayList<Junk>();
- this.populateCollection(list);
- return list;
- }
-
- private void populateCollection(Collection<Junk> c) {
- c.add(this.foo);
- c.add(this.bar);
- c.add(this.baz);
- c.add(this.joo);
- c.add(this.jar);
- c.add(this.jaz);
- }
-
-
- // ********** Junk class **********
-
- private class Junk extends AbstractModel implements Displayable {
- private String name;
- public Junk(String name) {
- this.name = name;
- }
- public String displayString() {
- return this.name;
- }
- public Icon icon() {
- return null;
- }
- public int compareTo(Displayable o) {
- return DEFAULT_COMPARATOR.compare(this, o);
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(DISPLAY_STRING_PROPERTY, old, name);
- }
- @Override
- public String toString() {
- return "Junk(" + this.name + ")";
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java
deleted file mode 100644
index 66146ded02..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.ItemStateListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ItemStateListValueModelAdapterTests extends TestCase {
- private Junk foo;
- private Junk bar;
- private Junk baz;
- private Junk joo;
- private Junk jar;
- private Junk jaz;
-
- private Junk tom;
- private Junk dick;
- private Junk harry;
-
- public ItemStateListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.foo = new Junk("this.foo");
- this.bar = new Junk("this.bar");
- this.baz = new Junk("this.baz");
- this.joo = new Junk("this.joo");
- this.jar = new Junk("this.jar");
- this.jaz = new Junk("this.jaz");
-
- this.tom = new Junk("this.tom");
- this.dick = new Junk("this.dick");
- this.harry = new Junk("this.harry");
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testCollectionSynchronization() {
- SimpleCollectionValueModel<Junk> collectionHolder = this.buildCollectionHolder();
- ListValueModel<Junk> listValueModel = new ItemStateListValueModelAdapter<Junk>(collectionHolder);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.add(this.tom);
- collectionHolder.add(this.dick);
- collectionHolder.add(this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.remove(this.foo);
- collectionHolder.remove(this.jar);
- collectionHolder.remove(this.harry);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- public void testListSynchronization() {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemStateListValueModelAdapter<Junk>(listHolder);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.add(6, this.tom);
- listHolder.add(7, this.dick);
- listHolder.add(8, this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.remove(8);
- listHolder.remove(0);
- listHolder.remove(4);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- private void compare(ListValueModel<Junk> listValueModel, List<Junk> list) {
- assertEquals(listValueModel.size(), list.size());
- for (int i = 0; i < listValueModel.size(); i++) {
- assertEquals(listValueModel.get(i), list.get(i));
- }
- }
-
- public void testCollectionSort() {
- this.verifyCollectionSort(null);
- }
-
- public void testListSort() {
- this.verifyListSort(null);
- }
-
- public void testCustomCollectionSort() {
- this.verifyCollectionSort(this.buildCustomComparator());
- }
-
- public void testCustomListSort() {
- this.verifyListSort(this.buildCustomComparator());
- }
-
- private Comparator<Junk> buildCustomComparator() {
- // sort with reverse order
- return new Comparator<Junk>() {
- public int compare(Junk o1, Junk o2) {
- return o2.compareTo(o1);
- }
- };
- }
-
- private void verifyCollectionSort(Comparator<Junk> comparator) {
- SimpleCollectionValueModel<Junk> collectionHolder = this.buildCollectionHolder();
- ListValueModel<Junk> listValueModel = new ItemStateListValueModelAdapter<Junk>(new SortedListValueModelAdapter<Junk>(collectionHolder, comparator));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- collectionHolder.add(this.tom);
- collectionHolder.add(this.dick);
- collectionHolder.add(this.harry);
- assertEquals(9, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- collectionHolder.remove(this.foo);
- collectionHolder.remove(this.jar);
- collectionHolder.remove(this.harry);
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
- }
-
- private void verifyListSort(Comparator<Junk> comparator) {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemStateListValueModelAdapter<Junk>(new SortedListValueModelAdapter<Junk>(listHolder, comparator));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- listHolder.add(0, this.tom);
- listHolder.add(0, this.dick);
- listHolder.add(0, this.harry);
- assertEquals(9, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- listHolder.remove(8);
- listHolder.remove(4);
- listHolder.remove(0);
- listHolder.remove(5);
- assertEquals(5, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
- }
-
- private void compareSort(ListValueModel<Junk> listValueModel, List<Junk> list, Comparator<Junk> comparator) {
- SortedSet<Junk> ss = new TreeSet<Junk>(comparator);
- for (int i = 0; i < listValueModel.size(); i++) {
- ss.add(listValueModel.get(i));
- }
- assertEquals(ss.size(), list.size());
- for (Iterator<Junk> stream1 = ss.iterator(), stream2 = list.iterator(); stream1.hasNext(); ) {
- assertEquals(stream1.next(), stream2.next());
- }
- }
-
- public void testHasListeners() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyStateChangeListeners());
- assertFalse(this.foo.hasAnyStateChangeListeners());
- assertFalse(this.jaz.hasAnyStateChangeListeners());
- assertFalse(this.jaz.hasAnyStateChangeListeners());
-
- ListValueModel<Junk> listValueModel = new ItemStateListValueModelAdapter<Junk>(new SortedListValueModelAdapter<Junk>(listHolder));
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyStateChangeListeners());
- assertFalse(this.foo.hasAnyStateChangeListeners());
- assertFalse(this.jaz.hasAnyStateChangeListeners());
- assertFalse(this.jaz.hasAnyStateChangeListeners());
- this.verifyHasNoListeners(listValueModel);
-
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.foo.hasAnyStateChangeListeners());
- assertTrue(this.foo.hasAnyStateChangeListeners());
- assertTrue(this.jaz.hasAnyStateChangeListeners());
- assertTrue(this.jaz.hasAnyStateChangeListeners());
- this.verifyHasListeners(listValueModel);
-
- listValueModel.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyStateChangeListeners());
- assertFalse(this.foo.hasAnyStateChangeListeners());
- assertFalse(this.jaz.hasAnyStateChangeListeners());
- assertFalse(this.jaz.hasAnyStateChangeListeners());
- this.verifyHasNoListeners(listValueModel);
- }
-
- public void testGetSize() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemStateListValueModelAdapter<Junk>(new SortedListValueModelAdapter<Junk>(listHolder));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(6, listValueModel.size());
- assertEquals(6, synchList.size());
- }
-
- public void testGet() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new SortedListValueModelAdapter<Junk>(new ItemStateListValueModelAdapter<Junk>(listHolder));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(this.bar, listValueModel.get(0));
- assertEquals(this.bar, synchList.get(0));
- this.bar.setName("zzz");
- assertEquals(this.bar, listValueModel.get(5));
- assertEquals(this.bar, synchList.get(5));
- this.bar.setName("this.bar");
- }
-
- private void verifyHasNoListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private void verifyHasListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private SimpleCollectionValueModel<Junk> buildCollectionHolder() {
- return new SimpleCollectionValueModel<Junk>(this.buildCollection());
- }
-
- private Collection<Junk> buildCollection() {
- Bag<Junk> bag = new HashBag<Junk>();
- this.populateCollection(bag);
- return bag;
- }
-
- private SimpleListValueModel<Junk> buildListHolder() {
- return new SimpleListValueModel<Junk>(this.buildList());
- }
-
- private List<Junk> buildList() {
- List<Junk> list = new ArrayList<Junk>();
- this.populateCollection(list);
- return list;
- }
-
- private void populateCollection(Collection<Junk> c) {
- c.add(this.foo);
- c.add(this.bar);
- c.add(this.baz);
- c.add(this.joo);
- c.add(this.jar);
- c.add(this.jaz);
- }
-
- // ********** Junk class **********
- private class Junk extends AbstractModel implements Comparable<Junk> {
- private String name;
- public Junk(String name) {
- this.name = name;
- }
- public void setName(String name) {
- this.name = name;
- this.fireStateChanged();
- }
- public int compareTo(Junk j) {
- return this.name.compareTo(j.name);
- }
- @Override
- public String toString() {
- return "Junk(" + this.name + ")";
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/JptUtilityModelValueTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/JptUtilityModelValueTests.java
deleted file mode 100644
index e53070c828..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/JptUtilityModelValueTests.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import org.eclipse.jpt.utility.tests.internal.model.value.prefs.JptUtilityModelValuePrefsTests;
-import org.eclipse.jpt.utility.tests.internal.model.value.swing.JptUtilityModelValueSwingTests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptUtilityModelValueTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityModelValueTests.class.getPackage().getName());
-
- suite.addTest(JptUtilityModelValuePrefsTests.suite());
- suite.addTest(JptUtilityModelValueSwingTests.suite());
-
- suite.addTestSuite(BufferedWritablePropertyValueModelTests.class);
- suite.addTestSuite(CollectionAspectAdapterTests.class);
- suite.addTestSuite(CollectionListValueModelAdapterTests.class);
- suite.addTestSuite(CollectionPropertyValueModelAdapterTests.class);
- suite.addTestSuite(CompositeCollectionValueModelTests.class);
- suite.addTestSuite(CompositeListValueModelTests.class);
- suite.addTestSuite(ExtendedListValueModelWrapperTests.class);
- suite.addTestSuite(FilteringCollectionValueModelTests.class);
- suite.addTestSuite(FilteringPropertyValueModelTests.class);
- suite.addTestSuite(ItemCollectionListValueModelAdapterTests.class);
- suite.addTestSuite(ItemListListValueModelAdapterTests.class);
- suite.addTestSuite(ItemPropertyListValueModelAdapterTests.class);
- suite.addTestSuite(ItemStateListValueModelAdapterTests.class);
- suite.addTestSuite(ListAspectAdapterTests.class);
- suite.addTestSuite(ListCollectionValueModelAdapterTests.class);
- suite.addTestSuite(ListCuratorTests.class);
- suite.addTestSuite(NullCollectionValueModelTests.class);
- suite.addTestSuite(NullListValueModelTests.class);
- suite.addTestSuite(NullPropertyValueModelTests.class);
- suite.addTestSuite(PropertyAspectAdapterTests.class);
- suite.addTestSuite(PropertyCollectionValueModelAdapterTests.class);
- suite.addTestSuite(PropertyListValueModelAdapterTests.class);
- suite.addTestSuite(StaticCollectionValueModelTests.class);
- suite.addTestSuite(StaticListValueModelTests.class);
- suite.addTestSuite(SimpleCollectionValueModelTests.class);
- suite.addTestSuite(SimpleListValueModelTests.class);
- suite.addTestSuite(SimplePropertyValueModelTests.class);
- suite.addTestSuite(SortedListValueModelAdapterTests.class);
- suite.addTestSuite(StaticValueModelTests.class);
- suite.addTestSuite(TransformationListValueModelAdapterTests.class);
- suite.addTestSuite(TransformationListValueModelAdapterTests.TransformerTests.class);
- suite.addTestSuite(TransformationPropertyValueModelTests.class);
- suite.addTestSuite(TreeAspectAdapterTests.class);
- suite.addTestSuite(ValueCollectionAdapterTests.class);
- suite.addTestSuite(ValueListAdapterTests.class);
- suite.addTestSuite(ValuePropertyAdapterTests.class);
- suite.addTestSuite(ValueStateAdapterTests.class);
-
- return suite;
- }
-
- private JptUtilityModelValueTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListAspectAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListAspectAdapterTests.java
deleted file mode 100644
index fe825baa96..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListAspectAdapterTests.java
+++ /dev/null
@@ -1,475 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ListAspectAdapterTests extends TestCase {
- private TestSubject subject1;
- private WritablePropertyValueModel<TestSubject> subjectHolder1;
- private LocalListAspectAdapter aa1;
- private ListChangeEvent event1;
- private ListChangeListener listener1;
-
- private TestSubject subject2;
-
- public ListAspectAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.subject1 = new TestSubject();
- this.subject1.addNames(this.subject1Names());
- this.subject1.addDescriptions(this.subject1Descriptions());
- this.subjectHolder1 = new SimplePropertyValueModel<TestSubject>(this.subject1);
- this.aa1 = this.buildAspectAdapter(this.subjectHolder1);
- this.listener1 = this.buildValueChangeListener1();
- this.aa1.addListChangeListener(ListValueModel.LIST_VALUES, this.listener1);
- this.event1 = null;
-
- this.subject2 = new TestSubject();
- this.subject2.addNames(this.subject2Names());
- this.subject2.addDescriptions(this.subject2Descriptions());
- }
-
- private List<String> subject1Names() {
- List<String> result = new ArrayList<String>();
- result.add("foo");
- result.add("bar");
- result.add("baz");
- result.add("bam");
- return result;
- }
-
- private List<String> subject1Descriptions() {
- List<String> result = new ArrayList<String>();
- result.add("this.subject1 description1");
- result.add("this.subject1 description2");
- return result;
- }
-
- private List<String> subject2Names() {
- List<String> result = new ArrayList<String>();
- result.add("joo");
- result.add("jar");
- result.add("jaz");
- result.add("jam");
- return result;
- }
-
- private List<String> subject2Descriptions() {
- List<String> result = new ArrayList<String>();
- result.add("this.subject2 description1");
- result.add("this.subject2 description2");
- return result;
- }
-
- private LocalListAspectAdapter buildAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- return new LocalListAspectAdapter(subjectHolder);
- }
-
- private ListChangeListener buildValueChangeListener1() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent e) {
- ListAspectAdapterTests.this.value1Changed(e);
- }
- public void itemsRemoved(ListChangeEvent e) {
- ListAspectAdapterTests.this.value1Changed(e);
- }
- public void itemsReplaced(ListChangeEvent e) {
- ListAspectAdapterTests.this.value1Changed(e);
- }
- public void itemsMoved(ListChangeEvent e) {
- ListAspectAdapterTests.this.value1Changed(e);
- }
- public void listCleared(ListChangeEvent e) {
- ListAspectAdapterTests.this.value1Changed(e);
- }
- public void listChanged(ListChangeEvent e) {
- ListAspectAdapterTests.this.value1Changed(e);
- }
- };
- }
-
- void value1Changed(ListChangeEvent e) {
- this.event1 = e;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSubjectHolder() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- this.subjectHolder1.setValue(this.subject2);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(-1, this.event1.getIndex());
- assertFalse(this.event1.items().hasNext());
- assertEquals(this.subject2Names(), CollectionTools.list(this.aa1.listIterator()));
-
- this.event1 = null;
- this.subjectHolder1.setValue(null);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(-1, this.event1.getIndex());
- assertFalse(this.event1.items().hasNext());
- assertFalse(this.aa1.iterator().hasNext());
-
- this.event1 = null;
- this.subjectHolder1.setValue(this.subject1);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(-1, this.event1.getIndex());
- assertFalse(this.event1.items().hasNext());
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testAdd() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- this.subject1.addName("jam");
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(this.subject1Names().size(), this.event1.getIndex());
- assertEquals("jam", this.event1.items().next());
- List<String> namesPlus = this.subject1Names();
- namesPlus.add("jam");
- assertEquals(namesPlus, CollectionTools.list(this.aa1.listIterator()));
-
- this.event1 = null;
- this.aa1.add(2, "jaz");
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(2, this.event1.getIndex());
- assertEquals("jaz", this.event1.items().next());
- namesPlus.add(2, "jaz");
- assertEquals(namesPlus, CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testDefaultAdd() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- List<String> items = new ArrayList<String>();
- items.add("joo");
- items.add("jar");
- items.add("jaz");
- items.add("jam");
-
- this.event1 = null;
- this.aa1.addAll(2, items);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(5, this.event1.getIndex()); // only the last "add" event will still be there
- assertEquals("jam", this.event1.items().next());
- List<String> namesPlus = this.subject1Names();
- namesPlus.addAll(2, items);
- assertEquals(namesPlus, CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testRemove() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- String removedName = this.subject1.removeName(0); // should be "foo"
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(0, this.event1.getIndex());
- assertEquals(removedName, this.event1.items().next());
- List<String> namesMinus = this.subject1Names();
- namesMinus.remove(0);
- assertEquals(namesMinus, CollectionTools.list(this.aa1.listIterator()));
-
- this.event1 = null;
- Object removedItem = this.aa1.remove(0);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(0, this.event1.getIndex());
- assertEquals(removedItem, this.event1.items().next());
- namesMinus.remove(0);
- assertEquals(namesMinus, CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testDefaultLength() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- List<String> items = new ArrayList<String>();
- items.add("bar");
- items.add("baz");
-
- this.event1 = null;
- this.aa1.remove(1, 2);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(1, this.event1.getIndex()); // only the last "remove" event will still be there
- assertEquals("baz", this.event1.items().next());
- List<String> namesPlus = this.subject1Names();
- namesPlus.remove(1);
- namesPlus.remove(1);
- assertEquals(namesPlus, CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testReplace() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- String replacedName = this.subject1.setName(0, "jelly"); // should be "foo"
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(0, this.event1.getIndex());
- assertEquals("jelly", this.event1.items().next());
- assertEquals(replacedName, this.event1.replacedItems().next());
- List<String> namesChanged = this.subject1Names();
- namesChanged.set(0, "jelly");
- assertEquals(namesChanged, CollectionTools.list(this.aa1.listIterator()));
-
- this.event1 = null;
- replacedName = this.subject1.setName(1, "roll"); // should be "bar"
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(1, this.event1.getIndex());
- assertEquals("roll", this.event1.items().next());
- assertEquals(replacedName, this.event1.replacedItems().next());
- namesChanged = this.subject1Names();
- namesChanged.set(0, "jelly");
- namesChanged.set(1, "roll");
- assertEquals(namesChanged, CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testListChange() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- this.subject1.addTwoNames("jam", "jaz");
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(-1, this.event1.getIndex());
- assertFalse(this.event1.items().hasNext());
- List<String> namesPlus2 = this.subject1Names();
- namesPlus2.add(0, "jaz");
- namesPlus2.add(0, "jam");
- assertEquals(namesPlus2, CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testIterator() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.subject1.names()));
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testGet() {
- assertEquals(this.subject1Names().get(0), this.subject1.getName(0));
- assertEquals(this.subject1Names().get(0), this.aa1.get(0));
- }
-
- public void testSize() {
- assertEquals(this.subject1Names().size(), CollectionTools.size(this.subject1.names()));
- assertEquals(this.subject1Names().size(), CollectionTools.size(this.aa1.listIterator()));
- }
-
- public void testHasListeners() {
- assertTrue(this.aa1.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.subject1.hasAnyListChangeListeners(TestSubject.NAMES_LIST));
- this.aa1.removeListChangeListener(ListValueModel.LIST_VALUES, this.listener1);
- assertFalse(this.subject1.hasAnyListChangeListeners(TestSubject.NAMES_LIST));
- assertFalse(this.aa1.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ListChangeListener listener2 = this.buildValueChangeListener1();
- this.aa1.addListChangeListener(listener2);
- assertTrue(this.aa1.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.subject1.hasAnyListChangeListeners(TestSubject.NAMES_LIST));
- this.aa1.removeListChangeListener(listener2);
- assertFalse(this.subject1.hasAnyListChangeListeners(TestSubject.NAMES_LIST));
- assertFalse(this.aa1.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
-
- // ********** inner class **********
-
- private class TestSubject extends AbstractModel {
- private List<String> names;
- public static final String NAMES_LIST = "names";
- private List<String> descriptions;
- public static final String DESCRIPTIONS_LIST = "descriptions";
-
- public TestSubject() {
- this.names = new ArrayList<String>();
- this.descriptions = new ArrayList<String>();
- }
- public ListIterator<String> names() {
- return new ReadOnlyListIterator<String>(this.names);
- }
- public String getName(int index) {
- return this.names.get(index);
- }
- public void addName(int index, String name) {
- this.names.add(index, name);
- this.fireItemAdded(NAMES_LIST, index, name);
- }
- public void addName(String name) {
- this.addName(this.names.size(), name);
- }
- public void addNames(ListIterator<String> newNames) {
- while (newNames.hasNext()) {
- this.addName(newNames.next());
- }
- }
- public void addNames(List<String> newNames) {
- this.addNames(newNames.listIterator());
- }
- public void addTwoNames(String name1, String name2) {
- this.names.add(0, name2);
- this.names.add(0, name1);
- this.fireListChanged(NAMES_LIST);
- }
- public String removeName(int index) {
- String removedName = this.names.remove(index);
- this.fireItemRemoved(NAMES_LIST, index, removedName);
- return removedName;
- }
- public String setName(int index, String name) {
- String replacedName = this.names.set(index, name);
- this.fireItemReplaced(NAMES_LIST, index, name, replacedName);
- return replacedName;
- }
- public ListIterator<String> descriptions() {
- return new ReadOnlyListIterator<String>(this.descriptions);
- }
- public String getDescription(int index) {
- return this.descriptions.get(index);
- }
- public void addDescription(int index, String description) {
- this.descriptions.add(index, description);
- this.fireItemAdded(DESCRIPTIONS_LIST, index, description);
- }
- public void addDescription(String description) {
- this.addDescription(this.descriptions.size(), description);
- }
- public void addDescriptions(ListIterator<String> newDescriptions) {
- while (newDescriptions.hasNext()) {
- this.addDescription(newDescriptions.next());
- }
- }
- public void addDescriptions(List<String> newDescriptions) {
- this.addDescriptions(newDescriptions.listIterator());
- }
- public String removeDescription(int index) {
- String removedDescription = this.descriptions.remove(index);
- this.fireItemRemoved(DESCRIPTIONS_LIST, index, removedDescription);
- return removedDescription;
- }
- public String setDescription(int index, String description) {
- String replacedDescription = this.descriptions.set(index, description);
- this.fireItemReplaced(DESCRIPTIONS_LIST, index, description, replacedDescription);
- return replacedDescription;
- }
- }
-
-
- // this is not a typical aspect adapter - the value is determined by the aspect name
- private class LocalListAspectAdapter extends ListAspectAdapter<TestSubject, String> {
-
- LocalListAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- super(subjectHolder, TestSubject.NAMES_LIST);
- }
-
- @Override
- protected ListIterator<String> listIterator_() {
- if (this.listNames[0] == TestSubject.NAMES_LIST) {
- return this.subject.names();
- } else if (this.listNames[0] == TestSubject.DESCRIPTIONS_LIST) {
- return this.subject.descriptions();
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.listNames[0]);
- }
- }
-
- public void add(int index, Object item) {
- if (this.listNames[0] == TestSubject.NAMES_LIST) {
- this.subject.addName(index, (String) item);
- } else if (this.listNames[0] == TestSubject.DESCRIPTIONS_LIST) {
- this.subject.addDescription(index, (String) item);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.listNames[0]);
- }
- }
-
- public void addAll(int index, List<String> items) {
- for (int i = 0; i < items.size(); i++) {
- this.add(index + i, items.get(i));
- }
- }
-
- public String remove(int index) {
- if (this.listNames[0] == TestSubject.NAMES_LIST) {
- return this.subject.removeName(index);
- } else if (this.listNames[0] == TestSubject.DESCRIPTIONS_LIST) {
- return this.subject.removeDescription(index);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.listNames[0]);
- }
- }
-
- public List<String> remove(int index, int length) {
- List<String> removedItems = new ArrayList<String>(length);
- for (int i = 0; i < length; i++) {
- removedItems.add(this.remove(index));
- }
- return removedItems;
- }
-
- public Object replace(int index, Object item) {
- if (this.listNames[0] == TestSubject.NAMES_LIST) {
- return this.subject.setName(index, (String) item);
- } else if (this.listNames[0] == TestSubject.DESCRIPTIONS_LIST) {
- return this.subject.setDescription(index, (String) item);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.listNames[0]);
- }
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java
deleted file mode 100644
index 6ec4c5d711..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.swing.JList;
-
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.ListCollectionValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ListCollectionValueModelAdapterTests extends TestCase {
- CollectionValueModel<String> adapter;
- private SimpleListValueModel<String> wrappedListHolder;
- private List<String> wrappedList;
-
- public ListCollectionValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.wrappedList = new ArrayList<String>();
- this.wrappedListHolder = new SimpleListValueModel<String>(this.wrappedList);
- this.adapter = new ListCollectionValueModelAdapter<String>(this.wrappedListHolder);
- }
-
- private Collection<String> wrappedCollection() {
- return CollectionTools.collection(this.wrappedList.iterator());
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionChangeEvent e) {
- // override failure
- }
- });
- this.wrappedListHolder.add(0, "foo");
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
- }
-
- public void testStaleValues() {
- CollectionChangeListener listener = new TestListener() {
- @Override
- public void itemsAdded(CollectionChangeEvent e) {/* OK */}
- };
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- this.wrappedListHolder.add(0, "foo");
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
-
- this.adapter.removeCollectionChangeListener(CollectionValueModel.VALUES, listener);
- adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(0, adapterCollection.size());
- assertEquals(new HashBag<String>(), adapterCollection);
-
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
- }
-
- public void testAdd() {
- Bag<String> synchCollection = new CoordinatedBag<String>(this.adapter);
- List<String> synchList = new CoordinatedList<String>(this.wrappedListHolder);
- this.wrappedListHolder.add(0, "foo");
- assertTrue(this.wrappedList.contains("foo"));
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- this.wrappedListHolder.add(3, "joo");
- this.wrappedListHolder.add(4, "jar");
- this.wrappedListHolder.add(5, "jaz");
- assertEquals(6, this.wrappedList.size());
-
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(this.wrappedCollection(), adapterCollection);
- assertEquals(this.wrappedCollection(), CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection(), synchCollection);
- }
-
- public void testRemove() {
- Bag<String> synchCollection = new CoordinatedBag<String>(this.adapter);
- List<String> synchList = new CoordinatedList<String>(this.wrappedListHolder);
- this.wrappedListHolder.add(0, "foo");
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- this.wrappedListHolder.add(3, "joo");
- this.wrappedListHolder.add(4, "jar");
- this.wrappedListHolder.add(5, "jaz");
- assertEquals("jaz", this.wrappedListHolder.remove(5));
- assertFalse(this.wrappedList.contains("jaz"));
- assertEquals("foo", this.wrappedListHolder.remove(0));
- assertFalse(this.wrappedList.contains("foo"));
- assertEquals(4, this.wrappedList.size());
-
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(this.wrappedCollection(), adapterCollection);
- assertEquals(this.wrappedCollection(), CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection(), synchCollection);
- }
-
- public void testListSynch() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionChangeEvent e) {
- // override failure
- }
- @Override
- public void itemsRemoved(CollectionChangeEvent e) {
- // override failure
- }
- });
- this.wrappedListHolder.add(0, "foo");
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- this.wrappedListHolder.add(3, "joo");
- this.wrappedListHolder.add(4, "jar");
- this.wrappedListHolder.add(5, "jaz");
- this.wrappedListHolder.remove(5);
- assertFalse(this.wrappedList.contains("jaz"));
- this.wrappedListHolder.remove(0);
- assertFalse(this.wrappedList.contains("foo"));
- assertEquals(4, this.wrappedList.size());
-
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(this.wrappedCollection(), adapterCollection);
- }
-
- public void testReplace() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionChangeEvent e) {
- // override failure
- }
- @Override
- public void itemsRemoved(CollectionChangeEvent e) {
- // override failure
- }
- });
- this.wrappedListHolder.add(0, "foo");
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(3, adapterCollection.size());
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsRemoved(CollectionChangeEvent e) {
- assertEquals("foo", e.items().next());
- assertFalse(CollectionTools.contains(ListCollectionValueModelAdapterTests.this.adapter.iterator(), "joo"));
- assertEquals(2, ListCollectionValueModelAdapterTests.this.adapter.size());
- }
- @Override
- public void itemsAdded(CollectionChangeEvent e) {
- assertEquals("joo", e.items().next());
- assertEquals(3, ListCollectionValueModelAdapterTests.this.adapter.size());
- }
- });
- this.wrappedListHolder.set(0, "joo");
- adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- CoordinatedBag<String> synchCollection = new CoordinatedBag<String>(this.adapter);
- assertTrue(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.adapter.removeCollectionChangeListener(CollectionValueModel.VALUES, synchCollection);
- assertFalse(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.adapter.addCollectionChangeListener(synchCollection);
- assertTrue(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.adapter.removeCollectionChangeListener(synchCollection);
- assertFalse(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
- public void testListChangedToEmpty() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionChangeEvent e) {/* OK */}
- @Override
- public void itemsRemoved(CollectionChangeEvent e) {/* OK */}
- });
- this.wrappedListHolder.add(0, "foo");
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- JList jList = new JList(new ListModelAdapter(this.adapter));
- this.wrappedListHolder.setList(new ArrayList<String>());
- assertEquals(0, jList.getModel().getSize());
- }
-
- public void testCollectionChangedFromEmpty() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionChangeEvent e) {/* OK */}
- @Override
- public void itemsRemoved(CollectionChangeEvent e) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- ArrayList<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- this.wrappedListHolder.setList(list);
- assertEquals(2, jList.getModel().getSize());
- }
-
- public void testCollectionChangedFromEmptyToEmpty() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionChangeEvent e) {/* OK */}
- @Override
- public void itemsRemoved(CollectionChangeEvent e) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- ArrayList<String> list = new ArrayList<String>();
- this.wrappedListHolder.setList(list);
- assertEquals(0, jList.getModel().getSize());
- }
-
-
- // ********** inner class **********
-
- class TestListener implements CollectionChangeListener {
- public void itemsAdded(CollectionChangeEvent e) {
- fail("unexpected event");
- }
- public void itemsRemoved(CollectionChangeEvent e) {
- fail("unexpected event");
- }
- public void collectionCleared(CollectionChangeEvent e) {
- fail("unexpected event");
- }
- public void collectionChanged(CollectionChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCuratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCuratorTests.java
deleted file mode 100644
index 692bbcfa54..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCuratorTests.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.ListCurator;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public final class ListCuratorTests
- extends TestCase
-{
- private TestSubject subject1;
- private WritablePropertyValueModel<TestSubject> subjectHolder1;
-
- private ListCurator<TestSubject, String> curator;
- private ListChangeListener listener1;
- private ListChangeEvent event1;
-
- private TestSubject subject2;
-
- public ListCuratorTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.subject1 = new TestSubject(this.subject1Names());
- this.subjectHolder1 = new SimplePropertyValueModel<TestSubject>(this.subject1);
- this.curator = this.buildListCurator(this.subjectHolder1);
- this.listener1 = this.buildListChangeListener1();
- this.curator.addListChangeListener(ListValueModel.LIST_VALUES, this.listener1);
- this.event1 = null;
-
- this.subject2 = new TestSubject(this.subject2Names());
- }
-
- private List<String> subject1Names() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("alpha");
- list.add("bravo");
- list.add("charlie");
- list.add("delta");
- return list;
- }
-
- private List<String> subject2Names() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("echo");
- list.add("foxtrot");
- list.add("glove");
- list.add("hotel");
- return list;
- }
-
- private ListCurator<TestSubject, String> buildListCurator(PropertyValueModel<TestSubject> subjectHolder) {
- return new ListCurator<TestSubject, String>(subjectHolder) {
- @Override
- public Iterator<String> iteratorForRecord() {
- return this.subject.strings();
- }
- };
- }
-
- private ListChangeListener buildListChangeListener1() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- public void itemsRemoved(ListChangeEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- public void itemsReplaced(ListChangeEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- public void itemsMoved(ListChangeEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- public void listCleared(ListChangeEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- public void listChanged(ListChangeEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- };
- }
-
- void value1Changed(ListChangeEvent e) {
- this.event1 = e;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSubjectHolder() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.curator.listIterator()));
- assertNull(this.event1);
-
- this.subjectHolder1.setValue(this.subject2);
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(-1, this.event1.getIndex());
- assertFalse(this.event1.items().hasNext());
- assertEquals(this.subject2Names(), CollectionTools.list(this.curator.listIterator()));
-
- this.event1 = null;
- this.subjectHolder1.setValue(null);
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(-1, this.event1.getIndex());
- assertFalse(this.event1.items().hasNext());
- assertFalse(this.curator.iterator().hasNext());
-
- this.event1 = null;
- this.subjectHolder1.setValue(this.subject1);
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(-1, this.event1.getIndex());
- assertFalse(this.event1.items().hasNext());
- assertEquals(this.subject1Names(), CollectionTools.list(this.curator.listIterator()));
- }
-
- public void testAdd() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.curator.listIterator()));
- assertNull(this.event1);
-
- this.subject1.addString("echo");
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(this.subject1Names().size(), this.event1.getIndex());
- assertEquals("echo", this.event1.items().next());
- List<String> stringsPlus = this.subject1Names();
- stringsPlus.add("echo");
- assertEquals(stringsPlus, CollectionTools.list(this.curator.listIterator()));
-
- this.event1 = null;
- this.subject1.addString(0, "zulu");
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(0, this.event1.getIndex());
- assertEquals("zulu", this.event1.items().next());
- stringsPlus.add(0, "zulu");
- assertEquals(stringsPlus, CollectionTools.list(this.curator.listIterator()));
- }
-
- public void testRemove() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.curator.listIterator()));
- assertNull(this.event1);
-
- String removedString = this.subject1.removeString(0); // should be "alpha"
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(0, this.event1.getIndex());
- assertEquals(removedString, this.event1.items().next());
- List<String> stringsMinus = this.subject1Names();
- stringsMinus.remove(0);
- assertEquals(stringsMinus, CollectionTools.list(this.curator.listIterator()));
-
- removedString = this.subject1.removeString(2); // should be "delta"
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(2, this.event1.getIndex());
- assertEquals(removedString, this.event1.items().next());
- stringsMinus.remove(2);
- assertEquals(stringsMinus, CollectionTools.list(this.curator.listIterator()));
- }
-
- public void testCompleteListChange() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.curator.listIterator()));
- assertNull(this.event1);
-
- this.subject1.setStrings(this.subject2Names());
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- List<String> newStrings = this.subject2Names();
- assertEquals(newStrings, CollectionTools.list(this.curator.listIterator()));
- }
-
- public void testPartialListChange() {
- List<String> startingList = CollectionTools.list(this.curator.listIterator());
- assertEquals(this.subject1Names(), startingList);
- assertNull(this.event1);
-
- String identicalString = startingList.get(1); // should be "bravo"
- String nonidenticalString = startingList.get(0); // should be "alpha"
- List<String> newStrings = CollectionTools.list(new String[] {new String("bravo"), new String("alpha"), "echo", "delta", "foxtrot"});
- this.subject1.setStrings(newStrings);
-
- List<String> finalList = CollectionTools.list(this.curator.listIterator());
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(newStrings, finalList);
- assertTrue(identicalString == finalList.get(0));
- assertTrue(nonidenticalString != finalList.get(1));
- }
-
- public void testIterator() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.subject1.strings()));
- assertEquals(this.subject1Names(), CollectionTools.list(this.curator.listIterator()));
- }
-
- public void testGet() {
- assertEquals(this.subject1Names().get(0), this.subject1.getString(0));
- assertEquals(this.subject1Names().get(0), this.curator.get(0));
- }
-
- public void testSize() {
- assertEquals(this.subject1Names().size(), CollectionTools.size(this.subject1.strings()));
- assertEquals(this.subject1Names().size(), CollectionTools.size(this.curator.listIterator()));
- assertEquals(this.subject1Names().size(), this.curator.size());
- }
-
- public void testHasListeners() {
- assertTrue(this.curator.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.subject1.hasAnyStateChangeListeners());
- this.curator.removeListChangeListener(ListValueModel.LIST_VALUES, this.listener1);
- assertFalse(this.subject1.hasAnyStateChangeListeners());
- assertFalse(this.curator.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ListChangeListener listener2 = this.buildListChangeListener1();
- this.curator.addListChangeListener(listener2);
- assertTrue(this.curator.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.subject1.hasAnyStateChangeListeners());
- this.curator.removeListChangeListener(listener2);
- assertFalse(this.subject1.hasAnyStateChangeListeners());
- assertFalse(this.curator.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
-
- // **************** Inner Class *******************************************
-
- class TestSubject extends AbstractModel {
- private List<String> strings;
-
- public TestSubject() {
- this.strings = new ArrayList<String>();
- }
-
- public TestSubject(List<String> strings) {
- this();
- this.setStrings(strings);
- }
-
- public String getString(int index) {
- return this.strings.get(index);
- }
-
- public ListIterator<String> strings() {
- return new ReadOnlyListIterator<String>(this.strings);
- }
-
- public void addString(int index, String string) {
- this.strings.add(index, string);
- this.fireStateChanged();
- }
-
- public void addString(String string) {
- this.addString(this.strings.size(), string);
- }
-
- public String removeString(int index) {
- String string = this.strings.get(index);
- this.removeString(string);
- return string;
- }
-
- public void removeString(String string) {
- this.strings.remove(string);
- this.fireStateChanged();
- }
-
- public void setStrings(List<String> strings) {
- this.strings = new ArrayList<String>(strings);
- this.fireStateChanged();
- }
-
- public void setStrings(String[] strings) {
- this.strings = CollectionTools.list(strings);
- this.fireStateChanged();
- }
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullCollectionValueModelTests.java
deleted file mode 100644
index 3fefeb9437..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullCollectionValueModelTests.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.value.NullCollectionValueModel;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class NullCollectionValueModelTests extends TestCase {
- private CollectionValueModel<Object> collectionHolder;
-
- public NullCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.collectionHolder = new NullCollectionValueModel<Object>();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSize() {
- assertEquals(0, this.collectionHolder.size());
- }
-
- public void testIterator() {
- assertFalse(this.collectionHolder.iterator().hasNext());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullListValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullListValueModelTests.java
deleted file mode 100644
index b4fed3568b..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullListValueModelTests.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.value.NullListValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class NullListValueModelTests extends TestCase {
- private ListValueModel<Object> listHolder;
-
- public NullListValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.listHolder = new NullListValueModel<Object>();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGet() {
- boolean exCaught = false;
- try {
- this.listHolder.get(0);
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testSize() {
- assertEquals(0, this.listHolder.size());
- }
-
- public void testIterator() {
- assertFalse(this.listHolder.iterator().hasNext());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullPropertyValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullPropertyValueModelTests.java
deleted file mode 100644
index 8dc75dc257..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullPropertyValueModelTests.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.value.NullPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class NullPropertyValueModelTests extends TestCase {
- private PropertyValueModel<Object> valueHolder;
-
- public NullPropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.valueHolder = new NullPropertyValueModel<Object>();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- assertNull(this.valueHolder.getValue());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyAspectAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyAspectAdapterTests.java
deleted file mode 100644
index 9d12a06466..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyAspectAdapterTests.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class PropertyAspectAdapterTests extends TestCase {
- private TestSubject subject1;
- private WritablePropertyValueModel<TestSubject> subjectHolder1;
- private PropertyAspectAdapter<TestSubject, String> aa1;
- private PropertyChangeEvent event1;
- private PropertyChangeListener listener1;
-
- private TestSubject subject2;
-
- private PropertyChangeEvent multipleValueEvent;
-
- private PropertyChangeEvent customValueEvent;
-
-
- public PropertyAspectAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.subject1 = new TestSubject("foo", "test subject 1");
- this.subjectHolder1 = new SimplePropertyValueModel<TestSubject> (this.subject1);
- this.aa1 = this.buildAspectAdapter(this.subjectHolder1);
- this.listener1 = this.buildValueChangeListener1();
- this.aa1.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener1);
- this.event1 = null;
-
- this.subject2 = new TestSubject("bar", "test subject 2");
- }
-
- private PropertyAspectAdapter<TestSubject, String> buildAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- return new PropertyAspectAdapter<TestSubject, String>(subjectHolder, TestSubject.NAME_PROPERTY) {
- // this is not a aspect adapter - the value is determined by the aspect name
- @Override
- protected String buildValue_() {
- if (this.propertyNames[0] == TestSubject.NAME_PROPERTY) {
- return this.subject.getName();
- } else if (this.propertyNames[0] == TestSubject.DESCRIPTION_PROPERTY) {
- return this.subject.getDescription();
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.propertyNames[0]);
- }
- }
- @Override
- protected void setValue_(String value) {
- if (this.propertyNames[0] == TestSubject.NAME_PROPERTY) {
- this.subject.setName(value);
- } else if (this.propertyNames[0] == TestSubject.DESCRIPTION_PROPERTY) {
- this.subject.setDescription(value);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.propertyNames[0]);
- }
- }
- };
- }
-
- private PropertyChangeListener buildValueChangeListener1() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- PropertyAspectAdapterTests.this.value1Changed(e);
- }
- };
- }
-
- void value1Changed(PropertyChangeEvent e) {
- this.event1 = e;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSubjectHolder() {
- assertEquals("foo", this.aa1.getValue());
- assertNull(this.event1);
-
- this.subjectHolder1.setValue(this.subject2);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event1.getPropertyName());
- assertEquals("foo", this.event1.getOldValue());
- assertEquals("bar", this.event1.getNewValue());
- assertEquals("bar", this.aa1.getValue());
-
- this.event1 = null;
- this.subjectHolder1.setValue(null);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event1.getPropertyName());
- assertEquals("bar", this.event1.getOldValue());
- assertNull(this.event1.getNewValue());
- assertNull(this.aa1.getValue());
-
- this.event1 = null;
- this.subjectHolder1.setValue(this.subject1);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event1.getPropertyName());
- assertEquals(null, this.event1.getOldValue());
- assertEquals("foo", this.event1.getNewValue());
- assertEquals("foo", this.aa1.getValue());
- }
-
- public void testPropertyChange() {
- assertEquals("foo", this.aa1.getValue());
- assertNull(this.event1);
-
- this.subject1.setName("baz");
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event1.getPropertyName());
- assertEquals("foo", this.event1.getOldValue());
- assertEquals("baz", this.event1.getNewValue());
- assertEquals("baz", this.aa1.getValue());
-
- this.event1 = null;
- this.subject1.setName(null);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event1.getPropertyName());
- assertEquals("baz", this.event1.getOldValue());
- assertEquals(null, this.event1.getNewValue());
- assertEquals(null, this.aa1.getValue());
-
- this.event1 = null;
- this.subject1.setName("foo");
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event1.getPropertyName());
- assertEquals(null, this.event1.getOldValue());
- assertEquals("foo", this.event1.getNewValue());
- assertEquals("foo", this.aa1.getValue());
- }
-
- public void testValue() {
- assertEquals("foo", this.subject1.getName());
- assertEquals("foo", this.aa1.getValue());
- }
-
- public void testStaleValue() {
- assertEquals("foo", this.subject1.getName());
- assertEquals("foo", this.aa1.getValue());
-
- this.aa1.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener1);
- assertEquals(null, this.aa1.getValue());
-
- this.aa1.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener1);
- assertEquals("foo", this.aa1.getValue());
-
- this.aa1.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener1);
- this.subjectHolder1.setValue(this.subject2);
- assertEquals(null, this.aa1.getValue());
-
- this.aa1.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener1);
- assertEquals("bar", this.aa1.getValue());
- }
-
- public void testSetValue() {
- this.aa1.setValue("baz");
- assertEquals("baz", this.aa1.getValue());
- assertEquals("baz", this.subject1.getName());
- }
-
- public void testHasListeners() {
- assertTrue(this.aa1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.subject1.hasAnyPropertyChangeListeners(TestSubject.NAME_PROPERTY));
- this.aa1.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener1);
- assertFalse(this.subject1.hasAnyPropertyChangeListeners(TestSubject.NAME_PROPERTY));
- assertFalse(this.aa1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- PropertyChangeListener listener2 = this.buildValueChangeListener1();
- this.aa1.addPropertyChangeListener(listener2);
- assertTrue(this.aa1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.subject1.hasAnyPropertyChangeListeners(TestSubject.NAME_PROPERTY));
- this.aa1.removePropertyChangeListener(listener2);
- assertFalse(this.subject1.hasAnyPropertyChangeListeners(TestSubject.NAME_PROPERTY));
- assertFalse(this.aa1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testMultipleAspectAdapter() {
- TestSubject testSubject = new TestSubject("fred", "husband");
- WritablePropertyValueModel<TestSubject> testSubjectHolder = new SimplePropertyValueModel<TestSubject>(testSubject);
- WritablePropertyValueModel<String> testAA = this.buildMultipleAspectAdapter(testSubjectHolder);
- PropertyChangeListener testListener = this.buildMultipleValueChangeListener();
- testAA.addPropertyChangeListener(PropertyValueModel.VALUE, testListener);
- assertEquals("fred:husband", testAA.getValue());
-
- this.multipleValueEvent = null;
- testSubject.setName("wilma");
- assertEquals("wilma:husband", testAA.getValue());
- assertEquals("fred:husband", this.multipleValueEvent.getOldValue());
- assertEquals("wilma:husband", this.multipleValueEvent.getNewValue());
-
- this.multipleValueEvent = null;
- testSubject.setDescription("wife");
- assertEquals("wilma:wife", testAA.getValue());
- assertEquals("wilma:husband", this.multipleValueEvent.getOldValue());
- assertEquals("wilma:wife", this.multipleValueEvent.getNewValue());
- }
-
- private WritablePropertyValueModel<String> buildMultipleAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- return new PropertyAspectAdapter<TestSubject, String>(subjectHolder, TestSubject.NAME_PROPERTY, TestSubject.DESCRIPTION_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getName() + ":" + this.subject.getDescription();
- }
- };
- }
-
- private PropertyChangeListener buildMultipleValueChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- PropertyAspectAdapterTests.this.multipleValueChanged(e);
- }
- };
- }
-
- void multipleValueChanged(PropertyChangeEvent e) {
- this.multipleValueEvent = e;
- }
-
- /**
- * test a bug where we would call #buildValue() in
- * #engageNonNullSubject(), when we needed to call
- * it in #engageSubject(), so the cached value would
- * be rebuilt when the this.subject was set to null
- */
- public void testCustomBuildValueWithNullSubject() {
- TestSubject customSubject = new TestSubject("fred", "laborer");
- WritablePropertyValueModel<TestSubject> customSubjectHolder = new SimplePropertyValueModel<TestSubject>(customSubject);
- WritablePropertyValueModel<String> customAA = this.buildCustomAspectAdapter(customSubjectHolder);
- PropertyChangeListener customListener = this.buildCustomValueChangeListener();
- customAA.addPropertyChangeListener(PropertyValueModel.VALUE, customListener);
- assertEquals("fred", customAA.getValue());
-
- this.customValueEvent = null;
- customSubject.setName("wilma");
- assertEquals("wilma", customAA.getValue());
- assertEquals("fred", this.customValueEvent.getOldValue());
- assertEquals("wilma", this.customValueEvent.getNewValue());
-
- this.customValueEvent = null;
- customSubjectHolder.setValue(null);
- // this would fail - the value would be null...
- assertEquals("<unnamed>", customAA.getValue());
- assertEquals("wilma", this.customValueEvent.getOldValue());
- assertEquals("<unnamed>", this.customValueEvent.getNewValue());
- }
-
- private WritablePropertyValueModel<String> buildCustomAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- return new PropertyAspectAdapter<TestSubject, String>(subjectHolder, TestSubject.NAME_PROPERTY) {
- @Override
- protected String buildValue() {
- return (this.subject == null) ? "<unnamed>" : this.subject.getName();
- }
- };
- }
-
- private PropertyChangeListener buildCustomValueChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- PropertyAspectAdapterTests.this.customValueChanged(e);
- }
- };
- }
-
- void customValueChanged(PropertyChangeEvent e) {
- this.customValueEvent = e;
- }
-
-
- // ********** inner class **********
-
- private class TestSubject extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
- private String description;
- public static final String DESCRIPTION_PROPERTY = "description";
-
- public TestSubject(String name, String description) {
- this.name = name;
- this.description = description;
- }
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
- public String getDescription() {
- return this.description;
- }
- public void setDescription(String description) {
- Object old = this.description;
- this.description = description;
- this.firePropertyChanged(DESCRIPTION_PROPERTY, old, description);
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java
deleted file mode 100644
index 3dbf87c0de..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.Collection;
-
-import javax.swing.JList;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyCollectionValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class PropertyCollectionValueModelAdapterTests extends TestCase {
- private CollectionValueModel<String> adapter;
- private WritablePropertyValueModel<String> wrappedValueHolder;
-
- public PropertyCollectionValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.wrappedValueHolder = new SimplePropertyValueModel<String>();
- this.adapter = new PropertyCollectionValueModelAdapter<String>(this.wrappedValueHolder);
- }
-
- private Collection<String> wrappedCollection() {
- return CollectionTools.collection(new SingleElementIterator<String>(this.wrappedValueHolder.getValue()));
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionChangeEvent e) {/* OK */}
- });
- this.wrappedValueHolder.setValue("foo");
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(1, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
- assertEquals("foo", adapterCollection.iterator().next());
- }
-
- public void testStaleValue() {
- CollectionChangeListener listener = new TestListener() {
- @Override
- public void itemsAdded(CollectionChangeEvent e) {/* OK */}
- };
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- this.wrappedValueHolder.setValue("foo");
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(1, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
- assertEquals("foo", adapterCollection.iterator().next());
-
- this.adapter.removeCollectionChangeListener(CollectionValueModel.VALUES, listener);
- adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(0, adapterCollection.size());
- assertEquals(new HashBag<String>(), adapterCollection);
-
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(1, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
- assertEquals("foo", adapterCollection.iterator().next());
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- CoordinatedBag<String> synchCollection = new CoordinatedBag<String>(this.adapter);
- assertTrue(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.adapter.removeCollectionChangeListener(CollectionValueModel.VALUES, synchCollection);
- assertFalse(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.adapter.addCollectionChangeListener(synchCollection);
- assertTrue(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.adapter.removeCollectionChangeListener(synchCollection);
- assertFalse(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
- public void testListChangedToEmpty() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionChangeEvent e) {/* OK */}
- @Override
- public void itemsRemoved(CollectionChangeEvent e) {/* OK */}
- });
- this.wrappedValueHolder.setValue("foo");
- JList jList = new JList(new ListModelAdapter(this.adapter));
- this.wrappedValueHolder.setValue(null);
- assertEquals(0, jList.getModel().getSize());
- }
-
- public void testCollectionChangedFromEmpty() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionChangeEvent e) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- this.wrappedValueHolder.setValue("foo");
- assertEquals(1, jList.getModel().getSize());
- }
-
- public void testCollectionChangedFromEmptyToEmpty() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener());
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- this.wrappedValueHolder.setValue(null);
- assertEquals(0, jList.getModel().getSize());
- }
-
-
- // ********** member class **********
-
- static class TestListener implements CollectionChangeListener {
- public void collectionChanged(CollectionChangeEvent event) {
- fail("unexpected event");
- }
- public void collectionCleared(CollectionChangeEvent event) {
- fail("unexpected event");
- }
- public void itemsAdded(CollectionChangeEvent event) {
- fail("unexpected event");
- }
- public void itemsRemoved(CollectionChangeEvent event) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyListValueModelAdapterTests.java
deleted file mode 100644
index 528bd3b6a1..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyListValueModelAdapterTests.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.swing.JList;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class PropertyListValueModelAdapterTests extends TestCase {
- private ListValueModel<String> adapter;
- private WritablePropertyValueModel<String> wrappedValueHolder;
-
- public PropertyListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.wrappedValueHolder = new SimplePropertyValueModel<String>();
- this.adapter = new PropertyListValueModelAdapter<String>(this.wrappedValueHolder);
- }
-
- private Collection<String> wrappedList() {
- return CollectionTools.list(new SingleElementIterator<String>(this.wrappedValueHolder.getValue()));
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener() {
- @Override
- public void itemsAdded(ListChangeEvent event) {/* OK */}
- });
- assertFalse(this.adapter.iterator().hasNext());
- this.wrappedValueHolder.setValue("foo");
- List<String> adapterList = CollectionTools.list(this.adapter.iterator());
- assertEquals(1, adapterList.size());
- assertEquals(this.wrappedList(), adapterList);
- assertEquals("foo", adapterList.iterator().next());
- }
-
- public void testGetInt() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener() {
- @Override
- public void itemsAdded(ListChangeEvent event) {/* OK */}
- });
- this.wrappedValueHolder.setValue("foo");
- assertEquals("foo", this.adapter.get(0));
- }
-
- public void testToArray1() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener() {
- @Override
- public void itemsAdded(ListChangeEvent event) {/* OK */}
- });
- this.wrappedValueHolder.setValue("foo");
- Object[] array = this.adapter.toArray();
- assertEquals("foo", array[0]);
- assertEquals(1, array.length);
- }
-
- public void testToArray2() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener());
- Object[] array = this.adapter.toArray();
- assertEquals(0, array.length);
- }
-
- public void testStaleValue() {
- ListChangeListener listener = new TestListener() {
- @Override
- public void itemsAdded(ListChangeEvent event) {/* OK */}
- };
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- this.wrappedValueHolder.setValue("foo");
- List<String> adapterList = CollectionTools.list(this.adapter.iterator());
- assertEquals(1, adapterList.size());
- assertEquals(this.wrappedList(), adapterList);
- assertEquals("foo", adapterList.iterator().next());
-
- this.adapter.removeListChangeListener(ListValueModel.LIST_VALUES, listener);
- adapterList = CollectionTools.list(this.adapter.iterator());
- assertEquals(0, adapterList.size());
- assertEquals(new ArrayList<String>(), adapterList);
-
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- adapterList = CollectionTools.list(this.adapter.iterator());
- assertEquals(1, adapterList.size());
- assertEquals(this.wrappedList(), adapterList);
- assertEquals("foo", adapterList.iterator().next());
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- CoordinatedList<String> synchList = new CoordinatedList<String>(this.adapter);
- assertTrue(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.addListChangeListener(synchList);
- assertTrue(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.removeListChangeListener(synchList);
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- public void testListChangedToEmpty() {
- this.wrappedValueHolder.setValue("foo");
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener() {
- @Override
- public void itemsRemoved(ListChangeEvent event) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
- this.wrappedValueHolder.setValue(null);
- assertEquals(0, jList.getModel().getSize());
- }
-
- public void testListChangedFromEmpty() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener() {
- @Override
- public void itemsAdded(ListChangeEvent event) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- this.wrappedValueHolder.setValue("foo");
- assertEquals(1, jList.getModel().getSize());
- }
-
- public void testListItemChanged() {
- this.wrappedValueHolder.setValue("foo");
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener() {
- @Override
- public void itemsReplaced(ListChangeEvent event) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
- assertEquals(1, jList.getModel().getSize());
- assertEquals("foo", jList.getModel().getElementAt(0));
-
- this.wrappedValueHolder.setValue("bar");
- assertEquals(1, jList.getModel().getSize());
- assertEquals("bar", jList.getModel().getElementAt(0));
- }
-
- public void testListChangedFromEmptyToEmpty() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener());
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- this.wrappedValueHolder.setValue(null);
- assertEquals(0, jList.getModel().getSize());
- }
-
-
- // ********** member class **********
-
- static class TestListener implements ListChangeListener {
- public void listChanged(ListChangeEvent event) {
- fail("unexpected event");
- }
- public void listCleared(ListChangeEvent event) {
- fail("unexpected event");
- }
- public void itemsAdded(ListChangeEvent event) {
- fail("unexpected event");
- }
- public void itemsRemoved(ListChangeEvent event) {
- fail("unexpected event");
- }
- public void itemsMoved(ListChangeEvent event) {
- fail("unexpected event");
- }
- public void itemsReplaced(ListChangeEvent event) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java
deleted file mode 100644
index 0f2ed43ee3..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java
+++ /dev/null
@@ -1,411 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class SimpleCollectionValueModelTests extends TestCase {
- private SimpleCollectionValueModel<String> bagHolder;
- CollectionChangeEvent bagEvent;
- String bagEventType;
-
- private SimpleCollectionValueModel<String> setHolder;
- CollectionChangeEvent setEvent;
- String setEventType;
-
- private static final String ADD = "add";
- private static final String REMOVE = "remove";
- private static final String CHANGE = "change";
- private static final String CLEAR = "clear";
-
-
- public SimpleCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.bagHolder = new SimpleCollectionValueModel<String>(this.buildBag());
- this.setHolder = new SimpleCollectionValueModel<String>(this.buildSet());
- }
-
- private Bag<String> buildBag() {
- Bag<String> result = new HashBag<String>();
- this.addItemsTo(result);
- return result;
- }
-
- private Set<String> buildSet() {
- Set<String> result = new HashSet<String>();
- this.addItemsTo(result);
- return result;
- }
-
- private void addItemsTo(Collection<String> c) {
- c.add("foo");
- c.add("bar");
- c.add("baz");
- }
-
- private Bag<String> buildAddItems() {
- Bag<String> result = new HashBag<String>();
- result.add("joo");
- result.add("jar");
- result.add("jaz");
- return result;
- }
-
- private Bag<String> buildRemoveItems() {
- Bag<String> result = new HashBag<String>();
- result.add("foo");
- result.add("baz");
- return result;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- assertEquals(this.buildBag(), CollectionTools.bag(this.bagHolder.iterator()));
- assertEquals(this.buildSet(), CollectionTools.set(this.setHolder.iterator()));
- }
-
- public void testSize() {
- assertEquals(this.buildBag().size(), CollectionTools.size(this.bagHolder.iterator()));
- assertEquals(this.buildSet().size(), CollectionTools.size(this.setHolder.iterator()));
- }
-
- private boolean bagHolderContains(Object item) {
- return CollectionTools.contains(this.bagHolder.iterator(), item);
- }
-
- private boolean setHolderContains(Object item) {
- return CollectionTools.contains(this.setHolder.iterator(), item);
- }
-
- private boolean bagHolderContainsAll(Collection<String> items) {
- return CollectionTools.containsAll(this.bagHolder.iterator(), items);
- }
-
- private boolean setHolderContainsAll(Collection<String> items) {
- return CollectionTools.containsAll(this.setHolder.iterator(), items);
- }
-
- private boolean bagHolderContainsAny(Collection<String> items) {
- Bag<String> bag = CollectionTools.bag(this.bagHolder.iterator());
- for (String string : items) {
- if (bag.contains(string)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean setHolderContainsAny(Collection<String> items) {
- Set<String> set = CollectionTools.set(this.setHolder.iterator());
- for (String string : items) {
- if (set.contains(string)) {
- return true;
- }
- }
- return false;
- }
-
- public void testAdd() {
- assertFalse(this.bagHolderContains("joo"));
- this.bagHolder.add("joo");
- assertTrue(this.bagHolderContains("joo"));
-
- assertFalse(this.bagHolderContains(null));
- this.bagHolder.add(null);
- assertTrue(this.bagHolderContains(null));
-
- assertFalse(this.setHolderContains("joo"));
- this.setHolder.add("joo");
- assertTrue(this.setHolderContains("joo"));
-
- assertFalse(this.setHolderContains(null));
- this.setHolder.add(null);
- assertTrue(this.setHolderContains(null));
- }
-
- public void testAddAll() {
- assertFalse(this.bagHolderContainsAny(this.buildAddItems()));
- this.bagHolder.addAll(this.buildAddItems());
- assertTrue(this.bagHolderContainsAll(this.buildAddItems()));
-
- assertFalse(this.setHolderContainsAny(this.buildAddItems()));
- this.setHolder.addAll(this.buildAddItems());
- assertTrue(this.setHolderContainsAll(this.buildAddItems()));
- }
-
- public void testRemove() {
- assertTrue(this.bagHolderContains("bar"));
- this.bagHolder.remove("bar");
- assertFalse(this.bagHolderContains("bar"));
-
- this.bagHolder.add(null);
- assertTrue(this.bagHolderContains(null));
- this.bagHolder.remove(null);
- assertFalse(this.bagHolderContains(null));
-
- assertTrue(this.setHolderContains("bar"));
- this.setHolder.remove("bar");
- assertFalse(this.setHolderContains("bar"));
-
- this.setHolder.add(null);
- assertTrue(this.setHolderContains(null));
- this.setHolder.remove(null);
- assertFalse(this.setHolderContains(null));
- }
-
- public void testRemoveAll() {
- assertTrue(this.bagHolderContainsAll(this.buildRemoveItems()));
- this.bagHolder.removeAll(this.buildRemoveItems());
- assertFalse(this.bagHolderContainsAny(this.buildRemoveItems()));
-
- assertTrue(this.setHolderContainsAll(this.buildRemoveItems()));
- this.setHolder.removeAll(this.buildRemoveItems());
- assertFalse(this.setHolderContainsAny(this.buildRemoveItems()));
- }
-
- public void testSetCollection() {
- assertTrue(this.bagHolderContains("bar"));
- assertFalse(this.bagHolderContains("jar"));
- this.bagHolder.setCollection(this.buildAddItems());
- assertFalse(this.bagHolderContains("bar"));
- assertTrue(this.bagHolderContains("jar"));
-
- this.bagHolder.add(null);
- assertTrue(this.bagHolderContains(null));
- this.bagHolder.remove(null);
- assertFalse(this.bagHolderContains(null));
-
- this.bagHolder.setCollection(new HashBag<String>());
- assertFalse(this.bagHolderContains("jar"));
-
- assertTrue(this.setHolderContains("bar"));
- assertFalse(this.setHolderContains("jar"));
- this.setHolder.setCollection(this.buildAddItems());
- assertFalse(this.setHolderContains("bar"));
- assertTrue(this.setHolderContains("jar"));
-
- this.setHolder.add(null);
- assertTrue(this.setHolderContains(null));
- this.setHolder.remove(null);
- assertFalse(this.setHolderContains(null));
-
- this.setHolder.setCollection(new HashBag<String>());
- assertFalse(this.setHolderContains("jar"));
- }
-
- public void testCollectionChange1() {
- this.bagHolder.addCollectionChangeListener(this.buildBagListener());
- this.verifyBagChange();
-
- this.setHolder.addCollectionChangeListener(this.buildSetListener());
- this.verifySetChange();
- }
-
- public void testCollectionChange2() {
- this.bagHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildBagListener());
- this.verifyBagChange();
-
- this.setHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildSetListener());
- this.verifySetChange();
- }
-
- private void verifyBagChange() {
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.add("foo");
- this.verifyBagEvent(ADD, "foo");
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.add("foo");
- this.verifyBagEvent(ADD, "foo");
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.add("joo");
- this.verifyBagEvent(ADD, "joo");
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.add(null);
- this.verifyBagEvent(ADD, null);
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.add(null);
- this.verifyBagEvent(ADD, null);
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.remove("joo");
- this.verifyBagEvent(REMOVE, "joo");
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.remove(null);
- this.verifyBagEvent(REMOVE, null);
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.setCollection(this.buildBag());
- this.verifyBagEvent(CHANGE);
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.addAll(this.buildBag());
- this.verifyBagEvent(ADD);
- assertEquals(this.buildBag(), CollectionTools.bag(this.bagEvent.items()));
- }
-
- private void verifySetChange() {
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.add("foo");
- assertNull(this.setEvent);
- assertNull(this.setEventType);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.add("joo");
- this.verifySetEvent(ADD, "joo");
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.add("joo");
- assertNull(this.setEvent);
- assertNull(this.setEventType);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.add(null);
- this.verifySetEvent(ADD, null);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.add(null);
- assertNull(this.setEvent);
- assertNull(this.setEventType);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.remove("joo");
- this.verifySetEvent(REMOVE, "joo");
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.remove("joo");
- assertNull(this.setEvent);
- assertNull(this.setEventType);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.remove(null);
- this.verifySetEvent(REMOVE, null);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.setCollection(this.buildSet());
- this.verifySetEvent(CHANGE);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.addAll(this.buildSet());
- assertNull(this.setEvent);
- assertNull(this.setEventType);
- }
-
- private CollectionChangeListener buildBagListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent e) {
- SimpleCollectionValueModelTests.this.bagEventType = ADD;
- SimpleCollectionValueModelTests.this.bagEvent = e;
- }
- public void itemsRemoved(CollectionChangeEvent e) {
- SimpleCollectionValueModelTests.this.bagEventType = REMOVE;
- SimpleCollectionValueModelTests.this.bagEvent = e;
- }
- public void collectionCleared(CollectionChangeEvent e) {
- SimpleCollectionValueModelTests.this.bagEventType = CLEAR;
- SimpleCollectionValueModelTests.this.bagEvent = e;
- }
- public void collectionChanged(CollectionChangeEvent e) {
- SimpleCollectionValueModelTests.this.bagEventType = CHANGE;
- SimpleCollectionValueModelTests.this.bagEvent = e;
- }
- };
- }
-
- private CollectionChangeListener buildSetListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent e) {
- SimpleCollectionValueModelTests.this.setEventType = ADD;
- SimpleCollectionValueModelTests.this.setEvent = e;
- }
- public void itemsRemoved(CollectionChangeEvent e) {
- SimpleCollectionValueModelTests.this.setEventType = REMOVE;
- SimpleCollectionValueModelTests.this.setEvent = e;
- }
- public void collectionCleared(CollectionChangeEvent e) {
- SimpleCollectionValueModelTests.this.setEventType = CLEAR;
- SimpleCollectionValueModelTests.this.setEvent = e;
- }
- public void collectionChanged(CollectionChangeEvent e) {
- SimpleCollectionValueModelTests.this.setEventType = CHANGE;
- SimpleCollectionValueModelTests.this.setEvent = e;
- }
- };
- }
-
- private void verifyBagEvent(String eventType) {
- assertEquals(eventType, this.bagEventType);
- assertEquals(this.bagHolder, this.bagEvent.getSource());
- assertEquals(CollectionValueModel.VALUES, this.bagEvent.getCollectionName());
- }
-
- private void verifyBagEvent(String eventType, Object item) {
- this.verifyBagEvent(eventType);
- assertEquals(item, this.bagEvent.items().next());
- }
-
- private void verifySetEvent(String eventType) {
- assertEquals(eventType, this.setEventType);
- assertEquals(this.setHolder, this.setEvent.getSource());
- assertEquals(CollectionValueModel.VALUES, this.setEvent.getCollectionName());
- }
-
- private void verifySetEvent(String eventType, Object item) {
- this.verifySetEvent(eventType);
- assertEquals(item, this.setEvent.items().next());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleListValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleListValueModelTests.java
deleted file mode 100644
index 39f54c1dfb..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleListValueModelTests.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class SimpleListValueModelTests extends TestCase {
- private SimpleListValueModel<String> listHolder;
- ListChangeEvent event;
- String eventType;
-
- private static final String ADD = "add";
- private static final String REMOVE = "remove";
- private static final String REPLACE = "replace";
- private static final String MOVE = "move";
- private static final String CLEAR = "clear";
- private static final String CHANGE = "change";
-
-
- public SimpleListValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.listHolder = new SimpleListValueModel<String>(this.buildList());
- }
-
- private List<String> buildList() {
- List<String> result = new ArrayList<String>();
- result.add("foo");
- result.add("bar");
- result.add("baz");
- return result;
- }
-
- private List<String> buildAddList() {
- List<String> result = new ArrayList<String>();
- result.add("joo");
- result.add("jar");
- result.add("jaz");
- return result;
- }
-
-// private List<String> buildRemoveList() {
-// List<String> result = new ArrayList<String>();
-// result.add("foo");
-// result.add("bar");
-// return result;
-// }
-//
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- assertEquals(this.buildList(), CollectionTools.list(this.listHolder.iterator()));
- }
-
- public void testListIterator() {
- assertEquals(this.buildList(), CollectionTools.list(this.listHolder.listIterator()));
- }
-
- public void testListIteratorInt() {
- assertEquals(CollectionTools.list(this.buildList().listIterator(1)), CollectionTools.list(this.listHolder.listIterator(1)));
- }
-
- public void testSize() {
- assertEquals(this.buildList().size(), this.listHolder.size());
- }
-
- private boolean listContains(Object item) {
- return CollectionTools.contains(this.listHolder.listIterator(), item);
- }
-
- private boolean listContainsAll(Collection<String> items) {
- return CollectionTools.containsAll(this.listHolder.listIterator(), items);
- }
-
- private boolean listContainsAny(Collection<String> items) {
- Set<String> set = CollectionTools.set(this.listHolder.iterator());
- for (Iterator<String> stream = items.iterator(); stream.hasNext(); ) {
- if (set.contains(stream.next())) {
- return true;
- }
- }
- return false;
- }
-
- public void testAddObject() {
- assertFalse(this.listContains("joo"));
- this.listHolder.add("joo");
- assertTrue(this.listContains("joo"));
-
- assertFalse(this.listContains(null));
- this.listHolder.add(null);
- assertTrue(this.listContains(null));
- }
-
- public void testAddIntObject() {
- assertFalse(this.listContains("joo"));
- this.listHolder.add(2, "joo");
- assertTrue(this.listContains("joo"));
-
- assertFalse(this.listContains(null));
- this.listHolder.add(0, null);
- assertTrue(this.listContains(null));
- }
-
- public void testAddAllCollection() {
- assertFalse(this.listContainsAny(this.buildAddList()));
- this.listHolder.addAll(this.buildAddList());
- assertTrue(this.listContainsAll(this.buildAddList()));
- }
-
- public void testAddAllIntCollection() {
- assertFalse(this.listContainsAny(this.buildAddList()));
- this.listHolder.addAll(2, this.buildAddList());
- assertTrue(this.listContainsAll(this.buildAddList()));
- }
-
- public void testClear() {
- assertFalse(this.listHolder.isEmpty());
- this.listHolder.clear();
- assertTrue(this.listHolder.isEmpty());
- }
-
- public void testContainsObject() {
- assertTrue(this.listHolder.contains("foo"));
- assertFalse(this.listHolder.contains("joo"));
- }
-
- public void testContainsAllCollection() {
- Collection<String> c = new ArrayList<String>();
- c.add("foo");
- c.add("bar");
- assertTrue(this.listHolder.containsAll(c));
-
- c.add("joo");
- assertFalse(this.listHolder.containsAll(c));
- }
-
- public void testEquals() {
- assertEquals(new SimpleListValueModel<String>(this.buildList()), this.listHolder);
- assertFalse(this.listHolder.equals(new SimpleListValueModel<String>(this.buildAddList())));
- assertFalse(this.listHolder.equals(this.buildList()));
- assertFalse(this.listHolder.equals(new SimpleListValueModel<String>()));
- }
-
- public void testGetInt() {
- assertEquals("foo", this.listHolder.get(0));
- assertEquals("bar", this.listHolder.get(1));
- assertEquals("baz", this.listHolder.get(2));
- }
-
- public void testHashCode() {
- assertEquals(new SimpleListValueModel<String>(this.buildList()).hashCode(), this.listHolder.hashCode());
- }
-
- public void testIndexOfObject() {
- assertEquals(0, this.listHolder.indexOf("foo"));
- assertEquals(1, this.listHolder.indexOf("bar"));
- assertEquals(2, this.listHolder.indexOf("baz"));
- assertEquals(-1, this.listHolder.indexOf("joo"));
- }
-
- public void testLastIndexOfObject() {
- assertEquals(0, this.listHolder.lastIndexOf("foo"));
- assertEquals(1, this.listHolder.lastIndexOf("bar"));
- assertEquals(2, this.listHolder.lastIndexOf("baz"));
- assertEquals(-1, this.listHolder.lastIndexOf("joo"));
-
- this.listHolder.add("foo");
- assertEquals(3, this.listHolder.lastIndexOf("foo"));
- }
-
- public void testIsEmpty() {
- assertFalse(this.listHolder.isEmpty());
- this.listHolder.clear();
- assertTrue(this.listHolder.isEmpty());
- }
-
- public void testRemove() {
- assertTrue(this.listContains("bar"));
- this.listHolder.remove(this.buildList().indexOf("bar"));
- assertFalse(this.listContains("bar"));
-
- this.listHolder.add(1, null);
- assertTrue(this.listContains(null));
- this.listHolder.remove(1);
- assertFalse(this.listContains(null));
- }
-
- public void testSetValues() {
- List<String> newList = new ArrayList<String>();
- newList.add("joo");
- newList.add("jar");
- newList.add("jaz");
-
- assertTrue(this.listContains("bar"));
- assertFalse(this.listContains("jar"));
- this.listHolder.setList(newList);
- assertFalse(this.listContains("bar"));
- assertTrue(this.listContains("jar"));
-
- this.listHolder.add(1, null);
- assertTrue(this.listContains(null));
- this.listHolder.remove(1);
- assertFalse(this.listContains(null));
-
- this.listHolder.setList(new ArrayList<String>());
- assertFalse(this.listContains("jar"));
- }
-
- public void testListChange1() {
- this.listHolder.addListChangeListener(this.buildListener());
- this.verifyListChange();
- }
-
- public void testListChange2() {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- this.verifyListChange();
- }
-
- private void verifyListChange() {
- this.event = null;
- this.eventType = null;
- this.listHolder.add(1, "joo");
- this.verifyEvent(ADD, 1, "joo");
-
- this.event = null;
- this.eventType = null;
- this.listHolder.add(1, null);
- this.verifyEvent(ADD, 1, null);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.remove(1);
- this.verifyEvent(REMOVE, 1, null);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.remove(1);
- this.verifyEvent(REMOVE, 1, "joo");
-
- this.event = null;
- this.eventType = null;
- this.listHolder.setList(this.buildList());
- this.verifyEvent(CHANGE);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.addAll(0, this.buildList());
- this.verifyEvent(ADD);
- assertEquals(this.buildList(), CollectionTools.list(this.event.items()));
-
- this.event = null;
- this.eventType = null;
- this.listHolder.set(0, "joo");
- this.verifyEvent(REPLACE);
- assertFalse(CollectionTools.contains(this.event.items(), "foo"));
- assertTrue(CollectionTools.contains(this.event.items(), "joo"));
- }
-
- private ListChangeListener buildListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent e) {
- SimpleListValueModelTests.this.eventType = ADD;
- SimpleListValueModelTests.this.event = e;
- }
- public void itemsRemoved(ListChangeEvent e) {
- SimpleListValueModelTests.this.eventType = REMOVE;
- SimpleListValueModelTests.this.event = e;
- }
- public void itemsReplaced(ListChangeEvent e) {
- SimpleListValueModelTests.this.eventType = REPLACE;
- SimpleListValueModelTests.this.event = e;
- }
- public void itemsMoved(ListChangeEvent e) {
- SimpleListValueModelTests.this.eventType = MOVE;
- SimpleListValueModelTests.this.event = e;
- }
- public void listCleared(ListChangeEvent e) {
- SimpleListValueModelTests.this.eventType = CLEAR;
- SimpleListValueModelTests.this.event = e;
- }
- public void listChanged(ListChangeEvent e) {
- SimpleListValueModelTests.this.eventType = CHANGE;
- SimpleListValueModelTests.this.event = e;
- }
- };
- }
-
- private void verifyEvent(String e) {
- assertEquals(e, this.eventType);
- assertEquals(this.listHolder, this.event.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event.getListName());
- }
-
- private void verifyEvent(String e, int index, Object item) {
- this.verifyEvent(e);
- assertEquals(index, this.event.getIndex());
- assertEquals(item, this.event.items().next());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimplePropertyValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimplePropertyValueModelTests.java
deleted file mode 100644
index e6bea20a70..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimplePropertyValueModelTests.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class SimplePropertyValueModelTests extends TestCase {
- private WritablePropertyValueModel<String> objectHolder;
- PropertyChangeEvent event;
-
-
- public SimplePropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.objectHolder = new SimplePropertyValueModel<String>("foo");
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- assertEquals("foo", this.objectHolder.getValue());
- }
-
- public void testSetValue() {
- this.objectHolder.setValue("bar");
- assertEquals("bar", this.objectHolder.getValue());
- this.objectHolder.setValue(null);
- assertEquals(null, this.objectHolder.getValue());
- this.objectHolder.setValue("baz");
- assertEquals("baz", this.objectHolder.getValue());
- }
-
- public void testPropertyChange1() {
- this.objectHolder.addPropertyChangeListener(this.buildListener());
- this.verifyPropertyChange();
- }
-
- public void testPropertyChange2() {
- this.objectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.verifyPropertyChange();
- }
-
- private void verifyPropertyChange() {
- this.event = null;
- this.objectHolder.setValue("bar");
- this.verifyEvent("foo", "bar");
-
- this.event = null;
- this.objectHolder.setValue(null);
- this.verifyEvent("bar", null);
-
- this.event = null;
- this.objectHolder.setValue("baz");
- this.verifyEvent(null, "baz");
- }
-
- private PropertyChangeListener buildListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- SimplePropertyValueModelTests.this.event = e;
- }
- };
- }
-
- private void verifyEvent(Object oldValue, Object newValue) {
- assertEquals(this.objectHolder, this.event.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event.getPropertyName());
- assertEquals(oldValue, this.event.getOldValue());
- assertEquals(newValue, this.event.getNewValue());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java
deleted file mode 100644
index d867d2275f..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.TreeSet;
-
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.ReverseComparator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class SortedListValueModelAdapterTests extends TestCase {
- private SortedListValueModelAdapter<String> adapter;
- private SimpleCollectionValueModel<String> wrappedCollectionHolder;
- private Collection<String> wrappedCollection;
-
-
- public SortedListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.wrappedCollection = new HashBag<String>();
- this.wrappedCollectionHolder = new SimpleCollectionValueModel<String>(this.wrappedCollection);
- this.adapter = new SortedListValueModelAdapter<String>(this.wrappedCollectionHolder);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- private void verifyList(Collection<String> expected, ListValueModel<String> actual) {
- this.verifyList(expected, actual, null);
- }
-
- private void verifyList(Collection<String> expected, ListValueModel<String> actual, Comparator<String> comparator) {
- Collection<String> sortedSet = new TreeSet<String>(comparator);
- sortedSet.addAll(expected);
- List<String> expectedList = new ArrayList<String>(sortedSet);
- List<String> actualList = CollectionTools.list(actual.iterator());
- assertEquals(expectedList, actualList);
- }
-
- public void testAdd() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListChangeEvent e) {/* OK */}
- @Override
- public void itemsReplaced(ListChangeEvent e) {/* OK */}
- });
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- assertEquals(3, this.adapter.size());
- this.verifyList(this.wrappedCollection, this.adapter);
- }
-
- public void testAddItem() {
- List<String> synchList = new CoordinatedList<String>(this.adapter);
- Bag<String> synchCollection = new CoordinatedBag<String>(this.wrappedCollectionHolder);
- this.wrappedCollectionHolder.add("foo");
- assertTrue(this.wrappedCollection.contains("foo"));
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- assertEquals(6, this.wrappedCollection.size());
-
- this.verifyList(this.wrappedCollection, this.adapter);
- assertEquals(this.wrappedCollection, CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection, synchCollection);
- }
-
- public void testRemoveItem() {
- List<String> synchList = new CoordinatedList<String>(this.adapter);
- Bag<String> synchCollection = new CoordinatedBag<String>(this.wrappedCollectionHolder);
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- this.wrappedCollectionHolder.remove("jaz");
- assertFalse(this.wrappedCollection.contains("jaz"));
- this.wrappedCollectionHolder.remove("foo");
- assertFalse(this.wrappedCollection.contains("foo"));
- assertEquals(4, this.wrappedCollection.size());
-
- this.verifyList(this.wrappedCollection, this.adapter);
- assertEquals(this.wrappedCollection, CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection, synchCollection);
- }
-
- public void testListSynch() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListChangeEvent e) {/* OK */}
- @Override
- public void itemsRemoved(ListChangeEvent e) {/* OK */}
- @Override
- public void itemsReplaced(ListChangeEvent e) {/* OK */}
- });
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- this.wrappedCollectionHolder.remove("jaz");
- assertFalse(this.wrappedCollection.contains("jaz"));
- this.wrappedCollectionHolder.remove("foo");
- assertFalse(this.wrappedCollection.contains("foo"));
- assertEquals(4, this.wrappedCollection.size());
-
- this.verifyList(this.wrappedCollection, this.adapter);
- }
-
- public void testSetComparator() {
- List<String> synchList = new CoordinatedList<String>(this.adapter);
- Bag<String> synchCollection = new CoordinatedBag<String>(this.wrappedCollectionHolder);
- this.wrappedCollectionHolder.add("foo");
- assertTrue(this.wrappedCollection.contains("foo"));
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- assertEquals(6, this.wrappedCollection.size());
-
- this.verifyList(this.wrappedCollection, this.adapter);
- assertEquals(this.wrappedCollection, CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection, synchCollection);
-
- this.adapter.setComparator(new ReverseComparator<String>());
- this.verifyList(this.wrappedCollection, this.adapter, new ReverseComparator<String>());
- assertEquals(this.wrappedCollection, CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection, synchCollection);
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- CoordinatedList<String> synchList = new CoordinatedList<String>(this.adapter);
- assertTrue(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.addListChangeListener(synchList);
- assertTrue(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.removeListChangeListener(synchList);
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- class TestListChangeListener implements ListChangeListener {
- public void itemsAdded(ListChangeEvent e) {
- fail("unexpected event");
- }
- public void itemsRemoved(ListChangeEvent e) {
- fail("unexpected event");
- }
- public void itemsReplaced(ListChangeEvent e) {
- fail("unexpected event");
- }
- public void itemsMoved(ListChangeEvent e) {
- fail("unexpected event");
- }
- public void listCleared(ListChangeEvent e) {
- fail("unexpected event");
- }
- public void listChanged(ListChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticCollectionValueModelTests.java
deleted file mode 100644
index b2839e2299..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticCollectionValueModelTests.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.model.value.StaticCollectionValueModel;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class StaticCollectionValueModelTests extends TestCase {
-
- private static final Collection<String> COLLECTION = buildCollection();
- private static Collection<String> buildCollection() {
- Collection<String> result = new HashBag<String>();
- result.add("foo");
- result.add("bar");
- return result;
- }
-
- private CollectionValueModel<String> collectionHolder;
-
-
- public StaticCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.collectionHolder = this.buildCollectionHolder();
- }
-
- private CollectionValueModel<String> buildCollectionHolder() {
- return new StaticCollectionValueModel<String>(COLLECTION);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- assertEquals(buildCollection(), CollectionTools.bag(this.collectionHolder.iterator()));
- }
-
- public void testSize() {
- assertEquals(buildCollection().size(), this.collectionHolder.size());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticListValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticListValueModelTests.java
deleted file mode 100644
index 65dd9ef176..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticListValueModelTests.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.value.StaticListValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class StaticListValueModelTests extends TestCase {
-
- private static final List<String> LIST = buildList();
- private static List<String> buildList() {
- List<String> result = new ArrayList<String>();
- result.add("foo");
- result.add("bar");
- return result;
- }
-
- private ListValueModel<String> listHolder;
-
-
- public StaticListValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.listHolder = new StaticListValueModel<String>(LIST);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGet() {
- List<String> expected = buildList();
- for (int i = 0; i < this.listHolder.size(); i++) {
- assertEquals(expected.get(i), this.listHolder.get(i));
- }
- }
-
- public void testIterator() {
- assertEquals(buildList(), CollectionTools.list(this.listHolder.listIterator()));
- }
-
- public void testSize() {
- assertEquals(buildList().size(), this.listHolder.size());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticValueModelTests.java
deleted file mode 100644
index c894e7183c..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticValueModelTests.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class StaticValueModelTests extends TestCase {
- private PropertyValueModel<String> objectHolder;
- private static final PropertyValueModel<String> OBJECT_HOLDER = new StaticPropertyValueModel<String>("foo");
-
-
- public StaticValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.objectHolder = OBJECT_HOLDER;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- assertEquals("foo", this.objectHolder.getValue());
- }
-
- public void testToString() {
- assertTrue(this.objectHolder.toString().indexOf("foo") >= 0);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/TransformationListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/TransformationListValueModelAdapterTests.java
deleted file mode 100644
index 8147853a51..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/TransformationListValueModelAdapterTests.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.Transformer;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.TransformationListValueModelAdapter;
-import org.eclipse.jpt.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class TransformationListValueModelAdapterTests extends TestCase {
- private SimpleListValueModel<String> listHolder;
- private ListValueModel<String> transformedListHolder;
- ListChangeEvent event;
- String eventType;
-
- private static final String ADD = "add";
- private static final String REMOVE = "remove";
- private static final String REPLACE = "replace";
- private static final String MOVE = "move";
- private static final String CLEAR = "clear";
- private static final String CHANGE = "change";
-
-
- public TransformationListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.listHolder = new SimpleListValueModel<String>(this.buildList());
- this.transformedListHolder = this.buildTransformedListHolder(this.listHolder);
- }
-
- private List<String> buildList() {
- List<String> result = new ArrayList<String>();
- result.add("foo");
- result.add("bar");
- result.add("baz");
- return result;
- }
-
- private List<String> buildTransformedList() {
- return this.transform(this.buildList());
- }
-
- private List<String> transform(List<String> list) {
- List<String> result = new ArrayList<String>(list.size());
- for (String string : list) {
- if (string == null) {
- result.add(null);
- } else {
- result.add(string.toUpperCase());
- }
- }
- return result;
- }
-
- private List<String> buildAddList() {
- List<String> result = new ArrayList<String>();
- result.add("joo");
- result.add("jar");
- result.add("jaz");
- return result;
- }
-
- private List<String> buildTransformedAddList() {
- return this.transform(this.buildAddList());
- }
-
-// private List<String> buildRemoveList() {
-// List<String> result = new ArrayList<String>();
-// result.add("foo");
-// result.add("bar");
-// return result;
-// }
-//
-// private List<String> buildTransformedRemoveList() {
-// return this.transform(this.buildRemoveList());
-// }
-//
- ListValueModel<String> buildTransformedListHolder(ListValueModel<String> lvm) {
- return new TransformationListValueModelAdapter<String, String>(lvm) {
- @Override
- protected String transformItem(String s) {
- return (s == null) ? null : s.toUpperCase();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- assertEquals(this.buildTransformedList(), CollectionTools.list(this.transformedListHolder.iterator()));
- }
-
- public void testStaleValues() {
- ListChangeListener listener = this.buildListener();
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- assertEquals(this.buildTransformedList(), CollectionTools.list(this.transformedListHolder.iterator()));
-
- this.transformedListHolder.removeListChangeListener(ListValueModel.LIST_VALUES, listener);
- assertEquals(Collections.EMPTY_LIST, CollectionTools.list(this.transformedListHolder.iterator()));
- }
-
- public void testSize() {
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- assertEquals(this.buildTransformedList().size(), CollectionTools.size(this.transformedListHolder.iterator()));
- }
-
- private boolean transformedListContains(Object item) {
- return CollectionTools.contains(this.transformedListHolder.iterator(), item);
- }
-
- private boolean transformedListContainsAll(Collection<String> items) {
- return CollectionTools.containsAll(this.transformedListHolder.iterator(), items);
- }
-
- private boolean transformedListContainsAny(Collection<String> items) {
- List<String> transformedList = CollectionTools.list(this.transformedListHolder.iterator());
- for (Iterator<String> stream = items.iterator(); stream.hasNext(); ) {
- if (transformedList.contains(stream.next())) {
- return true;
- }
- }
- return false;
- }
-
- public void testAdd() {
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertFalse(this.transformedListContains("JOO"));
- this.listHolder.add(2, "joo");
- assertTrue(this.transformedListContains("JOO"));
-
- assertFalse(this.transformedListContains(null));
- this.listHolder.add(0, null);
- assertTrue(this.transformedListContains(null));
- }
-
- public void testAddAll() {
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertFalse(this.transformedListContainsAny(this.buildTransformedAddList()));
- this.listHolder.addAll(2, this.buildAddList());
- assertTrue(this.transformedListContainsAll(this.buildTransformedAddList()));
- }
-
- public void testRemove() {
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertTrue(this.transformedListContains("BAR"));
- this.listHolder.remove(this.buildList().indexOf("bar"));
- assertFalse(this.transformedListContains("BAR"));
-
- this.listHolder.add(1, null);
- assertTrue(this.transformedListContains(null));
- this.listHolder.remove(1);
- assertFalse(this.transformedListContains(null));
- }
-
- public void testListChangeGeneric() {
- this.transformedListHolder.addListChangeListener(this.buildListener());
- this.verifyListChange();
- }
-
- public void testListChangeNamed() {
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- this.verifyListChange();
- }
-
- private void verifyListChange() {
- this.event = null;
- this.eventType = null;
- this.listHolder.add(1, "joo");
- this.verifyEvent(ADD, 1, "JOO");
-
- this.event = null;
- this.eventType = null;
- this.listHolder.add(1, null);
- this.verifyEvent(ADD, 1, null);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.remove(1);
- this.verifyEvent(REMOVE, 1, null);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.remove(1);
- this.verifyEvent(REMOVE, 1, "JOO");
-
- this.event = null;
- this.eventType = null;
- this.listHolder.addAll(0, this.buildList());
- this.verifyEvent(ADD);
- assertEquals(this.buildTransformedList(), CollectionTools.list(this.event.items()));
-
- this.event = null;
- this.eventType = null;
- this.listHolder.set(0, "joo");
- this.verifyEvent(REPLACE);
- assertFalse(CollectionTools.contains(this.event.items(), "FOO"));
- assertTrue(CollectionTools.contains(this.event.items(), "JOO"));
- }
-
- private ListChangeListener buildListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListChangeEvent e) {
- TransformationListValueModelAdapterTests.this.eventType = ADD;
- TransformationListValueModelAdapterTests.this.event = e;
- }
- public void itemsRemoved(ListChangeEvent e) {
- TransformationListValueModelAdapterTests.this.eventType = REMOVE;
- TransformationListValueModelAdapterTests.this.event = e;
- }
- public void itemsReplaced(ListChangeEvent e) {
- TransformationListValueModelAdapterTests.this.eventType = REPLACE;
- TransformationListValueModelAdapterTests.this.event = e;
- }
- public void itemsMoved(ListChangeEvent e) {
- TransformationListValueModelAdapterTests.this.eventType = MOVE;
- TransformationListValueModelAdapterTests.this.event = e;
- }
- public void listCleared(ListChangeEvent e) {
- TransformationListValueModelAdapterTests.this.eventType = CLEAR;
- TransformationListValueModelAdapterTests.this.event = e;
- }
- public void listChanged(ListChangeEvent e) {
- TransformationListValueModelAdapterTests.this.eventType = CHANGE;
- TransformationListValueModelAdapterTests.this.event = e;
- }
- };
- }
-
- private void verifyEvent(String type) {
- assertEquals(type, this.eventType);
- assertEquals(this.transformedListHolder, this.event.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event.getListName());
- }
-
- private void verifyEvent(String type, int index, Object item) {
- this.verifyEvent(type);
- assertEquals(index, this.event.getIndex());
- assertEquals(item, this.event.items().next());
- }
-
- public void testHasListeners() {
- /*
- * adding listeners to the transformed list will cause listeners
- * to be added to the wrapped list;
- * likewise, removing listeners from the transformed list will
- * cause listeners to be removed from the wrapped list
- */
- assertFalse(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ListChangeListener listener = this.buildListener();
-
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- assertTrue(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.transformedListHolder.removeListChangeListener(ListValueModel.LIST_VALUES, listener);
- assertFalse(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.transformedListHolder.addListChangeListener(listener);
- assertTrue(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.transformedListHolder.removeListChangeListener(listener);
- assertFalse(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
-
- /**
- * execute the same set of tests again, but by passing a Transformer to the adapter
- * (as opposed to overriding #transformItem(Object))
- */
- public static class TransformerTests extends TransformationListValueModelAdapterTests {
- public TransformerTests(String name) {
- super(name);
- }
- @Override
- ListValueModel<String> buildTransformedListHolder(ListValueModel<String> lvm) {
- return new TransformationListValueModelAdapter<String, String>(lvm, this.buildTransformer());
- }
- private Transformer<String, String> buildTransformer() {
- return new Transformer<String, String>() {
- public String transform(String s) {
- return (s == null) ? null : s.toUpperCase();
- }
- };
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java
deleted file mode 100644
index 1bd87e9f95..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.BidiTransformer;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.TransformationWritablePropertyValueModel;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class TransformationPropertyValueModelTests extends TestCase {
- private WritablePropertyValueModel<String> objectHolder;
- PropertyChangeEvent event;
-
- private WritablePropertyValueModel<String> transformationObjectHolder;
- PropertyChangeEvent transformationEvent;
-
- public TransformationPropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.objectHolder = new SimplePropertyValueModel<String>("foo");
- this.transformationObjectHolder = new TransformationWritablePropertyValueModel<String, String>(this.objectHolder, this.buildTransformer());
- }
-
- private BidiTransformer<String, String> buildTransformer() {
- return new BidiTransformer<String, String>() {
- public String transform(String s) {
- return (s == null) ? null : s.toUpperCase();
- }
- public String reverseTransform(String s) {
- return (s == null) ? null : s.toLowerCase();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- assertEquals("foo", this.objectHolder.getValue());
- assertEquals("FOO", this.transformationObjectHolder.getValue());
-
- this.objectHolder.setValue("bar");
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("BAR", this.transformationObjectHolder.getValue());
-
- this.objectHolder.setValue("baz");
- assertEquals("baz", this.objectHolder.getValue());
- assertEquals("BAZ", this.transformationObjectHolder.getValue());
-
- this.objectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
-
- this.objectHolder.setValue("foo");
- assertEquals("foo", this.objectHolder.getValue());
- assertEquals("FOO", this.transformationObjectHolder.getValue());
- }
-
- public void testSetValue() {
- this.transformationObjectHolder.setValue("BAR");
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("BAR", this.transformationObjectHolder.getValue());
-
- this.transformationObjectHolder.setValue("Foo");
- assertEquals("foo", this.objectHolder.getValue());
- assertEquals("FOO", this.transformationObjectHolder.getValue());
-
- this.transformationObjectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
-
- this.transformationObjectHolder.setValue("baz");
- assertEquals("baz", this.objectHolder.getValue());
- assertEquals("BAZ", this.transformationObjectHolder.getValue());
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- PropertyChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addPropertyChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removePropertyChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testPropertyChange1() {
- this.objectHolder.addPropertyChangeListener(this.buildListener());
- this.transformationObjectHolder.addPropertyChangeListener(this.buildTransformationListener());
- this.verifyPropertyChanges();
- }
-
- public void testPropertyChange2() {
- this.objectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildTransformationListener());
- this.verifyPropertyChanges();
- }
-
- private void verifyPropertyChanges() {
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("bar");
- this.verifyEvent(this.event, this.objectHolder, "foo", "bar");
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "FOO", "BAR");
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("baz");
- this.verifyEvent(this.event, this.objectHolder, "bar", "baz");
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "BAR", "BAZ");
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("Foo");
- this.verifyEvent(this.event, this.objectHolder, "baz", "Foo");
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "BAZ", "FOO");
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("FOO");
- this.verifyEvent(this.event, this.objectHolder, "Foo", "FOO");
- assertNull(this.transformationEvent);
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue(null);
- this.verifyEvent(this.event, this.objectHolder, "FOO", null);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "FOO", null);
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("bar");
- this.verifyEvent(this.event, this.objectHolder, null, "bar");
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, null, "BAR");
- }
-
- private PropertyChangeListener buildListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- TransformationPropertyValueModelTests.this.event = e;
- }
- };
- }
-
- private PropertyChangeListener buildTransformationListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- TransformationPropertyValueModelTests.this.transformationEvent = e;
- }
- };
- }
-
- private void verifyEvent(PropertyChangeEvent e, Object source, Object oldValue, Object newValue) {
- assertEquals(source, e.getSource());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- assertEquals(oldValue, e.getOldValue());
- assertEquals(newValue, e.getNewValue());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/TreeAspectAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/TreeAspectAdapterTests.java
deleted file mode 100644
index ef59751c50..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/TreeAspectAdapterTests.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.iterators.ChainIterator;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.utility.internal.iterators.TreeIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.TreeAspectAdapter;
-import org.eclipse.jpt.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.TreeValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class TreeAspectAdapterTests extends TestCase {
- private TestSubject subject1;
- private WritablePropertyValueModel<TestSubject> subjectHolder1;
- private TreeAspectAdapter<TestSubject, TestNode[]> aa1;
- private TreeChangeEvent event1;
- private TreeChangeListener listener1;
-
- private TestSubject subject2;
-
-
- public TreeAspectAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.subject1 = new TestSubject();
- TestNode root, node;
-
- root = this.subject1.getRootNameNode();
- node = this.subject1.addName(root, "name 1.1");
- this.subject1.addName(node, "name 1.1.1");
- this.subject1.addName(node, "name 1.1.2");
- node = this.subject1.addName(root, "name 1.2");
- this.subject1.addName(node, "name 1.2.1");
- node = this.subject1.addName(root, "name 1.3");
-
- root = this.subject1.getRootDescriptionNode();
- node = this.subject1.addDescription(root, "description 1.1");
- this.subject1.addDescription(node, "description 1.1.1");
- this.subject1.addDescription(node, "description 1.1.2");
- node = this.subject1.addDescription(root, "description 1.2");
- this.subject1.addDescription(node, "description 1.2.1");
- node = this.subject1.addDescription(root, "description 1.3");
-
- this.subjectHolder1 = new SimplePropertyValueModel<TestSubject>(this.subject1);
- this.aa1 = this.buildAspectAdapter(this.subjectHolder1);
- this.listener1 = this.buildValueChangeListener1();
- this.aa1.addTreeChangeListener(TreeValueModel.NODES, this.listener1);
- this.event1 = null;
-
- this.subject2 = new TestSubject();
-
- root = this.subject2.getRootNameNode();
- node = this.subject2.addName(root, "name 2.1");
- this.subject2.addName(node, "name 2.1.1");
- this.subject2.addName(node, "name 2.1.2");
- node = this.subject2.addName(root, "name 2.2");
- this.subject2.addName(node, "name 2.2.1");
- node = this.subject2.addName(root, "name 2.3");
-
- root = this.subject2.getRootDescriptionNode();
- node = this.subject2.addDescription(root, "description 2.1");
- this.subject2.addDescription(node, "description 2.1.1");
- this.subject2.addDescription(node, "description 2.1.2");
- node = this.subject2.addDescription(root, "description 2.2");
- this.subject2.addDescription(node, "description 2.2.1");
- node = this.subject2.addDescription(root, "description 2.3");
- }
-
- private TreeAspectAdapter<TestSubject, TestNode[]> buildAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- return new TreeAspectAdapter<TestSubject, TestNode[]>(subjectHolder, TestSubject.NAMES_TREE) {
- // this is not a typical aspect adapter - the value is determined by the aspect name
- @Override
- protected Iterator<TestNode[]> nodes_() {
- if (this.treeNames[0] == TestSubject.NAMES_TREE) {
- return this.subject.namePaths();
- }
- if (this.treeNames[0] == TestSubject.DESCRIPTIONS_TREE) {
- return this.subject.descriptionPaths();
- }
- throw new IllegalStateException("invalid aspect name: " + this.treeNames[0]);
- }
- };
- }
-
- private TreeChangeListener buildValueChangeListener1() {
- return new TreeChangeListener() {
- public void nodeAdded(TreeChangeEvent e) {
- TreeAspectAdapterTests.this.value1Changed(e);
- }
- public void nodeRemoved(TreeChangeEvent e) {
- TreeAspectAdapterTests.this.value1Changed(e);
- }
- public void treeCleared(TreeChangeEvent e) {
- TreeAspectAdapterTests.this.value1Changed(e);
- }
- public void treeChanged(TreeChangeEvent e) {
- TreeAspectAdapterTests.this.value1Changed(e);
- }
- };
- }
-
- void value1Changed(TreeChangeEvent e) {
- this.event1 = e;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSubjectHolder() {
- assertNull(this.event1);
-
- this.subjectHolder1.setValue(this.subject2);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(TreeValueModel.NODES, this.event1.getTreeName());
- assertEquals(0, this.event1.getPath().length);
-
- this.event1 = null;
- this.subjectHolder1.setValue(null);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(TreeValueModel.NODES, this.event1.getTreeName());
- assertEquals(0, this.event1.getPath().length);
-
- this.event1 = null;
- this.subjectHolder1.setValue(this.subject1);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(TreeValueModel.NODES, this.event1.getTreeName());
- assertEquals(0, this.event1.getPath().length);
- }
-
- public void testTreeStructureChange() {
- assertNull(this.event1);
-
- this.subject1.addTwoNames(this.subject1.getRootNameNode(), "jam", "jaz");
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(TreeValueModel.NODES, this.event1.getTreeName());
- Object[] path = this.event1.getPath();
- assertEquals(this.subject1.getRootNameNode(), path[path.length - 1]);
- assertTrue(this.subject1.containsNameNode("jam"));
- assertTrue(this.subject1.containsNameNode("jaz"));
- }
-
- public void testNodes() {
- assertEquals(this.convertToNames(this.subject1.namePaths()), this.convertToNames(this.aa1.nodes()));
- }
-
- private Collection<String> convertToNames(Iterator<TestNode[]> namePaths) {
- Collection<String> result = new HashBag<String>();
- while (namePaths.hasNext()) {
- Object[] path = namePaths.next();
- StringBuffer sb = new StringBuffer();
- sb.append('[');
- for (int i = 0; i < path.length; i++) {
- sb.append(((TestNode) path[i]).getText());
- if (i < path.length - 1) {
- sb.append(':');
- }
- }
- sb.append(']');
- result.add(sb.toString());
- }
- return result;
- }
-
- public void testHasListeners() {
- assertTrue(this.aa1.hasAnyTreeChangeListeners(TreeValueModel.NODES));
- assertTrue(this.subject1.hasAnyTreeChangeListeners(TestSubject.NAMES_TREE));
- this.aa1.removeTreeChangeListener(TreeValueModel.NODES, this.listener1);
- assertFalse(this.subject1.hasAnyTreeChangeListeners(TestSubject.NAMES_TREE));
- assertFalse(this.aa1.hasAnyTreeChangeListeners(TreeValueModel.NODES));
-
- TreeChangeListener listener2 = this.buildValueChangeListener1();
- this.aa1.addTreeChangeListener(listener2);
- assertTrue(this.aa1.hasAnyTreeChangeListeners(TreeValueModel.NODES));
- assertTrue(this.subject1.hasAnyTreeChangeListeners(TestSubject.NAMES_TREE));
- this.aa1.removeTreeChangeListener(listener2);
- assertFalse(this.subject1.hasAnyTreeChangeListeners(TestSubject.NAMES_TREE));
- assertFalse(this.aa1.hasAnyTreeChangeListeners(TreeValueModel.NODES));
- }
-
- // ********** inner classes **********
-
- private class TestSubject extends AbstractModel {
- private TestNode rootNameNode;
- public static final String NAMES_TREE = "names";
- private TestNode rootDescriptionNode;
- public static final String DESCRIPTIONS_TREE = "descriptions";
-
- public TestSubject() {
- this.rootNameNode = new TestNode("root name");
- this.rootDescriptionNode = new TestNode("root description");
- }
- public TestNode getRootNameNode() {
- return this.rootNameNode;
- }
- public Iterator<TestNode> nameNodes() {
- return new TreeIterator<TestNode>(this.rootNameNode) {
- @Override
- public Iterator<TestNode> children(TestNode next) {
- return next.children();
- }
- };
- }
- public Iterator<TestNode[]> namePaths() {
- return new TransformationIterator<TestNode, TestNode[]>(this.nameNodes()) {
- @Override
- protected TestNode[] transform(TestNode next) {
- return next.path();
- }
- };
- }
- public TestNode addName(TestNode parent, String name) {
- TestNode child = new TestNode(name);
- parent.addChild(child);
- this.fireNodeAdded(NAMES_TREE, child.path());
- return child;
- }
- public void addTwoNames(TestNode parent, String name1, String name2) {
- parent.addChild(new TestNode(name1));
- parent.addChild(new TestNode(name2));
- this.fireTreeChanged(NAMES_TREE, parent.path());
- }
- public void removeNameNode(TestNode nameNode) {
- nameNode.getParent().removeChild(nameNode);
- this.fireNodeRemoved(NAMES_TREE, nameNode.path());
- }
- public boolean containsNameNode(String name) {
- return this.nameNode(name) != null;
- }
- public TestNode nameNode(String name) {
- for (Iterator<TestNode> stream = this.nameNodes(); stream.hasNext(); ) {
- TestNode node = stream.next();
- if (node.getText().equals(name)) {
- return node;
- }
- }
- return null;
- }
- public TestNode getRootDescriptionNode() {
- return this.rootDescriptionNode;
- }
- public Iterator<TestNode> descriptionNodes() {
- return new TreeIterator<TestNode>(this.rootDescriptionNode) {
- @Override
- public Iterator<TestNode> children(TestNode next) {
- return next.children();
- }
- };
- }
- public Iterator<TestNode[]> descriptionPaths() {
- return new TransformationIterator<TestNode, TestNode[]>(this.descriptionNodes()) {
- @Override
- protected TestNode[] transform(TestNode next) {
- return next.path();
- }
- };
- }
- public TestNode addDescription(TestNode parent, String description) {
- TestNode child = new TestNode(description);
- parent.addChild(child);
- this.fireNodeAdded(DESCRIPTIONS_TREE, child.path());
- return child;
- }
- public void removeDescriptionNode(TestNode descriptionNode) {
- descriptionNode.getParent().removeChild(descriptionNode);
- this.fireNodeRemoved(DESCRIPTIONS_TREE, descriptionNode.path());
- }
- public boolean containsDescriptionNode(String name) {
- for (Iterator<TestNode> stream = this.descriptionNodes(); stream.hasNext(); ) {
- TestNode node = stream.next();
- if (node.getText().equals(name)) {
- return true;
- }
- }
- return false;
- }
- }
-
- private class TestNode {
- private final String text;
- private TestNode parent;
- private final Collection<TestNode> children;
-
- public TestNode(String text) {
- this.text = text;
- this.children = new HashBag<TestNode>();
- }
- public String getText() {
- return this.text;
- }
- public TestNode getParent() {
- return this.parent;
- }
- private void setParent(TestNode parent) {
- this.parent = parent;
- }
- public Iterator<TestNode> children() {
- return new ReadOnlyIterator<TestNode>(this.children);
- }
- public void addChild(TestNode child) {
- this.children.add(child);
- child.setParent(this);
- }
- public void removeChild(TestNode child) {
- this.children.remove(child);
- }
- public TestNode[] path() {
- return CollectionTools.reverseList(this.buildAntiPath()).toArray(new TestNode[0]);
- }
- private Iterator<TestNode> buildAntiPath() {
- return new ChainIterator<TestNode>(this) {
- @Override
- protected TestNode nextLink(TestNode currentLink) {
- return currentLink.getParent();
- }
- };
- }
- @Override
- public String toString() {
- return "TestNode(" + this.text + ")";
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValueCollectionAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValueCollectionAdapterTests.java
deleted file mode 100644
index 1f7bab6d37..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValueCollectionAdapterTests.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.ValueCollectionAdapter;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ValueCollectionAdapterTests extends TestCase {
- private Junk junk;
- private SimplePropertyValueModel<Junk> junkHolder;
- private ValueCollectionAdapter<Junk> junkHolder2;
-
-
- public ValueCollectionAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.junk = new Junk("foo");
- this.junkHolder = new SimplePropertyValueModel<Junk>(this.junk);
- this.junkHolder2 = new ValueCollectionAdapter<Junk>(this.junkHolder, Junk.STUFF_COLLECTION);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testWrappedPVM() {
- Junk junk2 = new Junk("bar");
- LocalListener l = new LocalListener(this.junkHolder2, this.junk, junk2);
- this.junkHolder2.addPropertyChangeListener(l);
- this.junkHolder.setValue(junk2);
- assertTrue(l.eventReceived());
- }
-
- public void testHasPropertyChangeListeners() throws Exception {
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addPropertyChangeListener(l);
- assertTrue(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.junkHolder2.removePropertyChangeListener(l);
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testHasStateChangeListeners() throws Exception {
- assertFalse(this.junk.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- assertTrue(this.junk.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- assertTrue(this.junkHolder2.hasAnyStateChangeListeners());
-
- this.junkHolder2.removeStateChangeListener(l);
- assertFalse(this.junk.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
- }
-
- public void testCollectionAdd() {
- LocalListener l = new LocalListener(this.junkHolder2);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.addStuff("bar");
- assertTrue(l.eventReceived());
- }
-
- public void testCollectionRemove() {
- LocalListener l = new LocalListener(this.junkHolder2);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.removeStuff("foo");
- assertTrue(l.eventReceived());
- }
-
-
- private class LocalListener implements PropertyChangeListener, StateChangeListener {
- private boolean eventReceived = false;
- private final Object source;
- private final Object oldValue;
- private final Object newValue;
- LocalListener(Object source) {
- this(source, null, null);
- }
- LocalListener(Object source, Object oldValue, Object newValue) {
- super();
- this.source = source;
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
- public void propertyChanged(PropertyChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- assertEquals(this.oldValue, e.getOldValue());
- assertEquals(this.newValue, e.getNewValue());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- }
- public void stateChanged(StateChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- assertNull(e.getAspectName());
- }
- boolean eventReceived() {
- return this.eventReceived;
- }
- }
-
-
- private class Junk extends AbstractModel {
- private Collection<String> stuff;
- public static final String STUFF_COLLECTION = "stuff";
-
- public Junk(String stuffItem) {
- this.stuff = new ArrayList<String>();
- this.stuff.add(stuffItem);
- }
-
- public void addStuff(String stuffItem) {
- this.addItemToCollection(stuffItem, this.stuff, STUFF_COLLECTION);
- }
-
- public void removeStuff(String stuffItem) {
- this.removeItemFromCollection(stuffItem, this.stuff, STUFF_COLLECTION);
- }
-
- @Override
- public String toString() {
- return "Junk(" + this.stuff + ")";
- }
-
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValueListAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValueListAdapterTests.java
deleted file mode 100644
index 31050d8c27..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValueListAdapterTests.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.ValueListAdapter;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ValueListAdapterTests extends TestCase {
- private Junk junk;
- private SimplePropertyValueModel<Junk> junkHolder;
- private ValueListAdapter<Junk> junkHolder2;
-
-
-
- public ValueListAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.junk = new Junk("foo");
- this.junkHolder = new SimplePropertyValueModel<Junk>(this.junk);
- this.junkHolder2 = new ValueListAdapter<Junk>(this.junkHolder, Junk.STUFF_LIST);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testWrappedPVM() {
- Junk junk2 = new Junk("bar");
- LocalListener l = new LocalListener(this.junkHolder2, this.junk, junk2);
- this.junkHolder2.addPropertyChangeListener(l);
- this.junkHolder.setValue(junk2);
- assertTrue(l.eventReceived());
- }
-
- public void testHasPropertyChangeListeners() throws Exception {
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addPropertyChangeListener(l);
- assertTrue(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.junkHolder2.removePropertyChangeListener(l);
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testHasStateChangeListeners() throws Exception {
- assertFalse(this.junk.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- assertTrue(this.junk.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertTrue(this.junkHolder2.hasAnyStateChangeListeners());
-
- this.junkHolder2.removeStateChangeListener(l);
- assertFalse(this.junk.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
- }
-
- public void testListAdd() {
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.addStuff("bar");
- assertTrue(l.eventReceived());
- }
-
- public void testListRemove() {
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.removeStuff("foo");
- assertTrue(l.eventReceived());
- }
-
- public void testListReplace() {
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.replaceStuff("foo", "bar");
- assertTrue(l.eventReceived());
- }
-
-
- private class LocalListener implements PropertyChangeListener, StateChangeListener {
- private boolean eventReceived = false;
- private final Object source;
- private final Object oldValue;
- private final Object newValue;
- LocalListener(Object source) {
- this(source, null, null);
- }
- LocalListener(Object source, Object oldValue, Object newValue) {
- super();
- this.source = source;
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
- public void propertyChanged(PropertyChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- assertEquals(this.oldValue, e.getOldValue());
- assertEquals(this.newValue, e.getNewValue());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- }
- public void stateChanged(StateChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- assertNull(e.getAspectName());
- }
- boolean eventReceived() {
- return this.eventReceived;
- }
- }
-
- private class Junk extends AbstractModel {
- private List<String> stuff;
- public static final String STUFF_LIST = "stuff";
-
- public Junk(String stuffItem) {
- this.stuff = new ArrayList<String>();
- this.stuff.add(stuffItem);
- }
-
- public void addStuff(String stuffItem) {
- this.addItemToList(stuffItem, this.stuff, STUFF_LIST);
- }
-
- public void removeStuff(String stuffItem) {
- this.removeItemFromList(stuffItem, this.stuff, STUFF_LIST);
- }
-
- public void replaceStuff(String oldStuffItem, String newStuffItem) {
- this.replaceItemInList(oldStuffItem, newStuffItem, this.stuff, STUFF_LIST);
- }
-
- @Override
- public String toString() {
- return "Junk(" + this.stuff + ")";
- }
-
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValuePropertyAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValuePropertyAdapterTests.java
deleted file mode 100644
index 62832c8a84..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValuePropertyAdapterTests.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.ValuePropertyAdapter;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ValuePropertyAdapterTests extends TestCase {
- private Junk junk;
- private SimplePropertyValueModel<Junk> junkHolder;
- private ValuePropertyAdapter<Junk> junkHolder2;
-
-
- public ValuePropertyAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.junk = new Junk("foo");
- this.junkHolder = new SimplePropertyValueModel<Junk>(this.junk);
- this.junkHolder2 = new ValuePropertyAdapter<Junk>(this.junkHolder, Junk.NAME_PROPERTY);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testWrappedPVM() {
- Junk junk2 = new Junk("bar");
- LocalListener l = new LocalListener(this.junkHolder2, this.junk, junk2);
- this.junkHolder2.addPropertyChangeListener(l);
- this.junkHolder.setValue(junk2);
- assertTrue(l.eventReceived());
- }
-
- public void testHasPropertyChangeListeners() throws Exception {
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addPropertyChangeListener(l);
- assertTrue(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.junkHolder2.removePropertyChangeListener(l);
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testHasStateChangeListeners() throws Exception {
- assertFalse(this.junk.hasAnyPropertyChangeListeners(Junk.NAME_PROPERTY));
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- assertTrue(this.junk.hasAnyPropertyChangeListeners(Junk.NAME_PROPERTY));
- assertTrue(this.junkHolder2.hasAnyStateChangeListeners());
-
- this.junkHolder2.removeStateChangeListener(l);
- assertFalse(this.junk.hasAnyPropertyChangeListeners(Junk.NAME_PROPERTY));
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
- }
-
- public void testChangeProperty() {
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.setName("bar");
- assertTrue(l.eventReceived());
- }
-
-
- private class LocalListener implements PropertyChangeListener, StateChangeListener {
- private boolean eventReceived = false;
- private final Object source;
- private final Object oldValue;
- private final Object newValue;
- LocalListener(Object source) {
- this(source, null, null);
- }
- LocalListener(Object source, Object oldValue, Object newValue) {
- super();
- this.source = source;
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
- public void propertyChanged(PropertyChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- assertEquals(this.oldValue, e.getOldValue());
- assertEquals(this.newValue, e.getNewValue());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- }
- public void stateChanged(StateChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- assertNull(e.getAspectName());
- }
- boolean eventReceived() {
- return this.eventReceived;
- }
- }
-
- private class Junk extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- public Junk(String name) {
- this.name = name;
- }
-
- public void setName(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- @Override
- public String toString() {
- return "Junk(" + this.name + ")";
- }
-
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValueStateAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValueStateAdapterTests.java
deleted file mode 100644
index 71dfee9e0f..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ValueStateAdapterTests.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.ValueStateAdapter;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ValueStateAdapterTests extends TestCase {
- private Junk junk;
- private SimplePropertyValueModel<Junk> junkHolder;
- private ValueStateAdapter<Junk> junkHolder2;
-
-
- public ValueStateAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.junk = new Junk("foo");
- this.junkHolder = new SimplePropertyValueModel<Junk>(this.junk);
- this.junkHolder2 = new ValueStateAdapter<Junk>(this.junkHolder);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testWrappedPVM() {
- Junk junk2 = new Junk("bar");
- LocalListener l = new LocalListener(this.junkHolder2, this.junk, junk2);
- this.junkHolder2.addPropertyChangeListener(l);
- this.junkHolder.setValue(junk2);
- assertTrue(l.eventReceived());
- }
-
- public void testHasPropertyChangeListeners() throws Exception {
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addPropertyChangeListener(l);
- assertTrue(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.junkHolder2.removePropertyChangeListener(l);
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testHasStateChangeListeners() throws Exception {
- assertFalse(this.junk.hasAnyStateChangeListeners());
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- assertTrue(this.junk.hasAnyStateChangeListeners());
- assertTrue(this.junkHolder2.hasAnyStateChangeListeners());
-
- this.junkHolder2.removeStateChangeListener(l);
- assertFalse(this.junk.hasAnyStateChangeListeners());
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
- }
-
- public void testChangeState() {
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addPropertyChangeListener(l);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.setName("bar");
- assertTrue(l.eventReceived());
- }
-
-
- private class LocalListener implements PropertyChangeListener, StateChangeListener {
- private boolean eventReceived = false;
- private final Object source;
- private final Object oldValue;
- private final Object newValue;
- LocalListener(Object source) {
- this(source, null, null);
- }
- LocalListener(Object source, Object oldValue, Object newValue) {
- super();
- this.source = source;
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
- public void propertyChanged(PropertyChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- assertEquals(this.oldValue, e.getOldValue());
- assertEquals(this.newValue, e.getNewValue());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- }
- public void stateChanged(StateChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- assertNull(e.getAspectName());
- }
- boolean eventReceived() {
- return this.eventReceived;
- }
- }
-
- private class Junk extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- public Junk(String name) {
- this.name = name;
- }
-
- public void setName(String name) {
- this.name = name;
- this.fireStateChanged();
- }
-
- @Override
- public String toString() {
- return "Junk(" + this.name + ")";
- }
-
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/JptUtilityModelValuePrefsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/JptUtilityModelValuePrefsTests.java
deleted file mode 100644
index 043da07fbf..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/JptUtilityModelValuePrefsTests.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.prefs;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptUtilityModelValuePrefsTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityModelValuePrefsTests.class.getPackage().getName());
-
- suite.addTestSuite(PreferencesCollectionValueModelTests.class);
- suite.addTestSuite(PreferencePropertyValueModelTests.class);
-
- return suite;
- }
-
- private JptUtilityModelValuePrefsTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
deleted file mode 100644
index 95f9cae3d7..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.prefs;
-
-import java.util.prefs.NodeChangeEvent;
-import java.util.prefs.NodeChangeListener;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.Preferences;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.prefs.PreferencePropertyValueModel;
-import org.eclipse.jpt.utility.model.Model;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-public class PreferencePropertyValueModelTests extends PreferencesTestCase {
- private WritablePropertyValueModel<Preferences> nodeHolder;
- PreferencePropertyValueModel<String> preferenceAdapter;
- PropertyChangeEvent event;
- PropertyChangeListener listener;
- boolean listenerRemoved = false;
- PreferenceChangeEvent preferenceEvent;
- private static final String KEY_NAME = "foo";
- private static final String STRING_VALUE = "original string value";
-
- public PreferencePropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.testNode.put(KEY_NAME, STRING_VALUE);
-
- this.nodeHolder = new SimplePropertyValueModel<Preferences>(this.testNode);
- this.preferenceAdapter = new PreferencePropertyValueModel<String>(this.nodeHolder, KEY_NAME);
- this.listener = this.buildValueChangeListener();
- this.preferenceAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- this.event = null;
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- private PropertyChangeListener buildValueChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- if (PreferencePropertyValueModelTests.this.event != null) {
- throw new IllegalStateException("unexpected this.event: " + e);
- }
- PreferencePropertyValueModelTests.this.event = e;
- }
- };
- }
-
- public void testSubjectHolder() throws Exception {
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- assertNull(this.event);
-
- String ANOTHER_STRING_VALUE = "some other value";
- Preferences anotherNode = this.classNode.node("another test node");
- anotherNode.put(KEY_NAME, ANOTHER_STRING_VALUE);
-
- this.nodeHolder.setValue(anotherNode);
- this.verifyEvent(STRING_VALUE, ANOTHER_STRING_VALUE);
- assertEquals(ANOTHER_STRING_VALUE, this.preferenceAdapter.getValue());
-
- this.event = null;
- this.nodeHolder.setValue(null);
- this.verifyEvent(ANOTHER_STRING_VALUE, null);
- assertNull(this.preferenceAdapter.getValue());
-
- this.event = null;
- this.nodeHolder.setValue(this.testNode);
- this.verifyEvent(null, STRING_VALUE);
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- }
-
- public void testPreferenceChange() throws Exception {
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- assertNull(this.event);
-
- this.testNode.put(KEY_NAME, STRING_VALUE + STRING_VALUE);
- this.waitForEventQueueToClear();
- this.verifyEvent(STRING_VALUE, STRING_VALUE + STRING_VALUE);
- assertEquals(STRING_VALUE + STRING_VALUE, this.preferenceAdapter.getValue());
-
- this.event = null;
- this.testNode.remove(KEY_NAME);
- this.waitForEventQueueToClear();
- this.verifyEvent(STRING_VALUE + STRING_VALUE, null);
- assertNull(this.preferenceAdapter.getValue());
-
- this.event = null;
- this.testNode.put(KEY_NAME, STRING_VALUE);
- this.waitForEventQueueToClear();
- this.verifyEvent(null, STRING_VALUE);
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- }
-
- public void testValue() throws Exception {
- assertEquals(STRING_VALUE, this.testNode.get(KEY_NAME, "<missing preference>"));
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- }
-
- public void testSetValue() throws Exception {
- String ANOTHER_STRING_VALUE = "some other value";
- this.preferenceAdapter.setValue(ANOTHER_STRING_VALUE);
- assertEquals(ANOTHER_STRING_VALUE, this.preferenceAdapter.getValue());
- assertEquals(ANOTHER_STRING_VALUE, this.testNode.get(KEY_NAME, "<missing preference>"));
- }
-
- public void testHasListeners() throws Exception {
- assertTrue(this.preferenceAdapter.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.nodeHasAnyPrefListeners(this.testNode));
- this.preferenceAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- assertFalse(this.nodeHasAnyPrefListeners(this.testNode));
- assertFalse(this.preferenceAdapter.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- PropertyChangeListener listener2 = this.buildValueChangeListener();
- this.preferenceAdapter.addPropertyChangeListener(listener2);
- assertTrue(this.preferenceAdapter.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.nodeHasAnyPrefListeners(this.testNode));
- this.preferenceAdapter.removePropertyChangeListener(listener2);
- assertFalse(this.nodeHasAnyPrefListeners(this.testNode));
- assertFalse(this.preferenceAdapter.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testRemoveAndReAddPreference() throws Exception {
- assertEquals(STRING_VALUE, this.testNode.get(KEY_NAME, null));
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- assertNull(this.event);
-
- // remove the preference entirely...
- this.testNode.remove(KEY_NAME);
- this.waitForEventQueueToClear();
- assertNull(this.testNode.get(KEY_NAME, null));
- this.verifyEvent(STRING_VALUE, null);
- assertNull(this.preferenceAdapter.getValue());
-
- // ...then re-add it with the same key
- this.event = null;
- this.testNode.put(KEY_NAME, STRING_VALUE);
- this.waitForEventQueueToClear();
- assertEquals(STRING_VALUE, this.testNode.get(KEY_NAME, null));
- this.verifyEvent(null, STRING_VALUE);
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- }
-
- public void testDefaultValue() throws Exception {
- // rebuild the adapter with a default value
- String DEFAULT_VALUE = "default value";
- this.preferenceAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- this.preferenceAdapter = new PreferencePropertyValueModel<String>(this.nodeHolder, KEY_NAME, DEFAULT_VALUE);
- this.preferenceAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener);
-
- assertEquals(STRING_VALUE, this.testNode.get(KEY_NAME, null));
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- assertNull(this.event);
-
- // remove the preference entirely...
- this.testNode.remove(KEY_NAME);
- this.waitForEventQueueToClear();
- assertNull(this.testNode.get(KEY_NAME, null));
- this.verifyEvent(STRING_VALUE, DEFAULT_VALUE);
- assertEquals(DEFAULT_VALUE, this.preferenceAdapter.getValue());
-
- // ...then re-add it with the same key
- this.event = null;
- this.testNode.put(KEY_NAME, STRING_VALUE);
- this.waitForEventQueueToClear();
- assertEquals(STRING_VALUE, this.testNode.get(KEY_NAME, null));
- this.verifyEvent(DEFAULT_VALUE, STRING_VALUE);
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- }
-
- public void testUnsynchronizedValue() throws Exception {
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- assertNull(this.event);
-
- // remove the this.listener so the adapter no longer listens to the preference
- this.preferenceAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
-
- this.testNode.put(KEY_NAME, STRING_VALUE + STRING_VALUE);
- this.waitForEventQueueToClear();
- // no this.event should have been fired...
- assertNull(this.event);
- // ...and the adapter's value should be null
- assertNull(this.preferenceAdapter.getValue());
-
- this.testNode.remove(KEY_NAME);
- this.waitForEventQueueToClear();
- assertNull(this.event);
- assertNull(this.preferenceAdapter.getValue());
-
- this.testNode.put(KEY_NAME, STRING_VALUE);
- this.waitForEventQueueToClear();
- assertNull(this.event);
- assertNull(this.preferenceAdapter.getValue());
-
- // add the this.listener so the adapter synchs
- this.preferenceAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- }
-
- public void testIntegerPreference() throws Exception {
- // stop listening to the node and convert it to an integer
- this.preferenceAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
-
- PreferencePropertyValueModel<Integer> integerPreferenceAdapter = new PreferencePropertyValueModel<Integer>(this.nodeHolder, KEY_NAME);
- this.testNode.putInt(KEY_NAME, 123);
- integerPreferenceAdapter = PreferencePropertyValueModel.forInteger(this.testNode, KEY_NAME, 0);
- integerPreferenceAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- assertEquals(new Integer(123), integerPreferenceAdapter.getValue());
- assertNull(this.event);
-
- this.testNode.putInt(KEY_NAME, 246);
- this.waitForEventQueueToClear();
- this.verifyEvent(integerPreferenceAdapter, new Integer(123), new Integer(246));
- assertEquals(new Integer(246), integerPreferenceAdapter.getValue());
-
- this.event = null;
- this.testNode.remove(KEY_NAME);
- this.waitForEventQueueToClear();
- this.verifyEvent(integerPreferenceAdapter, new Integer(246), new Integer(0));
- assertEquals(new Integer(0), integerPreferenceAdapter.getValue());
-
- this.event = null;
- this.testNode.putInt(KEY_NAME, 123);
- this.waitForEventQueueToClear();
- this.verifyEvent(integerPreferenceAdapter, new Integer(0), new Integer(123));
- assertEquals(new Integer(123), integerPreferenceAdapter.getValue());
- }
-
- /**
- * test a situation where
- * - we are listening to the node when it gets removed from the preferences "repository"
- * - we get notification that it has been removed
- * - we try to remove our this.listener
- * - the node will throw an IllegalStateException - the adapter should handle it OK...
- */
- public void testRemoveNode() throws Exception {
- assertTrue(this.preferenceAdapter.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- Preferences parent = this.testNode.parent();
- parent.addNodeChangeListener(this.buildParentNodeChangeListener());
- this.testNode.removeNode();
- this.testNode.flush(); // this seems to be required for the this.event to trigger...
- this.waitForEventQueueToClear();
-
- assertTrue(this.listenerRemoved);
- assertTrue(this.preferenceAdapter.hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- private NodeChangeListener buildParentNodeChangeListener() {
- return new NodeChangeListener() {
- public void childAdded(NodeChangeEvent e) {
- throw new IllegalStateException("unexpected this.event: " + e);
- }
- public void childRemoved(NodeChangeEvent e) {
- if (e.getChild() == PreferencePropertyValueModelTests.this.testNode) {
- PreferencePropertyValueModelTests.this.preferenceAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, PreferencePropertyValueModelTests.this.listener);
- // this line of code will not execute if the line above triggers an exception
- PreferencePropertyValueModelTests.this.listenerRemoved = true;
- }
- }
- };
- }
-
- public void testSetSameValue() {
- assertNull(this.event);
- assertNull(this.preferenceEvent);
- this.testNode.addPreferenceChangeListener(this.buildPreferenceChangeListener());
-
- String ANOTHER_STRING_VALUE = "some other value";
- this.preferenceAdapter.setValue(ANOTHER_STRING_VALUE);
-
- this.verifyEvent(STRING_VALUE, ANOTHER_STRING_VALUE);
- this.waitForEventQueueToClear();
- this.verifyPreferenceEvent(ANOTHER_STRING_VALUE);
-
- // now set to *same* value - nothing should happen...
- this.event = null;
- this.preferenceEvent = null;
- this.preferenceAdapter.setValue(ANOTHER_STRING_VALUE);
-
- assertNull(this.event);
- assertNull(this.preferenceEvent);
- }
-
- public void testSetSameValueForcePassThrough() throws Exception {
- assertNull(this.event);
- assertNull(this.preferenceEvent);
-
- this.preferenceAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- this.preferenceAdapter = new AlwaysUpdatePreferencePropertyValueModel<String>(this.nodeHolder, KEY_NAME);
- this.preferenceAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener);
-
- this.testNode.addPreferenceChangeListener(this.buildPreferenceChangeListener());
-
- String ANOTHER_STRING_VALUE = "some other value";
- this.preferenceAdapter.setValue(ANOTHER_STRING_VALUE);
-
- this.verifyEvent(STRING_VALUE, ANOTHER_STRING_VALUE);
- this.waitForEventQueueToClear();
- this.verifyPreferenceEvent(ANOTHER_STRING_VALUE);
-
- // now set to *same* value - only one this.event should fire
- this.event = null;
- this.preferenceEvent = null;
- this.preferenceAdapter.setValue(ANOTHER_STRING_VALUE);
-
- assertNull(this.event);
- this.waitForEventQueueToClear();
- this.verifyPreferenceEvent(ANOTHER_STRING_VALUE);
- assertNull(this.event);
- }
-
- private PreferenceChangeListener buildPreferenceChangeListener() {
- return new PreferenceChangeListener() {
- public void preferenceChange(PreferenceChangeEvent evt) {
- PreferencePropertyValueModelTests.this.preferenceEvent = evt;
- }
- };
- }
-
- private void verifyEvent(Model source, Object oldValue, Object newValue) {
- assertNotNull(this.event);
- assertEquals(source, this.event.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event.getPropertyName());
- assertEquals(oldValue, this.event.getOldValue());
- assertEquals(newValue, this.event.getNewValue());
- }
-
- private void verifyEvent(Object oldValue, Object newValue) {
- this.verifyEvent(this.preferenceAdapter, oldValue, newValue);
- }
-
- private void verifyPreferenceEvent(Object newValue) {
- assertNotNull(this.preferenceEvent);
- assertEquals(this.testNode, this.preferenceEvent.getSource());
- assertEquals(KEY_NAME, this.preferenceEvent.getKey());
- assertEquals(newValue, this.preferenceEvent.getNewValue());
- assertEquals(newValue, this.testNode.get(KEY_NAME, "<missing preference>"));
- }
-
- private boolean nodeHasAnyPrefListeners(Preferences node) throws Exception {
- PreferenceChangeListener[] prefListeners = (PreferenceChangeListener[]) ClassTools.fieldValue(node, "prefListeners");
- return prefListeners.length > 0;
- }
-
-
- /**
- * Use this adapter to test out always passing through the new value
- * to the preference.
- */
- private class AlwaysUpdatePreferencePropertyValueModel<P> extends PreferencePropertyValueModel<P> {
-
- AlwaysUpdatePreferencePropertyValueModel(PropertyValueModel<Preferences> preferencesHolder, String key) {
- super(preferencesHolder, key);
- }
-
- @Override
- protected boolean shouldSetPreference(Object oldValue, Object newValue) {
- return true;
- }
-
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
deleted file mode 100644
index f6e4a59a7b..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.prefs;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.prefs.NodeChangeEvent;
-import java.util.prefs.NodeChangeListener;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.Preferences;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.prefs.PreferencePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.prefs.PreferencesCollectionValueModel;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-public class PreferencesCollectionValueModelTests extends PreferencesTestCase {
- private Map<String, String> expectedValues;
- private WritablePropertyValueModel<Preferences> nodeHolder;
- PreferencesCollectionValueModel<String> preferencesAdapter;
- CollectionChangeEvent event;
- CollectionChangeListener listener;
- private PropertyChangeListener itemListener;
- boolean listenerRemoved = false;
- private static final String KEY_NAME_1 = "foo 1";
- private static final String KEY_NAME_2 = "foo 2";
- private static final String KEY_NAME_3 = "foo 3";
- private static final String STRING_VALUE_1 = "original string value 1";
- private static final String STRING_VALUE_2 = "original string value 2";
- private static final String STRING_VALUE_3 = "original string value 3";
-
- public PreferencesCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.expectedValues = new HashMap<String, String>();
- this.testNode.put(KEY_NAME_1, STRING_VALUE_1); this.expectedValues.put(KEY_NAME_1, STRING_VALUE_1);
- this.testNode.put(KEY_NAME_2, STRING_VALUE_2); this.expectedValues.put(KEY_NAME_2, STRING_VALUE_2);
- this.testNode.put(KEY_NAME_3, STRING_VALUE_3); this.expectedValues.put(KEY_NAME_3, STRING_VALUE_3);
-
- this.nodeHolder = new SimplePropertyValueModel<Preferences>(this.testNode);
- this.preferencesAdapter = new PreferencesCollectionValueModel<String>(this.nodeHolder);
- this.listener = this.buildCollectionChangeListener();
- this.itemListener = this.buildItemListener();
- this.preferencesAdapter.addCollectionChangeListener(CollectionValueModel.VALUES, this.listener);
- this.event = null;
- }
-
- private CollectionChangeListener buildCollectionChangeListener() {
- return new CollectionChangeListener() {
- public void collectionChanged(CollectionChangeEvent e) {
- this.logEvent(e);
- }
- public void collectionCleared(CollectionChangeEvent e) {
- this.logEvent(e);
- }
- public void itemsAdded(CollectionChangeEvent e) {
- this.logEvent(e);
- }
- public void itemsRemoved(CollectionChangeEvent e) {
- this.logEvent(e);
- }
- private void logEvent(CollectionChangeEvent e) {
- if (PreferencesCollectionValueModelTests.this.event != null) {
- throw new IllegalStateException("unexpected this.event: " + e);
- }
- PreferencesCollectionValueModelTests.this.event = e;
- }
- };
- }
-
- private PropertyChangeListener buildItemListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- throw new IllegalStateException("unexpected this.event: " + e);
- }
- };
- }
-
- public void testSubjectHolder() throws Exception {
- this.verifyAdapter(this.preferencesAdapter);
- assertNull(this.event);
-
- String ANOTHER_KEY_NAME_1 = "another key 1";
- String ANOTHER_KEY_NAME_2 = "another key 2";
- String ANOTHER_KEY_NAME_3 = "another key 3";
- String ANOTHER_STRING_VALUE_1 = "another string value 1";
- String ANOTHER_STRING_VALUE_2 = "another string value 2";
- String ANOTHER_STRING_VALUE_3 = "another string value 3";
- Preferences anotherNode = this.classNode.node("another test node");
- this.expectedValues.clear();
- anotherNode.put(ANOTHER_KEY_NAME_1, ANOTHER_STRING_VALUE_1); this.expectedValues.put(ANOTHER_KEY_NAME_1, ANOTHER_STRING_VALUE_1);
- anotherNode.put(ANOTHER_KEY_NAME_2, ANOTHER_STRING_VALUE_2); this.expectedValues.put(ANOTHER_KEY_NAME_2, ANOTHER_STRING_VALUE_2);
- anotherNode.put(ANOTHER_KEY_NAME_3, ANOTHER_STRING_VALUE_3); this.expectedValues.put(ANOTHER_KEY_NAME_3, ANOTHER_STRING_VALUE_3);
-
- this.nodeHolder.setValue(anotherNode);
- // collectionChanged does not pass any items in the this.event
- this.verifyEvent(Collections.<String, String>emptyMap());
- this.verifyAdapter(this.preferencesAdapter);
-
- this.event = null;
- this.expectedValues.clear();
- this.nodeHolder.setValue(null);
- this.verifyEvent(this.expectedValues);
- assertFalse(this.preferencesAdapter.iterator().hasNext());
-
- this.event = null;
- this.nodeHolder.setValue(this.testNode);
- this.verifyEvent(Collections.<String, String>emptyMap());
- this.expectedValues.clear();
- this.expectedValues.put(KEY_NAME_1, STRING_VALUE_1);
- this.expectedValues.put(KEY_NAME_2, STRING_VALUE_2);
- this.expectedValues.put(KEY_NAME_3, STRING_VALUE_3);
- this.verifyAdapter(this.preferencesAdapter);
- }
-
- public void testAddPreference() throws Exception {
- this.verifyAdapter(this.preferencesAdapter);
- assertNull(this.event);
-
- String ANOTHER_KEY_NAME = "another key";
- String ANOTHER_STRING_VALUE = "another string value";
- this.testNode.put(ANOTHER_KEY_NAME, ANOTHER_STRING_VALUE);
- this.waitForEventQueueToClear();
- Map<String, String> expectedItems = new HashMap<String, String>();
- expectedItems.put(ANOTHER_KEY_NAME, ANOTHER_STRING_VALUE);
- this.verifyEvent(expectedItems);
- this.expectedValues.put(ANOTHER_KEY_NAME, ANOTHER_STRING_VALUE);
- this.verifyAdapter(this.preferencesAdapter);
- }
-
- public void testRemovePreference() throws Exception {
- this.verifyAdapter(this.preferencesAdapter);
- assertNull(this.event);
-
- this.testNode.remove(KEY_NAME_2);
- this.waitForEventQueueToClear();
-
- assertNotNull(this.event);
- assertEquals(this.preferencesAdapter, this.event.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event.getCollectionName());
- assertEquals(1, this.event.itemsSize());
- @SuppressWarnings("unchecked")
- String key = ((PreferencePropertyValueModel<String>) this.event.items().next()).getKey();
- assertEquals(KEY_NAME_2, key);
-
- this.expectedValues.remove(KEY_NAME_2);
- this.verifyAdapter(this.preferencesAdapter);
- }
-
- public void testChangePreference() throws Exception {
- this.verifyAdapter(this.preferencesAdapter);
- assertNull(this.event);
-
- String DIFFERENT = "something completely different";
- this.testNode.put(KEY_NAME_2, DIFFERENT);
- this.waitForEventQueueToClear();
-
- assertNull(this.event);
-
- this.expectedValues.put(KEY_NAME_2, DIFFERENT);
- this.verifyAdapter(this.preferencesAdapter);
- }
-
- public void testValues() throws Exception {
- this.verifyNode(this.testNode);
- this.verifyAdapter(this.preferencesAdapter);
- }
-
- /**
- * test a situation where
- * - we are listening to the node when it gets removed from the preferences "repository"
- * - we get notification that it has been removed
- * - we try to remove our this.listener
- * - the node will throw an IllegalStateException - the adapter should handle it OK...
- */
- public void testRemoveNode() throws Exception {
- assertTrue(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- Preferences parent = this.testNode.parent();
- parent.addNodeChangeListener(this.buildParentNodeChangeListener());
- this.testNode.removeNode();
- this.testNode.flush(); // this seems to be required for the this.event to trigger...
- this.waitForEventQueueToClear();
-
- assertTrue(this.listenerRemoved);
- assertFalse(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
- private NodeChangeListener buildParentNodeChangeListener() {
- return new NodeChangeListener() {
- public void childAdded(NodeChangeEvent e) {
- throw new IllegalStateException("unexpected this.event: " + e);
- }
- public void childRemoved(NodeChangeEvent e) {
- if (e.getChild() == PreferencesCollectionValueModelTests.this.testNode) {
- PreferencesCollectionValueModelTests.this.preferencesAdapter.removeCollectionChangeListener(CollectionValueModel.VALUES, PreferencesCollectionValueModelTests.this.listener);
- // this line of code will not execute if the line above triggers an exception
- PreferencesCollectionValueModelTests.this.listenerRemoved = true;
- }
- }
- };
- }
-
- public void testHasListeners() throws Exception {
- assertTrue(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertTrue(this.nodeHasAnyPrefListeners(this.testNode));
- this.preferencesAdapter.removeCollectionChangeListener(CollectionValueModel.VALUES, this.listener);
- assertFalse(this.nodeHasAnyPrefListeners(this.testNode));
- assertFalse(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- CollectionChangeListener listener2 = this.buildCollectionChangeListener();
- this.preferencesAdapter.addCollectionChangeListener(listener2);
- assertTrue(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertTrue(this.nodeHasAnyPrefListeners(this.testNode));
- this.preferencesAdapter.removeCollectionChangeListener(listener2);
- assertFalse(this.nodeHasAnyPrefListeners(this.testNode));
- assertFalse(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
- private void verifyEvent(Map<String, String> items) {
- assertNotNull(this.event);
- assertEquals(this.preferencesAdapter, this.event.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event.getCollectionName());
- assertEquals(items.size(), this.event.itemsSize());
- @SuppressWarnings("unchecked")
- Iterator<PreferencePropertyValueModel<String>> eventItems = (Iterator<PreferencePropertyValueModel<String>>) this.event.items();
- this.verifyItems(items, eventItems);
- }
-
- private void verifyNode(Preferences node) throws Exception {
- String[] keys = node.keys();
- assertEquals(this.expectedValues.size(), keys.length);
- for (int i = 0; i < keys.length; i++) {
- assertEquals(this.expectedValues.get(keys[i]), node.get(keys[i], "<missing preference>"));
- }
- }
-
- private void verifyAdapter(PreferencesCollectionValueModel<String> cvm) {
- assertEquals(this.expectedValues.size(), cvm.size());
- this.verifyItems(this.expectedValues, cvm.iterator());
- }
-
- private void verifyItems(Map<String, String> expected, Iterator<PreferencePropertyValueModel<String>> stream) {
- while (stream.hasNext()) {
- PreferencePropertyValueModel<String> model = stream.next();
- model.addPropertyChangeListener(PropertyValueModel.VALUE, this.itemListener);
- assertEquals(expected.get(model.getKey()), model.getValue());
- model.removePropertyChangeListener(PropertyValueModel.VALUE, this.itemListener);
- }
- }
-
- private boolean nodeHasAnyPrefListeners(Preferences node) throws Exception {
- PreferenceChangeListener[] prefListeners = (PreferenceChangeListener[]) ClassTools.fieldValue(node, "prefListeners");
- return prefListeners.length > 0;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java
deleted file mode 100644
index bca284a8fd..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.prefs;
-
-import java.util.EventObject;
-import java.util.List;
-import java.util.prefs.AbstractPreferences;
-import java.util.prefs.Preferences;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-/**
- * set up and tear down a test node for any subclass that
- * needs to test preferences-related stuff
- */
-public abstract class PreferencesTestCase extends TestCase {
- protected Preferences classNode;
- public Preferences testNode;
- protected static final String TEST_NODE_NAME = "test node";
-
- public PreferencesTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- Preferences packageNode = Preferences.userNodeForPackage(this.getClass());
- this.classNode = packageNode.node(ClassTools.shortClassNameForObject(this));
- // clean out any leftover crap...
- if ((this.classNode.keys().length > 0) || (this.classNode.childrenNames().length > 0)) {
- this.classNode.removeNode();
- // ...and re-create the node
- this.classNode = packageNode.node(ClassTools.shortClassNameForObject(this));
- }
- this.testNode = this.classNode.node(TEST_NODE_NAME);
- }
-
- @Override
- protected void tearDown() throws Exception {
- // wait for all the events to be delivered before tearing down
- this.waitForEventQueueToClear();
- Preferences node = this.classNode.parent();
- this.classNode.removeNode();
- while (this.nodeIsVestigial(node)) {
- Preferences parent = node.parent();
- node.removeNode();
- node = parent;
- }
- TestTools.clear(this);
- super.tearDown();
- }
-
- private boolean nodeIsVestigial(Preferences node) throws Exception {
- return (node != null)
- && (node.keys().length == 0)
- && (node.childrenNames().length == 0)
- && (node != Preferences.userRoot());
- }
-
- protected void waitForEventQueueToClear() {
- try {
- while ( ! this.preferencesEventQueue().isEmpty()) {
- Thread.sleep(100);
- }
- Thread.sleep(100);
- } catch (InterruptedException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- @SuppressWarnings("unchecked")
- private List<EventObject> preferencesEventQueue() {
- return (List<EventObject>) ClassTools.staticFieldValue(AbstractPreferences.class, "eventQueue");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java
deleted file mode 100644
index ec19fcee7c..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import javax.swing.ButtonModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.EventListenerList;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.CheckBoxModelAdapter;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class CheckBoxModelAdapterTests extends TestCase {
- private WritablePropertyValueModel<Boolean> booleanHolder;
- private ButtonModel buttonModelAdapter;
- boolean eventFired;
-
- public CheckBoxModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.booleanHolder = new SimplePropertyValueModel<Boolean>(Boolean.TRUE);
- this.buttonModelAdapter = new CheckBoxModelAdapter(this.booleanHolder) {
- @Override
- protected PropertyChangeListener buildBooleanChangeListener() {
- return this.buildBooleanChangeListener_();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSetSelected() throws Exception {
- this.eventFired = false;
- this.buttonModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CheckBoxModelAdapterTests.this.eventFired = true;
- }
- });
- this.buttonModelAdapter.setSelected(false);
- assertTrue(this.eventFired);
- assertEquals(Boolean.FALSE, this.booleanHolder.getValue());
- }
-
- public void testSetValue() throws Exception {
- this.eventFired = false;
- this.buttonModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CheckBoxModelAdapterTests.this.eventFired = true;
- }
- });
- assertTrue(this.buttonModelAdapter.isSelected());
- this.booleanHolder.setValue(Boolean.FALSE);
- assertTrue(this.eventFired);
- assertFalse(this.buttonModelAdapter.isSelected());
- }
-
- public void testDefaultValue() throws Exception {
- this.eventFired = false;
- this.buttonModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CheckBoxModelAdapterTests.this.eventFired = true;
- }
- });
- assertTrue(this.buttonModelAdapter.isSelected());
- this.booleanHolder.setValue(null);
- assertTrue(this.eventFired);
- assertFalse(this.buttonModelAdapter.isSelected());
-
- this.eventFired = false;
- this.booleanHolder.setValue(Boolean.FALSE);
- assertFalse(this.eventFired);
- assertFalse(this.buttonModelAdapter.isSelected());
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Boolean> localBooleanHolder = (SimplePropertyValueModel<Boolean>) this.booleanHolder;
- assertFalse(localBooleanHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.buttonModelAdapter);
-
- ChangeListener listener = new TestChangeListener();
- this.buttonModelAdapter.addChangeListener(listener);
- assertTrue(localBooleanHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.buttonModelAdapter);
-
- this.buttonModelAdapter.removeChangeListener(listener);
- assertFalse(localBooleanHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.buttonModelAdapter);
- }
-
- private void verifyHasNoListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ClassTools.fieldValue(model, "listenerList");
- assertEquals(0, listenerList.getListenerList().length);
- }
-
- private void verifyHasListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ClassTools.fieldValue(model, "listenerList");
- assertFalse(listenerList.getListenerList().length == 0);
- }
-
-
- // ********** member class **********
- private class TestChangeListener implements ChangeListener {
- TestChangeListener() {
- super();
- }
- public void stateChanged(ChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java
deleted file mode 100644
index d41842e632..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ButtonModel;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.WindowConstants;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.CheckBoxModelAdapter;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * Play around with a set of check boxes.
- */
-public class CheckBoxModelAdapterUITest {
-
- private TestModel testModel;
- private WritablePropertyValueModel<TestModel> testModelHolder;
- private WritablePropertyValueModel<Boolean> flag1Holder;
- private WritablePropertyValueModel<Boolean> flag2Holder;
- private WritablePropertyValueModel<Boolean> notFlag2Holder;
- private ButtonModel flag1ButtonModel;
- private ButtonModel flag2ButtonModel;
- private ButtonModel notFlag2ButtonModel;
-
- public static void main(String[] args) throws Exception {
- new CheckBoxModelAdapterUITest().exec(args);
- }
-
- private CheckBoxModelAdapterUITest() {
- super();
- }
-
- private void exec(String[] args) throws Exception {
- this.testModel = new TestModel(true, true);
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.flag1Holder = this.buildFlag1Holder(this.testModelHolder);
- this.flag1ButtonModel = this.buildCheckBoxModelAdapter(this.flag1Holder);
- this.flag2Holder = this.buildFlag2Holder(this.testModelHolder);
- this.flag2ButtonModel = this.buildCheckBoxModelAdapter(this.flag2Holder);
- this.notFlag2Holder = this.buildNotFlag2Holder(this.testModelHolder);
- this.notFlag2ButtonModel = this.buildCheckBoxModelAdapter(this.notFlag2Holder);
- this.openWindow();
- }
-
- private WritablePropertyValueModel<Boolean> buildFlag1Holder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Boolean>(vm, TestModel.FLAG1_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isFlag1());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setFlag1(value.booleanValue());
- }
- };
- }
-
- private WritablePropertyValueModel<Boolean> buildFlag2Holder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Boolean>(vm, TestModel.FLAG2_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isFlag2());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setFlag2(value.booleanValue());
- }
- };
- }
-
- private WritablePropertyValueModel<Boolean> buildNotFlag2Holder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Boolean>(vm, TestModel.NOT_FLAG2_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isNotFlag2());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setNotFlag2(value.booleanValue());
- }
- };
- }
-
- private ButtonModel buildCheckBoxModelAdapter(WritablePropertyValueModel<Boolean> booleanHolder) {
- return new CheckBoxModelAdapter(booleanHolder);
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setSize(400, 100);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildCheckBoxPanel(), BorderLayout.NORTH);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildCheckBoxPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(1, 0));
- taskListPanel.add(this.buildFlag1CheckBox());
- taskListPanel.add(this.buildFlag2CheckBox());
- taskListPanel.add(this.buildNotFlag2CheckBox());
- taskListPanel.add(this.buildUnattachedCheckBox());
- return taskListPanel;
- }
-
- private JCheckBox buildFlag1CheckBox() {
- JCheckBox checkBox = new JCheckBox();
- checkBox.setText("flag 1");
- checkBox.setModel(this.flag1ButtonModel);
- return checkBox;
- }
-
- private JCheckBox buildFlag2CheckBox() {
- JCheckBox checkBox = new JCheckBox();
- checkBox.setText("flag 2");
- checkBox.setModel(this.flag2ButtonModel);
- return checkBox;
- }
-
- private JCheckBox buildNotFlag2CheckBox() {
- JCheckBox checkBox = new JCheckBox();
- checkBox.setText("not flag 2");
- checkBox.setModel(this.notFlag2ButtonModel);
- return checkBox;
- }
-
- private JCheckBox buildUnattachedCheckBox() {
- JCheckBox checkBox = new JCheckBox("unattached");
- checkBox.getModel().addItemListener(this.buildUnattachedItemListener());
- return checkBox;
- }
-
- private ItemListener buildUnattachedItemListener() {
- return new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- System.out.println("unattached state changed: " + e);
- }
- };
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(1, 0));
- controlPanel.add(this.buildFlipFlag1Button());
- controlPanel.add(this.buildClearModelButton());
- controlPanel.add(this.buildRestoreModelButton());
- controlPanel.add(this.buildPrintModelButton());
- return controlPanel;
- }
-
- private JButton buildFlipFlag1Button() {
- return new JButton(this.buildFlipFlag1Action());
- }
-
- private Action buildFlipFlag1Action() {
- Action action = new AbstractAction("flip flag 1") {
- public void actionPerformed(ActionEvent event) {
- CheckBoxModelAdapterUITest.this.flipFlag1();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void flipFlag1() {
- this.testModel.setFlag1( ! this.testModel.isFlag1());
- }
-
- private JButton buildClearModelButton() {
- return new JButton(this.buildClearModelAction());
- }
-
- private Action buildClearModelAction() {
- Action action = new AbstractAction("clear model") {
- public void actionPerformed(ActionEvent event) {
- CheckBoxModelAdapterUITest.this.clearModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private JButton buildRestoreModelButton() {
- return new JButton(this.buildRestoreModelAction());
- }
-
- private Action buildRestoreModelAction() {
- Action action = new AbstractAction("restore model") {
- public void actionPerformed(ActionEvent event) {
- CheckBoxModelAdapterUITest.this.restoreModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private JButton buildPrintModelButton() {
- return new JButton(this.buildPrintModelAction());
- }
-
- private Action buildPrintModelAction() {
- Action action = new AbstractAction("print model") {
- public void actionPerformed(ActionEvent event) {
- CheckBoxModelAdapterUITest.this.printModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void printModel() {
- System.out.println("flag 1: " + this.testModel.isFlag1());
- System.out.println("flag 2: " + this.testModel.isFlag2());
- System.out.println("not flag 2: " + this.testModel.isNotFlag2());
- System.out.println("***");
- }
-
-
- private class TestModel extends AbstractModel {
- private boolean flag1;
- public static final String FLAG1_PROPERTY = "flag1";
- private boolean flag2;
- public static final String FLAG2_PROPERTY = "flag2";
- private boolean notFlag2;
- public static final String NOT_FLAG2_PROPERTY = "notFlag2";
-
- public TestModel(boolean flag1, boolean flag2) {
- this.flag1 = flag1;
- this.flag2 = flag2;
- this.notFlag2 = ! flag2;
- }
- public boolean isFlag1() {
- return this.flag1;
- }
- public void setFlag1(boolean flag1) {
- boolean old = this.flag1;
- this.flag1 = flag1;
- this.firePropertyChanged(FLAG1_PROPERTY, old, flag1);
- }
- public boolean isFlag2() {
- return this.flag2;
- }
- public void setFlag2(boolean flag2) {
- boolean old = this.flag2;
- this.flag2 = flag2;
- this.firePropertyChanged(FLAG2_PROPERTY, old, flag2);
-
- old = this.notFlag2;
- this.notFlag2 = ! flag2;
- this.firePropertyChanged(NOT_FLAG2_PROPERTY, old, this.notFlag2);
- }
- public boolean isNotFlag2() {
- return this.notFlag2;
- }
- public void setNotFlag2(boolean notFlag2) {
- this.setFlag2( ! notFlag2);
- }
- @Override
- public String toString() {
- return "TestModel(" + this.isFlag1() + " - " + this.isFlag2() + ")";
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java
deleted file mode 100644
index 82a1dc622d..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.swing.ComboBoxModel;
-import javax.swing.ListModel;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.ComboBoxModelAdapter;
-import org.eclipse.jpt.utility.internal.swing.Displayable;
-import org.eclipse.jpt.utility.internal.swing.SimpleDisplayable;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.model.value.CoordinatedList;
-
-import junit.framework.TestCase;
-
-public class ComboBoxModelAdapterTests extends TestCase {
-
- public ComboBoxModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // nothing yet...
- }
-
- @Override
- protected void tearDown() throws Exception {
- // nothing yet...
- super.tearDown();
- }
-
- public void testHasListeners() throws Exception {
- SimpleListValueModel<Displayable> listHolder = this.buildListHolder();
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- SimplePropertyValueModel<Object> selectionHolder = new SimplePropertyValueModel<Object>(listHolder.iterator().next());
- assertFalse(selectionHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- ComboBoxModel comboBoxModel = new ComboBoxModelAdapter(listHolder, selectionHolder);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(selectionHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(comboBoxModel);
-
- CoordinatedList<Displayable> synchList = new CoordinatedList<Displayable>(comboBoxModel);
- PropertyChangeListener selectionListener = this.buildSelectionListener();
- selectionHolder.addPropertyChangeListener(PropertyValueModel.VALUE, selectionListener);
- assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(selectionHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(comboBoxModel);
-
- comboBoxModel.removeListDataListener(synchList);
- selectionHolder.removePropertyChangeListener(PropertyValueModel.VALUE, selectionListener);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(selectionHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(comboBoxModel);
- }
-
- private PropertyChangeListener buildSelectionListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent evt) {
- // do nothing...
- }
- };
- }
-
- private void verifyHasNoListeners(ListModel listModel) throws Exception {
- boolean hasNoListeners = ((Boolean) ClassTools.executeMethod(listModel, "hasNoListDataListeners")).booleanValue();
- assertTrue(hasNoListeners);
- }
-
- private void verifyHasListeners(ListModel listModel) throws Exception {
- boolean hasListeners = ((Boolean) ClassTools.executeMethod(listModel, "hasListDataListeners")).booleanValue();
- assertTrue(hasListeners);
- }
-
- private SimpleListValueModel<Displayable> buildListHolder() {
- return new SimpleListValueModel<Displayable>(this.buildList());
- }
-
- private List<Displayable> buildList() {
- List<Displayable> list = new ArrayList<Displayable>();
- this.populateCollection(list);
- return list;
- }
-
- private void populateCollection(Collection<Displayable> c) {
- c.add(new SimpleDisplayable("foo"));
- c.add(new SimpleDisplayable("bar"));
- c.add(new SimpleDisplayable("baz"));
- c.add(new SimpleDisplayable("joo"));
- c.add(new SimpleDisplayable("jar"));
- c.add(new SimpleDisplayable("jaz"));
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java
deleted file mode 100644
index 91d7713c4f..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ComboBoxModel;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.ListCellRenderer;
-import javax.swing.UIManager;
-import javax.swing.WindowConstants;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.ComboBoxModelAdapter;
-import org.eclipse.jpt.utility.internal.swing.FilteringListBrowser;
-import org.eclipse.jpt.utility.internal.swing.ListChooser;
-import org.eclipse.jpt.utility.internal.swing.SimpleListCellRenderer;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-
-/**
- * Play around with a set of combo-boxes.
- *
- * DefaultLongListBrowserDialogUITest subclasses this class; so be
- * careful when making changes.
- */
-public class ComboBoxModelAdapterUITest {
-
- protected JFrame window;
- private TestModel testModel;
- private WritablePropertyValueModel<TestModel> testModelHolder;
- private WritablePropertyValueModel<Object> colorHolder;
- private SimpleListValueModel<String> colorListHolder;
- protected ComboBoxModel colorComboBoxModel;
- private int nextColorNumber = 0;
-
- public static void main(String[] args) throws Exception {
- new ComboBoxModelAdapterUITest().exec(args);
- }
-
- protected ComboBoxModelAdapterUITest() {
- super();
- }
-
- protected void exec(String[] args) throws Exception {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
-// UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); // Metal LAF
-// UIManager.setLookAndFeel(com.sun.java.swing.plaf.windows.WindowsLookAndFeel.class.getName());
-// UIManager.setLookAndFeel(com.sun.java.swing.plaf.motif.MotifLookAndFeel.class.getName());
-// UIManager.setLookAndFeel(oracle.bali.ewt.olaf.OracleLookAndFeel.class.getName());
- this.testModel = this.buildTestModel();
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.colorHolder = this.buildColorHolder(this.testModelHolder);
- this.colorListHolder = this.buildColorListHolder();
- this.colorComboBoxModel = this.buildComboBoxModelAdapter(this.colorListHolder, this.colorHolder);
- this.openWindow();
- }
-
- private WritablePropertyValueModel<Object> buildColorHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Object>(vm, TestModel.COLOR_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getColor();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setColor((String) value);
- }
- };
- }
-
- protected TestModel buildTestModel() {
- return new TestModel();
- }
-
- private SimpleListValueModel<String> buildColorListHolder() {
- return new SimpleListValueModel<String>(TestModel.validColors());
-// return new AbstractReadOnlyListValueModel() {
-// public Object value() {
-// return new ArrayListIterator(TestModel.VALID_COLORS);
-// }
-// public int size() {
-// return TestModel.VALID_COLORS.length;
-// }
-// };
- }
-
- protected ListValueModel<String> uiColorListHolder() {
- return this.colorListHolder;
- }
-
- private ComboBoxModel buildComboBoxModelAdapter(ListValueModel<String> listHolder, WritablePropertyValueModel<Object> selectionHolder) {
- return new ComboBoxModelAdapter(listHolder, selectionHolder);
- }
-
- private void openWindow() {
- this.window = new JFrame(ClassTools.shortNameFor(this.getClass()));
- this.window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- this.window.addWindowListener(this.buildWindowListener());
- this.window.getContentPane().add(this.buildMainPanel(), "Center");
- this.window.setLocation(300, 300);
- this.window.setSize(400, 150);
- this.window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildComboBoxPanel(), BorderLayout.NORTH);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- protected JPanel buildComboBoxPanel() {
- JPanel panel = new JPanel(new GridLayout(1, 0));
- panel.add(this.buildComboBox());
- panel.add(this.buildComboBox());
- panel.add(this.buildListChooser1());
- panel.add(this.buildListChooser2());
- return panel;
- }
-
- private JComboBox buildComboBox() {
- JComboBox comboBox = new JComboBox(this.colorComboBoxModel);
- comboBox.setRenderer(this.buildComboBoxRenderer());
- return comboBox;
- }
-
- protected ListCellRenderer buildComboBoxRenderer() {
- return new SimpleListCellRenderer() {
- @Override
- protected String buildText(Object value) {
- return super.buildText(value);
- }
- };
- }
-
- private ListChooser buildListChooser1() {
- return new LocalListChooser1(this.colorComboBoxModel);
- }
-
- private ListChooser buildListChooser2() {
- return new LocalListChooser2(this.colorComboBoxModel);
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(2, 0));
- controlPanel.add(this.buildResetColorButton());
- controlPanel.add(this.buildClearModelButton());
- controlPanel.add(this.buildRestoreModelButton());
- controlPanel.add(this.buildPrintModelButton());
- controlPanel.add(this.buildAddTenButton());
- controlPanel.add(this.buildRemoveTenButton());
- return controlPanel;
- }
-
- // ********** reset color button **********
- private JButton buildResetColorButton() {
- return new JButton(this.buildResetColorAction());
- }
-
- private Action buildResetColorAction() {
- Action action = new AbstractAction("reset color") {
- public void actionPerformed(ActionEvent event) {
- ComboBoxModelAdapterUITest.this.resetColor();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void resetColor() {
- this.testModel.setColor(TestModel.DEFAULT_COLOR);
- }
-
- // ********** clear model button **********
- private JButton buildClearModelButton() {
- return new JButton(this.buildClearModelAction());
- }
-
- private Action buildClearModelAction() {
- Action action = new AbstractAction("clear model") {
- public void actionPerformed(ActionEvent event) {
- ComboBoxModelAdapterUITest.this.clearModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- // ********** restore model button **********
- private JButton buildRestoreModelButton() {
- return new JButton(this.buildRestoreModelAction());
- }
-
- private Action buildRestoreModelAction() {
- Action action = new AbstractAction("restore model") {
- public void actionPerformed(ActionEvent event) {
- ComboBoxModelAdapterUITest.this.restoreModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- // ********** print model button **********
- private JButton buildPrintModelButton() {
- return new JButton(this.buildPrintModelAction());
- }
-
- private Action buildPrintModelAction() {
- Action action = new AbstractAction("print model") {
- public void actionPerformed(ActionEvent event) {
- ComboBoxModelAdapterUITest.this.printModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void printModel() {
- System.out.println(this.testModel);
- }
-
- // ********** add 20 button **********
- private JButton buildAddTenButton() {
- return new JButton(this.buildAddTenAction());
- }
-
- private Action buildAddTenAction() {
- Action action = new AbstractAction("add 20") {
- public void actionPerformed(ActionEvent event) {
- ComboBoxModelAdapterUITest.this.addTen();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void addTen() {
- for (int i = this.nextColorNumber; i < this.nextColorNumber + 20; i++) {
- this.colorListHolder.add(this.colorListHolder.size(), "color" + i);
- }
- this.nextColorNumber += 20;
- }
-
- // ********** remove 20 button **********
- private JButton buildRemoveTenButton() {
- return new JButton(this.buildRemoveTenAction());
- }
-
- private Action buildRemoveTenAction() {
- Action action = new AbstractAction("remove 20") {
- public void actionPerformed(ActionEvent event) {
- ComboBoxModelAdapterUITest.this.removeTen();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void removeTen() {
- for (int i = 0; i < 20; i++) {
- if (this.colorListHolder.size() > 0) {
- this.colorListHolder.remove(this.colorListHolder.size() - 1);
- }
- }
- }
-
-
- protected static class TestModel extends AbstractModel {
- private String color;
- public static final String COLOR_PROPERTY = "color";
- public static final String RED = "red";
- public static final String ORANGE = "orange";
- public static final String YELLOW = "yellow";
- public static final String GREEN = "green";
- public static final String BLUE = "blue";
- public static final String INDIGO = "indigo";
- public static final String VIOLET = "violet";
- public static final String DEFAULT_COLOR = RED;
- public static List<String> validColors;
- public static final String[] DEFAULT_VALID_COLORS = {
- RED,
- ORANGE,
- YELLOW,
- GREEN,
- BLUE,
- INDIGO,
- VIOLET
- };
-
- public static List<String> validColors() {
- if (validColors == null) {
- validColors = buildDefaultValidColors();
- }
- return validColors;
- }
- public static List<String> buildDefaultValidColors() {
- List<String> result = new ArrayList<String>();
- CollectionTools.addAll(result, DEFAULT_VALID_COLORS);
- return result;
- }
-
- public TestModel() {
- this(DEFAULT_COLOR);
- }
- public TestModel(String color) {
- this.color = color;
- }
- public String getColor() {
- return this.color;
- }
- public void setColor(String color) {
- this.checkColor(color);
- Object old = this.color;
- this.color = color;
- this.firePropertyChanged(COLOR_PROPERTY, old, color);
- }
- public void checkColor(String c) {
- if ( ! validColors().contains(c)) {
- throw new IllegalArgumentException(c);
- }
- }
- @Override
- public String toString() {
- return "TestModel(" + this.color + ")";
- }
- }
-
-
- private class LocalListChooser1 extends ListChooser {
- public LocalListChooser1(ComboBoxModel model) {
- super(model);
- }
- }
-
-
- private class LocalListChooser2 extends ListChooser {
- public LocalListChooser2(ComboBoxModel model) {
- super(model);
- }
- @Override
- protected ListBrowser buildBrowser() {
- return new FilteringListBrowser<String>();
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java
deleted file mode 100644
index 1cd1c04947..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import javax.swing.ListCellRenderer;
-
-import org.eclipse.jpt.utility.internal.model.value.ExtendedListValueModelWrapper;
-import org.eclipse.jpt.utility.internal.swing.SimpleListCellRenderer;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-
-/**
- *
- */
-public class ComboBoxModelAdapterUITest2 extends ComboBoxModelAdapterUITest {
-
- public static void main(String[] args) throws Exception {
- new ComboBoxModelAdapterUITest2().exec(args);
- }
-
- public ComboBoxModelAdapterUITest2() {
- super();
- }
-
- /**
- * use a different model that allows the color to be set to null
- */
- @Override
- protected TestModel buildTestModel() {
- return new TestModel2();
- }
-
- /**
- * add a null to the front of the list
- */
- @Override
- protected ListValueModel<String> uiColorListHolder() {
- // the default is to prepend the wrapped list with a null item
- return new ExtendedListValueModelWrapper<String>(super.uiColorListHolder());
- }
-
- /**
- * convert null to some text
- */
- @Override
- protected ListCellRenderer buildComboBoxRenderer() {
- return new SimpleListCellRenderer() {
- @Override
- protected String buildText(Object value) {
- return (value == null) ? "<none selected>" : super.buildText(value);
- }
- };
- }
-
-
- protected static class TestModel2 extends TestModel {
- /**
- * null is OK here
- */
- @Override
- public void checkColor(String color) {
- if (color == null) {
- return;
- }
- super.checkColor(color);
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java
deleted file mode 100644
index 229f5ef63a..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.util.Date;
-
-import javax.swing.SpinnerModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.DateSpinnerModelAdapter;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class DateSpinnerModelAdapterTests extends TestCase {
- private WritablePropertyValueModel<Object> valueHolder;
- private SpinnerModel spinnerModelAdapter;
- boolean eventFired;
-
- public DateSpinnerModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Object>(new Date());
- this.spinnerModelAdapter = new DateSpinnerModelAdapter(this.valueHolder) {
- @Override
- protected PropertyChangeListener buildDateChangeListener() {
- return this.buildDateChangeListener_();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSetValueSpinnerModel() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- DateSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- Date newDate = new Date();
- newDate.setTime(777777);
- this.spinnerModelAdapter.setValue(newDate);
- assertTrue(this.eventFired);
- assertEquals(777777, ((Date) this.valueHolder.getValue()).getTime());
- }
-
- public void testSetValueValueHolder() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- DateSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- Date newDate = new Date();
- newDate.setTime(777777);
- this.valueHolder.setValue(newDate);
- assertTrue(this.eventFired);
- assertEquals(777777, ((Date) this.spinnerModelAdapter.getValue()).getTime());
- }
-
- public void testDefaultValue() throws Exception {
- Date newDate = new Date();
- newDate.setTime(777777);
- this.valueHolder.setValue(newDate);
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- DateSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(777777, ((Date) this.spinnerModelAdapter.getValue()).getTime());
- this.valueHolder.setValue(null);
- assertTrue(this.eventFired);
- assertFalse(((Date) this.spinnerModelAdapter.getValue()).getTime() == 777777);
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Object> localValueHolder = (SimplePropertyValueModel<Object>) this.valueHolder;
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
-
- ChangeListener listener = new TestChangeListener();
- this.spinnerModelAdapter.addChangeListener(listener);
- assertTrue(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.spinnerModelAdapter);
-
- this.spinnerModelAdapter.removeChangeListener(listener);
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
- }
-
- private void verifyHasNoListeners(SpinnerModel adapter) throws Exception {
- assertEquals(0, ((DateSpinnerModelAdapter) adapter).getChangeListeners().length);
- }
-
- private void verifyHasListeners(Object adapter) throws Exception {
- assertFalse(((DateSpinnerModelAdapter) adapter).getChangeListeners().length == 0);
- }
-
- public void testNullInitialValue() {
- Date today = new Date();
- this.valueHolder = new SimplePropertyValueModel<Object>();
- this.spinnerModelAdapter = new DateSpinnerModelAdapter(this.valueHolder, today) {
- @Override
- protected PropertyChangeListener buildDateChangeListener() {
- return this.buildDateChangeListener_();
- }
- };
-
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- DateSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(today, this.spinnerModelAdapter.getValue());
-
- Date newDate = new Date();
- newDate.setTime(777777);
- this.valueHolder.setValue(newDate);
-
- assertTrue(this.eventFired);
- assertEquals(777777, ((Date) this.spinnerModelAdapter.getValue()).getTime());
- }
-
-
- // ********** inner class **********
- private class TestChangeListener implements ChangeListener {
- TestChangeListener() {
- super();
- }
- public void stateChanged(ChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java
deleted file mode 100644
index cafe3aa820..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.event.DocumentEvent.EventType;
-import javax.swing.text.Document;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.DocumentAdapter;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class DocumentAdapterTests extends TestCase {
- private WritablePropertyValueModel<String> stringHolder;
- Document documentAdapter;
- boolean eventFired;
-
- public DocumentAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.stringHolder = new SimplePropertyValueModel<String>("0123456789");
- this.documentAdapter = new DocumentAdapter(this.stringHolder) {
- @Override
- protected PropertyChangeListener buildStringListener() {
- return this.buildStringListener_();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testRemove() throws Exception {
- this.eventFired = false;
- this.documentAdapter.addDocumentListener(new TestDocumentListener() {
- @Override
- public void removeUpdate(DocumentEvent e) {
- DocumentAdapterTests.this.eventFired = true;
- assertEquals(EventType.REMOVE, e.getType());
- assertEquals(DocumentAdapterTests.this.documentAdapter, e.getDocument());
- // this will be the removal of "23456"
- assertEquals(2, e.getOffset());
- assertEquals(5, e.getLength());
- }
- });
- this.documentAdapter.remove(2, 5);
- assertTrue(this.eventFired);
- assertEquals("01789", this.stringHolder.getValue());
- }
-
- public void testInsert() throws Exception {
- this.eventFired = false;
- this.documentAdapter.addDocumentListener(new TestDocumentListener() {
- @Override
- public void insertUpdate(DocumentEvent e) {
- DocumentAdapterTests.this.eventFired = true;
- assertEquals(EventType.INSERT, e.getType());
- assertEquals(DocumentAdapterTests.this.documentAdapter, e.getDocument());
- // this will be the insert of "xxxxxx"
- assertEquals(2, e.getOffset());
- assertEquals(5, e.getLength());
- }
- });
- this.documentAdapter.insertString(2, "xxxxx", null);
- assertTrue(this.eventFired);
- assertEquals("01xxxxx23456789", this.stringHolder.getValue());
- }
-
- public void testSetValue() throws Exception {
- this.eventFired = false;
- this.documentAdapter.addDocumentListener(new TestDocumentListener() {
- @Override
- public void insertUpdate(DocumentEvent e) {
- DocumentAdapterTests.this.eventFired = true;
- assertEquals(EventType.INSERT, e.getType());
- assertEquals(DocumentAdapterTests.this.documentAdapter, e.getDocument());
- // this will be the insert of "foo"
- assertEquals(0, e.getOffset());
- assertEquals(3, e.getLength());
- }
- @Override
- public void removeUpdate(DocumentEvent e) {
- assertEquals(EventType.REMOVE, e.getType());
- assertEquals(DocumentAdapterTests.this.documentAdapter, e.getDocument());
- // this will be the removal of "0123456789"
- assertEquals(0, e.getOffset());
- assertEquals(10, e.getLength());
- }
- });
- assertEquals("0123456789", this.documentAdapter.getText(0, this.documentAdapter.getLength()));
- this.stringHolder.setValue("foo");
- assertTrue(this.eventFired);
- assertEquals("foo", this.documentAdapter.getText(0, this.documentAdapter.getLength()));
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<String> localStringHolder = (SimplePropertyValueModel<String>) this.stringHolder;
- assertFalse(localStringHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.documentAdapter);
-
- DocumentListener listener = new TestDocumentListener();
- this.documentAdapter.addDocumentListener(listener);
- assertTrue(localStringHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.documentAdapter);
-
- this.documentAdapter.removeDocumentListener(listener);
- assertFalse(localStringHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.documentAdapter);
- }
-
- private void verifyHasNoListeners(Object document) throws Exception {
- Object delegate = ClassTools.fieldValue(document, "delegate");
- Object[] listeners = (Object[]) ClassTools.executeMethod(delegate, "getDocumentListeners");
- assertEquals(0, listeners.length);
- }
-
- private void verifyHasListeners(Object document) throws Exception {
- Object delegate = ClassTools.fieldValue(document, "delegate");
- Object[] listeners = (Object[]) ClassTools.executeMethod(delegate, "getDocumentListeners");
- assertFalse(listeners.length == 0);
- }
-
-
-private class TestDocumentListener implements DocumentListener {
- TestDocumentListener() {
- super();
- }
- public void changedUpdate(DocumentEvent e) {
- fail("unexpected event");
- }
- public void insertUpdate(DocumentEvent e) {
- fail("unexpected event");
- }
- public void removeUpdate(DocumentEvent e) {
- fail("unexpected event");
- }
-}
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java
deleted file mode 100644
index e38b4eaafa..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.WindowConstants;
-import javax.swing.text.AbstractDocument;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.Document;
-import javax.swing.text.PlainDocument;
-
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.DocumentAdapter;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * Play around with a set of entry fields.
- */
-public class DocumentAdapterUITest {
-
- private TestModel testModel;
- private static final String DEFAULT_NAME = "Scooby Doo";
- private WritablePropertyValueModel<TestModel> testModelHolder;
- private WritablePropertyValueModel<String> nameHolder;
- private Document nameDocument;
- private Document upperCaseNameDocument;
-
- public static void main(String[] args) throws Exception {
- new DocumentAdapterUITest().exec(args);
- }
-
- private DocumentAdapterUITest() {
- super();
- }
-
- private void exec(String[] args) throws Exception {
- this.testModel = new TestModel(DEFAULT_NAME);
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.nameHolder = this.buildNameHolder(this.testModelHolder);
- this.nameDocument = this.buildNameDocument(this.nameHolder);
- this.upperCaseNameDocument = this.buildUpperCaseNameDocument(this.nameHolder);
- this.openWindow();
- }
-
- private WritablePropertyValueModel<String> buildNameHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, String>(vm, TestModel.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getName();
- }
- @Override
- protected void setValue_(String value) {
- this.subject.setName(value);
- }
- };
- }
-
- private Document buildNameDocument(WritablePropertyValueModel<String> stringHolder) {
- return new DocumentAdapter(stringHolder);
- }
-
- private Document buildUpperCaseNameDocument(WritablePropertyValueModel<String> stringHolder) {
- return new DocumentAdapter(stringHolder, this.buildUpperCaseNameDocumentDelegate());
- }
-
- private AbstractDocument buildUpperCaseNameDocumentDelegate() {
- return new PlainDocument() {
- @Override
- public void insertString(int offset, String string, AttributeSet a) throws BadLocationException {
- if (string == null) {
- return;
- }
- char[] upper = string.toCharArray();
- for (int i = 0; i < upper.length; i++) {
- upper[i] = Character.toUpperCase(upper[i]);
- }
- super.insertString(offset, new String(upper), a);
- }
- };
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setSize(400, 100);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildTextFieldPanel(), BorderLayout.NORTH);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildTextFieldPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(1, 0));
- taskListPanel.add(this.buildNameTextField());
- taskListPanel.add(this.buildReadOnlyNameTextField());
- taskListPanel.add(this.buildUpperCaseNameTextField());
- return taskListPanel;
- }
-
- private JTextField buildNameTextField() {
- return new JTextField(this.nameDocument, null, 0);
- }
-
- private JTextField buildReadOnlyNameTextField() {
- JTextField nameTextField = this.buildNameTextField();
- nameTextField.setEditable(false);
- return nameTextField;
- }
-
- private JTextField buildUpperCaseNameTextField() {
- return new JTextField(this.upperCaseNameDocument, null, 0);
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(1, 0));
- controlPanel.add(this.buildResetNameButton());
- controlPanel.add(this.buildClearModelButton());
- controlPanel.add(this.buildRestoreModelButton());
- controlPanel.add(this.buildPrintModelButton());
- return controlPanel;
- }
-
- private JButton buildResetNameButton() {
- return new JButton(this.buildResetNameAction());
- }
-
- private Action buildResetNameAction() {
- Action action = new AbstractAction("reset name") {
- public void actionPerformed(ActionEvent event) {
- DocumentAdapterUITest.this.resetName();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void resetName() {
- this.testModel.setName(DEFAULT_NAME);
- }
-
- private JButton buildClearModelButton() {
- return new JButton(this.buildClearModelAction());
- }
-
- private Action buildClearModelAction() {
- Action action = new AbstractAction("clear model") {
- public void actionPerformed(ActionEvent event) {
- DocumentAdapterUITest.this.clearModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private JButton buildRestoreModelButton() {
- return new JButton(this.buildRestoreModelAction());
- }
-
- private Action buildRestoreModelAction() {
- Action action = new AbstractAction("restore model") {
- public void actionPerformed(ActionEvent event) {
- DocumentAdapterUITest.this.restoreModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private JButton buildPrintModelButton() {
- return new JButton(this.buildPrintModelAction());
- }
-
- private Action buildPrintModelAction() {
- Action action = new AbstractAction("print model") {
- public void actionPerformed(ActionEvent event) {
- DocumentAdapterUITest.this.printModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void printModel() {
- System.out.println("name: " + this.testModel.getName());
- }
-
-
- private class TestModel extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- public TestModel(String name) {
- this.name = name;
- }
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
- @Override
- public String toString() {
- return "TestModel(" + this.getName() + ")";
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/JptUtilityModelValueSwingTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/JptUtilityModelValueSwingTests.java
deleted file mode 100644
index b531bd3c73..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/JptUtilityModelValueSwingTests.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptUtilityModelValueSwingTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityModelValueSwingTests.class.getPackage().getName());
-
- suite.addTestSuite(CheckBoxModelAdapterTests.class);
- suite.addTestSuite(ComboBoxModelAdapterTests.class);
- suite.addTestSuite(DateSpinnerModelAdapterTests.class);
- suite.addTestSuite(DocumentAdapterTests.class);
- suite.addTestSuite(ListModelAdapterTests.class);
- suite.addTestSuite(ListSpinnerModelAdapterTests.class);
- suite.addTestSuite(NumberSpinnerModelAdapterTests.class);
- suite.addTestSuite(ObjectListSelectionModelTests.class);
- suite.addTestSuite(PrimitiveListTreeModelTests.class);
- suite.addTestSuite(RadioButtonModelAdapterTests.class);
- suite.addTestSuite(SpinnerModelAdapterTests.class);
- suite.addTestSuite(TableModelAdapterTests.class);
- suite.addTestSuite(TreeModelAdapterTests.class);
-
- return suite;
- }
-
- private JptUtilityModelValueSwingTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
deleted file mode 100644
index 1488e5fab9..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.swing.ListModel;
-
-import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.model.value.CoordinatedList;
-
-import junit.framework.TestCase;
-
-public class ListModelAdapterTests extends TestCase {
-
- public ListModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // nothing yet...
- }
-
- @Override
- protected void tearDown() throws Exception {
- // nothing yet...
- super.tearDown();
- }
-
- private ListModelAdapter buildListModel(ListValueModel<String> listHolder) {
- return new ListModelAdapter(listHolder) {
- @Override
- protected ListChangeListener buildListChangeListener() {
- return this.buildListChangeListener_();
- }
- };
- }
-
- private ListModel buildListModel(CollectionValueModel<String> collectionHolder) {
- return new ListModelAdapter(collectionHolder) {
- @Override
- protected ListChangeListener buildListChangeListener() {
- return this.buildListChangeListener_();
- }
- };
- }
-
- public void testCollectionSynchronization() {
- SimpleCollectionValueModel<String> collectionHolder = this.buildCollectionHolder();
- ListModel listModel = this.buildListModel(collectionHolder);
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- assertEquals(6, synchList.size());
- this.compare(listModel, synchList);
-
- collectionHolder.add("tom");
- collectionHolder.add("dick");
- collectionHolder.add("harry");
- collectionHolder.add(null);
- assertEquals(10, synchList.size());
- this.compare(listModel, synchList);
-
- collectionHolder.remove("foo");
- collectionHolder.remove("jar");
- collectionHolder.remove("harry");
- collectionHolder.remove(null);
- assertEquals(6, synchList.size());
- this.compare(listModel, synchList);
- }
-
- public void testListSynchronization() {
- SimpleListValueModel<String> listHolder = this.buildListHolder();
- ListModel listModel = this.buildListModel(listHolder);
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- assertEquals(6, synchList.size());
- this.compare(listModel, synchList);
-
- listHolder.add(6, "tom");
- listHolder.add(7, "dick");
- listHolder.add(8, "harry");
- listHolder.add(9, null);
- assertEquals(10, synchList.size());
- this.compare(listModel, synchList);
-
- listHolder.remove(9);
- listHolder.remove(8);
- listHolder.remove(4);
- listHolder.remove(0);
- assertEquals(6, synchList.size());
- this.compare(listModel, synchList);
- }
-
- public void testSetModel() {
- SimpleListValueModel<String> listHolder1 = this.buildListHolder();
- ListModelAdapter listModel = this.buildListModel(listHolder1);
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- assertTrue(listHolder1.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertEquals(6, synchList.size());
- this.compare(listModel, synchList);
-
- SimpleListValueModel<String> listHolder2 = this.buildListHolder2();
- listModel.setModel(listHolder2);
- assertEquals(3, synchList.size());
- this.compare(listModel, synchList);
- assertTrue(listHolder1.hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(listHolder2.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- listModel.setModel(new SimpleListValueModel<String>());
- assertEquals(0, synchList.size());
- this.compare(listModel, synchList);
- assertTrue(listHolder1.hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(listHolder2.hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private void compare(ListModel listModel, List<String> list) {
- assertEquals(listModel.getSize(), list.size());
- for (int i = 0; i < listModel.getSize(); i++) {
- assertEquals(listModel.getElementAt(i), list.get(i));
- }
- }
-
- public void testCollectionSort() {
- this.verifyCollectionSort(null);
- }
-
- public void testListSort() {
- this.verifyListSort(null);
- }
-
- public void testCustomCollectionSort() {
- this.verifyCollectionSort(this.buildCustomComparator());
- }
-
- public void testCustomListSort() {
- this.verifyListSort(this.buildCustomComparator());
- }
-
- private Comparator<String> buildCustomComparator() {
- // sort with reverse order
- return new Comparator<String>() {
- public int compare(String s1, String s2) {
- return s2.compareTo(s1);
- }
- };
- }
-
- private void verifyCollectionSort(Comparator<String> comparator) {
- SimpleCollectionValueModel<String> collectionHolder = this.buildCollectionHolder();
- ListModel listModel = this.buildListModel(new SortedListValueModelAdapter<String>(collectionHolder, comparator));
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- assertEquals(6, synchList.size());
- this.compareSort(listModel, synchList, comparator);
-
- collectionHolder.add("tom");
- collectionHolder.add("dick");
- collectionHolder.add("harry");
- assertEquals(9, synchList.size());
- this.compareSort(listModel, synchList, comparator);
-
- collectionHolder.remove("foo");
- collectionHolder.remove("jar");
- collectionHolder.remove("harry");
- assertEquals(6, synchList.size());
- this.compareSort(listModel, synchList, comparator);
- }
-
- private void verifyListSort(Comparator<String> comparator) {
- SimpleListValueModel<String> listHolder = this.buildListHolder();
- ListModel listModel = this.buildListModel(new SortedListValueModelAdapter<String>(listHolder, comparator));
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- assertEquals(6, synchList.size());
- this.compareSort(listModel, synchList, comparator);
-
- listHolder.add(0, "tom");
- listHolder.add(0, "dick");
- listHolder.add(0, "harry");
- assertEquals(9, synchList.size());
- this.compareSort(listModel, synchList, comparator);
-
- listHolder.remove(8);
- listHolder.remove(4);
- listHolder.remove(0);
- listHolder.remove(5);
- assertEquals(5, synchList.size());
- this.compareSort(listModel, synchList, comparator);
- }
-
- private void compareSort(ListModel listModel, List<String> list, Comparator<String> comparator) {
- SortedSet<String> ss = new TreeSet<String>(comparator);
- for (int i = 0; i < listModel.getSize(); i++) {
- ss.add((String) listModel.getElementAt(i));
- }
- assertEquals(ss.size(), list.size());
- for (Iterator<String> stream1 = ss.iterator(), stream2 = list.iterator(); stream1.hasNext(); ) {
- assertEquals(stream1.next(), stream2.next());
- }
- }
-
- public void testHasListeners() throws Exception {
- SimpleListValueModel<String> listHolder = this.buildListHolder();
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ListModel listModel = this.buildListModel(listHolder);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.verifyHasNoListeners(listModel);
-
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.verifyHasListeners(listModel);
-
- listModel.removeListDataListener(synchList);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.verifyHasNoListeners(listModel);
- }
-
- public void testGetSize() throws Exception {
- SimpleListValueModel<String> listHolder = this.buildListHolder();
- ListModel listModel = this.buildListModel(listHolder);
- this.verifyHasNoListeners(listModel);
- assertEquals(6, listModel.getSize());
-
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- this.verifyHasListeners(listModel);
- assertEquals(6, listModel.getSize());
-
- listModel.removeListDataListener(synchList);
- this.verifyHasNoListeners(listModel);
- assertEquals(6, listModel.getSize());
- }
-
- public void testGetElementAt() throws Exception {
- SimpleListValueModel<String> listHolder = this.buildListHolder();
- ListModel listModel = this.buildListModel(new SortedListValueModelAdapter<String>(listHolder));
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- this.verifyHasListeners(listModel);
- assertEquals("bar", listModel.getElementAt(0));
- assertEquals("bar", synchList.get(0));
- }
-
- private void verifyHasNoListeners(ListModel listModel) throws Exception {
- boolean hasNoListeners = ((Boolean) ClassTools.executeMethod(listModel, "hasNoListDataListeners")).booleanValue();
- assertTrue(hasNoListeners);
- }
-
- private void verifyHasListeners(ListModel listModel) throws Exception {
- boolean hasListeners = ((Boolean) ClassTools.executeMethod(listModel, "hasListDataListeners")).booleanValue();
- assertTrue(hasListeners);
- }
-
- private SimpleCollectionValueModel<String> buildCollectionHolder() {
- return new SimpleCollectionValueModel<String>(this.buildCollection());
- }
-
- private Collection<String> buildCollection() {
- Bag<String> bag = new HashBag<String>();
- this.populateCollection(bag);
- return bag;
- }
-
- private SimpleListValueModel<String> buildListHolder() {
- return new SimpleListValueModel<String>(this.buildList());
- }
-
- private List<String> buildList() {
- List<String> list = new ArrayList<String>();
- this.populateCollection(list);
- return list;
- }
-
- private void populateCollection(Collection<String> c) {
- c.add("foo");
- c.add("bar");
- c.add("baz");
- c.add("joo");
- c.add("jar");
- c.add("jaz");
- }
-
- private SimpleListValueModel<String> buildListHolder2() {
- return new SimpleListValueModel<String>(this.buildList2());
- }
-
- private List<String> buildList2() {
- List<String> list = new ArrayList<String>();
- this.populateCollection2(list);
- return list;
- }
-
- private void populateCollection2(Collection<String> c) {
- c.add("tom");
- c.add("dick");
- c.add("harry");
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java
deleted file mode 100644
index acebc1fc39..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java
+++ /dev/null
@@ -1,372 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.TextField;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-import java.util.ListIterator;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.Icon;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.ListModel;
-import javax.swing.WindowConstants;
-
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.utility.internal.swing.Displayable;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * an example UI for testing various permutations of the ListModelAdapter
- */
-public class ListModelAdapterUITest {
-
- private WritablePropertyValueModel<TaskList> taskListHolder;
- private TextField taskTextField;
-
- public static void main(String[] args) throws Exception {
- new ListModelAdapterUITest().exec(args);
- }
-
- private ListModelAdapterUITest() {
- super();
- }
-
- private void exec(String[] args) throws Exception {
- this.taskListHolder = new SimplePropertyValueModel<TaskList>(new TaskList());
- this.openWindow();
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setSize(800, 400);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildTaskListPanel(), BorderLayout.CENTER);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildTaskListPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(0, 1));
- taskListPanel.add(this.buildPrimitiveTaskListPanel());
- taskListPanel.add(this.buildDisplayableTaskListPanel());
- return taskListPanel;
- }
-
- private Component buildPrimitiveTaskListPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(1, 0));
- taskListPanel.add(this.buildUnsortedPrimitiveListPanel());
- taskListPanel.add(this.buildStandardSortedPrimitiveListPanel());
- taskListPanel.add(this.buildCustomSortedPrimitiveListPanel());
- return taskListPanel;
- }
-
- private Component buildDisplayableTaskListPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(1, 0));
- taskListPanel.add(this.buildUnsortedDisplayableListPanel());
- taskListPanel.add(this.buildStandardSortedDisplayableListPanel());
- taskListPanel.add(this.buildCustomSortedDisplayableListPanel());
- return taskListPanel;
- }
-
- private Component buildUnsortedPrimitiveListPanel() {
- return this.buildListPanel("primitive unsorted", this.buildUnsortedPrimitiveListModel());
- }
-
- private Component buildStandardSortedPrimitiveListPanel() {
- return this.buildListPanel("primitive sorted", this.buildStandardSortedPrimitiveListModel());
- }
-
- private Component buildCustomSortedPrimitiveListPanel() {
- return this.buildListPanel("primitive reverse sorted", this.buildCustomSortedPrimitiveListModel());
- }
-
- private Component buildUnsortedDisplayableListPanel() {
- return this.buildListPanel("displayable unsorted", this.buildUnsortedDisplayableListModel());
- }
-
- private Component buildStandardSortedDisplayableListPanel() {
- return this.buildListPanel("displayable sorted", this.buildStandardSortedDisplayableListModel());
- }
-
- private Component buildCustomSortedDisplayableListPanel() {
- return this.buildListPanel("displayable reverse sorted", this.buildCustomSortedDisplayableListModel());
- }
-
- private ListModel buildUnsortedPrimitiveListModel() {
- return new ListModelAdapter(this.buildPrimitiveTaskListAdapter());
- }
-
- private ListModel buildStandardSortedPrimitiveListModel() {
- return new ListModelAdapter(new SortedListValueModelAdapter<String>(this.buildPrimitiveTaskListAdapter()));
- }
-
- private ListModel buildCustomSortedPrimitiveListModel() {
- return new ListModelAdapter(new SortedListValueModelAdapter<String>(this.buildPrimitiveTaskListAdapter(), this.buildCustomStringComparator()));
- }
-
- private ListModel buildUnsortedDisplayableListModel() {
- return new ListModelAdapter(this.buildDisplayableTaskListAdapter());
- }
-
- private ListModel buildStandardSortedDisplayableListModel() {
- return new ListModelAdapter(new SortedListValueModelAdapter<Task>(this.buildDisplayableTaskListAdapter()));
- }
-
- private ListModel buildCustomSortedDisplayableListModel() {
- return new ListModelAdapter(new SortedListValueModelAdapter<Task>(this.buildDisplayableTaskListAdapter(), this.buildCustomTaskObjectComparator()));
- }
-
- private Component buildListPanel(String label, ListModel listModel) {
- JPanel listPanel = new JPanel(new BorderLayout());
- JLabel listLabel = new JLabel(" " + label);
- listPanel.add(listLabel, BorderLayout.NORTH);
-
- JList listBox = new JList();
- listBox.setModel(listModel);
- listBox.setDoubleBuffered(true);
- listLabel.setLabelFor(listBox);
- listPanel.add(new JScrollPane(listBox), BorderLayout.CENTER);
- return listPanel;
- }
-
- private Comparator<String> buildCustomStringComparator() {
- return new Comparator<String>() {
- public int compare(String s1, String s2) {
- return s2.compareTo(s1);
- }
- };
- }
-
- private Comparator<Task> buildCustomTaskObjectComparator() {
- return new Comparator<Task>() {
- public int compare(Task to1, Task to2) {
- return to2.compareTo(to1);
- }
- };
- }
-
- private ListValueModel<String> buildPrimitiveTaskListAdapter() {
- return new ListAspectAdapter<TaskList, String>(TaskList.TASK_NAMES_LIST, this.taskList()) {
- @Override
- protected ListIterator<String> listIterator_() {
- return this.subject.taskNames();
- }
- };
- }
-
- private ListValueModel<Task> buildDisplayableTaskListAdapter() {
- return new ListAspectAdapter<TaskList, Task>(TaskList.TASKS_LIST, this.taskList()) {
- @Override
- protected ListIterator<Task> listIterator_() {
- return this.subject.tasks();
- }
- };
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new BorderLayout());
- controlPanel.add(this.buildAddRemoveTaskPanel(), BorderLayout.CENTER);
- controlPanel.add(this.buildClearButton(), BorderLayout.EAST);
- return controlPanel;
- }
-
- private Component buildAddRemoveTaskPanel() {
- JPanel addRemoveTaskPanel = new JPanel(new BorderLayout());
- addRemoveTaskPanel.add(this.buildAddButton(), BorderLayout.WEST);
- addRemoveTaskPanel.add(this.buildTaskTextField(), BorderLayout.CENTER);
- addRemoveTaskPanel.add(this.buildRemoveButton(), BorderLayout.EAST);
- return addRemoveTaskPanel;
- }
-
- private String getTask() {
- return this.taskTextField.getText();
- }
-
- private TaskList taskList() {
- return this.taskListHolder.getValue();
- }
-
- void addTask() {
- String task = this.getTask();
- if (task.length() != 0) {
- this.taskList().addTask(task);
- }
- }
-
- void removeTask() {
- String task = this.getTask();
- if (task.length() != 0) {
- this.taskList().removeTask(task);
- }
- }
-
- void clearTasks() {
- this.taskList().clearTasks();
- }
-
- private TextField buildTaskTextField() {
- this.taskTextField = new TextField();
- return this.taskTextField;
- }
-
- private JButton buildAddButton() {
- return new JButton(this.buildAddAction());
- }
-
- private Action buildAddAction() {
- Action action = new AbstractAction("add") {
- public void actionPerformed(ActionEvent event) {
- ListModelAdapterUITest.this.addTask();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- private JButton buildRemoveButton() {
- return new JButton(this.buildRemoveAction());
- }
-
- private Action buildRemoveAction() {
- Action action = new AbstractAction("remove") {
- public void actionPerformed(ActionEvent event) {
- ListModelAdapterUITest.this.removeTask();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- private JButton buildClearButton() {
- return new JButton(this.buildClearAction());
- }
-
- private Action buildClearAction() {
- Action action = new AbstractAction("clear") {
- public void actionPerformed(ActionEvent event) {
- ListModelAdapterUITest.this.clearTasks();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- private class TaskList extends AbstractModel {
- private List<String> taskNames = new ArrayList<String>();
- private List<Task> taskObjects = new ArrayList<Task>();
- public static final String TASK_NAMES_LIST = "taskNames";
- public static final String TASKS_LIST = "tasks";
- TaskList() {
- super();
- }
- public ListIterator<String> taskNames() {
- return this.taskNames.listIterator();
- }
- public ListIterator<Task> tasks() {
- return this.taskObjects.listIterator();
- }
- public void addTask(String taskName) {
- int index = this.taskNames.size();
- this.taskNames.add(index, taskName);
- this.fireItemAdded(TASK_NAMES_LIST, index, taskName);
-
- Task taskObject = new Task(taskName);
- this.taskObjects.add(index, taskObject);
- this.fireItemAdded(TASKS_LIST, index, taskObject);
- }
- public void removeTask(String taskName) {
- int index = this.taskNames.indexOf(taskName);
- if (index != -1) {
- Object removedTask = this.taskNames.remove(index);
- this.fireItemRemoved(TASK_NAMES_LIST, index, removedTask);
- // assume the indexes match...
- Object removedTaskObject = this.taskObjects.remove(index);
- this.fireItemRemoved(TASKS_LIST, index, removedTaskObject);
- }
- }
- public void clearTasks() {
- this.taskNames.clear();
- this.fireListChanged(TASK_NAMES_LIST);
- this.taskObjects.clear();
- this.fireListChanged(TASKS_LIST);
- }
- }
-
- private class Task extends AbstractModel implements Displayable {
- private String name;
- private Date creationTimeStamp;
- public Task(String name) {
- this.name = name;
- this.creationTimeStamp = new Date();
- }
- public String displayString() {
- return this.name + ": " + this.creationTimeStamp.getTime();
- }
- public Icon icon() {
- return null;
- }
- public int compareTo(Displayable o) {
- return DEFAULT_COMPARATOR.compare(this, o);
- }
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(DISPLAY_STRING_PROPERTY, old, name);
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.displayString());
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java
deleted file mode 100644
index d8e8255c51..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import javax.swing.SpinnerModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.ListSpinnerModelAdapter;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ListSpinnerModelAdapterTests extends TestCase {
- private WritablePropertyValueModel<Object> valueHolder;
- private SpinnerModel spinnerModelAdapter;
- boolean eventFired;
- private static final String[] VALUE_LIST = {"red", "green", "blue"};
- private static final String DEFAULT_VALUE = VALUE_LIST[0];
-
- public ListSpinnerModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Object>(DEFAULT_VALUE);
- this.spinnerModelAdapter = new ListSpinnerModelAdapter(this.valueHolder, VALUE_LIST) {
- @Override
- protected PropertyChangeListener buildValueChangeListener() {
- return this.buildValueChangeListener_();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSetValueSpinnerModel() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- ListSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(DEFAULT_VALUE, this.valueHolder.getValue());
- this.spinnerModelAdapter.setValue(VALUE_LIST[2]);
- assertTrue(this.eventFired);
- assertEquals(VALUE_LIST[2], this.valueHolder.getValue());
- }
-
- public void testSetValueValueHolder() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- ListSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(DEFAULT_VALUE, this.spinnerModelAdapter.getValue());
- this.valueHolder.setValue(VALUE_LIST[2]);
- assertTrue(this.eventFired);
- assertEquals(VALUE_LIST[2], this.spinnerModelAdapter.getValue());
- }
-
- public void testDefaultValue() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- ListSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(DEFAULT_VALUE, this.spinnerModelAdapter.getValue());
-
- this.valueHolder.setValue(VALUE_LIST[2]);
- assertTrue(this.eventFired);
- assertEquals(VALUE_LIST[2], this.spinnerModelAdapter.getValue());
-
- this.eventFired = false;
- this.valueHolder.setValue(null);
- assertTrue(this.eventFired);
- assertEquals(VALUE_LIST[0], this.spinnerModelAdapter.getValue());
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Object> localValueHolder = (SimplePropertyValueModel<Object>) this.valueHolder;
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
-
- ChangeListener listener = new TestChangeListener();
- this.spinnerModelAdapter.addChangeListener(listener);
- assertTrue(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.spinnerModelAdapter);
-
- this.spinnerModelAdapter.removeChangeListener(listener);
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
- }
-
- private void verifyHasNoListeners(SpinnerModel adapter) throws Exception {
- assertEquals(0, ((ListSpinnerModelAdapter) adapter).getChangeListeners().length);
- }
-
- private void verifyHasListeners(Object adapter) throws Exception {
- assertFalse(((ListSpinnerModelAdapter) adapter).getChangeListeners().length == 0);
- }
-
-
- private class TestChangeListener implements ChangeListener {
- TestChangeListener() {
- super();
- }
- public void stateChanged(ChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java
deleted file mode 100644
index 985d28116e..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import javax.swing.SpinnerModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.NumberSpinnerModelAdapter;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class NumberSpinnerModelAdapterTests extends TestCase {
- private WritablePropertyValueModel<Number> valueHolder;
- private SpinnerModel spinnerModelAdapter;
- boolean eventFired;
-
- public NumberSpinnerModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Number>(new Integer(0));
- this.spinnerModelAdapter = new NumberSpinnerModelAdapter(this.valueHolder, -33, 33, 1) {
- @Override
- protected PropertyChangeListener buildNumberChangeListener() {
- return this.buildNumberChangeListener_();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSetValueSpinnerModel() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- NumberSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- this.spinnerModelAdapter.setValue(new Integer(5));
- assertTrue(this.eventFired);
- assertEquals(new Integer(5), this.valueHolder.getValue());
- }
-
- public void testSetValueValueHolder() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- NumberSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(new Integer(0), this.spinnerModelAdapter.getValue());
- this.valueHolder.setValue(new Integer(7));
- assertTrue(this.eventFired);
- assertEquals(new Integer(7), this.spinnerModelAdapter.getValue());
- }
-
- public void testDefaultValue() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- NumberSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(new Integer(0), this.spinnerModelAdapter.getValue());
- this.valueHolder.setValue(null);
- assertTrue(this.eventFired);
- assertEquals(new Integer(-33), this.spinnerModelAdapter.getValue());
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Number> localValueHolder = (SimplePropertyValueModel<Number>) this.valueHolder;
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
-
- ChangeListener listener = new TestChangeListener();
- this.spinnerModelAdapter.addChangeListener(listener);
- assertTrue(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.spinnerModelAdapter);
-
- this.spinnerModelAdapter.removeChangeListener(listener);
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
- }
-
- private void verifyHasNoListeners(SpinnerModel adapter) throws Exception {
- assertEquals(0, ((NumberSpinnerModelAdapter) adapter).getChangeListeners().length);
- }
-
- private void verifyHasListeners(Object adapter) throws Exception {
- assertFalse(((NumberSpinnerModelAdapter) adapter).getChangeListeners().length == 0);
- }
-
- public void testNullInitialValue() {
- this.valueHolder = new SimplePropertyValueModel<Number>();
- this.spinnerModelAdapter = new NumberSpinnerModelAdapter(this.valueHolder, new Integer(-33), new Integer(33), new Integer(1), new Integer(0)) {
- @Override
- protected PropertyChangeListener buildNumberChangeListener() {
- return this.buildNumberChangeListener_();
- }
- };
-
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- NumberSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(new Integer(0), this.spinnerModelAdapter.getValue());
- this.valueHolder.setValue(new Integer(7));
- assertTrue(this.eventFired);
- assertEquals(new Integer(7), this.spinnerModelAdapter.getValue());
- }
-
-
- // ********** inner class **********
- private class TestChangeListener implements ChangeListener {
- TestChangeListener() {
- super();
- }
- public void stateChanged(ChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java
deleted file mode 100644
index 1935068f27..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import javax.swing.DefaultListModel;
-import javax.swing.ListModel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class ObjectListSelectionModelTests extends TestCase {
- private DefaultListModel listModel;
- private ObjectListSelectionModel selectionModel;
-
- public ObjectListSelectionModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.listModel = this.buildListModel();
- this.selectionModel = this.buildSelectionModel(this.listModel);
- }
-
- private DefaultListModel buildListModel() {
- DefaultListModel lm = new DefaultListModel();
- lm.addElement("foo");
- lm.addElement("bar");
- lm.addElement("baz");
- return lm;
- }
-
- private ObjectListSelectionModel buildSelectionModel(ListModel lm) {
- return new ObjectListSelectionModel(lm);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testListDataListener() {
- this.selectionModel.addListSelectionListener(this.buildListSelectionListener());
- this.selectionModel.setSelectionInterval(0, 0);
- assertEquals("foo", this.selectionModel.selectedValue());
- this.listModel.set(0, "jar");
- assertEquals("jar", this.selectionModel.selectedValue());
- }
-
- public void testGetSelectedValue() {
- this.selectionModel.setSelectionInterval(0, 0);
- assertEquals("foo", this.selectionModel.selectedValue());
- }
-
- public void testGetSelectedValues() {
- this.selectionModel.setSelectionInterval(0, 0);
- this.selectionModel.addSelectionInterval(2, 2);
- assertEquals(2, this.selectionModel.selectedValues().length);
- assertTrue(CollectionTools.contains(this.selectionModel.selectedValues(), "foo"));
- assertTrue(CollectionTools.contains(this.selectionModel.selectedValues(), "baz"));
- }
-
- public void testSetSelectedValue() {
- this.selectionModel.setSelectedValue("foo");
- assertEquals(0, this.selectionModel.getMinSelectionIndex());
- assertEquals(0, this.selectionModel.getMaxSelectionIndex());
- }
-
- public void testSetSelectedValues() {
- this.selectionModel.setSelectedValues(new Object[] {"foo", "baz"});
- assertEquals(0, this.selectionModel.getMinSelectionIndex());
- assertEquals(2, this.selectionModel.getMaxSelectionIndex());
- }
-
- public void testAddSelectedValue() {
- this.listModel.addElement("joo");
- this.listModel.addElement("jar");
- this.listModel.addElement("jaz");
- this.selectionModel.setSelectedValue("foo");
- this.selectionModel.addSelectedValue("jaz");
- assertEquals(0, this.selectionModel.getMinSelectionIndex());
- assertEquals(5, this.selectionModel.getMaxSelectionIndex());
- assertTrue(this.selectionModel.isSelectedIndex(0));
- assertFalse(this.selectionModel.isSelectedIndex(1));
- assertFalse(this.selectionModel.isSelectedIndex(2));
- assertFalse(this.selectionModel.isSelectedIndex(3));
- assertFalse(this.selectionModel.isSelectedIndex(4));
- assertTrue(this.selectionModel.isSelectedIndex(5));
- }
-
- public void testAddSelectedValues() {
- this.listModel.addElement("joo");
- this.listModel.addElement("jar");
- this.listModel.addElement("jaz");
- this.selectionModel.setSelectedValue("foo");
- this.selectionModel.addSelectedValues(new Object[] {"bar", "jar"});
- assertEquals(0, this.selectionModel.getMinSelectionIndex());
- assertEquals(4, this.selectionModel.getMaxSelectionIndex());
- assertTrue(this.selectionModel.isSelectedIndex(0));
- assertTrue(this.selectionModel.isSelectedIndex(1));
- assertFalse(this.selectionModel.isSelectedIndex(2));
- assertFalse(this.selectionModel.isSelectedIndex(3));
- assertTrue(this.selectionModel.isSelectedIndex(4));
- assertFalse(this.selectionModel.isSelectedIndex(5));
- }
-
- public void testRemoveSelectedValue() {
- this.listModel.addElement("joo");
- this.listModel.addElement("jar");
- this.listModel.addElement("jaz");
- this.selectionModel.setSelectedValues(new Object[] {"foo", "baz", "jar"});
- this.selectionModel.removeSelectedValue("jar");
- assertEquals(0, this.selectionModel.getMinSelectionIndex());
- assertEquals(2, this.selectionModel.getMaxSelectionIndex());
- assertTrue(this.selectionModel.isSelectedIndex(0));
- assertFalse(this.selectionModel.isSelectedIndex(1));
- assertTrue(this.selectionModel.isSelectedIndex(2));
- assertFalse(this.selectionModel.isSelectedIndex(3));
- assertFalse(this.selectionModel.isSelectedIndex(4));
- assertFalse(this.selectionModel.isSelectedIndex(5));
- }
-
- public void testRemoveSelectedValues() {
- this.listModel.addElement("joo");
- this.listModel.addElement("jar");
- this.listModel.addElement("jaz");
- this.selectionModel.setSelectedValues(new Object[] {"foo", "baz", "joo", "jar"});
- this.selectionModel.removeSelectedValues(new Object[] {"foo", "joo"});
- assertEquals(2, this.selectionModel.getMinSelectionIndex());
- assertEquals(4, this.selectionModel.getMaxSelectionIndex());
- assertFalse(this.selectionModel.isSelectedIndex(0));
- assertFalse(this.selectionModel.isSelectedIndex(1));
- assertTrue(this.selectionModel.isSelectedIndex(2));
- assertFalse(this.selectionModel.isSelectedIndex(3));
- assertTrue(this.selectionModel.isSelectedIndex(4));
- assertFalse(this.selectionModel.isSelectedIndex(5));
- }
-
- public void testGetAnchorSelectedValue() {
- this.selectionModel.setAnchorSelectionIndex(1);
- assertEquals("bar", this.selectionModel.getAnchorSelectedValue());
- }
-
- public void testGetLeadSelectedValue() {
- this.selectionModel.setSelectedValue("bar");
- assertEquals("bar", this.selectionModel.getLeadSelectedValue());
- this.selectionModel.setSelectedValues(new Object[] {"foo", "baz"});
- assertEquals("baz", this.selectionModel.getLeadSelectedValue());
- }
-
- public void testGetMinMaxSelectedValue() {
- this.listModel.addElement("joo");
- this.listModel.addElement("jar");
- this.listModel.addElement("jaz");
- this.selectionModel.setSelectedValue("foo");
- this.selectionModel.addSelectedValues(new Object[] {"bar", "jar"});
- assertEquals("foo", this.selectionModel.getMinSelectedValue());
- assertEquals("jar", this.selectionModel.getMaxSelectedValue());
- }
-
- public void testValueIsSelected() {
- this.listModel.addElement("joo");
- this.listModel.addElement("jar");
- this.listModel.addElement("jaz");
- this.selectionModel.setSelectedValue("foo");
- this.selectionModel.addSelectedValues(new Object[] {"bar", "jar"});
- assertTrue(this.selectionModel.valueIsSelected("foo"));
- assertTrue(this.selectionModel.valueIsSelected("bar"));
- assertTrue(this.selectionModel.valueIsSelected("jar"));
- assertFalse(this.selectionModel.valueIsSelected("baz"));
- }
-
- public void testHasListeners() throws Exception {
- ListSelectionListener listener = this.buildListSelectionListener();
- assertEquals(0, this.listModel.getListDataListeners().length);
- this.selectionModel.addListSelectionListener(listener);
- assertEquals(1, this.listModel.getListDataListeners().length);
- this.selectionModel.removeListSelectionListener(listener);
- assertEquals(0, this.listModel.getListDataListeners().length);
- }
-
- private ListSelectionListener buildListSelectionListener() {
- return new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent e) {
- // do nothing for now...
- }
- };
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java
deleted file mode 100644
index df9e200232..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.ListIterator;
-
-import javax.swing.event.TreeModelEvent;
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.TreeModel;
-
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.PrimitiveListTreeModel;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class PrimitiveListTreeModelTests extends TestCase {
- TestModel testModel;
- private TreeModel treeModel;
-
- public PrimitiveListTreeModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.testModel = this.buildTestModel();
- this.treeModel = this.buildTreeModel();
- }
-
- private TestModel buildTestModel() {
- return new TestModel();
- }
-
- private TreeModel buildTreeModel() {
- return new PrimitiveListTreeModel(this.buildListValueModel()) {
- @Override
- protected void primitiveChanged(int index, Object newValue) {
- if ( ! newValue.equals("")) {
- PrimitiveListTreeModelTests.this.testModel.replaceName(index, (String) newValue);
- }
- }
- @Override
- protected ListChangeListener buildListChangeListener() {
- return this.buildListChangeListener_();
- }
- };
- }
-
- private ListValueModel<?> buildListValueModel() {
- return new ListAspectAdapter<TestModel, String>(TestModel.NAMES_LIST, this.testModel) {
- @Override
- protected ListIterator<String> listIterator_() {
- return this.subject.names();
- }
- @Override
- public String get(int index) {
- return this.subject.getName(index);
- }
- @Override
- public int size() {
- return this.subject.namesSize();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testAddPrimitive() {
- this.treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesInserted(TreeModelEvent e) {
- PrimitiveListTreeModelTests.this.verifyTreeModelEvent(e, new int[] {0}, new String[] {"foo"});
- }
- });
- this.testModel.addName("foo");
- }
-
- public void testRemovePrimitive() {
- this.testModel.addName("foo");
- this.testModel.addName("bar");
- this.testModel.addName("baz");
- this.treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesRemoved(TreeModelEvent e) {
- PrimitiveListTreeModelTests.this.verifyTreeModelEvent(e, new int[] {1}, new String[] {"bar"});
- }
- });
- String name = this.testModel.removeName(1);
- assertEquals("bar", name);
- }
-
- public void testReplacePrimitive() {
- this.testModel.addName("foo");
- this.testModel.addName("bar");
- this.testModel.addName("baz");
- this.treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesChanged(TreeModelEvent e) {
- PrimitiveListTreeModelTests.this.verifyTreeModelEvent(e, new int[] {1}, new String[] {"jar"});
- }
- });
- String name = this.testModel.replaceName(1, "jar");
- assertEquals("bar", name);
- }
-
- void verifyTreeModelEvent(TreeModelEvent e, int[] expectedChildIndices, String[] expectedNames) {
- assertTrue(Arrays.equals(expectedChildIndices, e.getChildIndices()));
- Object[] actualChildren = e.getChildren();
- assertEquals(expectedNames.length, actualChildren.length);
- for (int i = 0; i < expectedNames.length; i++) {
- DefaultMutableTreeNode node = (DefaultMutableTreeNode) actualChildren[i];
- assertEquals(expectedNames[i], node.getUserObject());
- }
- assertEquals(1, e.getPath().length);
- assertEquals(this.treeModel.getRoot(), e.getPath()[0]);
- assertEquals(this.treeModel, e.getSource());
- }
-
-
-// ********** inner classes **********
-
- private class TestModel extends AbstractModel {
- private final List<String> names;
- static final String NAMES_LIST = "names";
-
- TestModel() {
- super();
- this.names = new ArrayList<String>();
- }
-
- public ListIterator<String> names() {
- return new ReadOnlyListIterator<String>(this.names);
- }
- public int namesSize() {
- return this.names.size();
- }
- public String getName(int index) {
- return this.names.get(index);
- }
- public void addName(int index, String name) {
- this.addItemToList(index, name, this.names, NAMES_LIST);
- }
- public void addName(String name) {
- this.addName(this.namesSize(), name);
- }
- public void addNames(int index, List<String> list) {
- this.addItemsToList(index, this.names, list, NAMES_LIST);
- }
- public void addNames(List<String> list) {
- this.addNames(this.namesSize(), list);
- }
- public String removeName(int index) {
- return this.removeItemFromList(index, this.names, NAMES_LIST);
- }
- public List<String> removeNames(int index, int length) {
- return this.removeItemsFromList(index, length, this.names, NAMES_LIST);
- }
- public String replaceName(int index, String newName) {
- return this.setItemInList(index, newName, this.names, NAMES_LIST);
- }
- }
-
-
- public class TestTreeModelListener implements TreeModelListener {
- public void treeNodesChanged(TreeModelEvent e) {
- fail("unexpected event");
- }
- public void treeNodesInserted(TreeModelEvent e) {
- fail("unexpected event");
- }
- public void treeNodesRemoved(TreeModelEvent e) {
- fail("unexpected event");
- }
- public void treeStructureChanged(TreeModelEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java
deleted file mode 100644
index 4617c45990..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import javax.swing.ButtonModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.EventListenerList;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.RadioButtonModelAdapter;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class RadioButtonModelAdapterTests extends TestCase {
- private WritablePropertyValueModel<Object> valueHolder;
-
- private ButtonModel redButtonModelAdapter;
- private ChangeListener redListener;
- boolean redEventFired;
-
- private ButtonModel greenButtonModelAdapter;
- private ChangeListener greenListener;
- boolean greenEventFired;
-
- private ButtonModel blueButtonModelAdapter;
- private ChangeListener blueListener;
- boolean blueEventFired;
-
-// private ButtonGroup buttonGroup; // DO NOT use a ButtonGroup
-
- private static final String RED = "red";
- private static final String GREEN = "green";
- private static final String BLUE = "blue";
-
- public RadioButtonModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Object>(null);
-// buttonGroup = new ButtonGroup();
-
- this.redButtonModelAdapter = this.buildButtonModel(this.valueHolder, RED);
-// this.redButtonModelAdapter.setGroup(buttonGroup);
- this.redListener = new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- RadioButtonModelAdapterTests.this.redEventFired = true;
- }
- };
-
- this.greenButtonModelAdapter = this.buildButtonModel(this.valueHolder, GREEN);
-// this.greenButtonModelAdapter.setGroup(buttonGroup);
- this.greenListener = new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- RadioButtonModelAdapterTests.this.greenEventFired = true;
- }
- };
-
- this.blueButtonModelAdapter = this.buildButtonModel(this.valueHolder, BLUE);
-// this.blueButtonModelAdapter.setGroup(buttonGroup);
- this.blueListener = new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- RadioButtonModelAdapterTests.this.blueEventFired = true;
- }
- };
-
- this.clearFlags();
- }
-
- private ButtonModel buildButtonModel(WritablePropertyValueModel<Object> pvm, Object buttonValue) {
- return new RadioButtonModelAdapter(pvm, buttonValue) {
- @Override
- protected PropertyChangeListener buildBooleanChangeListener() {
- return this.buildBooleanChangeListener_();
- }
- };
- }
-
- private void listenToModelAdapters() {
- this.redButtonModelAdapter.addChangeListener(this.redListener);
- this.greenButtonModelAdapter.addChangeListener(this.greenListener);
- this.blueButtonModelAdapter.addChangeListener(this.blueListener);
- }
-
- private void clearFlags() {
- this.redEventFired = false;
- this.greenEventFired = false;
- this.blueEventFired = false;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSetSelected() throws Exception {
- this.listenToModelAdapters();
-
- this.greenButtonModelAdapter.setSelected(true);
- assertFalse(this.redEventFired);
- assertTrue(this.greenEventFired);
- assertFalse(this.blueEventFired);
- assertEquals(GREEN, this.valueHolder.getValue());
-
- this.clearFlags();
- this.blueButtonModelAdapter.setSelected(true);
- assertFalse(this.redEventFired);
- assertTrue(this.greenEventFired);
- assertTrue(this.blueEventFired);
- assertEquals(BLUE, this.valueHolder.getValue());
-
- this.clearFlags();
- this.redButtonModelAdapter.setSelected(true);
- assertTrue(this.redEventFired);
- assertFalse(this.greenEventFired);
- assertTrue(this.blueEventFired);
- assertEquals(RED, this.valueHolder.getValue());
- }
-
- public void testSetValue() throws Exception {
- this.listenToModelAdapters();
-
- this.greenButtonModelAdapter.setSelected(true);
-
- this.clearFlags();
- this.valueHolder.setValue(BLUE);
- assertFalse(this.redEventFired);
- assertTrue(this.greenEventFired);
- assertTrue(this.blueEventFired);
- assertFalse(this.redButtonModelAdapter.isSelected());
- assertFalse(this.greenButtonModelAdapter.isSelected());
- assertTrue(this.blueButtonModelAdapter.isSelected());
-
- this.clearFlags();
- this.valueHolder.setValue(RED);
- assertTrue(this.redEventFired);
- assertFalse(this.greenEventFired);
- assertTrue(this.blueEventFired);
- assertTrue(this.redButtonModelAdapter.isSelected());
- assertFalse(this.greenButtonModelAdapter.isSelected());
- assertFalse(this.blueButtonModelAdapter.isSelected());
- }
-
- public void testDefaultValue() throws Exception {
- this.listenToModelAdapters();
-
- this.valueHolder.setValue(GREEN);
- assertFalse(this.redButtonModelAdapter.isSelected());
- assertTrue(this.greenButtonModelAdapter.isSelected());
- assertFalse(this.blueButtonModelAdapter.isSelected());
-
- this.clearFlags();
- this.valueHolder.setValue(null);
- assertFalse(this.redEventFired);
- assertTrue(this.greenEventFired);
- assertFalse(this.blueEventFired);
- assertFalse(this.redButtonModelAdapter.isSelected());
- assertFalse(this.greenButtonModelAdapter.isSelected());
- assertFalse(this.blueButtonModelAdapter.isSelected());
-
- this.clearFlags();
- this.valueHolder.setValue(BLUE);
- assertFalse(this.redEventFired);
- assertFalse(this.greenEventFired);
- assertTrue(this.blueEventFired);
- assertFalse(this.redButtonModelAdapter.isSelected());
- assertFalse(this.greenButtonModelAdapter.isSelected());
- assertTrue(this.blueButtonModelAdapter.isSelected());
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Object> localValueHolder = (SimplePropertyValueModel<Object>) this.valueHolder;
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.redButtonModelAdapter);
- this.verifyHasNoListeners(this.greenButtonModelAdapter);
- this.verifyHasNoListeners(this.blueButtonModelAdapter);
-
- ChangeListener listener = new TestChangeListener();
- this.redButtonModelAdapter.addChangeListener(listener);
- assertTrue(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.redButtonModelAdapter);
- this.verifyHasNoListeners(this.greenButtonModelAdapter);
- this.verifyHasNoListeners(this.blueButtonModelAdapter);
-
- this.redButtonModelAdapter.removeChangeListener(listener);
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.redButtonModelAdapter);
- this.verifyHasNoListeners(this.greenButtonModelAdapter);
- this.verifyHasNoListeners(this.blueButtonModelAdapter);
- }
-
- private void verifyHasNoListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ClassTools.fieldValue(model, "listenerList");
- assertEquals(0, listenerList.getListenerList().length);
- }
-
- private void verifyHasListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ClassTools.fieldValue(model, "listenerList");
- assertFalse(listenerList.getListenerList().length == 0);
- }
-
-
- private class TestChangeListener implements ChangeListener {
- TestChangeListener() {
- super();
- }
- public void stateChanged(ChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java
deleted file mode 100644
index b75725f49d..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ButtonModel;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JRadioButton;
-import javax.swing.WindowConstants;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.RadioButtonModelAdapter;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-
-/**
- * Play around with a set of radio buttons.
- */
-public class RadioButtonModelAdapterUITest {
-
- private TestModel testModel;
- private WritablePropertyValueModel<TestModel> testModelHolder;
- private WritablePropertyValueModel<Object> colorHolder;
- private ButtonModel redButtonModel;
- private ButtonModel greenButtonModel;
- private ButtonModel blueButtonModel;
-
- public static void main(String[] args) throws Exception {
- new RadioButtonModelAdapterUITest().exec(args);
- }
-
- private RadioButtonModelAdapterUITest() {
- super();
- }
-
- private void exec(String[] args) throws Exception {
- this.testModel = new TestModel();
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.colorHolder = this.buildColorHolder(this.testModelHolder);
- this.redButtonModel = this.buildRadioButtonModelAdapter(this.colorHolder, TestModel.RED);
- this.greenButtonModel = this.buildRadioButtonModelAdapter(this.colorHolder, TestModel.GREEN);
- this.blueButtonModel = this.buildRadioButtonModelAdapter(this.colorHolder, TestModel.BLUE);
- this.openWindow();
- }
-
- private WritablePropertyValueModel<Object> buildColorHolder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Object>(subjectHolder, TestModel.COLOR_PROPERTY) {
- @Override
- protected Object buildValue_() {
- return this.subject.getColor();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setColor((String) value);
- }
- };
- }
-
- private ButtonModel buildRadioButtonModelAdapter(WritablePropertyValueModel<Object> colorPVM, String color) {
- return new RadioButtonModelAdapter(colorPVM, color);
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setSize(400, 100);
- window.setLocation(200, 200);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildRadioButtonPanel(), BorderLayout.NORTH);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildRadioButtonPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(1, 0));
- taskListPanel.add(this.buildRedRadioButton());
- taskListPanel.add(this.buildGreenRadioButton());
- taskListPanel.add(this.buildBlueRadioButton());
- return taskListPanel;
- }
-
- private JRadioButton buildRedRadioButton() {
- JRadioButton radioButton = new JRadioButton();
- radioButton.setText("red");
- radioButton.setModel(this.redButtonModel);
- return radioButton;
- }
-
- private JRadioButton buildGreenRadioButton() {
- JRadioButton radioButton = new JRadioButton();
- radioButton.setText("green");
- radioButton.setModel(this.greenButtonModel);
- return radioButton;
- }
-
- private JRadioButton buildBlueRadioButton() {
- JRadioButton radioButton = new JRadioButton();
- radioButton.setText("blue");
- radioButton.setModel(this.blueButtonModel);
- return radioButton;
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(1, 0));
- controlPanel.add(this.buildResetColorButton());
- controlPanel.add(this.buildClearModelButton());
- controlPanel.add(this.buildRestoreModelButton());
- controlPanel.add(this.buildPrintModelButton());
- return controlPanel;
- }
-
- private JButton buildResetColorButton() {
- return new JButton(this.buildResetColorAction());
- }
-
- private Action buildResetColorAction() {
- Action action = new AbstractAction("reset color") {
- public void actionPerformed(ActionEvent event) {
- RadioButtonModelAdapterUITest.this.resetColor();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void resetColor() {
- this.testModel.setColor(TestModel.DEFAULT_COLOR);
- }
-
- private JButton buildClearModelButton() {
- return new JButton(this.buildClearModelAction());
- }
-
- private Action buildClearModelAction() {
- Action action = new AbstractAction("clear model") {
- public void actionPerformed(ActionEvent event) {
- RadioButtonModelAdapterUITest.this.clearModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private JButton buildRestoreModelButton() {
- return new JButton(this.buildRestoreModelAction());
- }
-
- private Action buildRestoreModelAction() {
- Action action = new AbstractAction("restore model") {
- public void actionPerformed(ActionEvent event) {
- RadioButtonModelAdapterUITest.this.restoreModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private JButton buildPrintModelButton() {
- return new JButton(this.buildPrintModelAction());
- }
-
- private Action buildPrintModelAction() {
- Action action = new AbstractAction("print model") {
- public void actionPerformed(ActionEvent event) {
- RadioButtonModelAdapterUITest.this.printModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void printModel() {
- System.out.println(this.testModel);
- }
-
-
- private static class TestModel extends AbstractModel {
- private String color;
- public static final String COLOR_PROPERTY = "color";
- public static final String RED = "red";
- public static final String GREEN = "green";
- public static final String BLUE = "blue";
- public static final String DEFAULT_COLOR = RED;
- public static final String[] VALID_COLORS = {
- RED,
- GREEN,
- BLUE
- };
-
- public TestModel() {
- this(DEFAULT_COLOR);
- }
- public TestModel(String color) {
- this.color = color;
- }
- public String getColor() {
- return this.color;
- }
- public void setColor(String color) {
- if ( ! CollectionTools.contains(VALID_COLORS, color)) {
- throw new IllegalArgumentException(color);
- }
- Object old = this.color;
- this.color = color;
- this.firePropertyChanged(COLOR_PROPERTY, old, color);
- }
- @Override
- public String toString() {
- return "TestModel(" + this.color + ")";
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java
deleted file mode 100644
index 3bfb66f4ba..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import org.eclipse.jpt.utility.internal.model.value.swing.ColumnAdapter;
-import org.eclipse.jpt.utility.tests.internal.model.value.swing.TableModelAdapterTests.PersonColumnAdapter;
-
-/**
- * Make it easy to test the table model adapter and
- * renderers without any editing allowed.
- */
-public class ReadOnlyTableModelAdapterUITest extends TableModelAdapterUITest {
-
- public static void main(String[] args) throws Exception {
- new ReadOnlyTableModelAdapterUITest().exec(args);
- }
-
- protected ReadOnlyTableModelAdapterUITest() {
- super();
- }
-
- @Override
- protected ColumnAdapter buildColumnAdapter() {
- return new PersonColumnAdapter() {
- @Override
- public boolean columnIsEditable(int index) {
- return false;
- }
- };
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java
deleted file mode 100644
index 1d4b0efd3d..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import javax.swing.SpinnerModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.SpinnerModelAdapter;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class SpinnerModelAdapterTests extends TestCase {
- private WritablePropertyValueModel<Object> valueHolder;
- SpinnerModel spinnerModelAdapter;
- boolean eventFired;
-
- public SpinnerModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Object>(new Integer(0));
- this.spinnerModelAdapter = new SpinnerModelAdapter(this.valueHolder) {
- @Override
- protected PropertyChangeListener buildValueListener() {
- return this.buildValueListener_();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSetValueSpinnerModel() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- SpinnerModelAdapterTests.this.eventFired = true;
- assertEquals(SpinnerModelAdapterTests.this.spinnerModelAdapter, e.getSource());
- }
- });
- this.spinnerModelAdapter.setValue(new Integer(5));
- assertTrue(this.eventFired);
- assertEquals(new Integer(5), this.valueHolder.getValue());
- }
-
- public void testSetValueValueHolder() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- SpinnerModelAdapterTests.this.eventFired = true;
- assertEquals(SpinnerModelAdapterTests.this.spinnerModelAdapter, e.getSource());
- }
- });
- assertEquals(new Integer(0), this.spinnerModelAdapter.getValue());
- this.valueHolder.setValue(new Integer(7));
- assertTrue(this.eventFired);
- assertEquals(new Integer(7), this.spinnerModelAdapter.getValue());
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Object> localValueHolder = (SimplePropertyValueModel<Object>) this.valueHolder;
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
-
- ChangeListener listener = new TestChangeListener();
- this.spinnerModelAdapter.addChangeListener(listener);
- assertTrue(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.spinnerModelAdapter);
-
- this.spinnerModelAdapter.removeChangeListener(listener);
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
- }
-
- private void verifyHasNoListeners(Object adapter) throws Exception {
- Object delegate = ClassTools.fieldValue(adapter, "delegate");
- Object[] listeners = (Object[]) ClassTools.executeMethod(delegate, "getChangeListeners");
- assertEquals(0, listeners.length);
- }
-
- private void verifyHasListeners(Object adapter) throws Exception {
- Object delegate = ClassTools.fieldValue(adapter, "delegate");
- Object[] listeners = (Object[]) ClassTools.executeMethod(delegate, "getChangeListeners");
- assertFalse(listeners.length == 0);
- }
-
-
- private class TestChangeListener implements ChangeListener {
- TestChangeListener() {
- super();
- }
- public void stateChanged(ChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java
deleted file mode 100644
index 9c6ec4419e..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.util.Calendar;
-import java.util.Date;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JSpinner;
-import javax.swing.SpinnerModel;
-import javax.swing.WindowConstants;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.DateSpinnerModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.ListSpinnerModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.NumberSpinnerModelAdapter;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-/**
- * Play around with a set of spinners.
- */
-public class SpinnerModelAdapterUITest {
-
- private TestModel testModel;
- private WritablePropertyValueModel<TestModel> testModelHolder;
-
- private WritablePropertyValueModel<Object> birthDateHolder;
- private SpinnerModel birthDateSpinnerModel;
-
- private WritablePropertyValueModel<Number> ageHolder;
- private SpinnerModel ageSpinnerModel;
-
- private WritablePropertyValueModel<Object> eyeColorHolder;
- private SpinnerModel eyeColorSpinnerModel;
-
-
- public static void main(String[] args) throws Exception {
- new SpinnerModelAdapterUITest().exec(args);
- }
-
- private SpinnerModelAdapterUITest() {
- super();
- }
-
- private void exec(String[] args) throws Exception {
- this.testModel = new TestModel();
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
-
- this.birthDateHolder = this.buildBirthDateHolder(this.testModelHolder);
- this.birthDateSpinnerModel = this.buildBirthDateSpinnerModel(this.birthDateHolder);
-
- this.ageHolder = this.buildAgeHolder(this.testModelHolder);
- this.ageSpinnerModel = this.buildAgeSpinnerModel(this.ageHolder);
-
- this.eyeColorHolder = this.buildEyeColorHolder(this.testModelHolder);
- this.eyeColorSpinnerModel = this.buildEyeColorSpinnerModel(this.eyeColorHolder);
-
- this.openWindow();
- }
-
- private WritablePropertyValueModel<Object> buildBirthDateHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Object>(vm, TestModel.BIRTH_DATE_PROPERTY) {
- @Override
- protected Object buildValue_() {
- return this.subject.getBirthDate();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setBirthDate((Date) value);
- }
- };
- }
-
- private SpinnerModel buildBirthDateSpinnerModel(WritablePropertyValueModel<Object> valueHolder) {
- return new DateSpinnerModelAdapter(valueHolder);
- }
-
- private WritablePropertyValueModel<Number> buildAgeHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Number>(vm, TestModel.AGE_PROPERTY) {
- @Override
- protected Number buildValue_() {
- return new Integer(this.subject.getAge());
- }
- @Override
- protected void setValue_(Number value) {
- this.subject.setAge(value.intValue());
- }
- };
- }
-
- private SpinnerModel buildAgeSpinnerModel(WritablePropertyValueModel<Number> valueHolder) {
- return new NumberSpinnerModelAdapter(valueHolder, valueHolder.getValue().intValue(), TestModel.MIN_AGE, TestModel.MAX_AGE, 1);
- }
-
- private WritablePropertyValueModel<Object> buildEyeColorHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Object>(vm, TestModel.EYE_COLOR_PROPERTY) {
- @Override
- protected Object buildValue_() {
- return this.subject.getEyeColor();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setEyeColor((String) value);
- }
- };
- }
-
- private SpinnerModel buildEyeColorSpinnerModel(WritablePropertyValueModel<Object> valueHolder) {
- return new ListSpinnerModelAdapter(valueHolder, TestModel.VALID_EYE_COLORS);
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setSize(600, 100);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildSpinnerPanel(), BorderLayout.NORTH);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildSpinnerPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(1, 0));
- taskListPanel.add(this.buildBirthDateSpinner());
- taskListPanel.add(this.buildAgeSpinner());
- taskListPanel.add(this.buildEyeColorSpinner());
- return taskListPanel;
- }
-
- private JSpinner buildBirthDateSpinner() {
- return new JSpinner(this.birthDateSpinnerModel);
- }
-
- private JSpinner buildAgeSpinner() {
- return new JSpinner(this.ageSpinnerModel);
- }
-
- private JSpinner buildEyeColorSpinner() {
- return new JSpinner(this.eyeColorSpinnerModel);
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(1, 0));
- controlPanel.add(this.buildResetModelButton());
- controlPanel.add(this.buildClearModelButton());
- controlPanel.add(this.buildRestoreModelButton());
- controlPanel.add(this.buildPrintModelButton());
- return controlPanel;
- }
-
- private JButton buildResetModelButton() {
- return new JButton(this.buildResetModelAction());
- }
-
- private Action buildResetModelAction() {
- Action action = new AbstractAction("reset model") {
- public void actionPerformed(ActionEvent event) {
- SpinnerModelAdapterUITest.this.resetModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void resetModel() {
- this.testModel.setBirthDate(TestModel.DEFAULT_BIRTH_DATE);
- this.testModel.setEyeColor(TestModel.DEFAULT_EYE_COLOR);
- }
-
- private JButton buildClearModelButton() {
- return new JButton(this.buildClearModelAction());
- }
-
- private Action buildClearModelAction() {
- Action action = new AbstractAction("clear model") {
- public void actionPerformed(ActionEvent event) {
- SpinnerModelAdapterUITest.this.clearModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private JButton buildRestoreModelButton() {
- return new JButton(this.buildRestoreModelAction());
- }
-
- private Action buildRestoreModelAction() {
- Action action = new AbstractAction("restore model") {
- public void actionPerformed(ActionEvent event) {
- SpinnerModelAdapterUITest.this.restoreModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private JButton buildPrintModelButton() {
- return new JButton(this.buildPrintModelAction());
- }
-
- private Action buildPrintModelAction() {
- Action action = new AbstractAction("print model") {
- public void actionPerformed(ActionEvent event) {
- SpinnerModelAdapterUITest.this.printModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void printModel() {
- System.out.println("birth date: " + this.testModel.getBirthDate());
- System.out.println("age: " + this.testModel.getAge());
- System.out.println("eyes: " + this.testModel.getEyeColor());
- }
-
-
- private static class TestModel extends AbstractModel {
- private Calendar birthCal = Calendar.getInstance();
- // "virtual" properties
- public static final String BIRTH_DATE_PROPERTY = "birthDate";
- public static final String AGE_PROPERTY = "age";
- public static final Date DEFAULT_BIRTH_DATE = new Date();
- public static final int DEFAULT_AGE = 0;
- public static final int MIN_AGE = 0;
- public static final int MAX_AGE = 150;
- private String eyeColor;
- public static final String EYE_COLOR_PROPERTY = "eyeColor";
- public static final String[] VALID_EYE_COLORS = {"blue", "brown", "green", "hazel", "pink"};
- public static final String DEFAULT_EYE_COLOR = VALID_EYE_COLORS[3];
-
- public TestModel() {
- this(DEFAULT_BIRTH_DATE, DEFAULT_EYE_COLOR);
- }
- public TestModel(Date birthDate, String eyeColor) {
- this.setBirthDate(birthDate);
- this.setEyeColor(eyeColor);
- }
- public Date getBirthDate() {
- return (Date) this.birthCal.getTime().clone();
- }
- public void setBirthDate(Date birthDate) {
- Date oldBirthDate = this.getBirthDate();
- int oldAge = this.getAge();
- this.birthCal.setTimeInMillis(birthDate.getTime());
- int newAge = this.getAge();
- if (newAge < MIN_AGE || newAge > MAX_AGE) {
- throw new IllegalArgumentException(birthDate.toString());
- }
- this.firePropertyChanged(BIRTH_DATE_PROPERTY, oldBirthDate, this.getBirthDate());
- this.firePropertyChanged(AGE_PROPERTY, oldAge, newAge);
- }
- public int getAge() {
- Calendar currentCal = Calendar.getInstance();
- int age = currentCal.get(Calendar.YEAR) - this.birthCal.get(Calendar.YEAR);
- if (currentCal.get(Calendar.MONTH) < this.birthCal.get(Calendar.MONTH)) {
- age--;
- } else if (currentCal.get(Calendar.MONTH) == this.birthCal.get(Calendar.MONTH)) {
- if (currentCal.get(Calendar.DAY_OF_MONTH) < this.birthCal.get(Calendar.DAY_OF_MONTH)) {
- age--;
- }
- }
- return age;
- }
- public void setAge(int newAge) {
- if (newAge < MIN_AGE || newAge > MAX_AGE) {
- throw new IllegalArgumentException(String.valueOf(newAge));
- }
-
- int oldAge = this.getAge();
- int delta = newAge - oldAge;
-
- Calendar newBirthCal = Calendar.getInstance();
- newBirthCal.setTimeInMillis(this.birthCal.getTime().getTime());
- // if the age increased, the birth date must be "decreased"; and vice versa
- newBirthCal.set(Calendar.YEAR, newBirthCal.get(Calendar.YEAR) - delta);
- this.setBirthDate(newBirthCal.getTime());
- }
- public String getEyeColor() {
- return this.eyeColor;
- }
- public void setEyeColor(String eyeColor) {
- if ( ! CollectionTools.contains(VALID_EYE_COLORS, eyeColor)) {
- throw new IllegalArgumentException(eyeColor);
- }
- Object old = this.eyeColor;
- this.eyeColor = eyeColor;
- this.firePropertyChanged(EYE_COLOR_PROPERTY, old, eyeColor);
- }
- @Override
- public String toString() {
- return "TestModel(birth: " + this.getBirthDate() + " - eyes: " + this.eyeColor + ")";
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java
deleted file mode 100644
index c253c723a5..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java
+++ /dev/null
@@ -1,646 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.CollectionAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.ColumnAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.TableModelAdapter;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-/**
- *
- */
-public class TableModelAdapterTests extends TestCase {
- private Crowd crowd;
- TableModelEvent event;
-
- public TableModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.crowd = this.buildCrowd();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGetRowCount() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- assertEquals(0, tableModelAdapter.getRowCount());
- // we need to add a listener to wake up the adapter
- tableModelAdapter.addTableModelListener(this.buildTableModelListener());
- assertEquals(this.crowd.peopleSize(), tableModelAdapter.getRowCount());
- }
-
- public void testGetColumnCount() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- assertEquals(PersonColumnAdapter.COLUMN_COUNT, tableModelAdapter.getColumnCount());
- }
-
- public void testGetValueAt() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- tableModelAdapter.addTableModelListener(this.buildTableModelListener());
-
- List<String> sortedNames = this.sortedNames();
- for (int i = 0; i < this.crowd.peopleSize(); i++) {
- assertEquals(sortedNames.get(i), tableModelAdapter.getValueAt(i, PersonColumnAdapter.NAME_COLUMN));
- }
- }
-
- public void testSetValueAt() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- this.event = null;
- tableModelAdapter.addTableModelListener(new TestTableModelListener() {
- @Override
- public void tableChanged(TableModelEvent e) {
- TableModelAdapterTests.this.event = e;
- }
- });
-
- Person person = this.crowd.personNamed("Gollum");
- assertEquals(Person.EYE_COLOR_BLUE, person.getEyeColor());
- assertFalse(person.isEvil());
- assertEquals(0, person.getRank());
-
- for (int i = 0; i < tableModelAdapter.getRowCount(); i++) {
- if (tableModelAdapter.getValueAt(i, PersonColumnAdapter.NAME_COLUMN).equals("Gollum")) {
- tableModelAdapter.setValueAt(Person.EYE_COLOR_HAZEL, i, PersonColumnAdapter.EYE_COLOR_COLUMN);
- tableModelAdapter.setValueAt(Boolean.TRUE, i, PersonColumnAdapter.EVIL_COLUMN);
- tableModelAdapter.setValueAt(new Integer(-1), i, PersonColumnAdapter.RANK_COLUMN);
- break;
- }
- }
- assertNotNull(this.event);
- assertEquals(Person.EYE_COLOR_HAZEL, person.getEyeColor());
- assertTrue(person.isEvil());
- assertEquals(-1, person.getRank());
- }
-
- public void testAddRow() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- this.event = null;
- tableModelAdapter.addTableModelListener(this.buildSingleEventListener());
- // add a person to the end of the list so we only trigger one event
- this.crowd.addPerson("Zzzzz");
- assertNotNull(this.event);
- assertEquals(TableModelEvent.INSERT, this.event.getType());
- assertEquals(TableModelEvent.ALL_COLUMNS, this.event.getColumn());
- }
-
- public void testRemoveRow() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- this.event = null;
- tableModelAdapter.addTableModelListener(this.buildSingleEventListener());
- // removing a person should only trigger one event, since a re-sort is not needed
- this.crowd.removePerson(this.crowd.personNamed("Gollum"));
- assertNotNull(this.event);
- assertEquals(TableModelEvent.DELETE, this.event.getType());
- assertEquals(TableModelEvent.ALL_COLUMNS, this.event.getColumn());
- }
-
- public void testChangeCell() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- this.event = null;
- tableModelAdapter.addTableModelListener(this.buildSingleEventListener());
- // add a person to the end of the list so we only trigger one event
- Person person = this.crowd.personNamed("Gollum");
- person.setEvil(true);
- assertNotNull(this.event);
- assertEquals(TableModelEvent.UPDATE, this.event.getType());
- assertEquals(PersonColumnAdapter.EVIL_COLUMN, this.event.getColumn());
- }
-
- public void testLazyListListener() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- TableModelListener listener = this.buildTableModelListener();
- assertTrue(this.crowd.hasNoCollectionChangeListeners(Crowd.PEOPLE_COLLECTION));
- tableModelAdapter.addTableModelListener(listener);
- assertTrue(this.crowd.hasAnyCollectionChangeListeners(Crowd.PEOPLE_COLLECTION));
- tableModelAdapter.removeTableModelListener(listener);
- assertTrue(this.crowd.hasNoCollectionChangeListeners(Crowd.PEOPLE_COLLECTION));
- }
-
- public void testLazyCellListener() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- TableModelListener listener = this.buildTableModelListener();
- Person person = this.crowd.personNamed("Gollum");
- assertTrue(person.hasNoPropertyChangeListeners(Person.NAME_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.BIRTH_DATE_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.EYE_COLOR_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.EVIL_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.RANK_PROPERTY));
-
- tableModelAdapter.addTableModelListener(listener);
- assertTrue(person.hasAnyPropertyChangeListeners(Person.NAME_PROPERTY));
- assertTrue(person.hasAnyPropertyChangeListeners(Person.BIRTH_DATE_PROPERTY));
- assertTrue(person.hasAnyPropertyChangeListeners(Person.EYE_COLOR_PROPERTY));
- assertTrue(person.hasAnyPropertyChangeListeners(Person.EVIL_PROPERTY));
- assertTrue(person.hasAnyPropertyChangeListeners(Person.RANK_PROPERTY));
-
- tableModelAdapter.removeTableModelListener(listener);
- assertTrue(person.hasNoPropertyChangeListeners(Person.NAME_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.BIRTH_DATE_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.EYE_COLOR_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.EVIL_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.RANK_PROPERTY));
- }
-
- private TableModelAdapter<Person> buildTableModelAdapter() {
- return new TableModelAdapter<Person>(this.buildSortedPeopleAdapter(), this.buildColumnAdapter()) {
- @Override
- protected PropertyChangeListener buildCellListener() {
- return this.buildCellListener_();
- }
- @Override
- protected ListChangeListener buildListChangeListener() {
- return this.buildListChangeListener_();
- }
- };
- }
-
- private ListValueModel<Person> buildSortedPeopleAdapter() {
- return new SortedListValueModelAdapter<Person>(this.buildPeopleAdapter());
- }
-
- private CollectionValueModel<Person> buildPeopleAdapter() {
- return new CollectionAspectAdapter<Crowd, Person>(Crowd.PEOPLE_COLLECTION, this.crowd) {
- @Override
- protected Iterator<Person> iterator_() {
- return this.subject.people();
- }
- @Override
- protected int size_() {
- return this.subject.peopleSize();
- }
- };
- }
-
- private Crowd buildCrowd() {
- Crowd result = new Crowd();
- result.addPerson("Bilbo");
- result.addPerson("Gollum");
- result.addPerson("Frodo");
- result.addPerson("Samwise");
- return result;
- }
-
- private ColumnAdapter buildColumnAdapter() {
- return new PersonColumnAdapter();
- }
-
- private TableModelListener buildTableModelListener() {
- return new TestTableModelListener();
- }
-
- private List<String> sortedNames() {
- return new ArrayList<String>(CollectionTools.sortedSet(this.crowd.peopleNames()));
- }
-
- private TableModelListener buildSingleEventListener() {
- return new TestTableModelListener() {
- @Override
- public void tableChanged(TableModelEvent e) {
- // we expect only a single event
- if (TableModelAdapterTests.this.event == null) {
- TableModelAdapterTests.this.event = e;
- } else {
- fail("unexpected event");
- }
- }
- };
- }
-
-
- // ********** classes **********
-
- public static class PersonColumnAdapter implements ColumnAdapter {
- public static final int COLUMN_COUNT = 7;
-
- public static final int NAME_COLUMN = 0;
- public static final int BIRTH_DATE_COLUMN = 1;
- public static final int GONE_WEST_DATE_COLUMN = 2;
- public static final int EYE_COLOR_COLUMN = 3;
- public static final int EVIL_COLUMN = 4;
- public static final int RANK_COLUMN = 5;
- public static final int ADVENTURE_COUNT_COLUMN = 6;
-
- private static final String[] COLUMN_NAMES = new String[] {
- "Name",
- "Birth",
- "Gone West",
- "Eyes",
- "Evil",
- "Rank",
- "Adventures"
- };
-
-
- public int columnCount() {
- return COLUMN_COUNT;
- }
-
- public String columnName(int index) {
- return COLUMN_NAMES[index];
- }
-
- public Class<?> columnClass(int index) {
- switch (index) {
- case NAME_COLUMN: return Object.class;
- case BIRTH_DATE_COLUMN: return Date.class;
- case GONE_WEST_DATE_COLUMN: return Date.class;
- case EYE_COLOR_COLUMN: return Object.class;
- case EVIL_COLUMN: return Boolean.class;
- case RANK_COLUMN: return Integer.class;
- case ADVENTURE_COUNT_COLUMN:return Integer.class;
- default: return Object.class;
- }
- }
-
- public boolean columnIsEditable(int index) {
- return index != NAME_COLUMN;
- }
-
- public WritablePropertyValueModel<Object>[] cellModels(Object subject) {
- Person person = (Person) subject;
- @SuppressWarnings("unchecked")
- WritablePropertyValueModel<Object>[] result = new WritablePropertyValueModel[COLUMN_COUNT];
-
- result[NAME_COLUMN] = this.buildNameAdapter(person);
- result[BIRTH_DATE_COLUMN] = this.buildBirthDateAdapter(person);
- result[GONE_WEST_DATE_COLUMN] = this.buildGoneWestDateAdapter(person);
- result[EYE_COLOR_COLUMN] = this.buildEyeColorAdapter(person);
- result[EVIL_COLUMN] = this.buildEvilAdapter(person);
- result[RANK_COLUMN] = this.buildRankAdapter(person);
- result[ADVENTURE_COUNT_COLUMN] = this.buildAdventureCountAdapter(person);
-
- return result;
- }
-
- private WritablePropertyValueModel<Object> buildNameAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.NAME_PROPERTY, person) {
- @Override
- protected String buildValue_() {
- return this.subject.getName();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setName((String) value);
- }
- };
- }
-
- private WritablePropertyValueModel<Object> buildBirthDateAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.BIRTH_DATE_PROPERTY, person) {
- @Override
- protected Date buildValue_() {
- return this.subject.getBirthDate();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setBirthDate((Date) value);
- }
- };
- }
-
- private WritablePropertyValueModel<Object> buildGoneWestDateAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.GONE_WEST_DATE_PROPERTY, person) {
- @Override
- protected Date buildValue_() {
- return this.subject.getGoneWestDate();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setGoneWestDate((Date) value);
- }
- };
- }
-
- private WritablePropertyValueModel<Object> buildEyeColorAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.EYE_COLOR_PROPERTY, person) {
- @Override
- protected String buildValue_() {
- return this.subject.getEyeColor();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setEyeColor((String) value);
- }
- };
- }
-
- private WritablePropertyValueModel<Object> buildEvilAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.EVIL_PROPERTY, person) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isEvil());
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setEvil(((Boolean)value).booleanValue());
- }
- };
- }
-
- private WritablePropertyValueModel<Object> buildRankAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.RANK_PROPERTY, person) {
- @Override
- protected Integer buildValue_() {
- return new Integer(this.subject.getRank());
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setRank(((Integer) value).intValue());
- }
- };
- }
-
- private WritablePropertyValueModel<Object> buildAdventureCountAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.ADVENTURE_COUNT_PROPERTY, person) {
- @Override
- protected Integer buildValue_() {
- return new Integer(this.subject.getAdventureCount());
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setAdventureCount(((Integer) value).intValue());
- }
- };
- }
-
- }
-
-
- public static class Crowd extends AbstractModel {
- private final Collection<Person> people;
- public static final String PEOPLE_COLLECTION = "people";
-
- public Crowd() {
- super();
- this.people = new ArrayList<Person>();
- }
-
-
- public Iterator<Person> people() {
- return new CloneIterator<Person>(this.people) {
- @Override
- protected void remove(Person person) {
- Crowd.this.removePerson(person);
- }
- };
- }
-
- public int peopleSize() {
- return this.people.size();
- }
-
- public Person addPerson(String name) {
- this.checkPersonName(name);
- return this.addPerson(new Person(this, name));
- }
-
- private Person addPerson(Person person) {
- this.addItemToCollection(person, this.people, PEOPLE_COLLECTION);
- return person;
- }
-
- public void removePerson(Person person) {
- this.removeItemFromCollection(person, this.people, PEOPLE_COLLECTION);
- }
-
- public void removePeople(Collection<Person> persons) {
- this.removeItemsFromCollection(persons, this.people, PEOPLE_COLLECTION);
- }
-
- public void removePeople(Iterator<Person> persons) {
- this.removeItemsFromCollection(persons, this.people, PEOPLE_COLLECTION);
- }
-
- void checkPersonName(String personName) {
- if (personName == null) {
- throw new NullPointerException();
- }
- if (CollectionTools.contains(this.peopleNames(), personName)) {
- throw new IllegalArgumentException(personName);
- }
- }
-
- public Iterator<String> peopleNames() {
- return new TransformationIterator<Person, String>(this.people.iterator()) {
- @Override
- protected String transform(Person person) {
- return person.getName();
- }
- };
- }
-
- public Person personNamed(String name) {
- for (Iterator<Person> stream = this.people.iterator(); stream.hasNext(); ) {
- Person person = stream.next();
- if (person.getName().equals(name)) {
- return person;
- }
- }
- return null;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, String.valueOf(this.people.size()) + " people");
- }
-
- }
-
-
- public static class Person extends AbstractModel implements Comparable<Person> {
- private Crowd crowd;
- private String name;
- public static final String NAME_PROPERTY= "name";
- private Date birthDate;
- public static final String BIRTH_DATE_PROPERTY= "birthDate";
- private Date goneWestDate;
- public static final String GONE_WEST_DATE_PROPERTY= "goneWestDate";
- private String eyeColor;
- public static final String EYE_COLOR_PROPERTY= "eyeColor";
- public static final String EYE_COLOR_BLUE = "blue";
- public static final String EYE_COLOR_GREEN = "green";
- public static final String EYE_COLOR_BROWN = "brown";
- public static final String EYE_COLOR_HAZEL = "hazel";
- public static final String EYE_COLOR_PINK = "pink";
- private static Collection<String> validEyeColors;
- public static final String DEFAULT_EYE_COLOR = EYE_COLOR_BLUE;
- private boolean evil;
- public static final String EVIL_PROPERTY= "evil";
- private int rank;
- public static final String RANK_PROPERTY= "rank";
- private int adventureCount;
- public static final String ADVENTURE_COUNT_PROPERTY= "adventureCount";
-
- Person(Crowd crowd, String name) {
- super();
- this.crowd = crowd;
- this.name = name;
- this.birthDate = new Date();
- Calendar c = Calendar.getInstance();
- c.add(Calendar.YEAR, 250);
- this.goneWestDate = new Date(c.getTimeInMillis());
- this.eyeColor = DEFAULT_EYE_COLOR;
- this.evil = false;
- this.rank = 0;
- this.adventureCount = 0;
- }
-
- public static Collection<String> getValidEyeColors() {
- if (validEyeColors == null) {
- validEyeColors = buildValidEyeColors();
- }
- return validEyeColors;
- }
-
- private static Collection<String> buildValidEyeColors() {
- Collection<String> result = new ArrayList<String>();
- result.add(EYE_COLOR_BLUE);
- result.add(EYE_COLOR_GREEN);
- result.add(EYE_COLOR_BROWN);
- result.add(EYE_COLOR_HAZEL);
- result.add(EYE_COLOR_PINK);
- return result;
- }
-
- public Crowd getCrowd() {
- return this.crowd;
- }
-
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- this.crowd.checkPersonName(name);
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- public Date getBirthDate() {
- return this.birthDate;
- }
- public void setBirthDate(Date birthDate) {
- Object old = this.birthDate;
- this.birthDate = birthDate;
- this.firePropertyChanged(BIRTH_DATE_PROPERTY, old, birthDate);
- }
-
- public Date getGoneWestDate() {
- return this.goneWestDate;
- }
- public void setGoneWestDate(Date goneWestDate) {
- Object old = this.goneWestDate;
- this.goneWestDate = goneWestDate;
- this.firePropertyChanged(GONE_WEST_DATE_PROPERTY, old, goneWestDate);
- }
-
- public String getEyeColor() {
- return this.eyeColor;
- }
- public void setEyeColor(String eyeColor) {
- if (! getValidEyeColors().contains(eyeColor)) {
- throw new IllegalArgumentException(eyeColor);
- }
- Object old = this.eyeColor;
- this.eyeColor = eyeColor;
- this.firePropertyChanged(EYE_COLOR_PROPERTY, old, eyeColor);
- }
-
- public boolean isEvil() {
- return this.evil;
- }
- public void setEvil(boolean evil) {
- boolean old = this.evil;
- this.evil = evil;
- this.firePropertyChanged(EVIL_PROPERTY, old, evil);
- }
-
- public int getRank() {
- return this.rank;
- }
- public void setRank(int rank) {
- int old = this.rank;
- this.rank = rank;
- this.firePropertyChanged(RANK_PROPERTY, old, rank);
- }
-
- public int getAdventureCount() {
- return this.adventureCount;
- }
- public void setAdventureCount(int adventureCount) {
- int old = this.adventureCount;
- this.adventureCount = adventureCount;
- this.firePropertyChanged(ADVENTURE_COUNT_PROPERTY, old, adventureCount);
- }
-
- public int compareTo(Person p) {
- return this.name.compareToIgnoreCase(p.name);
- }
-
- @Override
- public String toString() {
- return this.name +
- "\tborn: " + DateFormat.getDateInstance().format(this.birthDate) +
- "\tgone west: " + DateFormat.getDateInstance().format(this.goneWestDate) +
- "\teyes: " + this.eyeColor +
- "\tevil: " + this.evil +
- "\trank: " + this.rank +
- "\tadventures: " + this.adventureCount
- ;
- }
-
- }
-
-
- private class TestTableModelListener implements TableModelListener {
- TestTableModelListener() {
- super();
- }
- public void tableChanged(TableModelEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
deleted file mode 100644
index 8d60845745..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
+++ /dev/null
@@ -1,733 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ButtonModel;
-import javax.swing.ComboBoxModel;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JList;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JSpinner;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.ListCellRenderer;
-import javax.swing.ListSelectionModel;
-import javax.swing.SpinnerModel;
-import javax.swing.UIManager;
-import javax.swing.WindowConstants;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableModel;
-import javax.swing.text.Document;
-
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.value.CollectionAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.CheckBoxModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.ColumnAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.ComboBoxModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.DateSpinnerModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.DocumentAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.NumberSpinnerModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.TableModelAdapter;
-import org.eclipse.jpt.utility.internal.swing.CheckBoxTableCellRenderer;
-import org.eclipse.jpt.utility.internal.swing.ComboBoxTableCellRenderer;
-import org.eclipse.jpt.utility.internal.swing.SpinnerTableCellRenderer;
-import org.eclipse.jpt.utility.internal.swing.TableCellEditorAdapter;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.model.value.swing.TableModelAdapterTests.Crowd;
-import org.eclipse.jpt.utility.tests.internal.model.value.swing.TableModelAdapterTests.Person;
-import org.eclipse.jpt.utility.tests.internal.model.value.swing.TableModelAdapterTests.PersonColumnAdapter;
-
-/**
- * an example UI for testing the TableModelAdapter
- * "name" column is read-only text field
- * "birth date" column is date text field
- * "gone west date" column is date spinner
- * "eye color" column is combo-box
- * "evil" column is check box
- * "rank" column is number text field
- * "adventure count" column is number spinner
- *
- * Note that the table model and row selection model share the same
- * list value model (the sorted people adapter)
- */
-public class TableModelAdapterUITest {
- private SimpleCollectionValueModel<Object> eyeColorsHolder; // Object because it adapts to a combo-box
- private WritablePropertyValueModel<Crowd> crowdHolder;
- private WritablePropertyValueModel<Person> selectedPersonHolder;
- private ListValueModel<Person> sortedPeopleAdapter;
- private TableModel tableModel;
- private ObjectListSelectionModel rowSelectionModel;
- private Action removeAction;
- private Action renameAction;
-
- public static void main(String[] args) throws Exception {
- new TableModelAdapterUITest().exec(args);
- }
-
- protected TableModelAdapterUITest() {
- super();
- }
-
- protected void exec(String[] args) throws Exception {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- this.eyeColorsHolder = this. buildEyeColorCollectionHolder();
- this.crowdHolder = this.buildCrowdHolder();
- this.selectedPersonHolder = this.buildSelectedPersonHolder();
- this.sortedPeopleAdapter = this.buildSortedPeopleAdapter();
- this.tableModel = this.buildTableModel();
- this.rowSelectionModel = this.buildRowSelectionModel();
- this.openWindow();
- }
-
- private SimpleCollectionValueModel<Object> buildEyeColorCollectionHolder() {
- return new SimpleCollectionValueModel<Object>(new ArrayList<Object>(Person.getValidEyeColors()));
- }
-
- private WritablePropertyValueModel<Crowd> buildCrowdHolder() {
- return new SimplePropertyValueModel<Crowd>(this.buildCrowd());
- }
-
- private Crowd buildCrowd() {
- Crowd crowd = new Crowd();
-
- Person p = crowd.addPerson("Bilbo");
- p.setEyeColor(Person.EYE_COLOR_BROWN);
- p.setRank(22);
- p.setAdventureCount(1);
-
- p = crowd.addPerson("Gollum");
- p.setEyeColor(Person.EYE_COLOR_PINK);
- p.setEvil(true);
- p.setRank(2);
- p.setAdventureCount(50);
-
- p = crowd.addPerson("Frodo");
- p.setEyeColor(Person.EYE_COLOR_BLUE);
- p.setRank(34);
- p.setAdventureCount(1);
-
- p = crowd.addPerson("Samwise");
- p.setEyeColor(Person.EYE_COLOR_GREEN);
- p.setRank(19);
- p.setAdventureCount(1);
-
- return crowd;
- }
-
- private WritablePropertyValueModel<Person> buildSelectedPersonHolder() {
- return new SimplePropertyValueModel<Person>();
- }
-
- private ListValueModel<Person> buildSortedPeopleAdapter() {
- return new SortedListValueModelAdapter<Person>(this.buildPeopleNameAdapter());
- }
-
- // the list will need to be re-sorted if a name changes
- private ListValueModel<Person> buildPeopleNameAdapter() {
- return new ItemPropertyListValueModelAdapter<Person>(this.buildPeopleAdapter(), Person.NAME_PROPERTY);
- }
-
- private CollectionValueModel<Person> buildPeopleAdapter() {
- return new CollectionAspectAdapter<Crowd, Person>(this.crowdHolder, Crowd.PEOPLE_COLLECTION) {
- @Override
- protected Iterator<Person> iterator_() {
- return this.subject.people();
- }
- @Override
- protected int size_() {
- return this.subject.peopleSize();
- }
- };
- }
-
- private TableModel buildTableModel() {
- return new TableModelAdapter<Person>(this.sortedPeopleAdapter, this.buildColumnAdapter());
- }
-
- protected ColumnAdapter buildColumnAdapter() {
- return new PersonColumnAdapter();
- }
-
- private ObjectListSelectionModel buildRowSelectionModel() {
- ObjectListSelectionModel rsm = new ObjectListSelectionModel(new ListModelAdapter(this.sortedPeopleAdapter));
- rsm.addListSelectionListener(this.buildRowSelectionListener());
- rsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- return rsm;
- }
-
- private ListSelectionListener buildRowSelectionListener() {
- return new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent e) {
- if (e.getValueIsAdjusting()) {
- return;
- }
- TableModelAdapterUITest.this.rowSelectionChanged(e);
- }
- };
- }
-
- void rowSelectionChanged(ListSelectionEvent e) {
- Person selection = (Person) this.rowSelectionModel.selectedValue();
- this.selectedPersonHolder.setValue(selection);
- boolean personSelected = (selection != null);
- this.removeAction.setEnabled(personSelected);
- this.renameAction.setEnabled(personSelected);
- }
-
- private void openWindow() {
- JFrame window = new JFrame(ClassTools.shortClassNameForObject(this));
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setLocation(200, 200);
- window.setSize(600, 400);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildTablePane(), BorderLayout.CENTER);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildTablePane() {
- return new JScrollPane(this.buildTable());
- }
-
- private JTable buildTable() {
- JTable table = new JTable(this.tableModel);
- table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); // see Java bug 5007652
- table.setSelectionModel(this.rowSelectionModel);
- table.setDoubleBuffered(true);
- table.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
- int rowHeight = 20; // start with minimum of 20
-
- // gone west column (spinner)
- TableColumn column = table.getColumnModel().getColumn(PersonColumnAdapter.GONE_WEST_DATE_COLUMN);
- SpinnerTableCellRenderer spinnerRenderer = this.buildDateSpinnerRenderer();
- column.setCellRenderer(spinnerRenderer);
- column.setCellEditor(new TableCellEditorAdapter(this.buildDateSpinnerRenderer()));
- rowHeight = Math.max(rowHeight, spinnerRenderer.preferredHeight());
-
- // eye color column (combo-box)
- // the jdk combo-box renderer looks like a text field
- // until the user starts an edit - use a custom one
- column = table.getColumnModel().getColumn(PersonColumnAdapter.EYE_COLOR_COLUMN);
- ComboBoxTableCellRenderer eyeColorRenderer = this.buildEyeColorComboBoxRenderer();
- column.setCellRenderer(eyeColorRenderer);
- column.setCellEditor(new TableCellEditorAdapter(this.buildEyeColorComboBoxRenderer()));
- rowHeight = Math.max(rowHeight, eyeColorRenderer.preferredHeight());
-
- // evil (check box)
- // the jdk check box renderer and editor suck - use a custom ones
- column = table.getColumnModel().getColumn(PersonColumnAdapter.EVIL_COLUMN);
- CheckBoxTableCellRenderer evilRenderer = new CheckBoxTableCellRenderer();
- column.setCellRenderer(evilRenderer);
- column.setCellEditor(new TableCellEditorAdapter(new CheckBoxTableCellRenderer()));
- rowHeight = Math.max(rowHeight, evilRenderer.preferredHeight());
-
- // adventure count column (spinner)
- column = table.getColumnModel().getColumn(PersonColumnAdapter.ADVENTURE_COUNT_COLUMN);
- spinnerRenderer = this.buildNumberSpinnerRenderer();
- column.setCellRenderer(spinnerRenderer);
- column.setCellEditor(new TableCellEditorAdapter(this.buildNumberSpinnerRenderer()));
- rowHeight = Math.max(rowHeight, spinnerRenderer.preferredHeight());
-
- table.setRowHeight(rowHeight);
- return table;
- }
-
- private SpinnerTableCellRenderer buildDateSpinnerRenderer() {
- return new SpinnerTableCellRenderer(new DateSpinnerModelAdapter(new SimplePropertyValueModel<Object>()));
- }
-
- private SpinnerTableCellRenderer buildNumberSpinnerRenderer() {
- return new SpinnerTableCellRenderer(new NumberSpinnerModelAdapter(new SimplePropertyValueModel<Number>()));
- }
-
- private ComboBoxTableCellRenderer buildEyeColorComboBoxRenderer() {
- return new ComboBoxTableCellRenderer(this.buildReadOnlyEyeColorComboBoxModel(), this.buildEyeColorRenderer());
- }
-
- private ComboBoxModel buildReadOnlyEyeColorComboBoxModel() {
- return new ComboBoxModelAdapter(this.eyeColorsHolder, new SimplePropertyValueModel<Object>());
- }
-
- private ListCellRenderer buildEyeColorRenderer() {
- return new EyeColorRenderer();
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(0, 1));
- controlPanel.add(this.buildButtonPanel());
- controlPanel.add(this.buildPersonPanel());
- return controlPanel;
- }
-
- private Component buildButtonPanel() {
- JPanel buttonPanel = new JPanel(new GridLayout(1, 0));
- buttonPanel.add(this.buildAddButton());
- buttonPanel.add(this.buildRemoveButton());
- buttonPanel.add(this.buildRenameButton());
- buttonPanel.add(this.buildAddEyeColorButton());
- buttonPanel.add(this.buildPrintButton());
- buttonPanel.add(this.buildResetButton());
- return buttonPanel;
- }
-
- private Component buildPersonPanel() {
- JPanel personPanel = new JPanel(new GridLayout(1, 0));
- personPanel.add(this.buildNameTextField());
- personPanel.add(this.buildBirthDateSpinner());
- personPanel.add(this.buildGoneWestDateSpinner());
- personPanel.add(this.buildEyeColorComboBox());
- personPanel.add(this.buildEvilCheckBox());
- personPanel.add(this.buildRankSpinner());
- personPanel.add(this.buildAdventureCountSpinner());
- return personPanel;
- }
-
-
- // ********** add button **********
-
- private JButton buildAddButton() {
- return new JButton(this.buildAddAction());
- }
-
- private Action buildAddAction() {
- Action action = new AbstractAction("add") {
- public void actionPerformed(ActionEvent event) {
- TableModelAdapterUITest.this.addPerson();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void addPerson() {
- String name = this.getNameFromUser();
- if (name != null) {
- this.setSelectedPerson(this.crowd().addPerson(name));
- }
- }
-
-
- // ********** remove button **********
-
- private JButton buildRemoveButton() {
- return new JButton(this.buildRemoveAction());
- }
-
- private Action buildRemoveAction() {
- this.removeAction = new AbstractAction("remove") {
- public void actionPerformed(ActionEvent event) {
- TableModelAdapterUITest.this.removePerson();
- }
- };
- this.removeAction.setEnabled(false);
- return this.removeAction;
- }
-
- void removePerson() {
- Person person = this.selectedPerson();
- if (person != null) {
- this.crowd().removePerson(person);
- }
- }
-
-
- // ********** rename button **********
-
- private JButton buildRenameButton() {
- return new JButton(this.buildRenameAction());
- }
-
- private Action buildRenameAction() {
- this.renameAction = new AbstractAction("rename") {
- public void actionPerformed(ActionEvent event) {
- TableModelAdapterUITest.this.renamePerson();
- }
- };
- this.renameAction.setEnabled(false);
- return this.renameAction;
- }
-
- void renamePerson() {
- Person person = this.selectedPerson();
- if (person != null) {
- String name = this.promptUserForName(person.getName());
- if (name != null) {
- person.setName(name);
- this.setSelectedPerson(person);
- }
- }
- }
-
-
- // ********** add eye color button **********
-
- private JButton buildAddEyeColorButton() {
- return new JButton(this.buildAddEyeColorAction());
- }
-
- private Action buildAddEyeColorAction() {
- Action action = new AbstractAction("add eye color") {
- public void actionPerformed(ActionEvent event) {
- TableModelAdapterUITest.this.addEyeColor();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void addEyeColor() {
- String color = this.promptUserForEyeColor();
- if (color != null) {
- this.eyeColorsHolder.add(color);
- }
- }
-
- private String promptUserForEyeColor() {
- while (true) {
- String eyeColor = JOptionPane.showInputDialog("Eye Color");
- if (eyeColor == null) {
- return null; // user pressed <Cancel>
- }
- if ((eyeColor.length() == 0)) {
- JOptionPane.showMessageDialog(null, "The eye color is required.", "Invalid Eye Color", JOptionPane.ERROR_MESSAGE);
- } else if (CollectionTools.contains(this.eyeColorsHolder.iterator(), eyeColor)) {
- JOptionPane.showMessageDialog(null, "The eye color already exists.", "Invalid Eye Color", JOptionPane.ERROR_MESSAGE);
- } else {
- return eyeColor;
- }
- }
- }
-
-
- // ********** print button **********
-
- private JButton buildPrintButton() {
- return new JButton(this.buildPrintAction());
- }
-
- private Action buildPrintAction() {
- Action action = new AbstractAction("print") {
- public void actionPerformed(ActionEvent event) {
- TableModelAdapterUITest.this.printCrowd();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void printCrowd() {
- System.out.println(this.crowd());
- for (Iterator<Person> stream = this.crowd().people(); stream.hasNext(); ) {
- System.out.println("\t" + stream.next());
- }
- }
-
-
- // ********** reset button **********
-
- private JButton buildResetButton() {
- return new JButton(this.buildResetAction());
- }
-
- private Action buildResetAction() {
- Action action = new AbstractAction("reset") {
- public void actionPerformed(ActionEvent event) {
- TableModelAdapterUITest.this.reset();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void reset() {
- this.crowdHolder.setValue(this.buildCrowd());
- }
-
-
- // ********** new name dialog **********
-
- private String getNameFromUser() {
- return this.promptUserForName(null);
- }
-
- private String promptUserForName(String originalName) {
- while (true) {
- String name = JOptionPane.showInputDialog("Person Name");
- if (name == null) {
- return null; // user pressed <Cancel>
- }
- if ((name.length() == 0)) {
- JOptionPane.showMessageDialog(null, "The name is required.", "Invalid Name", JOptionPane.ERROR_MESSAGE);
- } else if (CollectionTools.contains(this.crowd().peopleNames(), name)) {
- JOptionPane.showMessageDialog(null, "The name already exists.", "Invalid Name", JOptionPane.ERROR_MESSAGE);
- } else {
- return name;
- }
- }
- }
-
-
- // ********** name text field **********
-
- private Component buildNameTextField() {
- JTextField textField = new JTextField(this.buildNameDocument(), null, 0);
- textField.setEditable(false);
- return textField;
- }
-
- private Document buildNameDocument() {
- return new DocumentAdapter(this.buildNameAdapter());
- }
-
- private WritablePropertyValueModel<String> buildNameAdapter() {
- return new PropertyAspectAdapter<Person, String>(this.selectedPersonHolder, Person.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getName();
- }
- @Override
- protected void setValue_(String value) {
- this.subject.setName(value);
- }
- };
- }
-
-
- // ********** birth date spinner **********
-
- private JSpinner buildBirthDateSpinner() {
- return new JSpinner(this.buildBirthDateSpinnerModel());
- }
-
- private SpinnerModel buildBirthDateSpinnerModel() {
- return new DateSpinnerModelAdapter(this.buildBirthDateAdapter());
- }
-
- private WritablePropertyValueModel<Object> buildBirthDateAdapter() {
- return new PropertyAspectAdapter<Person, Object>(this.selectedPersonHolder, Person.BIRTH_DATE_PROPERTY) {
- @Override
- protected Date buildValue_() {
- return this.subject.getBirthDate();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setBirthDate((Date) value);
- }
- };
- }
-
-
- // ********** gone west date spinner **********
-
- private JSpinner buildGoneWestDateSpinner() {
- return new JSpinner(this.buildGoneWestDateSpinnerModel());
- }
-
- private SpinnerModel buildGoneWestDateSpinnerModel() {
- return new DateSpinnerModelAdapter(this.buildGoneWestDateAdapter());
- }
-
- private WritablePropertyValueModel<Object> buildGoneWestDateAdapter() {
- return new PropertyAspectAdapter<Person, Object>(this.selectedPersonHolder, Person.GONE_WEST_DATE_PROPERTY) {
- @Override
- protected Date buildValue_() {
- return this.subject.getGoneWestDate();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setGoneWestDate((Date) value);
- }
- };
- }
-
-
- // ********** eye color combo-box **********
-
- private JComboBox buildEyeColorComboBox() {
- return new JComboBox(this.buildEyeColorComboBoxModel());
- }
-
- private ComboBoxModel buildEyeColorComboBoxModel() {
- return new ComboBoxModelAdapter(this.eyeColorsHolder, this.buildEyeColorAdapter());
- }
-
- private WritablePropertyValueModel<Object> buildEyeColorAdapter() {
- return new PropertyAspectAdapter<Person, Object>(this.selectedPersonHolder, Person.EYE_COLOR_PROPERTY) {
- @Override
- protected Object buildValue_() {
- return this.subject.getEyeColor();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setEyeColor((String) value);
- }
- };
- }
-
-
- // ********** evil check box **********
-
- private JCheckBox buildEvilCheckBox() {
- JCheckBox checkBox = new JCheckBox();
- checkBox.setText("evil");
- checkBox.setModel(this.buildEvilCheckBoxModel());
- return checkBox;
- }
-
- private ButtonModel buildEvilCheckBoxModel() {
- return new CheckBoxModelAdapter(this.buildEvilAdapter());
- }
-
- private WritablePropertyValueModel<Boolean> buildEvilAdapter() {
- return new PropertyAspectAdapter<Person, Boolean>(this.selectedPersonHolder, Person.EVIL_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isEvil());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setEvil(value.booleanValue());
- }
- };
- }
-
-
- // ********** rank spinner **********
-
- private JSpinner buildRankSpinner() {
- return new JSpinner(this.buildRankSpinnerModel());
- }
-
- private SpinnerModel buildRankSpinnerModel() {
- return new NumberSpinnerModelAdapter(this.buildRankAdapter());
- }
-
- private WritablePropertyValueModel<Number> buildRankAdapter() {
- return new PropertyAspectAdapter<Person, Number>(this.selectedPersonHolder, Person.RANK_PROPERTY) {
- @Override
- protected Number buildValue_() {
- return new Integer(this.subject.getRank());
- }
- @Override
- protected void setValue_(Number value) {
- this.subject.setRank(value.intValue());
- }
- };
- }
-
-
- // ********** adventure count spinner **********
-
- private JSpinner buildAdventureCountSpinner() {
- return new JSpinner(this.buildAdventureCountSpinnerModel());
- }
-
- private SpinnerModel buildAdventureCountSpinnerModel() {
- return new NumberSpinnerModelAdapter(this.buildAdventureCountAdapter());
- }
-
- private WritablePropertyValueModel<Number> buildAdventureCountAdapter() {
- return new PropertyAspectAdapter<Person, Number>(this.selectedPersonHolder, Person.ADVENTURE_COUNT_PROPERTY) {
- @Override
- protected Number buildValue_() {
- return new Integer(this.subject.getAdventureCount());
- }
- @Override
- protected void setValue_(Number value) {
- this.subject.setAdventureCount(value.intValue());
- }
- };
- }
-
-
- // ********** queries **********
-
- private Crowd crowd() {
- return this.crowdHolder.getValue();
- }
-
- private Person selectedPerson() {
- if (this.rowSelectionModel.isSelectionEmpty()) {
- return null;
- }
- return (Person) this.rowSelectionModel.selectedValue();
- }
-
- private void setSelectedPerson(Person person) {
- this.rowSelectionModel.setSelectedValue(person);
- }
-
-
- // ********** custom renderer **********
-
- /**
- * This is simply an example of a renderer for the embedded combo-box.
- * It does nothing special unless you uncomment the code below....
- */
- private class EyeColorRenderer extends DefaultListCellRenderer {
- EyeColorRenderer() {
- super();
- }
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- // just do something to show the renderer is working...
- // value = ">" + value;
- return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java
deleted file mode 100644
index 91aa582d85..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java
+++ /dev/null
@@ -1,817 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.swing.Icon;
-import javax.swing.JTree;
-import javax.swing.event.TreeModelEvent;
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.TreeModel;
-
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.IndentingPrintWriter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.utility.internal.model.value.AbstractTreeNodeValueModel;
-import org.eclipse.jpt.utility.internal.model.value.CollectionAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.NullListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.TransformationListValueModelAdapter;
-import org.eclipse.jpt.utility.internal.model.value.swing.TreeModelAdapter;
-import org.eclipse.jpt.utility.internal.swing.Displayable;
-import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.utility.model.value.ListValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.TreeNodeValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-
-import junit.framework.TestCase;
-
-/**
- *
- */
-public class TreeModelAdapterTests extends TestCase {
- boolean eventFired;
-
- public TreeModelAdapterTests(String name) {
- super(name);
- }
-
- public void testGetRoot() {
- TreeModel treeModel = this.buildSortedTreeModel();
- treeModel.addTreeModelListener(new TestTreeModelListener());
- TestNode rootNode = (TestNode) treeModel.getRoot();
- TestModel root = rootNode.getTestModel();
- assertEquals("root", root.getName());
-// root.dump();
-// rootNode.dump();
- }
-
- public void testGetChild() {
- TreeModel treeModel = this.buildSortedTreeModel();
- treeModel.addTreeModelListener(new TestTreeModelListener());
- TestNode rootNode = (TestNode) treeModel.getRoot();
-
- TestNode expected = rootNode.childNamed("node 1");
- TestNode actual = (TestNode) treeModel.getChild(rootNode, 1);
- assertEquals(expected, actual);
-
- expected = rootNode.childNamed("node 2");
- actual = (TestNode) treeModel.getChild(rootNode, 2);
- assertEquals(expected, actual);
- }
-
- public void testGetChildCount() {
- TreeModel treeModel = this.buildSortedTreeModel();
- treeModel.addTreeModelListener(new TestTreeModelListener());
- TestNode rootNode = (TestNode) treeModel.getRoot();
-
- assertEquals(5, treeModel.getChildCount(rootNode));
-
- TestNode node = rootNode.childNamed("node 1");
- assertEquals(1, treeModel.getChildCount(node));
- }
-
- public void testGetIndexOfChild() {
- TreeModel treeModel = this.buildSortedTreeModel();
- treeModel.addTreeModelListener(new TestTreeModelListener());
- TestNode rootNode = (TestNode) treeModel.getRoot();
-
- TestNode child = rootNode.childNamed("node 0");
- assertEquals(0, treeModel.getIndexOfChild(rootNode, child));
-
- child = rootNode.childNamed("node 1");
- assertEquals(1, treeModel.getIndexOfChild(rootNode, child));
-
- child = rootNode.childNamed("node 2");
- assertEquals(2, treeModel.getIndexOfChild(rootNode, child));
- TestNode grandchild = child.childNamed("node 2.2");
- assertEquals(2, treeModel.getIndexOfChild(child, grandchild));
- }
-
- public void testIsLeaf() {
- TreeModel treeModel = this.buildSortedTreeModel();
- treeModel.addTreeModelListener(new TestTreeModelListener());
- TestNode rootNode = (TestNode) treeModel.getRoot();
- assertFalse(treeModel.isLeaf(rootNode));
- TestNode node = rootNode.childNamed("node 1");
- assertFalse(treeModel.isLeaf(node));
- node = rootNode.childNamed("node 3");
- assertTrue(treeModel.isLeaf(node));
- }
-
-
- public void testTreeNodesChanged() {
- // the only way to trigger a "node changed" event is to use an unsorted tree;
- // a sorted tree will will trigger only "node removed" and "node inserted" events
- TreeModel treeModel = this.buildUnsortedTreeModel();
- this.eventFired = false;
- treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesChanged(TreeModelEvent e) {
- TreeModelAdapterTests.this.eventFired = true;
- }
- });
- TestNode rootNode = (TestNode) treeModel.getRoot();
- TestNode node = rootNode.childNamed("node 1");
- TestModel tm = node.getTestModel();
- tm.setName("node 1++");
- assertTrue(this.eventFired);
-
- this.eventFired = false;
- node = node.childNamed("node 1.1");
- tm = node.getTestModel();
- tm.setName("node 1.1++");
- assertTrue(this.eventFired);
- }
-
- public void testTreeNodesInserted() {
- // use an unsorted tree so the nodes are not re-shuffled...
- TreeModel treeModel = this.buildUnsortedTreeModel();
- this.eventFired = false;
- treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesInserted(TreeModelEvent e) {
- TreeModelAdapterTests.this.eventFired = true;
- }
- });
- TestNode rootNode = (TestNode) treeModel.getRoot();
- TestNode node = rootNode.childNamed("node 1");
- TestModel tm = node.getTestModel();
- tm.addChild("new child...");
- assertTrue(this.eventFired);
-
- this.eventFired = false;
- node = node.childNamed("node 1.1");
- tm = node.getTestModel();
- tm.addChild("another new child...");
- assertTrue(this.eventFired);
- }
-
- public void testTreeNodesRemoved() {
- TreeModel treeModel = this.buildUnsortedTreeModel();
- this.eventFired = false;
- treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesRemoved(TreeModelEvent e) {
- TreeModelAdapterTests.this.eventFired = true;
- }
- });
- TestNode rootNode = (TestNode) treeModel.getRoot();
- TestModel root = rootNode.getTestModel();
- root.removeChild(root.childNamed("node 3"));
- assertTrue(this.eventFired);
-
- this.eventFired = false;
- TestNode node = rootNode.childNamed("node 2");
- TestModel tm = node.getTestModel();
- tm.removeChild(tm.childNamed("node 2.2"));
- assertTrue(this.eventFired);
- }
-
- public void testTreeStructureChanged() {
- WritablePropertyValueModel<TreeNodeValueModel<Object>> nodeHolder = new SimplePropertyValueModel<TreeNodeValueModel<Object>>(this.buildSortedRootNode());
- TreeModel treeModel = this.buildTreeModel(nodeHolder);
- this.eventFired = false;
- treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesInserted(TreeModelEvent e) {
- // do nothing
- }
- @Override
- public void treeNodesRemoved(TreeModelEvent e) {
- // do nothing
- }
- @Override
- public void treeStructureChanged(TreeModelEvent e) {
- TreeModelAdapterTests.this.eventFired = true;
- }
- });
- nodeHolder.setValue(this.buildUnsortedRootNode());
- assertTrue(this.eventFired);
- }
-
- /**
- * test a problem we had where removing a child from a tree would cause
- * the JTree to call #equals(Object) on each node removed (actually, it was
- * TreePath, but that was because its own #equals(Object) was called by
- * JTree); and since we had already removed the last listener from the
- * aspect adapter, the aspect adapter would say its value was null; this
- * would cause a NPE until we tweaked TreeModelAdapter to remove its
- * listeners from a node only *after* the node had been completely
- * removed from the JTree
- * @see TreeModelAdapter#removeNode(Object[], int, TreeNodeValueModel)
- * @see TreeModelAdapter#addNode(Object[], int, TreeNodeValueModel)
- */
- public void testLazyInitialization() {
- TreeModel treeModel = this.buildSpecialTreeModel();
- JTree jTree = new JTree(treeModel);
- TestNode rootNode = (TestNode) treeModel.getRoot();
- TestModel root = rootNode.getTestModel();
- // this would cause a NPE:
- root.removeChild(root.childNamed("node 3"));
- assertEquals(treeModel, jTree.getModel());
- }
-
-
- private TreeModel buildSortedTreeModel() {
- return this.buildTreeModel(this.buildSortedRootNode());
- }
-
- private TestNode buildSortedRootNode() {
- return new SortedTestNode(this.buildRoot());
- }
-
- private TreeModel buildUnsortedTreeModel() {
- return this.buildTreeModel(this.buildUnsortedRootNode());
- }
-
- private TestNode buildUnsortedRootNode() {
- return new UnsortedTestNode(this.buildRoot());
- }
-
- private TreeModel buildSpecialTreeModel() {
- return this.buildTreeModel(this.buildSpecialRootNode());
- }
-
- private TestNode buildSpecialRootNode() {
- return new SpecialTestNode(this.buildRoot());
- }
-
- private TestModel buildRoot() {
- TestModel root = new TestModel("root");
- /*Node node_0 = */root.addChild("node 0");
- TestModel node_1 = root.addChild("node 1");
- TestModel node_1_1 = node_1.addChild("node 1.1");
- /*Node node_1_1_1 = */node_1_1.addChild("node 1.1.1");
- TestModel node_2 = root.addChild("node 2");
- /*Node node_2_0 = */node_2.addChild("node 2.0");
- /*Node node_2_1 = */node_2.addChild("node 2.1");
- /*Node node_2_2 = */node_2.addChild("node 2.2");
- /*Node node_2_3 = */node_2.addChild("node 2.3");
- /*Node node_2_4 = */node_2.addChild("node 2.4");
- /*Node node_2_5 = */node_2.addChild("node 2.5");
- /*Node node_3 = */root.addChild("node 3");
- /*Node node_4 = */root.addChild("node 4");
- return root;
- }
-
-
- // ********** member classes **********
-
- /**
- * This is a typical model class with the typical change notifications
- * for #name and #children.
- */
- public static class TestModel extends AbstractModel {
-
- // the parent is immutable; the root's parent is null
- private final TestModel parent;
-
- // the name is mutable; so I guess it isn't the "primary key" :-)
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- private final Collection<TestModel> children;
- public static final String CHILDREN_COLLECTION = "children";
-
-
- public TestModel(String name) { // root ctor
- this(null, name);
- }
- private TestModel(TestModel parent, String name) {
- super();
- this.parent = parent;
- this.name = name;
- this.children = new HashBag<TestModel>();
- }
-
- public TestModel getParent() {
- return this.parent;
- }
-
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- public Iterator<TestModel> children() {
- return new ReadOnlyIterator<TestModel>(this.children);
- }
- public int childrenSize() {
- return this.children.size();
- }
- public TestModel addChild(String childName) {
- TestModel child = new TestModel(this, childName);
- this.addItemToCollection(child, this.children, CHILDREN_COLLECTION);
- return child;
- }
- public TestModel[] addChildren(String[] childNames) {
- TestModel[] newChildren = new TestModel[childNames.length];
- for (int i = 0; i < childNames.length; i++) {
- newChildren[i] = new TestModel(this, childNames[i]);
- }
- this.addItemsToCollection(newChildren, this.children, CHILDREN_COLLECTION);
- return newChildren;
- }
- public void removeChild(TestModel child) {
- this.removeItemFromCollection(child, this.children, CHILDREN_COLLECTION);
- }
- public void removeChildren(TestModel[] testModels) {
- this.removeItemsFromCollection(testModels, this.children, CHILDREN_COLLECTION);
- }
- public void clearChildren() {
- this.clearCollection(this.children, CHILDREN_COLLECTION);
- }
- public TestModel childNamed(String childName) {
- for (TestModel child : this.children) {
- if (child.getName().equals(childName)) {
- return child;
- }
- }
- throw new RuntimeException("child not found: " + childName);
- }
-
- public String dumpString() {
- StringWriter sw = new StringWriter();
- IndentingPrintWriter ipw = new IndentingPrintWriter(sw);
- this.dumpOn(ipw);
- return sw.toString();
- }
- public void dumpOn(IndentingPrintWriter writer) {
- writer.println(this);
- writer.indent();
- for (TestModel child : this.children) {
- child.dumpOn(writer);
- }
- writer.undent();
- }
- public void dumpOn(OutputStream stream) {
- IndentingPrintWriter writer = new IndentingPrintWriter(new OutputStreamWriter(stream));
- this.dumpOn(writer);
- writer.flush();
- }
- public void dump() {
- this.dumpOn(System.out);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.name);
- }
-
- }
-
-
- /**
- * This Node wraps a TestModel and converts into something that can
- * be used by TreeModelAdapter. It converts changes to the TestModel's
- * name into "state changes" to the Node; and converts the
- * TestModel's children into a ListValueModel of Nodes whose order is
- * determined by subclass implementations.
- */
- public static abstract class TestNode extends AbstractTreeNodeValueModel<Object> implements Displayable {
- /** the model object wrapped by this node */
- private final TestModel testModel;
- /** this node's parent node; null for the root node */
- private final TestNode parent;
- /** this node's child nodes */
- private final ListValueModel<TreeNodeValueModel<Object>> childrenModel;
- /** a listener that notifies us when the model object's "internal state" changes */
- private final PropertyChangeListener testModelListener;
-
-
- // ********** constructors/initialization **********
-
- /**
- * root node constructor
- */
- public TestNode(TestModel testModel) {
- this(null, testModel);
- }
-
- /**
- * branch or leaf node constructor
- */
- public TestNode(TestNode parent, TestModel testModel) {
- super();
- this.parent = parent;
- this.testModel = testModel;
- this.childrenModel = this.buildChildrenModel(testModel);
- this.testModelListener = this.buildTestModelListener();
- }
-
- private PropertyChangeListener buildTestModelListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- TestNode.this.testModelChanged(e);
- }
- };
- }
-
- /**
- * subclasses decide the order of the child nodes
- */
- protected abstract ListValueModel<TreeNodeValueModel<Object>> buildChildrenModel(TestModel model);
-
- /**
- * used by subclasses;
- * transform the test model children into nodes
- */
- protected ListValueModel<TreeNodeValueModel<Object>> buildNodeAdapter(TestModel model) {
- return new TransformationListValueModelAdapter<TestModel, TreeNodeValueModel<Object>>(this.buildChildrenAdapter(model)) {
- @Override
- protected TestNode transformItem(TestModel item) {
- return TestNode.this.buildChildNode(item);
- }
- };
- }
-
- /**
- * subclasses must build a concrete node for the specified test model
- */
- protected abstract TestNode buildChildNode(TestModel childTestModel);
-
- /**
- * return a collection value model on the specified model's children
- */
- protected CollectionValueModel<TestModel> buildChildrenAdapter(TestModel model) {
- return new CollectionAspectAdapter<TestModel, TestModel>(TestModel.CHILDREN_COLLECTION, model) {
- @Override
- protected Iterator<TestModel> iterator_() {
- return this.subject.children();
- }
- @Override
- protected int size_() {
- return this.subject.childrenSize();
- }
- };
- }
-
-
- // ********** TreeNodeValueModel implementation **********
-
- public TestModel getValue() {
- return this.testModel;
- }
-
- public TreeNodeValueModel<Object> parent() {
- return this.parent;
- }
-
- public ListValueModel<TreeNodeValueModel<Object>> childrenModel() {
- return this.childrenModel;
- }
-
-
- // ********** AbstractTreeNodeValueModel implementation **********
-
- @Override
- protected void engageValue() {
- this.testModel.addPropertyChangeListener(TestModel.NAME_PROPERTY, this.testModelListener);
- }
-
- @Override
- protected void disengageValue() {
- this.testModel.removePropertyChangeListener(TestModel.NAME_PROPERTY, this.testModelListener);
- }
-
-
- // ********** Displayable implementation **********
-
- public String displayString() {
- return this.testModel.getName();
- }
-
- public Icon icon() {
- return null;
- }
-
-
- // ********** debugging support **********
-
- public String dumpString() {
- StringWriter sw = new StringWriter();
- IndentingPrintWriter ipw = new IndentingPrintWriter(sw);
- this.dumpOn(ipw);
- return sw.toString();
- }
-
- public void dumpOn(IndentingPrintWriter writer) {
- writer.println(this);
- writer.indent();
- for (Iterator<TreeNodeValueModel<Object>> stream = this.childrenModel.iterator(); stream.hasNext(); ) {
- // cast to a TestNode (i.e. this won't work with a NameTestNode in the tree)
- ((TestNode) stream.next()).dumpOn(writer);
- }
- writer.undent();
- }
-
- public void dumpOn(OutputStream stream) {
- IndentingPrintWriter writer = new IndentingPrintWriter(new OutputStreamWriter(stream));
- this.dumpOn(writer);
- writer.flush();
- }
-
- public void dump() {
- this.dumpOn(System.out);
- }
-
-
- // ********** behavior **********
-
- /**
- * the model's name has changed, forward the event to our listeners
- */
- protected void testModelChanged(PropertyChangeEvent e) {
- // we need to notify listeners that our "internal state" has changed
- this.fireStateChanged();
- // our display string stays in synch with the model's name
- this.firePropertyChanged(DISPLAY_STRING_PROPERTY, e.getOldValue(), e.getNewValue());
- }
-
-
- // ********** queries **********
-
- public TestModel getTestModel() {
- return this.testModel;
- }
-
- /**
- * testing convenience method
- */
- public TestNode childNamed(String name) {
- for (Iterator<TreeNodeValueModel<Object>> stream = this.childrenModel.iterator(); stream.hasNext(); ) {
- TreeNodeValueModel<Object> childNode = stream.next();
- if (childNode instanceof TestNode) {
- if (((TestNode) childNode).getTestModel().getName().equals(name)) {
- return (TestNode) childNode;
- }
- }
- }
- throw new IllegalArgumentException("child not found: " + name);
- }
-
-
- // ********** standard methods **********
-
- /**
- * use the standard Displayable comparator
- */
- public int compareTo(Displayable d) {
- return DEFAULT_COMPARATOR.compare(this, d);
- }
-
- @Override
- public String toString() {
- return "Node(" + this.testModel + ")";
- }
-
- }
-
- /**
- * concrete implementation that keeps its children sorted
- */
- public static class SortedTestNode extends TestNode {
-
- // ********** constructors **********
- public SortedTestNode(TestModel testModel) {
- super(testModel);
- }
- public SortedTestNode(TestNode parent, TestModel testModel) {
- super(parent, testModel);
- }
-
- // ********** initialization **********
- /** the list should be sorted */
- @Override
- protected ListValueModel<TreeNodeValueModel<Object>> buildChildrenModel(TestModel testModel) {
- return new SortedListValueModelAdapter<TreeNodeValueModel<Object>>(this.buildDisplayStringAdapter(testModel));
- }
- /** the display string (name) of each node can change */
- protected ListValueModel<TreeNodeValueModel<Object>> buildDisplayStringAdapter(TestModel testModel) {
- return new ItemPropertyListValueModelAdapter<TreeNodeValueModel<Object>>(this.buildNodeAdapter(testModel), DISPLAY_STRING_PROPERTY);
- }
- /** children are also sorted nodes */
- @Override
- protected TestNode buildChildNode(TestModel childNode) {
- return new SortedTestNode(this, childNode);
- }
-
- }
-
-
- /**
- * concrete implementation that leaves its children unsorted
- */
- public static class UnsortedTestNode extends TestNode {
-
- // ********** constructors **********
- public UnsortedTestNode(TestModel testModel) {
- super(testModel);
- }
- public UnsortedTestNode(TestNode parent, TestModel testModel) {
- super(parent, testModel);
- }
-
- // ********** initialization **********
- /** the list should NOT be sorted */
- @Override
- protected ListValueModel<TreeNodeValueModel<Object>> buildChildrenModel(TestModel testModel) {
- return this.buildNodeAdapter(testModel);
- }
- /** children are also unsorted nodes */
- @Override
- protected TestNode buildChildNode(TestModel childNode) {
- return new UnsortedTestNode(this, childNode);
- }
-
- }
-
-
- /**
- * concrete implementation that leaves its children unsorted
- * and has a special set of children for "node 3"
- */
- public static class SpecialTestNode extends UnsortedTestNode {
-
- // ********** constructors **********
- public SpecialTestNode(TestModel testModel) {
- super(testModel);
- }
- public SpecialTestNode(TestNode parent, TestModel testModel) {
- super(parent, testModel);
- }
-
- // ********** initialization **********
- /** return a different list of children for "node 3" */
- @Override
- protected ListValueModel<TreeNodeValueModel<Object>> buildChildrenModel(TestModel testModel) {
- if (testModel.getName().equals("node 3")) {
- return this.buildSpecialChildrenModel(testModel);
- }
- return super.buildChildrenModel(testModel);
- }
- protected ListValueModel<TreeNodeValueModel<Object>> buildSpecialChildrenModel(TestModel testModel) {
- TreeNodeValueModel<Object>[] children = new NameTestNode[1];
- children[0] = new NameTestNode(this);
- return new SimpleListValueModel<TreeNodeValueModel<Object>>(Arrays.asList(children));
- }
- /** children are also special nodes */
- @Override
- protected TestNode buildChildNode(TestModel childNode) {
- return new SpecialTestNode(this, childNode);
- }
-
- }
-
-
- public static class NameTestNode extends AbstractTreeNodeValueModel<Object> {
- private final WritablePropertyValueModel<String> nameAdapter;
- private final SpecialTestNode specialNode; // parent node
- private final PropertyChangeListener nameListener;
- private final ListValueModel<TreeNodeValueModel<Object>> childrenModel;
-
- // ********** construction/initialization **********
-
- public NameTestNode(SpecialTestNode specialNode) {
- super();
- this.nameListener = this.buildNameListener();
- this.specialNode = specialNode;
- this.nameAdapter = this.buildNameAdapter();
- this.childrenModel = new NullListValueModel<TreeNodeValueModel<Object>>();
- }
- protected PropertyChangeListener buildNameListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- NameTestNode.this.nameChanged(e);
- }
- };
- }
- protected WritablePropertyValueModel<String> buildNameAdapter() {
- return new PropertyAspectAdapter<TestModel, String>(TestModel.NAME_PROPERTY, this.getTestModel()) {
- @Override
- protected String buildValue_() {
- return this.subject.getName();
- }
- @Override
- protected void setValue_(String value) {
- this.subject.setName(value);
- }
- };
- }
-
- public TestModel getTestModel() {
- return this.specialNode.getTestModel();
- }
-
- // ********** TreeNodeValueModel implementation **********
-
- public String getValue() {
- return this.nameAdapter.getValue();
- }
- @Override
- public void setValue(Object value) {
- this.nameAdapter.setValue((String) value);
- }
- public TreeNodeValueModel<Object> parent() {
- return this.specialNode;
- }
- public ListValueModel<TreeNodeValueModel<Object>> childrenModel() {
- return this.childrenModel;
- }
-
- // ********** AbstractTreeNodeValueModel implementation **********
-
- @Override
- protected void engageValue() {
- this.nameAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.nameListener);
- }
- @Override
- protected void disengageValue() {
- this.nameAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, this.nameListener);
- }
-
- // ********** behavior **********
-
- protected void nameChanged(PropertyChangeEvent e) {
- // we need to notify listeners that our "value" has changed
- this.firePropertyChanged(VALUE, e.getOldValue(), e.getNewValue());
- }
- }
-
- private TreeModel buildTreeModel(TestNode root) {
- return this.buildTreeModel(new StaticPropertyValueModel<TreeNodeValueModel<Object>>(root));
- }
-
- private TreeModel buildTreeModel(PropertyValueModel<TreeNodeValueModel<Object>> rootHolder) {
- return new TreeModelAdapter<Object>(rootHolder) {
- @Override
- protected ListChangeListener buildChildrenListener() {
- return this.buildChildrenListener_();
- }
- @Override
- protected StateChangeListener buildNodeStateListener() {
- return this.buildNodeStateListener_();
- }
- @Override
- protected PropertyChangeListener buildNodeValueListener() {
- return this.buildNodeValueListener_();
- }
- @Override
- protected PropertyChangeListener buildRootListener() {
- return this.buildRootListener_();
- }
- };
- }
-
-
-
- /**
- * listener that will blow up with any event;
- * override and implement expected event methods
- */
- public class TestTreeModelListener implements TreeModelListener {
- public void treeNodesChanged(TreeModelEvent e) {
- fail("unexpected event");
- }
- public void treeNodesInserted(TreeModelEvent e) {
- fail("unexpected event");
- }
- public void treeNodesRemoved(TreeModelEvent e) {
- fail("unexpected event");
- }
- public void treeStructureChanged(TreeModelEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java
deleted file mode 100644
index be2c5b252d..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java
+++ /dev/null
@@ -1,426 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.TextField;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTree;
-import javax.swing.WindowConstants;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.DefaultTreeSelectionModel;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-import javax.swing.tree.TreeSelectionModel;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.EnumerationIterator;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.swing.TreeModelAdapter;
-import org.eclipse.jpt.utility.internal.swing.Displayable;
-import org.eclipse.jpt.utility.model.value.TreeNodeValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.utility.tests.internal.model.value.swing.TreeModelAdapterTests.SortedTestNode;
-import org.eclipse.jpt.utility.tests.internal.model.value.swing.TreeModelAdapterTests.TestModel;
-import org.eclipse.jpt.utility.tests.internal.model.value.swing.TreeModelAdapterTests.TestNode;
-import org.eclipse.jpt.utility.tests.internal.model.value.swing.TreeModelAdapterTests.UnsortedTestNode;
-
-/**
- * an example UI for testing the TreeModelAdapter
- */
-public class TreeModelAdapterUITest {
-
- // hold the tree so we can restore its expansion state
- private JTree tree;
- private WritablePropertyValueModel<TreeNodeValueModel<Object>> rootNodeHolder;
- private boolean sorted;
- private TreeModel treeModel;
- private TreeSelectionModel treeSelectionModel;
- private TextField nameTextField;
-
- public static void main(String[] args) throws Exception {
- new TreeModelAdapterUITest().exec(args);
- }
-
- private TreeModelAdapterUITest() {
- super();
- }
-
- private void exec(String[] args) throws Exception {
- this.rootNodeHolder = this.buildRootNodeHolder();
- this.sorted = this.rootNodeHolder.getValue() instanceof SortedTestNode;
- this.treeModel = this.buildTreeModel();
- this.treeSelectionModel = this.buildTreeSelectionModel();
- this.nameTextField = new TextField();
- this.openWindow();
- }
-
- private WritablePropertyValueModel<TreeNodeValueModel<Object>> buildRootNodeHolder() {
- return new SimplePropertyValueModel<TreeNodeValueModel<Object>>(this.buildSortedRootNode());
- }
-
- private TestNode buildSortedRootNode() {
- return new SortedTestNode(this.buildRoot());
- }
-
- private TestNode buildUnsortedRootNode() {
- return new UnsortedTestNode(this.buildRoot());
- }
-
- private TestModel buildRoot() {
- TestModel root = new TestModel("root");
-
- TestModel node_1 = root.addChild("node 1");
- /*Node node_1_1 = */node_1.addChild("node 1.1");
-
- TestModel node_2 = root.addChild("node 2");
- /*Node node_2_1 = */node_2.addChild("node 2.1");
- TestModel node_2_2 = node_2.addChild("node 2.2");
- /*Node node_2_2_1 = */node_2_2.addChild("node 2.2.1");
- /*Node node_2_2_2 = */node_2_2.addChild("node 2.2.2");
- /*Node node_2_3 = */node_2.addChild("node 2.3");
- /*Node node_2_4 = */node_2.addChild("node 2.4");
- /*Node node_2_5 = */node_2.addChild("node 2.5");
-
- TestModel node_3 = root.addChild("node 3");
- TestModel node_3_1 = node_3.addChild("node 3.1");
- TestModel node_3_1_1 = node_3_1.addChild("node 3.1.1");
- /*Node node_3_1_1_1 = */node_3_1_1.addChild("node 3.1.1.1");
-
- /*Node node_4 = */root.addChild("node 4");
-
- return root;
- }
-
- private TreeModel buildTreeModel() {
- return new TreeModelAdapter<Object>(this.rootNodeHolder);
- }
-
- private TreeSelectionModel buildTreeSelectionModel() {
- TreeSelectionModel tsm = new DefaultTreeSelectionModel();
- tsm.addTreeSelectionListener(this.buildTreeSelectionListener());
- tsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
- return tsm;
- }
-
- private TreeSelectionListener buildTreeSelectionListener() {
- return new TreeSelectionListener() {
- public void valueChanged(TreeSelectionEvent e) {
- TreeModelAdapterUITest.this.treeSelectionChanged(e);
- }
- };
- }
-
- void treeSelectionChanged(TreeSelectionEvent e) {
- TestModel selectedTestModel = this.selectedTestModel();
- if (selectedTestModel != null) {
- this.nameTextField.setText(selectedTestModel.getName());
- }
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setLocation(300, 300);
- window.setSize(400, 400);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildTreePane(), BorderLayout.CENTER);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildTreePane() {
- return new JScrollPane(this.buildTree());
- }
-
- private JTree buildTree() {
- this.tree = new JTree(this.treeModel) {
- @Override
- public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
- return ((Displayable) value).displayString();
- }
- };
- this.tree.setSelectionModel(this.treeSelectionModel);
- this.tree.setRootVisible(true);
- this.tree.setShowsRootHandles(true);
- this.tree.setRowHeight(20);
- this.tree.setDoubleBuffered(true);
- return this.tree;
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(0, 1));
- controlPanel.add(this.buildAddRenameNodePanel());
- controlPanel.add(this.buildMiscPanel());
- return controlPanel;
- }
-
- private Component buildAddRenameNodePanel() {
- JPanel addRenameNodePanel = new JPanel(new BorderLayout());
- addRenameNodePanel.add(this.buildAddButton(), BorderLayout.WEST);
- addRenameNodePanel.add(this.nameTextField, BorderLayout.CENTER);
- addRenameNodePanel.add(this.buildRenameButton(), BorderLayout.EAST);
- return addRenameNodePanel;
- }
-
- private Component buildMiscPanel() {
- JPanel miscPanel = new JPanel(new GridLayout(1, 0));
- miscPanel.add(this.buildClearChildrenButton());
- miscPanel.add(this.buildRemoveButton());
- miscPanel.add(this.buildResetButton());
- return miscPanel;
- }
-
- private String getName() {
- return this.nameTextField.getText();
- }
-
- // ********** queries **********
- private TestNode selectedNode() {
- if (this.treeSelectionModel.isSelectionEmpty()) {
- return null;
- }
- return (TestNode) this.treeSelectionModel.getSelectionPath().getLastPathComponent();
- }
-
- private TestModel selectedTestModel() {
- if (this.treeSelectionModel.isSelectionEmpty()) {
- return null;
- }
- return this.selectedNode().getValue();
- }
-
- private TestNode rootNode() {
- return (TestNode) this.treeModel.getRoot();
- }
-
- private TestModel root() {
- return this.rootNode().getValue();
- }
-
- private Collection<TreePath> expandedPaths() {
- Enumeration<TreePath> stream = this.tree.getExpandedDescendants(new TreePath(this.rootNode()));
- if (stream == null) {
- return Collections.emptyList();
- }
- return CollectionTools.list(new EnumerationIterator<TreePath>(stream));
- }
-
- // ********** behavior **********
- private void setSelectedNode(TestNode selectedNode) {
- this.treeSelectionModel.setSelectionPath(new TreePath(selectedNode.path()));
- }
-
- private void expandPaths(Collection<TreePath> paths) {
- for (TreePath path : paths) {
- this.tree.expandPath(path);
- }
- }
-
- // ********** add **********
- private JButton buildAddButton() {
- return new JButton(this.buildAddAction());
- }
-
- private Action buildAddAction() {
- Action action = new AbstractAction("add") {
- public void actionPerformed(ActionEvent event) {
- TreeModelAdapterUITest.this.addNode();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- /**
- * adding causes the tree to be sorted and nodes to be
- * removed and re-added; so we have to fiddle with the expansion state
- */
- void addNode() {
- TestModel selectedTestModel = this.selectedTestModel();
- if (selectedTestModel != null) {
- String name = this.getName();
- // save the expansion state and restore it after the add
- Collection<TreePath> paths = this.expandedPaths();
-
- selectedTestModel.addChild(name);
-
- this.expandPaths(paths);
- this.setSelectedNode(this.selectedNode().childNamed(name));
- }
- }
-
- // ********** remove **********
- private JButton buildRemoveButton() {
- return new JButton(this.buildRemoveAction());
- }
-
- private Action buildRemoveAction() {
- Action action = new AbstractAction("remove") {
- public void actionPerformed(ActionEvent event) {
- TreeModelAdapterUITest.this.removeNode();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- /**
- * we need to figure out which node to select after
- * the selected node is deleted
- */
- void removeNode() {
- TestModel selectedTestModel = this.selectedTestModel();
- // do not allow the root to be removed
- if ((selectedTestModel != null) && (selectedTestModel != this.root())) {
- // save the parent and index, so we can select another, nearby, node
- // once the selected node is removed
- TestNode parentNode = (TestNode) this.selectedNode().parent();
- int childIndex = parentNode.indexOfChild(this.selectedNode());
-
- selectedTestModel.getParent().removeChild(selectedTestModel);
-
- int childrenSize = parentNode.childrenSize();
- if (childIndex < childrenSize) {
- // select the child that moved up and replaced the just-deleted child
- this.setSelectedNode((TestNode) parentNode.child(childIndex));
- } else {
- if (childrenSize == 0) {
- // if there are no more children, select the parent
- this.setSelectedNode(parentNode);
- } else {
- // if the child at the bottom of the list was deleted, select the next child up
- this.setSelectedNode((TestNode) parentNode.child(childIndex - 1));
- }
- }
- }
- }
-
- // ********** rename **********
- private JButton buildRenameButton() {
- return new JButton(this.buildRenameAction());
- }
-
- private Action buildRenameAction() {
- Action action = new AbstractAction("rename") {
- public void actionPerformed(ActionEvent event) {
- TreeModelAdapterUITest.this.renameNode();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- /**
- * renaming causes the tree to be sorted and nodes to be
- * removed and re-added; so we have to fiddle with the expansion state
- */
- void renameNode() {
- TestModel selectedTestModel = this.selectedTestModel();
- if (selectedTestModel != null) {
- // save the node and re-select it after the rename
- TestNode selectedNode = this.selectedNode();
- // save the expansion state and restore it after the rename
- Collection<TreePath> paths = this.expandedPaths();
-
- selectedTestModel.setName(this.getName());
-
- this.expandPaths(paths);
- this.setSelectedNode(selectedNode);
- }
- }
-
- // ********** clear children **********
- private JButton buildClearChildrenButton() {
- return new JButton(this.buildClearChildrenAction());
- }
-
- private Action buildClearChildrenAction() {
- Action action = new AbstractAction("clear children") {
- public void actionPerformed(ActionEvent event) {
- TreeModelAdapterUITest.this.clearChildren();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- /**
- * nothing special, we just want to test #fireCollectionChanged(String)
- */
- void clearChildren() {
- TestModel selectedTestModel = this.selectedTestModel();
- if (selectedTestModel != null) {
- selectedTestModel.clearChildren();
- }
- }
-
- // ********** reset **********
- private JButton buildResetButton() {
- return new JButton(this.buildResetAction());
- }
-
- private Action buildResetAction() {
- Action action = new AbstractAction("reset") {
- public void actionPerformed(ActionEvent event) {
- TreeModelAdapterUITest.this.reset();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- /**
- * test the adapter's root node holder;
- * toggle between sorted and unsorted lists
- */
- void reset() {
- this.sorted = ! this.sorted;
- if (this.sorted) {
- this.rootNodeHolder.setValue(this.buildSortedRootNode());
- } else {
- this.rootNodeHolder.setValue(this.buildUnsortedRootNode());
- }
- this.tree.expandPath(new TreePath(this.rootNode()));
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/AbstractNodeTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/AbstractNodeTests.java
deleted file mode 100644
index f642f8acc7..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/AbstractNodeTests.java
+++ /dev/null
@@ -1,528 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.node;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.Range;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.node.AbstractNode;
-import org.eclipse.jpt.utility.internal.node.Node;
-import org.eclipse.jpt.utility.internal.node.Problem;
-import org.eclipse.jpt.utility.tests.internal.TestTools;
-
-import junit.framework.TestCase;
-
-public class AbstractNodeTests extends TestCase {
- private TestWorkbenchModel root;
-
- public AbstractNodeTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.root = this.buildRoot();
- }
-
- private TestWorkbenchModel buildRoot() {
- TestWorkbenchModel r = new RootTestWorkbenchModel("root");
- TestWorkbenchModel node1 = r.addTestChildNamed("node 1");
- TestWorkbenchModel node1_1 = node1.addTestChildNamed("node 1.1");
- node1_1.addTestChildNamed("node 1.1.1");
- node1_1.addTestChildNamed("node 1.1.2");
- node1_1.addTestChildNamed("node 1.1.3");
- node1.addTestChildNamed("node 1.2");
- TestWorkbenchModel node2 = r.addTestChildNamed("node 2");
- node2.addTestChildNamed("node 2.1");
- node2.addTestChildNamed("node 2.2");
- r.addTestChildNamed("node 3");
- r.addTestChildNamed("node 4");
-
- // mark the entire tree clean
- r.markEntireBranchClean();
- return r;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testTestWorkbenchModel() {
- // make sure our test class works OK...
- assertNull(this.root.testChildNamed(""));
- assertNotNull(this.root.testChildNamed("node 1"));
- assertTrue(this.root.testChildNamed("node 1").isClean());
- assertTrue(this.root.testChildNamed("node 1").isCleanBranch());
- assertNotNull(this.root.testChildNamed("node 2"));
- assertTrue(this.root.testChildNamed("node 2").isClean());
- assertTrue(this.root.testChildNamed("node 2").isCleanBranch());
- assertNull(this.root.testChildNamed("node 2.1"));
-
- assertNull(this.root.testDescendantNamed(""));
- assertNotNull(this.root.testDescendantNamed("node 1"));
- assertNotNull(this.root.testDescendantNamed("node 2"));
- assertNotNull(this.root.testDescendantNamed("node 2.1"));
- assertTrue(this.root.testDescendantNamed("node 2.1").isClean());
- assertTrue(this.root.testDescendantNamed("node 2.1").isCleanBranch());
- assertNotNull(this.root.testDescendantNamed("node 1.1.3"));
- assertTrue(this.root.testDescendantNamed("node 1.1.3").isClean());
- assertTrue(this.root.testDescendantNamed("node 1.1.3").isCleanBranch());
- }
-
- public void testParentAndChildren() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- assertEquals("node 1.1.3", node.getName());
- assertEquals(0, CollectionTools.size(node.children()));
-
- node = (TestWorkbenchModel) node.getParent();
- assertEquals("node 1.1", node.getName());
- assertEquals(3, CollectionTools.size(node.children()));
-
- node = (TestWorkbenchModel) node.getParent();
- assertEquals("node 1", node.getName());
- assertEquals(2, CollectionTools.size(node.children()));
-
- node = (TestWorkbenchModel) node.getParent();
- assertEquals("root", node.getName());
- assertEquals(4, CollectionTools.size(node.children()));
-
- node = (TestWorkbenchModel) node.getParent();
- assertNull(node);
- }
-
- public void testDirty() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setSize(42);
- assertTrue(node.isDirty());
-
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- assertTrue(parent.isClean());
- assertTrue(this.root.isClean());
- }
-
- public void testDirtyUnchangedAttribute() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setSize(42);
- assertTrue(node.isDirty());
-
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- assertTrue(parent.isClean());
- assertTrue(this.root.isClean());
-
- this.root.markEntireBranchClean();
- // set size to same number - should stay clean
- node.setSize(42);
- assertTrue(node.isClean());
- assertTrue(parent.isClean());
- assertTrue(this.root.isClean());
- }
-
- public void testDirtyBranch() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setSize(42);
- assertTrue(node.isDirtyBranch());
-
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- assertTrue(parent.isDirtyBranch());
- assertTrue(this.root.isDirtyBranch());
-
- parent.setSize(77);
- assertTrue(parent.isDirty());
- assertTrue(parent.isDirtyBranch());
-
- node.markEntireBranchClean();
- assertTrue(parent.isDirty());
- assertTrue(parent.isDirtyBranch());
- }
-
- public void testDirtyBranchCleanChildDirtyParent() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setSize(42);
-
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- parent.setSize(77);
- assertTrue(parent.isDirty());
- assertTrue(parent.isDirtyBranch());
-
- // now, clean the child, but leave the parent dirty
- node.markEntireBranchClean();
- assertTrue(parent.isDirty());
- assertTrue(parent.isDirtyBranch());
- }
-
- public void testDirtyBranchCleanChildDirtyChild() {
- TestWorkbenchModel node1 = this.root.testDescendantNamed("node 1.1.1");
- node1.setSize(41);
- TestWorkbenchModel node2 = this.root.testDescendantNamed("node 1.1.2");
- node2.setSize(42);
-
- TestWorkbenchModel parent = (TestWorkbenchModel) node1.getParent();
- assertTrue(parent.isClean());
- assertTrue(parent.isDirtyBranch());
-
- // now, clean the first child, but leave the second child dirty
- node1.markEntireBranchClean();
- assertTrue(parent.isClean());
- assertTrue(parent.isDirtyBranch());
- }
-
- public void testDirtyBranchForced() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
-
- assertTrue(node.isClean());
- assertTrue(node.isCleanBranch());
- assertTrue(parent.isClean());
- assertTrue(parent.isCleanBranch());
- assertTrue(this.root.isClean());
- assertTrue(this.root.isCleanBranch());
-
- this.root.markEntireBranchDirty();
-
- assertTrue(node.isDirty());
- assertTrue(node.isDirtyBranch());
- assertTrue(parent.isDirty());
- assertTrue(parent.isDirtyBranch());
- assertTrue(this.root.isDirty());
- assertTrue(this.root.isDirtyBranch());
- }
-
- public void testDirtyTransientAttribute() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setName("BOGUS");
- assertTrue(node.isDirty());
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- assertTrue(parent.isClean());
- assertTrue(parent.isDirtyBranch());
- assertTrue(this.root.isClean());
- assertTrue(this.root.isDirtyBranch());
-
- this.root.markEntireBranchClean();
-
- this.root.validateBranch();
-
- assertTrue(this.root.problemsSize() == 0);
- assertTrue(node.branchProblems().hasNext());
- assertTrue(parent.problemsSize() == 0);
- assertTrue(parent.branchProblems().hasNext());
- assertTrue(node.problemsSize() > 0);
-
- // since problems are transient, everything should still be clean
- assertTrue(node.isClean());
- assertTrue(node.isCleanBranch());
- assertTrue(parent.isClean());
- assertTrue(parent.isCleanBranch());
- assertTrue(this.root.isClean());
- assertTrue(this.root.isCleanBranch());
- }
-
- public void testProblems() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setName("BOGUS");
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
-
- this.root.validateBranch();
-
- assertEquals(0, this.root.problemsSize());
- assertTrue(node.branchProblems().hasNext());
- assertEquals(0, parent.problemsSize());
- assertTrue(parent.branchProblems().hasNext());
- assertEquals(1, node.problemsSize());
- Problem problem1 = node.problems().next();
-
- // now create another problem that should remove the old problem
- node.setName("STILL BOGUS");
- this.root.validateBranch();
-
- assertEquals(0, this.root.problemsSize());
- assertTrue(node.branchProblems().hasNext());
- assertEquals(0, parent.problemsSize());
- assertTrue(parent.branchProblems().hasNext());
- assertEquals(1, node.problemsSize());
- Problem problem2 = node.problems().next();
- assertFalse(problem1 == problem2);
- problem1 = problem2;
-
- // now create another problem that should replace the old problem
- node.setName("STILL BOGUS");
- this.root.validateBranch();
-
- assertEquals(0, this.root.problemsSize());
- assertTrue(node.branchProblems().hasNext());
- assertEquals(0, parent.problemsSize());
- assertTrue(parent.branchProblems().hasNext());
- assertEquals(1, node.problemsSize());
- problem2 = node.problems().next();
- // the same problem should be there
- assertTrue(problem1.equals(problem2));
- }
-
- public void testBranchProblems() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setName("BOGUS");
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- parent.setName("BOGUS TOO");
- this.root.setName("BOGUS TOO TOO");
-
- this.root.validateBranch();
-
- assertEquals(1, this.root.problemsSize());
- assertEquals(3, this.root.branchProblemsSize());
- assertEquals(1, parent.problemsSize());
- assertEquals(2, parent.branchProblemsSize());
- assertEquals(1, node.problemsSize());
- assertEquals(1, node.branchProblemsSize());
-
- node.setName("okie-dokie");
-
- this.root.validateBranch();
-
- assertEquals(1, this.root.problemsSize());
- assertEquals(2, this.root.branchProblemsSize());
- assertEquals(1, parent.problemsSize());
- assertEquals(1, parent.branchProblemsSize());
- assertEquals(0, node.problemsSize());
- assertEquals(0, node.branchProblemsSize());
- }
-
- public void testClearAllBranchProblems() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setName("BOGUS");
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- parent.setName("BOGUS TOO");
- this.root.setName("BOGUS TOO TOO");
-
- this.root.validateBranch();
-
- assertEquals(1, this.root.problemsSize());
- assertEquals(3, this.root.branchProblemsSize());
- assertEquals(1, parent.problemsSize());
- assertEquals(2, parent.branchProblemsSize());
- assertEquals(1, node.problemsSize());
- assertEquals(1, node.branchProblemsSize());
-
- parent.clearAllBranchProblems();
-
- assertEquals(1, this.root.problemsSize());
- assertEquals(1, this.root.branchProblemsSize());
- assertEquals(0, parent.problemsSize());
- assertEquals(0, parent.branchProblemsSize());
- assertEquals(0, node.problemsSize());
- assertEquals(0, CollectionTools.size(node.branchProblems()));
- }
-
- public void testRemovedBranchProblems() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setName("BOGUS");
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- parent.setName("BOGUS TOO");
- this.root.setName("BOGUS TOO TOO");
-
- this.root.validateBranch();
-
- assertEquals(1, this.root.problemsSize());
- assertEquals(3, CollectionTools.size(this.root.branchProblems()));
- assertEquals(1, parent.problemsSize());
- assertEquals(2, parent.branchProblemsSize());
- assertEquals(1, node.problemsSize());
- assertEquals(1, CollectionTools.size(node.branchProblems()));
-
- // completely remove a node that has problems -
- // the entire tree should recalculate its "branch" problems
- parent.removeTestChild(node);
-
- this.root.validateBranch();
-
- assertEquals(1, this.root.problemsSize());
- assertEquals(2, CollectionTools.size(this.root.branchProblems()));
- assertEquals(1, parent.problemsSize());
- assertEquals(1, parent.branchProblemsSize());
- }
-
- public void testSort() {
- List<TestWorkbenchModel> nodes = this.buildSortedNodes();
- assertTrue(new Range(0, 1).includes(this.indexOf(nodes, "aaa")));
- assertTrue(new Range(0, 1).includes(this.indexOf(nodes, "AAA")));
- assertTrue(new Range(2, 3).includes(this.indexOf(nodes, "bbb")));
- assertTrue(new Range(2, 3).includes(this.indexOf(nodes, "BBB")));
- assertTrue(new Range(4, 6).includes(this.indexOf(nodes, "ccc")));
- assertTrue(new Range(4, 6).includes(this.indexOf(nodes, "CCC")));
- assertTrue(new Range(4, 6).includes(this.indexOf(nodes, "���")));
- }
-
- private int indexOf(List<TestWorkbenchModel> nodes, String nodeName) {
- for (int i = nodes.size(); i-- > 0; ) {
- if (nodes.get(i).getName().equals(nodeName)) {
- return i;
- }
- }
- throw new IllegalArgumentException();
- }
-
- private List<TestWorkbenchModel> buildSortedNodes() {
- List<TestWorkbenchModel> result = new ArrayList<TestWorkbenchModel>();
- result.add(new RootTestWorkbenchModel("AAA"));
- result.add(new RootTestWorkbenchModel("BBB"));
- result.add(new RootTestWorkbenchModel("CCC"));
- result.add(new RootTestWorkbenchModel("���"));
- result.add(new RootTestWorkbenchModel("ccc"));
- result.add(new RootTestWorkbenchModel("bbb"));
- result.add(new RootTestWorkbenchModel("aaa"));
- return CollectionTools.sort(result);
- }
-
-
- // ********** inner classes **********
-
- private class TestWorkbenchModel extends AbstractNode {
- private String name;
- public static final String NAME_PROPERTY = "name";
- private int size;
- public static final String SIZE_PROPERTY = "size";
- private Collection<TestWorkbenchModel> testChildren;
- public static final String TEST_CHILDREN_COLLECTION = "children";
-
- // ********** construction/initialization **********
- public TestWorkbenchModel(TestWorkbenchModel parent, String name) {
- super(parent);
- if (name == null) {
- throw new NullPointerException();
- }
- this.name = name;
- }
- @Override
- protected void initialize() {
- super.initialize();
- this.size = 0;
- this.testChildren = new HashBag<TestWorkbenchModel>();
- }
-
- @Override
- protected void checkParent(Node parent) {
- // do nothing
- }
-
-
- // ********** accessors **********
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- public int getSize() {
- return this.size;
- }
- public void setSize(int size) {
- int old = this.size;
- this.size = size;
- this.firePropertyChanged(SIZE_PROPERTY, old, size);
- }
-
- public Iterator<TestWorkbenchModel> testChildren() {
- return new CloneIterator<TestWorkbenchModel>(this.testChildren) {
- @Override
- protected void remove(TestWorkbenchModel current) {
- TestWorkbenchModel.this.removeTestChild(current);
- }
- };
- }
- public int testChildrenSize() {
- return this.testChildren.size();
- }
- private TestWorkbenchModel addTestChild(TestWorkbenchModel testChild) {
- this.addItemToCollection(testChild, this.testChildren, TEST_CHILDREN_COLLECTION);
- return testChild;
- }
- public TestWorkbenchModel addTestChildNamed(String childName) {
- if (this.testChildNamed(childName) != null) {
- throw new IllegalArgumentException(childName);
- }
- return this.addTestChild(new TestWorkbenchModel(this, childName));
- }
- public void removeTestChild(TestWorkbenchModel testChild) {
- this.removeItemFromCollection(testChild, this.testChildren, TEST_CHILDREN_COLLECTION);
- }
-
- // ********** queries **********
- public String displayString() {
- return this.name;
- }
- public TestWorkbenchModel testChildNamed(String childName) {
- for (TestWorkbenchModel testChild : this.testChildren) {
- if (testChild.getName().equals(childName)) {
- return testChild;
- }
- }
- return null;
- }
- public TestWorkbenchModel testDescendantNamed(String descendantName) {
- for (TestWorkbenchModel testDescendant : this.testChildren) {
- if (testDescendant.getName().equals(descendantName)) {
- return testDescendant;
- }
- // recurse...
- testDescendant = testDescendant.testDescendantNamed(descendantName);
- if (testDescendant != null) {
- return testDescendant;
- }
- }
- return null;
- }
-
- // ********** behavior **********
- @Override
- protected void addChildrenTo(List<Node> children) {
- super.addChildrenTo(children);
- children.addAll(this.testChildren);
- }
- @Override
- protected void addProblemsTo(List<Problem> currentProblems) {
- super.addProblemsTo(currentProblems);
- // names must be all lowercase...
- for (int i = this.name.length(); i-- > 0; ) {
- char c = this.name.charAt(i);
- if (Character.isLetter(c) && ! Character.isLowerCase(c)) {
- currentProblems.add(this.buildProblem("NAME_MUST_BE_LOWERCASE", this.name));
- return;
- }
- }
- }
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
- }
-
-
- private class RootTestWorkbenchModel extends TestWorkbenchModel {
- public RootTestWorkbenchModel(String name) {
- super(null, name);
- }
- @Override
- public Validator getValidator() {
- return Node.NULL_VALIDATOR;
- }
- }
-
-}
-
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/JptUtilityNodeTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/JptUtilityNodeTests.java
deleted file mode 100644
index 94f682d878..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/JptUtilityNodeTests.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal.node;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptUtilityNodeTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityNodeTests.class.getPackage().getName());
-
- suite.addTestSuite(AbstractNodeTests.class);
-
- return suite;
- }
-
- private JptUtilityNodeTests() {
- super();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/test.xml b/jpa/tests/org.eclipse.jpt.utility.tests/test.xml
deleted file mode 100644
index bf3ab7e506..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/test.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0"?>
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <echo message="basedir ${basedir}" />
- <echo message="eclipse place ${eclipse-home}" />
- <!-- sets the properties plugin-name -->
- <property name="plugin-name" value="org.eclipse.jpt.utility.tests"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname" value="org.eclipse.jpt.utility.tests.internal.JptUtilityTests" />
- <property name="plugin-path" value="${eclipse-home}/plugins/${plugin-name}"/>
- <property name="extraVMargs" value=""/>
- </ant>
- </target>
-
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init, suite, cleanup">
- </target>
-</project> \ No newline at end of file

Back to the top